diff --git a/desktoplayout.cpp b/desktoplayout.cpp index 75785590b3..f275782e9e 100644 --- a/desktoplayout.cpp +++ b/desktoplayout.cpp @@ -19,6 +19,7 @@ along with this program. If not, see . *********************************************************************/ #include "workspace.h" +#include "options.h" #include "assert.h" @@ -27,6 +28,11 @@ namespace KWin void Workspace::updateDesktopLayout() { +#ifdef KWIN_BUILD_SCREENEDGES + if (options->electricBorders() == Options::ElectricAlways) { + m_screenEdge.reserveDesktopSwitching(false, m_screenEdgeOrientation); + } +#endif // TODO: Is there a sane way to avoid overriding the existing grid? int width = rootInfo->desktopLayoutColumnsRows().width(); int height = rootInfo->desktopLayoutColumnsRows().height(); @@ -36,6 +42,17 @@ void Workspace::updateDesktopLayout() rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical, width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. ); + +#ifdef KWIN_BUILD_SCREENEDGES + m_screenEdgeOrientation = 0; + if (width > 1) + m_screenEdgeOrientation |= Qt::Horizontal; + if (height > 1) + m_screenEdgeOrientation |= Qt::Vertical; + if (options->electricBorders() == Options::ElectricAlways) { + m_screenEdge.reserveDesktopSwitching(true, m_screenEdgeOrientation); + } +#endif } void Workspace::setNETDesktopLayout(Qt::Orientation orientation, int width, int height, diff --git a/effects.cpp b/effects.cpp index 4b1c242af5..b07ccc8b08 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1075,10 +1075,10 @@ void EffectsHandlerImpl::unreserveElectricBorder(ElectricBorder border) #endif } -void EffectsHandlerImpl::reserveElectricBorderSwitching(bool reserve) +void EffectsHandlerImpl::reserveElectricBorderSwitching(bool reserve, Qt::Orientations o) { #ifdef KWIN_BUILD_SCREENEDGES - Workspace::self()->screenEdge()->reserveDesktopSwitching(reserve); + Workspace::self()->screenEdge()->reserveDesktopSwitching(reserve, o); #else Q_UNUSED(reserve) #endif diff --git a/effects.h b/effects.h index 7278118228..b2055733ba 100644 --- a/effects.h +++ b/effects.h @@ -137,7 +137,7 @@ public: virtual void checkElectricBorder(const QPoint &pos, Time time); virtual void reserveElectricBorder(ElectricBorder border); virtual void unreserveElectricBorder(ElectricBorder border); - virtual void reserveElectricBorderSwitching(bool reserve); + virtual void reserveElectricBorderSwitching(bool reserve, Qt::Orientations o); virtual unsigned long xrenderBufferPicture(); virtual void reconfigure(); diff --git a/geometry.cpp b/geometry.cpp index 4c70e2cc26..33cd4cb5a6 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -2564,7 +2564,7 @@ bool Client::startMoveResize() if (options->electricBorders() == Options::ElectricMoveOnly || options->electricBorderMaximize() || options->electricBorderTiling()) - workspace()->screenEdge()->reserveDesktopSwitching(true); + workspace()->screenEdge()->reserveDesktopSwitching(true, Qt::Vertical|Qt::Horizontal); #endif if (fakeMove) // fix geom_restore position - it HAS to happen at the end, ie. when all moving is set up. inline call will lock focus!! handleMoveResize(QCursor::pos().x(), QCursor::pos().y(), QCursor::pos().x(), QCursor::pos().y()); @@ -2677,7 +2677,7 @@ void Client::leaveMoveResize() if (options->electricBorders() == Options::ElectricMoveOnly || options->electricBorderMaximize() || options->electricBorderTiling()) - workspace()->screenEdge()->reserveDesktopSwitching(false); + workspace()->screenEdge()->reserveDesktopSwitching(false, Qt::Vertical|Qt::Horizontal); #endif } diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index c8fa295dc9..88913006b6 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -167,7 +167,7 @@ X-KDE-Library=kwin4_effect_cooleffect #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) #define KWIN_EFFECT_API_VERSION_MAJOR 0 -#define KWIN_EFFECT_API_VERSION_MINOR 182 +#define KWIN_EFFECT_API_VERSION_MINOR 183 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) @@ -645,7 +645,7 @@ public: virtual void checkElectricBorder(const QPoint &pos, Time time) = 0; virtual void reserveElectricBorder(ElectricBorder border) = 0; virtual void unreserveElectricBorder(ElectricBorder border) = 0; - virtual void reserveElectricBorderSwitching(bool reserve) = 0; + virtual void reserveElectricBorderSwitching(bool reserve, Qt::Orientations o) = 0; // functions that allow controlling windows/desktop virtual void activateWindow(KWin::EffectWindow* c) = 0; diff --git a/scene.cpp b/scene.cpp index ff6aec7273..ffd181d0fe 100644 --- a/scene.cpp +++ b/scene.cpp @@ -583,8 +583,7 @@ WindowQuadList Scene::Window::buildQuads(bool force) const Client *client = dynamic_cast(toplevel); QRegion contents = clientShape(); QRegion center = toplevel->transparentRect(); - QRegion decoration = (client && Workspace::self()->decorationHasAlpha() ? - QRegion(client->decorationRect()) : shape()) - center; + QRegion decoration = shape() - center; ret = makeQuads(WindowQuadContents, contents); if (!client || !(center.isEmpty() || client->isShade())) ret += makeQuads(WindowQuadDecoration, decoration); diff --git a/screenedge.cpp b/screenedge.cpp index 858b823e57..8bdc1c17f0 100644 --- a/screenedge.cpp +++ b/screenedge.cpp @@ -58,9 +58,6 @@ ScreenEdge::~ScreenEdge() void ScreenEdge::init() { reserveActions(true); - if (options->electricBorders() == Options::ElectricAlways) { - reserveDesktopSwitching(true); - } update(); } @@ -143,13 +140,39 @@ void ScreenEdge::reserveActions(bool isToReserve) } } -void ScreenEdge::reserveDesktopSwitching(bool isToReserve) +void ScreenEdge::reserveDesktopSwitching(bool isToReserve, Qt::Orientations o) { - for (int pos = 0; pos < ELECTRIC_COUNT; ++pos) - if (isToReserve) - reserve(static_cast(pos)); - else - unreserve(static_cast(pos)); + if (!o) + return; + if (isToReserve) { + reserve(ElectricTopLeft); + reserve(ElectricTopRight); + reserve(ElectricBottomRight); + reserve(ElectricBottomLeft); + + if (o & Qt::Horizontal) { + reserve(ElectricLeft); + reserve(ElectricRight); + } + if (o & Qt::Vertical) { + reserve(ElectricTop); + reserve(ElectricBottom); + } + } else { + unreserve(ElectricTopLeft); + unreserve(ElectricTopRight); + unreserve(ElectricBottomRight); + unreserve(ElectricBottomLeft); + + if (o & Qt::Horizontal) { + unreserve(ElectricLeft); + unreserve(ElectricRight); + } + if (o & Qt::Vertical) { + unreserve(ElectricTop); + unreserve(ElectricBottom); + } + } } void ScreenEdge::reserve(ElectricBorder border) diff --git a/screenedge.h b/screenedge.h index cf08164664..16a2542d71 100644 --- a/screenedge.h +++ b/screenedge.h @@ -84,7 +84,7 @@ public: * Reserve desktop switching for screen edges, if reserve is true. Unreserve otherwise. * @param reserve indicated weather desktop switching should be reserved or unreseved */ - void reserveDesktopSwitching(bool isToReserve); + void reserveDesktopSwitching(bool isToReserve, Qt::Orientations o); /** * Raise electric border windows to the real top of the screen. We only need * to do this if an effect input window is active. diff --git a/workspace.cpp b/workspace.cpp index d501d24569..eee91efe8b 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -107,6 +107,7 @@ Workspace::Workspace(bool restore) , desktopGridSize_(1, 2) // Default to two rows , desktopGrid_(new int[2]) , currentDesktop_(0) + , m_screenEdgeOrientation(0) // Unsorted , active_popup(NULL) , active_popup_client(NULL) @@ -958,7 +959,7 @@ void Workspace::slotReconfigure() #ifdef KWIN_BUILD_SCREENEDGES m_screenEdge.reserveActions(false); if (options->electricBorders() == Options::ElectricAlways) - m_screenEdge.reserveDesktopSwitching(false); + m_screenEdge.reserveDesktopSwitching(false, m_screenEdgeOrientation); #endif bool borderlessMaximizedWindows = options->borderlessMaximizedWindows(); @@ -996,8 +997,15 @@ void Workspace::slotReconfigure() #ifdef KWIN_BUILD_SCREENEDGES m_screenEdge.reserveActions(true); - if (options->electricBorders() == Options::ElectricAlways) - m_screenEdge.reserveDesktopSwitching(true); + if (options->electricBorders() == Options::ElectricAlways) { + QSize desktopMatrix = rootInfo->desktopLayoutColumnsRows(); + m_screenEdgeOrientation = 0; + if (desktopMatrix.width() > 1) + m_screenEdgeOrientation |= Qt::Horizontal; + if (desktopMatrix.height() > 1) + m_screenEdgeOrientation |= Qt::Vertical; + m_screenEdge.reserveDesktopSwitching(true, m_screenEdgeOrientation); + } m_screenEdge.update(); #endif diff --git a/workspace.h b/workspace.h index 254bf4ef30..d8f9d13cc5 100644 --- a/workspace.h +++ b/workspace.h @@ -318,6 +318,7 @@ private: Outline* m_outline; #ifdef KWIN_BUILD_SCREENEDGES ScreenEdge m_screenEdge; + Qt::Orientations m_screenEdgeOrientation; #endif //-------------------------------------------------