2 * ion/ioncore/fullscreen.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
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
)
30 int swf
=(switchto
? MPLEX_ATTACH_SWITCHTO
: 0);
32 bool newph
=FALSE
, ret
;
34 ph
=region_unset_get_return(reg
);
37 ph
=region_make_return_pholder(reg
);
41 ret
=(mplex_attach_simple((WMPlex
*)scr
, reg
, swf
)!=NULL
);
44 warn(TR("Failed to enter full screen mode."));
47 destroy_obj((Obj
*)ph
);
48 else if(!region_do_set_return(reg
, ph
))
49 destroy_obj((Obj
*)ph
);
55 bool region_enter_fullscreen(WRegion
*reg
, bool switchto
)
57 WScreen
*scr
=region_screen_of(reg
);
60 scr
=rootwin_current_scr(region_rootwin_of(reg
));
65 return region_fullscreen_scr(reg
, scr
, switchto
);
69 bool region_leave_fullscreen(WRegion
*reg
, bool switchto
)
71 int swf
=(switchto
? PHOLDER_ATTACH_SWITCHTO
: 0);
72 WPHolder
*ph
=region_unset_get_return(reg
);
77 if(!pholder_attach_mcfgoto(ph
, swf
, reg
)){
78 warn(TR("Failed to return from full screen mode; remaining manager "
79 "or parent from previous location refused to manage us."));
83 destroy_obj((Obj
*)ph
);
89 /*#undef REGION_IS_FULLSCREEN
90 #define REGION_IS_FULLSCREEN(REG) (region_get_return((WRegion*)REG)!=NULL)*/
93 static bool region_set_fullscreen(WRegion
*reg
, int sp
)
95 bool set
=REGION_IS_FULLSCREEN(reg
);
96 bool nset
=libtu_do_setparam(sp
, set
);
102 region_enter_fullscreen(reg
, TRUE
);
104 region_leave_fullscreen(reg
, TRUE
);
106 return REGION_IS_FULLSCREEN(reg
);
113 /*{{{ Client window requests */
116 bool clientwin_fullscreen_may_switchto(WClientWin
*cwin
)
118 return (region_may_control_focus((WRegion
*)cwin
)
119 || !REGION_IS_ACTIVE(region_screen_of((WRegion
*)cwin
)));
123 WScreen
*clientwin_fullscreen_chkrq(WClientWin
*cwin
, int w
, int h
)
128 mwm
=xwindow_get_mwmhints(cwin
->win
);
129 if(mwm
==NULL
|| !(mwm
->flags
&MWM_HINTS_DECORATIONS
) ||
133 FOR_ALL_SCREENS(scr
){
134 if(!region_same_rootwin((WRegion
*)scr
, (WRegion
*)cwin
))
136 /* Only Mplayer supports single Xinerama region FS to my knowledge,
137 * and doesn't set position, so we also don't check position here,
138 * and instead take the first screen with matching size.
140 if(REGION_GEOM(scr
).w
==w
&& REGION_GEOM(scr
).h
==h
)
151 /*{{{ Group exports */
155 * Set client window \var{reg} full screen state according to the
156 * parameter \var{how} (one of \codestr{set}, \codestr{unset}, or
157 * \codestr{toggle}). Resulting state is returned, which may not be
158 * what was requested.
160 EXTL_EXPORT_AS(WGroup
, set_fullscreen
)
161 bool group_set_fullscreen_extl(WGroup
*grp
, const char *how
)
163 return region_set_fullscreen((WRegion
*)grp
, libtu_string_to_setparam(how
));