From 7d673802050ebeb55572b0275416eb87a7c251bc Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Thu, 28 Jul 2011 23:49:08 +0200 Subject: [PATCH] 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 (cherry picked from commit d35ec6d18377fd872207b88dd39f560a483bcc14) --- client.h | 1 + geometry.cpp | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/client.h b/client.h index 6a89d694e2..d9cdddfcca 100644 --- a/client.h +++ b/client.h @@ -643,6 +643,7 @@ private: uint urgency : 1; ///< XWMHints, UrgencyHint uint ignore_focus_stealing : 1; ///< Don't apply focus stealing prevention to this client uint demands_attention : 1; + int m_screenNum; bool blocks_compositing; WindowRules client_rules; void getWMHints(); diff --git a/geometry.cpp b/geometry.cpp index 51ed034ac3..b1096dd02d 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -2354,8 +2354,10 @@ void Client::setFullScreen(bool set, bool user) 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; @@ -2372,10 +2374,26 @@ void Client::setFullScreen(bool set, bool user) else 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)); }