2 * ion/ioncore/fullscreen.c
4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * See the included file LICENSE for details.
9 #include <libtu/setparam.h>
13 #include "clientwin.h"
17 #include "fullscreen.h"
25 /*{{{ Generic full screen mode code */
28 bool region_fullscreen_scr(WRegion *reg, WScreen *scr, bool switchto)
32 int swf=(switchto ? MPLEX_ATTACH_SWITCHTO : 0);
34 bool newph=FALSE, ret;
36 ph=region_unset_get_return(reg);
39 ph=region_make_return_pholder(reg);
43 ret=(mplex_attach_simple((WMPlex*)scr, reg, swf)!=NULL);
46 warn(TR("Failed to enter full screen mode."));
49 destroy_obj((Obj*)ph);
50 else if(!region_do_set_return(reg, ph))
51 destroy_obj((Obj*)ph);
57 bool region_enter_fullscreen(WRegion *reg, bool switchto)
59 WScreen *scr=region_screen_of(reg);
62 scr=rootwin_current_scr(region_rootwin_of(reg));
67 return region_fullscreen_scr(reg, scr, switchto);
71 bool region_leave_fullscreen(WRegion *reg, bool switchto)
73 int swf=(switchto ? PHOLDER_ATTACH_SWITCHTO : 0);
74 WPHolder *ph=region_unset_get_return(reg);
79 if(!pholder_attach_mcfgoto(ph, swf, reg)){
80 warn(TR("Failed to return from full screen mode; remaining manager "
81 "or parent from previous location refused to manage us."));
85 destroy_obj((Obj*)ph);
91 /*#undef REGION_IS_FULLSCREEN
92 #define REGION_IS_FULLSCREEN(REG) (region_get_return((WRegion*)REG)!=NULL)*/
95 static bool region_set_fullscreen(WRegion *reg, int sp)
97 bool set=REGION_IS_FULLSCREEN(reg);
98 bool nset=libtu_do_setparam(sp, set);
104 region_enter_fullscreen(reg, TRUE);
106 region_leave_fullscreen(reg, TRUE);
108 return REGION_IS_FULLSCREEN(reg);
115 /*{{{ Client window requests */
118 bool clientwin_fullscreen_may_switchto(WClientWin *cwin)
120 return (region_may_control_focus((WRegion*)cwin)
121 || !REGION_IS_ACTIVE(region_screen_of((WRegion*)cwin)));
125 WScreen *clientwin_fullscreen_chkrq(WClientWin *cwin, int w, int h)
131 mwm=xwindow_get_mwmhints(cwin->win);
132 if(mwm==NULL || !(mwm->flags&MWM_HINTS_DECORATIONS) ||
136 FOR_ALL_SCREENS(scr){
137 if(!region_same_rootwin((WRegion*)scr, (WRegion*)cwin))
139 /* Only Mplayer supports single Xinerama region FS to my knowledge,
140 * and doesn't set position, so we also don't check position here,
141 * and instead take the first screen with matching size.
143 if(REGION_GEOM(scr).w==w && REGION_GEOM(scr).h==h)
154 /*{{{ Group exports */
158 * Set client window \var{reg} full screen state according to the
159 * parameter \var{how} (one of \codestr{set}, \codestr{unset}, or
160 * \codestr{toggle}). Resulting state is returned, which may not be
161 * what was requested.
163 EXTL_EXPORT_AS(WGroup, set_fullscreen)
164 bool group_set_fullscreen_extl(WGroup *grp, const char *how)
166 return region_set_fullscreen((WRegion*)grp, libtu_string_to_setparam(how));