1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
/*
* ion/ioncore/fullscreen.c
*
* Copyright (c) Tuomo Valkonen 1999-2004.
*
* Ion is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*/
#include "common.h"
#include "global.h"
#include "sizehint.h"
#include "clientwin.h"
#include "attach.h"
#include "screen.h"
#include "manage.h"
#include "fullscreen.h"
#include "mwmhints.h"
bool clientwin_check_fullscreen_request(WClientWin *cwin, int w, int h,
bool sw)
{
WScreen *scr;
WMwmHints *mwm;
mwm=get_mwm_hints(cwin->win);
if(mwm==NULL || !(mwm->flags&MWM_HINTS_DECORATIONS) ||
mwm->decorations!=0)
return FALSE;
FOR_ALL_SCREENS(scr){
if(!same_rootwin((WRegion*)scr, (WRegion*)cwin))
continue;
/* TODO: if there are multiple possible rootwins, use the one with
* requested position, if any.
*/
if(REGION_GEOM(scr).w==w && REGION_GEOM(scr).h==h){
return clientwin_fullscreen_scr(cwin, (WScreen*)scr, sw);
}
}
/* Catch Xinerama-unaware apps here */
if(REGION_GEOM(ROOTWIN_OF(cwin)).w==w &&
REGION_GEOM(ROOTWIN_OF(cwin)).h==h){
return clientwin_enter_fullscreen(cwin, sw);
}
return FALSE;
}
static void lastmgr_watchhandler(WWatch *watch, WObj *obj)
{
WClientWinFSInfo *fsinfo=(WClientWinFSInfo*)watch;
WRegion *r;
assert(WOBJ_IS(obj, WRegion));
r=region_find_rescue_manager((WRegion*)obj);
if(r!=NULL)
setup_watch(&(fsinfo->last_mgr_watch), (WObj*)r, lastmgr_watchhandler);
}
bool clientwin_fullscreen_scr(WClientWin *cwin, WScreen *scr, bool switchto)
{
int rootx, rooty;
bool wasfs=TRUE;
if(cwin->fsinfo.last_mgr_watch.obj==NULL){
wasfs=FALSE;
if(REGION_MANAGER(cwin)!=NULL){
setup_watch(&(cwin->fsinfo.last_mgr_watch),
(WObj*)REGION_MANAGER(cwin),
lastmgr_watchhandler);
}else if(scr->mplex.current_sub!=NULL){
setup_watch(&(cwin->fsinfo.last_mgr_watch),
(WObj*)scr->mplex.current_sub,
lastmgr_watchhandler);
}
region_rootpos((WRegion*)cwin, &rootx, &rooty);
cwin->fsinfo.saved_rootrel_geom.x=rootx;
cwin->fsinfo.saved_rootrel_geom.y=rooty;
cwin->fsinfo.saved_rootrel_geom.w=REGION_GEOM(cwin).w;
cwin->fsinfo.saved_rootrel_geom.h=REGION_GEOM(cwin).h;
}
if(!mplex_attach_simple((WMPlex*)scr, (WRegion*)cwin, switchto)){
warn("Failed to enter full screen mode");
if(!wasfs)
reset_watch(&(cwin->fsinfo.last_mgr_watch));
return FALSE;
}
return TRUE;
}
bool clientwin_enter_fullscreen(WClientWin *cwin, bool switchto)
{
WScreen *scr=region_screen_of((WRegion*)cwin);
if(scr==NULL){
scr=rootwin_current_scr(ROOTWIN_OF(cwin));
if(scr==NULL)
return FALSE;
}
return clientwin_fullscreen_scr(cwin, scr, switchto);
}
bool clientwin_leave_fullscreen(WClientWin *cwin, bool switchto)
{
WRegion *reg;
WManageParams param=INIT_WMANAGEPARAMS;
int rootx, rooty;
bool cf;
if(cwin->fsinfo.last_mgr_watch.obj==NULL)
return FALSE;
cf=region_may_control_focus((WRegion*)cwin);
reg=(WRegion*)cwin->fsinfo.last_mgr_watch.obj;
reset_watch(&(cwin->fsinfo.last_mgr_watch));
assert(WOBJ_IS(reg, WRegion));
param.geom=cwin->fsinfo.saved_rootrel_geom;
param.tfor=NULL;
param.userpos=FALSE;
param.maprq=FALSE;
param.switchto=switchto;
param.dockapp=FALSE;
param.gravity=StaticGravity;
if(!region_manage_clientwin(reg, cwin, ¶m)){
warn("WClientWin failed to return from full screen mode; remaining "
"manager or parent from previous location refused to manage us.");
return FALSE;
}
if(!cf)
return TRUE;
return region_goto((WRegion*)cwin);
}
/*EXTL_DOC
* Toggle between full screen and normal (framed) mode.
*/
EXTL_EXPORT_MEMBER
bool clientwin_toggle_fullscreen(WClientWin *cwin)
{
if(cwin->fsinfo.last_mgr_watch.obj!=NULL)
return clientwin_leave_fullscreen(cwin, TRUE);
return clientwin_enter_fullscreen(cwin, TRUE);
}
|