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 bool clientwin_check_fullscreen_request(WClientWin *cwin, int w, int h,
135 mwm=xwindow_get_mwmhints(cwin->win);
136 if(mwm==NULL || !(mwm->flags&MWM_HINTS_DECORATIONS) ||
140 FOR_ALL_SCREENS(scr){
141 if(!region_same_rootwin((WRegion*)scr, (WRegion*)cwin))
143 /* Only Mplayer supports single Xinerama region FS to my knowledge,
144 * and doesn't set position, so we also don't check position here,
145 * and instead take the first screen with matching size.
147 if(REGION_GEOM(scr).w==w && REGION_GEOM(scr).h==h){
148 cwin->flags|=CLIENTWIN_FS_RQ;
149 if(!region_fullscreen_scr((WRegion*)cwin, (WScreen*)scr, sw)){
150 cwin->flags&=~CLIENTWIN_FS_RQ;
164 /*{{{ Group exports */
168 * Set client window \var{reg} full screen state according to the
169 * parameter \var{how} (set/unset/toggle). Resulting state is returned,
170 * which may not be what was requested.
172 EXTL_EXPORT_AS(WGroup, set_fullscreen)
173 bool group_set_fullscreen_extl(WGroup *grp, const char *how)
175 return region_set_fullscreen((WRegion*)grp, libtu_string_to_setparam(how));
180 * Is \var{reg} in full screen mode?
184 bool group_is_fullscreen(WGroup *grp)
186 return REGION_IS_FULLSCREEN(grp);