From 9001af8e5a127dac02ebc7a568f27c213a2b3652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sat, 17 Aug 2013 16:46:46 +0200 Subject: [PATCH 1/4] reset custom cube shaders on screen change the reset/setup invokes the viewport dimensions... BUG: 323311 FIXED-IN: 4.11.1 REVIEW: 112133 --- effects/cube/cube.cpp | 9 +++++++++ effects/cube/cube.h | 1 + libkwineffects/kwinglutils.cpp | 10 ++++++++++ libkwineffects/kwinglutils.h | 6 ++++++ 4 files changed, 26 insertions(+) diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index df01d7c5bb..858356d63f 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -122,6 +122,7 @@ CubeEffect::CubeEffect() connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int))); connect(effects, SIGNAL(tabBoxClosed()), this, SLOT(slotTabBoxClosed())); connect(effects, SIGNAL(tabBoxUpdated()), this, SLOT(slotTabBoxUpdated())); + connect(effects, SIGNAL(screenGeometryChanged(const QSize&)), this, SLOT(slotResetShaders())); reconfigure(ReconfigureAll); } @@ -290,6 +291,14 @@ void CubeEffect::slotWallPaperLoaded() watcher->deleteLater(); } +void CubeEffect::slotResetShaders() +{ + ShaderManager::instance()->resetShader(m_capShader, ShaderManager::GenericShader); + ShaderManager::instance()->resetShader(m_reflectionShader, ShaderManager::GenericShader); + ShaderManager::instance()->resetShader(cylinderShader, ShaderManager::GenericShader); + ShaderManager::instance()->resetShader(sphereShader, ShaderManager::GenericShader); +} + bool CubeEffect::loadShader() { if (!(GLPlatform::instance()->supports(GLSL) && diff --git a/effects/cube/cube.h b/effects/cube/cube.h index 4fb15adfd2..d222ee4c02 100644 --- a/effects/cube/cube.h +++ b/effects/cube/cube.h @@ -139,6 +139,7 @@ private slots: void slotTabBoxClosed(); void slotCubeCapLoaded(); void slotWallPaperLoaded(); + void slotResetShaders(); private: enum RotationDirection { Left, diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp index 777755af79..a6cd8c33d9 100644 --- a/libkwineffects/kwinglutils.cpp +++ b/libkwineffects/kwinglutils.cpp @@ -787,6 +787,16 @@ void ShaderManager::resetAllShaders() } } +void ShaderManager::resetShader(GLShader *shader, ShaderType type) +{ + if (!(shader && shader->isValid())) + return; + + pushShader(shader); + resetShader(type); + popShader(); +} + void ShaderManager::pushShader(GLShader *shader) { diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h index 20a66013b4..e5c6f7660f 100644 --- a/libkwineffects/kwinglutils.h +++ b/libkwineffects/kwinglutils.h @@ -352,6 +352,12 @@ public: **/ void resetAllShaders(); + /** + * Resets ShaderType @p type uniforms of a custom shader + * @since 4.11.1 + */ + void resetShader(GLShader *shader, ShaderType type); + /** * Creates a GLShader with a built-in vertex shader and a custom fragment shader. * @param vertex The generic vertex shader From 2568fcb149227cb6f90ac284bc2540bc2635e51e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 16 Aug 2013 21:21:21 +0200 Subject: [PATCH 2/4] guide partially max'd windows against corner snaps BUG: 323598 FIXED-IN: 4.11.1 REVIEW: 112124 --- geometry.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/geometry.cpp b/geometry.cpp index 9adcb98776..480f97da82 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -383,13 +383,16 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted, { QSize borderSnapZone(options->borderSnapZone(), options->borderSnapZone()); QRect maxRect; + int guideMaximized = MaximizeRestore; if (c->maximizeMode() != MaximizeRestore) { maxRect = clientArea(MovementArea, pos + c->rect().center(), c->desktop()); QRect geo = c->geometry(); if (c->maximizeMode() & MaximizeHorizontal && (geo.x() == maxRect.left() || geo.right() == maxRect.right())) { + guideMaximized |= MaximizeHorizontal; borderSnapZone.setWidth(qMax(borderSnapZone.width() + 2, maxRect.width() / 16)); } if (c->maximizeMode() & MaximizeVertical && (geo.y() == maxRect.top() || geo.bottom() == maxRect.bottom())) { + guideMaximized |= MaximizeVertical; borderSnapZone.setHeight(qMax(borderSnapZone.height() + 2, maxRect.height() / 16)); } } @@ -478,7 +481,8 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted, lrx = lx + (*l)->width(); lry = ly + (*l)->height(); - if (((cy <= lry) && (cy >= ly)) || ((ry >= ly) && (ry <= lry)) || ((cy <= ly) && (ry >= lry))) { + if (!(guideMaximized & MaximizeHorizontal) && + (((cy <= lry) && (cy >= ly)) || ((ry >= ly) && (ry <= lry)) || ((cy <= ly) && (ry >= lry)))) { if ((sOWO ? (cx < lrx) : true) && (qAbs(lrx - cx) < snap) && (qAbs(lrx - cx) < deltaX)) { deltaX = qAbs(lrx - cx); nx = lrx; @@ -489,7 +493,8 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted, } } - if (((cx <= lrx) && (cx >= lx)) || ((rx >= lx) && (rx <= lrx)) || ((cx <= lx) && (rx >= lrx))) { + if (!(guideMaximized & MaximizeVertical) && + (((cx <= lrx) && (cx >= lx)) || ((rx >= lx) && (rx <= lrx)) || ((cx <= lx) && (rx >= lrx)))) { if ((sOWO ? (cy < lry) : true) && (qAbs(lry - cy) < snap) && (qAbs(lry - cy) < deltaY)) { deltaY = qAbs(lry - cy); ny = lry; @@ -502,7 +507,7 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted, } // Corner snapping - if (nx == lrx || nx + cw == lx) { + if (!(guideMaximized & MaximizeVertical) && (nx == lrx || nx + cw == lx)) { if ((sOWO ? (ry > lry) : true) && (qAbs(lry - ry) < snap) && (qAbs(lry - ry) < deltaY)) { deltaY = qAbs(lry - ry); ny = lry - ch; @@ -512,7 +517,7 @@ QPoint Workspace::adjustClientPosition(Client* c, QPoint pos, bool unrestricted, ny = ly; } } - if (ny == lry || ny + ch == ly) { + if (!(guideMaximized & MaximizeHorizontal) && (ny == lry || ny + ch == ly)) { if ((sOWO ? (rx > lrx) : true) && (qAbs(lrx - rx) < snap) && (qAbs(lrx - rx) < deltaX)) { deltaX = qAbs(lrx - rx); nx = lrx - cw; From 7d6d80351cc5c059b7dcda738ae4f0e588acfadb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Thu, 15 Aug 2013 11:53:02 +0200 Subject: [PATCH 3/4] align zero corner placement to client, not deco BUG: 318107 FIXED-IN: 4.11.1 REVIEW: 112102 --- manage.cpp | 3 ++- placement.cpp | 30 ++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/manage.cpp b/manage.cpp index e4faec0914..c4206d2d9b 100644 --- a/manage.cpp +++ b/manage.cpp @@ -377,6 +377,7 @@ bool Client::manage(xcb_window_t w, bool isMapped) if (!placementDone) { // Placement needs to be after setting size Placement::self()->place(this, area); + dontKeepInArea = true; placementDone = true; } @@ -419,7 +420,7 @@ bool Client::manage(xcb_window_t w, bool isMapped) if (pseudo_max != Client::MaximizeRestore) { maximize((MaximizeMode)pseudo_max); // from now on, care about maxmode, since the maximization call will override mode for fix aspects - dontKeepInArea = (max_mode == Client::MaximizeFull); + dontKeepInArea |= (max_mode == Client::MaximizeFull); geom_restore = QRect(); // Use placement when unmaximizing ... if (!(max_mode & Client::MaximizeVertical)) { geom_restore.setY(y()); // ...but only for horizontal direction diff --git a/placement.cpp b/placement.cpp index 55fcb34e87..493ae158c7 100644 --- a/placement.cpp +++ b/placement.cpp @@ -28,6 +28,7 @@ along with this program. If not, see . #include #ifndef KCMRULES +#include #include "workspace.h" #include "client.h" #include "options.h" @@ -96,6 +97,30 @@ void Placement::place(Client* c, QRect& area, Policy policy, Policy nextPlacemen placeMaximizing(c, area, nextPlacement); else placeSmart(c, area, nextPlacement); + + if (options->borderSnapZone()) { + // snap to titlebar / snap to window borders on inner screen edges + const QRect geo(c->geometry()); + QPoint corner = geo.topLeft(); + const QPoint cp = c->clientPos(); + const QSize cs = geo.size() - c->clientSize(); + KDecorationDefines::Position titlePos = c->titlebarPosition(); + + const QRect fullRect = workspace()->clientArea(FullArea, c); + if (!(c->maximizeMode() & KDecorationDefines::MaximizeHorizontal)) { + if (titlePos != KDecorationDefines::PositionRight && geo.right() == fullRect.right()) + corner.rx() += cs.width() - cp.x(); + if (titlePos != KDecorationDefines::PositionLeft && geo.x() == fullRect.x()) + corner.rx() -= cp.x(); + } + if (!(c->maximizeMode() & KDecorationDefines::MaximizeVertical)) { + if (titlePos != KDecorationDefines::PositionBottom && geo.bottom() == fullRect.bottom()) + corner.ry() += cs.height() - cp.y(); + if (titlePos != KDecorationDefines::PositionTop && geo.y() == fullRect.y()) + corner.ry() -= cp.y(); + } + c->move(corner); + } } /*! @@ -442,10 +467,7 @@ void Placement::placeCentered(Client* c, const QRect& area, Policy /*next*/) void Placement::placeZeroCornered(Client* c, const QRect& area, Policy /*next*/) { // get the maximum allowed windows space and desk's origin - const QRect maxRect = checkArea(c, area); - - // place the window - c->move(QPoint(maxRect.left(), maxRect.top())); + c->move(checkArea(c, area).topLeft()); } void Placement::placeUtility(Client* c, QRect& area, Policy /*next*/) From 29e230dca3604f0202f480a4dd0c8fcbf7515865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 16 Aug 2013 19:38:26 +0200 Subject: [PATCH 4/4] enforce reactivation threshold to be 50ms bigger than actication threshold. Things don't work otherwise. BUG: 323588 FIXED-IN: 4.11.1 REVIEW: 112125 --- kcmkwin/kwinscreenedges/main.cpp | 8 ++++++++ kcmkwin/kwinscreenedges/main.h | 3 ++- screenedge.cpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/kcmkwin/kwinscreenedges/main.cpp b/kcmkwin/kwinscreenedges/main.cpp index 9de436a813..72d2b53dbd 100644 --- a/kcmkwin/kwinscreenedges/main.cpp +++ b/kcmkwin/kwinscreenedges/main.cpp @@ -54,6 +54,7 @@ KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget* parent, const QVariantList connect(m_ui->monitor, SIGNAL(changed()), this, SLOT(changed())); connect(m_ui->desktopSwitchCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); + connect(m_ui->activationDelaySpin, SIGNAL(valueChanged(int)), this, SLOT(sanitizeCooldown())); connect(m_ui->activationDelaySpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui->triggerCooldownSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui->quickMaximizeBox, SIGNAL(stateChanged(int)), this, SLOT(changed())); @@ -66,6 +67,8 @@ KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget* parent, const QVariantList connect(m_ui->quickTileBox, SIGNAL(stateChanged(int)), this, SLOT(groupChanged())); load(); + + sanitizeCooldown(); } KWinScreenEdgesConfig::~KWinScreenEdgesConfig() @@ -147,6 +150,11 @@ void KWinScreenEdgesConfig::showEvent(QShowEvent* e) monitorShowEvent(); } +void KWinScreenEdgesConfig::sanitizeCooldown() +{ + m_ui->triggerCooldownSpin->setMinimum(m_ui->activationDelaySpin->value() + 50); +} + // Copied from kcmkwin/kwincompositing/main.cpp bool KWinScreenEdgesConfig::effectEnabled(const QString& effect, const KConfigGroup& cfg) const { diff --git a/kcmkwin/kwinscreenedges/main.h b/kcmkwin/kwinscreenedges/main.h index ec802d6be2..d42271022f 100644 --- a/kcmkwin/kwinscreenedges/main.h +++ b/kcmkwin/kwinscreenedges/main.h @@ -56,7 +56,8 @@ public slots: virtual void defaults(); protected: virtual void showEvent(QShowEvent* e); - +private slots: + void sanitizeCooldown(); private: KWinScreenEdgesConfigForm* m_ui; KSharedConfigPtr m_config; diff --git a/screenedge.cpp b/screenedge.cpp index 3d04f13d1a..a7169d7422 100644 --- a/screenedge.cpp +++ b/screenedge.cpp @@ -591,7 +591,7 @@ void ScreenEdges::reconfigure() // TODO: migrate settings to a group ScreenEdges KConfigGroup windowsConfig = m_config->group("Windows"); setTimeThreshold(windowsConfig.readEntry("ElectricBorderDelay", 150)); - setReActivationThreshold(windowsConfig.readEntry("ElectricBorderCooldown", 350)); + setReActivationThreshold(qMax(timeThreshold() + 50, windowsConfig.readEntry("ElectricBorderCooldown", 350))); int desktopSwitching = windowsConfig.readEntry("ElectricBorders", static_cast(ElectricDisabled)); if (desktopSwitching == ElectricDisabled) { setDesktopSwitching(false);