diff --git a/screenedge.cpp b/screenedge.cpp index a683a3dca3..ee81bd1064 100644 --- a/screenedge.cpp +++ b/screenedge.cpp @@ -60,6 +60,7 @@ Edge::Edge(ScreenEdges *parent) , m_reserved(0) , m_approaching(false) , m_lastApproachingFactor(0.0) + , m_blocked(false) { } @@ -102,6 +103,9 @@ void Edge::unreserve(QObject *object) bool Edge::triggersFor(const QPoint &cursorPos) const { + if (isBlocked()) { + return false; + } if (!m_geometry.contains(cursorPos)) { return false; } @@ -316,6 +320,26 @@ void Edge::setGeometry(const QRect &geometry) doGeometryUpdate(); } +void Edge::checkBlocking() +{ + if (isCorner()) { + return; + } + bool newValue = false; + if (Client *client = Workspace::self()->activeClient()) { + newValue = client->isFullScreen() && client->geometry().contains(m_geometry.center()); + } + if (newValue == m_blocked) { + return; + } + m_blocked = newValue; + doUpdateBlocking(); +} + +void Edge::doUpdateBlocking() +{ +} + void Edge::doGeometryUpdate() { } @@ -422,6 +446,7 @@ void WindowBasedEdge::activate() { createWindow(); createApproachWindow(); + doUpdateBlocking(); } void WindowBasedEdge::deactivate() @@ -499,6 +524,20 @@ void WindowBasedEdge::doStopApproaching() } } +void WindowBasedEdge::doUpdateBlocking() +{ + if (!isReserved()) { + return; + } + if (isBlocked()) { + xcb_unmap_window(connection(), m_window); + xcb_unmap_window(connection(), m_approachWindow); + } else { + xcb_map_window(connection(), m_window); + xcb_map_window(connection(), m_approachWindow); + } +} + /********************************************************** * ScreenEdges *********************************************************/ @@ -872,6 +911,9 @@ WindowBasedEdge *ScreenEdges::createEdge(ElectricBorder border, int x, int y, in } } connect(edge, SIGNAL(approaching(ElectricBorder,qreal,QRect)), SIGNAL(approaching(ElectricBorder,qreal,QRect))); + if (edge->isScreenEdge()) { + connect(this, SIGNAL(checkBlocking()), edge, SLOT(checkBlocking())); + } return edge; } diff --git a/screenedge.h b/screenedge.h index 5b8a00f743..345acfc35a 100644 --- a/screenedge.h +++ b/screenedge.h @@ -73,17 +73,20 @@ public Q_SLOTS: void setAction(ElectricBorderAction action); void setGeometry(const QRect &geometry); void updateApproaching(const QPoint &point); + void checkBlocking(); Q_SIGNALS: void approaching(ElectricBorder border, qreal factor, const QRect &geometry); protected: ScreenEdges *edges(); const ScreenEdges *edges() const; const QRect &geometry() const; + bool isBlocked() const; virtual void doGeometryUpdate(); virtual void activate(); virtual void deactivate(); virtual void doStartApproaching(); virtual void doStopApproaching(); + virtual void doUpdateBlocking(); private: bool canActivate(const QPoint &cursorPos, const QDateTime &triggerTime); void handle(const QPoint &cursorPos); @@ -103,6 +106,7 @@ private: QHash m_callBacks; bool m_approaching; qreal m_lastApproachingFactor; + bool m_blocked; }; class WindowBasedEdge : public Edge @@ -125,6 +129,7 @@ protected: virtual void deactivate(); virtual void doStartApproaching(); virtual void doStopApproaching(); + virtual void doUpdateBlocking(); private: void destroyWindow(); @@ -318,6 +323,7 @@ Q_SIGNALS: **/ void approaching(ElectricBorder border, qreal factor, const QRect &geometry); void mousePollingTimerEvent(QPoint cursorPos); + void checkBlocking(); private Q_SLOTS: void performMousePoll(); @@ -443,6 +449,11 @@ inline const QHash< QObject *, QByteArray > &Edge::callBacks() const return m_callBacks; } +inline bool Edge::isBlocked() const +{ + return m_blocked; +} + /********************************************************** * Inlines WindowBasedEdge *********************************************************/ diff --git a/workspace.cpp b/workspace.cpp index d16d7fd1d2..8f7e450d68 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -267,6 +267,7 @@ void Workspace::init() screenEdges->init(); connect(options, SIGNAL(configChanged()), screenEdges, SLOT(reconfigure())); connect(VirtualDesktopManager::self(), SIGNAL(layoutChanged(int,int)), screenEdges, SLOT(updateLayout())); + connect(this, SIGNAL(clientActivated(KWin::Client*)), screenEdges, SIGNAL(checkBlocking())); #endif supportWindow = new QWidget(NULL, Qt::X11BypassWindowManagerHint); @@ -567,6 +568,9 @@ Client* Workspace::createClient(Window w, bool is_mapped) connect(c, SIGNAL(geometryChanged()), m_compositor, SLOT(checkUnredirect())); connect(c, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), m_compositor, SLOT(checkUnredirect())); connect(c, SIGNAL(blockingCompositingChanged(KWin::Client*)), m_compositor, SLOT(updateCompositeBlocking(KWin::Client*))); +#ifdef KWIN_BUILD_SCREENEDGES + connect(c, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)), ScreenEdges::self(), SIGNAL(checkBlocking())); +#endif if (!c->manage(w, is_mapped)) { Client::deleteClient(c, Allowed); return NULL;