Add functions to check fullscreen windows
This commit is contained in:
		
							parent
							
								
									28db0416b4
								
							
						
					
					
						commit
						9e824a79ee
					
				| @ -186,6 +186,61 @@ void screen_update_fallback(void) | ||||
|         screens[0].dim.h = DisplayHeight(xctx.dpy, screen); | ||||
| } | ||||
| 
 | ||||
| /* see screen.h */ | ||||
| bool have_fullscreen_window(void) | ||||
| { | ||||
|         return window_is_fullscreen(get_focused_window()); | ||||
| } | ||||
| 
 | ||||
| /* see screen.h */ | ||||
| bool window_is_fullscreen(Window window) | ||||
| { | ||||
|         bool fs = false; | ||||
| 
 | ||||
|         Atom has_wm_state = XInternAtom(xctx.dpy, "_NET_WM_STATE", True); | ||||
|         if (has_wm_state == None){ | ||||
|                 return false; | ||||
|         } | ||||
| 
 | ||||
|         Atom actual_type_return; | ||||
|         int actual_format_return; | ||||
|         unsigned long bytes_after_return; | ||||
|         unsigned char *prop_to_return; | ||||
|         unsigned long n_items; | ||||
|         int result = XGetWindowProperty( | ||||
|                         xctx.dpy, | ||||
|                         window, | ||||
|                         has_wm_state, | ||||
|                         0,                     /* long_offset */ | ||||
|                         sizeof(window),        /* long_length */ | ||||
|                         false,                 /* delete */ | ||||
|                         AnyPropertyType,       /* req_type */ | ||||
|                         &actual_type_return, | ||||
|                         &actual_format_return, | ||||
|                         &n_items, | ||||
|                         &bytes_after_return, | ||||
|                         &prop_to_return); | ||||
| 
 | ||||
|         if (result == Success) { | ||||
|                 for(int i = 0; i < n_items; i++) { | ||||
|                         char *atom = XGetAtomName(xctx.dpy, ((Atom*)prop_to_return)[i]); | ||||
| 
 | ||||
|                         if (atom) { | ||||
|                                 if(0 == strcmp("_NET_WM_STATE_FULLSCREEN", atom)) | ||||
|                                         fs = true; | ||||
|                                 XFree(atom); | ||||
|                                 if(fs) | ||||
|                                         break; | ||||
|                         } | ||||
|                 } | ||||
|         } | ||||
| 
 | ||||
|         if (prop_to_return) | ||||
|                 XFree(prop_to_return); | ||||
| 
 | ||||
|         return fs; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * Select the screen on which the Window | ||||
|  * should be displayed. | ||||
|  | ||||
| @ -3,6 +3,7 @@ | ||||
| #define DUNST_SCREEN_H | ||||
| 
 | ||||
| #include <X11/Xlib.h> | ||||
| #include <stdbool.h> | ||||
| 
 | ||||
| #define INRECT(x,y,rx,ry,rw,rh) ((x) >= (rx) && (x) < (rx)+(rw) && (y) >= (ry) && (y) < (ry)+(rh)) | ||||
| 
 | ||||
| @ -27,5 +28,24 @@ void screen_check_event(XEvent event); | ||||
| screen_info *get_active_screen(void); | ||||
| double get_dpi_for_screen(screen_info *scr); | ||||
| 
 | ||||
| /**
 | ||||
|  * Find the currently focused window and check if it's in | ||||
|  * fullscreen mode | ||||
|  * | ||||
|  * @see window_is_fullscreen() | ||||
|  * @see get_focused_window() | ||||
|  * | ||||
|  * @return `true` if the focused window is in fullscreen mode | ||||
|  */ | ||||
| bool have_fullscreen_window(void); | ||||
| 
 | ||||
| /**
 | ||||
|  * Check if window is in fullscreen mode | ||||
|  * | ||||
|  * @param window the x11 window object | ||||
|  * @return `true` if `window` is in fullscreen mode | ||||
|  */ | ||||
| bool window_is_fullscreen(Window window); | ||||
| 
 | ||||
| #endif | ||||
| /* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Benedikt Heine
						Benedikt Heine