Krolyxon
Commit f2ceac2

Branches

Refs →

nsxivf2ceac2

New option: -F, fixed/floating window

Author
Bert
Date
2011-02-01 16:40 +0100
Parent
8fb3110
Commit
f2ceac2f8ab04f91672a9cb168dfdf69dab02b3c

+20 −8

3 files changed

  1. M options.c +6 −2
  2. M options.h +1 −0
  3. M window.c +13 −6
M options.c View
@@ -29,7 +29,7 @@ options_t _options;
2929 const options_t *options = (const options_t*) &_options;
3030
3131 void print_usage() {
32− printf("usage: sxiv [-dfhpqsvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
32+ printf("usage: sxiv [-dFfhpqsvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n");
3333 }
3434
3535 void print_version() {
@@ -45,12 +45,13 @@ void parse_options(int argc, char **argv) {
4545 _options.zoom = 1.0;
4646 _options.aa = 1;
4747
48+ _options.fixed = 0;
4849 _options.fullscreen = 0;
4950 _options.geometry = NULL;
5051
5152 _options.quiet = 0;
5253
53− while ((opt = getopt(argc, argv, "dfg:hpqsvZz:")) != -1) {
54+ while ((opt = getopt(argc, argv, "dFfg:hpqsvZz:")) != -1) {
5455 switch (opt) {
5556 case '?':
5657 print_usage();
@@ -58,6 +59,9 @@ void parse_options(int argc, char **argv) {
5859 case 'd':
5960 _options.scalemode = SCALE_DOWN;
6061 break;
62+ case 'F':
63+ _options.fixed = 1;
64+ break;
6165 case 'f':
6266 _options.fullscreen = 1;
6367 break;
M options.h View
@@ -29,6 +29,7 @@ typedef struct options_s {
2929 float zoom;
3030 unsigned char aa;
3131
32+ unsigned char fixed;
3233 unsigned char fullscreen;
3334 char *geometry;
3435
M window.c View
@@ -33,7 +33,8 @@ static GC bgc;
3333
3434 void win_open(win_t *win) {
3535 win_env_t *e;
36− XClassHint *classhint;
36+ XClassHint classhint;
37+ XSizeHints sizehints;
3738 XColor bgcol;
3839 int gmask;
3940
@@ -99,11 +100,17 @@ void win_open(win_t *win) {
99100
100101 win_set_title(win, "sxiv");
101102
102− if ((classhint = XAllocClassHint())) {
103− classhint->res_name = "sxiv";
104− classhint->res_class = "sxiv";
105− XSetClassHint(e->dpy, win->xwin, classhint);
106− XFree(classhint);
103+ classhint.res_name = "sxiv";
104+ classhint.res_class = "sxiv";
105+ XSetClassHint(e->dpy, win->xwin, &classhint);
106+
107+ if (options->fixed) {
108+ sizehints.flags = PMinSize | PMaxSize;
109+ sizehints.min_width = win->w;
110+ sizehints.max_width = win->w;
111+ sizehints.min_height = win->h;
112+ sizehints.max_height = win->h;
113+ XSetWMNormalHints(e->dpy, win->xwin, &sizehints);
107114 }
108115
109116 XMapWindow(e->dpy, win->xwin);