From 1cc5c2ff3febf2d2182aa96902727b9c2a2e46a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Mon, 4 Feb 2013 16:46:34 +0100 Subject: [PATCH] react on screenCountChanged to re-validate lists includes fixing commit 1ac2f407c67c5740fb79cb11b610814a056b3268 BUG: 314409 REVIEW: 108775 FIXED-IN: 4.10.1 (cherry picked from commit e4ef2f072336a59039b1372266e4a5ab05d29cc0) --- effects/presentwindows/presentwindows.cpp | 41 ++++++++++++++++------- effects/presentwindows/presentwindows.h | 1 + 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index 2f937f418c..7a59aece8c 100755 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -42,6 +42,8 @@ along with this program. If not, see . #include #include #include +#include +#include #include #include #include @@ -102,6 +104,8 @@ PresentWindowsEffect::PresentWindowsEffect() connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*))); connect(effects, SIGNAL(windowGeometryShapeChanged(KWin::EffectWindow*,QRect)), this, SLOT(slotWindowGeometryShapeChanged(KWin::EffectWindow*,QRect))); connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), this, SLOT(slotPropertyNotify(KWin::EffectWindow*,long))); + + connect (qApp->desktop(), SIGNAL(screenCountChanged(int)), SLOT(screenCountChanged())); } PresentWindowsEffect::~PresentWindowsEffect() @@ -1540,19 +1544,7 @@ void PresentWindowsEffect::setActive(bool active) m_hasKeyboardGrab = effects->grabKeyboard(this); effects->setActiveFullScreenEffect(this); - m_gridSizes.clear(); - for (int i = 0; i < effects->numScreens(); ++i) { - m_gridSizes.append(GridSize()); - if (m_dragToClose) { - const QRect screenRect = effects->clientArea(FullScreenArea, i, 1); - EffectFrame *frame = effects->effectFrame(EffectFrameNone, false); - KIcon icon("user-trash"); - frame->setIcon(icon.pixmap(QSize(128, 128))); - frame->setPosition(QPoint(screenRect.x() + screenRect.width(), screenRect.y())); - frame->setAlignment(Qt::AlignRight | Qt::AlignTop); - m_dropTargets.append(frame); - } - } + screenCountChanged(); rearrangeWindows(); setHighlightedWindow(effects->activeWindow()); @@ -1930,6 +1922,29 @@ bool PresentWindowsEffect::isActive() const return m_activated || m_motionManager.managingWindows(); } +void PresentWindowsEffect::screenCountChanged() +{ + if (!isActive()) + return; + while (!m_dropTargets.empty()) { + delete m_dropTargets.takeFirst(); + } + m_gridSizes.clear(); + for (int i = 0; i < effects->numScreens(); ++i) { + m_gridSizes.append(GridSize()); + if (m_dragToClose) { + const QRect screenRect = effects->clientArea(FullScreenArea, i, 1); + EffectFrame *frame = effects->effectFrame(EffectFrameNone, false); + KIcon icon("user-trash"); + frame->setIcon(icon.pixmap(QSize(128, 128))); + frame->setPosition(QPoint(screenRect.x() + screenRect.width(), screenRect.y())); + frame->setAlignment(Qt::AlignRight | Qt::AlignTop); + m_dropTargets.append(frame); + } + } + rearrangeWindows(); +} + /************************************************ * CloseWindowView ************************************************/ diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index e891715aa4..0906455cab 100644 --- a/effects/presentwindows/presentwindows.h +++ b/effects/presentwindows/presentwindows.h @@ -224,6 +224,7 @@ public slots: private slots: void closeWindow(); void elevateCloseWindow(); + void screenCountChanged(); protected: // Window rearranging