2 * ion/ioncore/fullscreen.c
4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
12 #include <libtu/setparam.h>
16 #include "clientwin.h"
20 #include "fullscreen.h"
28 /*{{{ Generic full screen mode code */
31 bool region_fullscreen_scr(WRegion *reg, WScreen *scr, bool switchto)
35 int swf=(switchto ? MPLEX_ATTACH_SWITCHTO : 0);
37 bool newph=FALSE, ret;
39 ph=region_unset_get_return(reg);
42 ph=region_make_return_pholder(reg);
46 ret=(mplex_attach_simple((WMPlex*)scr, reg, swf)!=NULL);
49 warn(TR("Failed to enter full screen mode."));
52 destroy_obj((Obj*)ph);
53 else if(!region_do_set_return(reg, ph))
54 destroy_obj((Obj*)ph);
60 bool region_enter_fullscreen(WRegion *reg, bool switchto)
62 WScreen *scr=region_screen_of(reg);
65 scr=rootwin_current_scr(region_rootwin_of(reg));
70 return region_fullscreen_scr(reg, scr, switchto);
74 bool region_leave_fullscreen(WRegion *reg, bool switchto)
76 int swf=(switchto ? PHOLDER_ATTACH_SWITCHTO : 0);
77 WPHolder *ph=region_unset_get_return(reg);
82 if(!pholder_attach_mcfgoto(ph, swf, reg)){
83 warn(TR("Failed to return from full screen mode; remaining manager "
84 "or parent from previous location refused to manage us."));
88 destroy_obj((Obj*)ph);
94 /*#undef REGION_IS_FULLSCREEN
95 #define REGION_IS_FULLSCREEN(REG) (region_get_return((WRegion*)REG)!=NULL)*/
98 static bool region_set_fullscreen(WRegion *reg, int sp)
100 bool set=REGION_IS_FULLSCREEN(reg);
101 bool nset=libtu_do_setparam(sp, set);
107 region_enter_fullscreen(reg, TRUE);
109 region_leave_fullscreen(reg, TRUE);
111 return REGION_IS_FULLSCREEN(reg);
118 /*{{{ Client window requests */
121 bool clientwin_fullscreen_may_switchto(WClientWin *cwin)
123 return (region_may_control_focus((WRegion*)cwin)
124 || !REGION_IS_ACTIVE(region_screen_of((WRegion*)cwin)));
128 WScreen *clientwin_fullscreen_chkrq(WClientWin *cwin, int w, int h)
134 mwm=xwindow_get_mwmhints(cwin->win);
135 if(mwm==NULL || !(mwm->flags&MWM_HINTS_DECORATIONS) ||
139 FOR_ALL_SCREENS(scr){
140 if(!region_same_rootwin((WRegion*)scr, (WRegion*)cwin))
142 /* Only Mplayer supports single Xinerama region FS to my knowledge,
143 * and doesn't set position, so we also don't check position here,
144 * and instead take the first screen with matching size.
146 if(REGION_GEOM(scr).w==w && REGION_GEOM(scr).h==h)
157 /*{{{ Group exports */
161 * Set client window \var{reg} full screen state according to the
162 * parameter \var{how} (set/unset/toggle). Resulting state is returned,
163 * which may not be what was requested.
165 EXTL_EXPORT_AS(WGroup, set_fullscreen)
166 bool group_set_fullscreen_extl(WGroup *grp, const char *how)
168 return region_set_fullscreen((WRegion*)grp, libtu_string_to_setparam(how));
173 * Is \var{reg} in full screen mode?
177 bool group_is_fullscreen(WGroup *grp)
179 return REGION_IS_FULLSCREEN(grp);