Add Error Handler to fullscreen check
This commit is contained in:
		
							parent
							
								
									aa7a851fdd
								
							
						
					
					
						commit
						dd28e62c11
					
				| @ -192,6 +192,24 @@ bool have_fullscreen_window(void) | |||||||
|         return window_is_fullscreen(get_focused_window()); |         return window_is_fullscreen(get_focused_window()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /**
 | ||||||
|  |  * X11 ErrorHandler to mainly discard BadWindow parameter error | ||||||
|  |  */ | ||||||
|  | static int XErrorHandlerFullscreen(Display *display, XErrorEvent *e) | ||||||
|  | { | ||||||
|  |         /* Ignore BadWindow errors. Window may have been gone */ | ||||||
|  |         if (e->error_code == BadWindow) { | ||||||
|  |                 return 0; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         char err_buf[BUFSIZ]; | ||||||
|  |         XGetErrorText(display, e->error_code, err_buf, BUFSIZ); | ||||||
|  |         fputs(err_buf, stderr); | ||||||
|  |         fputs("\n", stderr); | ||||||
|  | 
 | ||||||
|  |         return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* see screen.h */ | /* see screen.h */ | ||||||
| bool window_is_fullscreen(Window window) | bool window_is_fullscreen(Window window) | ||||||
| { | { | ||||||
| @ -205,6 +223,9 @@ bool window_is_fullscreen(Window window) | |||||||
|                 return false; |                 return false; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         XFlush(xctx.dpy); | ||||||
|  |         XSetErrorHandler(XErrorHandlerFullscreen); | ||||||
|  | 
 | ||||||
|         Atom actual_type_return; |         Atom actual_type_return; | ||||||
|         int actual_format_return; |         int actual_format_return; | ||||||
|         unsigned long bytes_after_return; |         unsigned long bytes_after_return; | ||||||
| @ -224,6 +245,10 @@ bool window_is_fullscreen(Window window) | |||||||
|                         &bytes_after_return, |                         &bytes_after_return, | ||||||
|                         &prop_to_return); |                         &prop_to_return); | ||||||
| 
 | 
 | ||||||
|  |         XFlush(xctx.dpy); | ||||||
|  |         XSync(xctx.dpy, false); | ||||||
|  |         XSetErrorHandler(NULL); | ||||||
|  | 
 | ||||||
|         if (result == Success) { |         if (result == Success) { | ||||||
|                 for(int i = 0; i < n_items; i++) { |                 for(int i = 0; i < n_items; i++) { | ||||||
|                         char *atom = XGetAtomName(xctx.dpy, ((Atom*)prop_to_return)[i]); |                         char *atom = XGetAtomName(xctx.dpy, ((Atom*)prop_to_return)[i]); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Benedikt Heine
						Benedikt Heine