New option: -F, fixed/floating window
This commit is contained in:
		
							parent
							
								
									8fb3110ebb
								
							
						
					
					
						commit
						f2ceac2f8a
					
				| @ -29,7 +29,7 @@ options_t _options; | ||||
| const options_t *options = (const options_t*) &_options; | ||||
| 
 | ||||
| void print_usage() { | ||||
| 	printf("usage: sxiv [-dfhpqsvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n"); | ||||
| 	printf("usage: sxiv [-dFfhpqsvZ] [-g GEOMETRY] [-z ZOOM] FILES...\n"); | ||||
| } | ||||
| 
 | ||||
| void print_version() { | ||||
| @ -45,12 +45,13 @@ void parse_options(int argc, char **argv) { | ||||
| 	_options.zoom = 1.0; | ||||
| 	_options.aa = 1; | ||||
| 
 | ||||
| 	_options.fixed = 0; | ||||
| 	_options.fullscreen = 0; | ||||
| 	_options.geometry = NULL; | ||||
| 
 | ||||
| 	_options.quiet = 0; | ||||
| 
 | ||||
| 	while ((opt = getopt(argc, argv, "dfg:hpqsvZz:")) != -1) { | ||||
| 	while ((opt = getopt(argc, argv, "dFfg:hpqsvZz:")) != -1) { | ||||
| 		switch (opt) { | ||||
| 			case '?': | ||||
| 				print_usage(); | ||||
| @ -58,6 +59,9 @@ void parse_options(int argc, char **argv) { | ||||
| 			case 'd': | ||||
| 				_options.scalemode = SCALE_DOWN; | ||||
| 				break; | ||||
| 			case 'F': | ||||
| 				_options.fixed = 1; | ||||
| 				break; | ||||
| 			case 'f': | ||||
| 				_options.fullscreen = 1; | ||||
| 				break; | ||||
|  | ||||
| @ -29,6 +29,7 @@ typedef struct options_s { | ||||
| 	float zoom; | ||||
| 	unsigned char aa; | ||||
| 
 | ||||
| 	unsigned char fixed; | ||||
| 	unsigned char fullscreen; | ||||
| 	char *geometry; | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										19
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								window.c
									
									
									
									
									
								
							| @ -33,7 +33,8 @@ static GC bgc; | ||||
| 
 | ||||
| void win_open(win_t *win) { | ||||
| 	win_env_t *e; | ||||
| 	XClassHint *classhint; | ||||
| 	XClassHint classhint; | ||||
| 	XSizeHints sizehints; | ||||
| 	XColor bgcol; | ||||
| 	int gmask; | ||||
| 
 | ||||
| @ -99,11 +100,17 @@ void win_open(win_t *win) { | ||||
| 
 | ||||
| 	win_set_title(win, "sxiv"); | ||||
| 
 | ||||
| 	if ((classhint = XAllocClassHint())) { | ||||
| 		classhint->res_name = "sxiv"; | ||||
| 		classhint->res_class = "sxiv"; | ||||
| 		XSetClassHint(e->dpy, win->xwin, classhint); | ||||
| 		XFree(classhint); | ||||
| 	classhint.res_name = "sxiv"; | ||||
| 	classhint.res_class = "sxiv"; | ||||
| 	XSetClassHint(e->dpy, win->xwin, &classhint); | ||||
| 
 | ||||
| 	if (options->fixed) { | ||||
| 		sizehints.flags = PMinSize | PMaxSize; | ||||
| 		sizehints.min_width = win->w; | ||||
| 		sizehints.max_width = win->w; | ||||
| 		sizehints.min_height = win->h; | ||||
| 		sizehints.max_height = win->h; | ||||
| 		XSetWMNormalHints(e->dpy, win->xwin, &sizehints); | ||||
| 	} | ||||
| 
 | ||||
| 	XMapWindow(e->dpy, win->xwin); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Bert
						Bert