From d97499cae8e344af6118f38ffa1c4b183a4d30cc Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 30 Jul 2015 18:18:11 -0400 Subject: Fix up the issues with some apps which re-configure the Xsession/screens to match their own internal specifications. On single-screen setups it works fine now, but on multi-screen setups the app does not seem to return the xsettings back to their original specs properly (Tested with OpenArena and MegaMario). This may result in the screen being "flipped" or placed on different monitors after closing the app. --- libLumina/LuminaX11.cpp | 70 ++++++++++++++++++++++++++++++++++++++++--------- libLumina/LuminaX11.h | 1 + 2 files changed, 59 insertions(+), 12 deletions(-) (limited to 'libLumina') diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index 71346e19..61af0803 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include //X includes (these need to be last due to Qt compile issues) #include @@ -1165,6 +1167,50 @@ bool LXCB::WindowIsMaximized(WId win){ return false; } +// === WindowIsFullscreen() === +int LXCB::WindowIsFullscreen(WId win){ + if(DEBUG){ qDebug() << "XCB: WindowIsFullscreen()"; } + if(win==0){ return -1; } + //bool fullS = false; + //See if the _NET_WM_STATE_FULLSCREEN flag is set on the window + /*xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state_unchecked(&EWMH, win); + if(cookie.sequence == 0){ return false; } + xcb_ewmh_get_atoms_reply_t states; + if( 1 == xcb_ewmh_get_wm_state_reply(&EWMH, cookie, &states, NULL) ){ + //Loop over the states + for(unsigned int i=0; iscreenCount(); i++){ + QRect sgeom = desk->screenGeometry(i); + qDebug() << " -- Check Window Geom:" << sgeom << geom << this->WindowClass(win); + if( sgeom.contains(geom.center()) ){ + //Allow a 1 pixel variation in "full-screen" detection + qDebug() << " -- Found Screen:" << i; + if( geom.width() >= (sgeom.width()-1) && geom.height()>=(sgeom.height()-1) ){ + qDebug() << " -- Is Fullscreen!"; + //fullS = true; + fscreen = i; + } + break; //found the screen which contains this window + } + } + //} + //return fullS; + return fscreen; +} + // === WindowIcon() === QIcon LXCB::WindowIcon(WId win){ //Fetch the _NET_WM_ICON for the window and return it as a QIcon @@ -1237,17 +1283,17 @@ void LXCB::SetAsPanel(WId win){ //Disable Input focus (panel activation ruins task manager window detection routines) // - Disable Input flag in WM_HINTS xcb_icccm_wm_hints_t hints; - qDebug() << " - Disable WM_HINTS input flag"; + //qDebug() << " - Disable WM_HINTS input flag"; xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(QX11Info::connection(), win); - qDebug() << " -- got cookie"; + //qDebug() << " -- got cookie"; if(1 == xcb_icccm_get_wm_hints_reply(QX11Info::connection(), cookie, &hints, NULL) ){ - qDebug() << " -- Set no inputs flag"; + //qDebug() << " -- Set no inputs flag"; xcb_icccm_wm_hints_set_input(&hints, False); //set no input focus xcb_icccm_set_wm_hints(QX11Info::connection(), win, &hints); //save hints back to window } // - Remove WM_TAKE_FOCUS from the WM_PROTOCOLS for the window // - - Generate the necessary atoms - qDebug() << " - Generate WM_PROTOCOLS and WM_TAKE_FOCUS atoms"; + //qDebug() << " - Generate WM_PROTOCOLS and WM_TAKE_FOCUS atoms"; xcb_atom_t WM_PROTOCOLS, WM_TAKE_FOCUS; //the two atoms needed xcb_intern_atom_reply_t *preply = xcb_intern_atom_reply(QX11Info::connection(), \ xcb_intern_atom(QX11Info::connection(), 0, 12, "WM_PROTOCOLS"), NULL); @@ -1260,11 +1306,11 @@ void LXCB::SetAsPanel(WId win){ free(preply); free(freply); gotatoms = true; - qDebug() << " -- success"; + //qDebug() << " -- success"; } // - - Now update the protocols for the window if(gotatoms){ //requires the atoms - qDebug() << " - Get WM_PROTOCOLS"; + //qDebug() << " - Get WM_PROTOCOLS"; xcb_icccm_get_wm_protocols_reply_t proto; if( 1 == xcb_icccm_get_wm_protocols_reply(QX11Info::connection(), \ xcb_icccm_get_wm_protocols_unchecked(QX11Info::connection(), win, WM_PROTOCOLS), \ @@ -1274,12 +1320,12 @@ void LXCB::SetAsPanel(WId win){ //remove the take focus atom and re-save them bool needremove = false; //Note: This first loop is required so that we can initialize the modified list with a valid size - qDebug() << " -- Check current protocols"; + //qDebug() << " -- Check current protocols"; for(unsigned int i=0; i