commit d35ec6d18377fd872207b88dd39f560a483bcc14 Author: Matthias Fuchs <mat69@gmx.net> Date: Thu Jul 28 23:49:08 2011 +0200 Fixes disabling fullscreen for windows using two displays. Dragging a fullscreen window to another screen and then disabling fullscreen keeps the window at the new screen. BUG:261704 FIXED-IN:4.7.1 REVIEW:102103 diff --git a/kwin/client.h b/kwin/client.h index 32ce6f7..c0a87db 100644 --- a/kwin/client.h +++ b/kwin/client.h 2011-09-10 20:47:51.289468128 -0300 @@ -621,7 +621,8 @@ uint urgency : 1; ///< XWMHints, UrgencyHint uint ignore_focus_stealing : 1; ///< Don't apply focus stealing prevention to this client uint demands_attention : 1; - WindowRules client_rules; + int m_screenNum; + WindowRules client_rules; void getWMHints(); void readIcons(); void getWindowProtocols(); diff --git a/kwin/geometry.cpp b/kwin/geometry.cpp index c5e4fd9..4a05392 100644 --- a/kwin/geometry.cpp +++ b/kwin/geometry.cpp 2011-09-10 20:57:15.467499928 -0300 @@ -2543,8 +2543,10 @@ set = rules()->checkFullScreen( set ); setShade( ShadeNone ); bool was_fs = isFullScreen(); - if( !was_fs ) + if( !was_fs ) { geom_fs_restore = geometry(); + m_screenNum = workspace()->activeScreen(); + } fullscreen_mode = set ? FullScreenNormal : FullScreenNone; if( was_fs == isFullScreen()) return; @@ -2562,10 +2564,27 @@ setGeometry( workspace()->clientArea( FullScreenArea, this )); else { - if( !geom_fs_restore.isNull()) + if( !geom_fs_restore.isNull()) { + //adapt geom_fs_restore to the current screen geometry if needed + const int newScreen = workspace()->activeScreen(); + if (options->xineramaFullscreenEnabled && (newScreen != m_screenNum)) { + const QRect oldGeom = workspace()->screenGeometry(m_screenNum); + const QRect newGeom = workspace()->screenGeometry(newScreen); + if (oldGeom.isValid()) { + const QPoint dist = geom_fs_restore.topLeft() - oldGeom.topLeft(); + geom_fs_restore.moveTopLeft(newGeom.topLeft() + dist); + + + //make sure that the client is still visible + if (!newGeom.intersects(geom_fs_restore)) { + geom_fs_restore.moveTopLeft(newGeom.topLeft()); + } + } + } setGeometry( QRect( geom_fs_restore.topLeft(), adjustedSize( geom_fs_restore.size()))); + checkWorkspacePosition(); // TODO isShaded() ? - else + } else { // does this ever happen? setGeometry( workspace()->clientArea( MaximizeArea, this )); }