diff --git a/abstract_client.cpp b/abstract_client.cpp index 45b99521b9..edf3c3004b 100644 --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -1137,4 +1137,65 @@ void AbstractClient::doPerformMoveResize() { } +void AbstractClient::checkQuickTilingMaximizationZones(int xroot, int yroot) +{ + QuickTileMode mode = QuickTileNone; + bool innerBorder = false; + for (int i=0; i < screens()->count(); ++i) { + + if (!screens()->geometry(i).contains(QPoint(xroot, yroot))) + continue; + + auto isInScreen = [i](const QPoint &pt) { + for (int j = 0; j < screens()->count(); ++j) { + if (j == i) + continue; + if (screens()->geometry(j).contains(pt)) { + return true; + } + } + return false; + }; + + QRect area = workspace()->clientArea(MaximizeArea, QPoint(xroot, yroot), desktop()); + if (options->electricBorderTiling()) { + if (xroot <= area.x() + 20) { + mode |= QuickTileLeft; + innerBorder = isInScreen(QPoint(area.x() - 1, yroot)); + } else if (xroot >= area.x() + area.width() - 20) { + mode |= QuickTileRight; + innerBorder = isInScreen(QPoint(area.right() + 1, yroot)); + } + } + + if (mode != QuickTileNone) { + if (yroot <= area.y() + area.height() * options->electricBorderCornerRatio()) + mode |= QuickTileTop; + else if (yroot >= area.y() + area.height() - area.height() * options->electricBorderCornerRatio()) + mode |= QuickTileBottom; + } else if (options->electricBorderMaximize() && yroot <= area.y() + 5 && isMaximizable()) { + mode = QuickTileMaximize; + innerBorder = isInScreen(QPoint(xroot, area.y() - 1)); + } + break; // no point in checking other screens to contain this... "point"... + } + if (mode != electricBorderMode()) { + setElectricBorderMode(mode); + if (innerBorder) { + if (!m_electricMaximizingDelay) { + m_electricMaximizingDelay = new QTimer(this); + m_electricMaximizingDelay->setInterval(250); + m_electricMaximizingDelay->setSingleShot(true); + connect(m_electricMaximizingDelay, &QTimer::timeout, [this]() { + if (isMove()) + setElectricBorderMaximizing(electricBorderMode() != QuickTileNone); + }); + } + m_electricMaximizingDelay->start(); + } else { + setElectricBorderMaximizing(mode != QuickTileNone); + } + } +} + } diff --git a/abstract_client.h b/abstract_client.h index c5b10f165e..3b488f063a 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -725,6 +725,11 @@ protected: * Default implementation does nothing. **/ virtual void doPerformMoveResize(); + /* + * Checks if the mouse cursor is near the edge of the screen and if so + * activates quick tiling or maximization + */ + void checkQuickTilingMaximizationZones(int xroot, int yroot); static bool haveResizeEffect() { return s_haveResizeEffect; @@ -772,6 +777,7 @@ private: /** The quick tile mode of this window. */ int m_quickTileMode = QuickTileNone; + QTimer *m_electricMaximizingDelay = nullptr; // geometry int m_blockGeometryUpdates = 0; // > 0 = New geometry is remembered, but not actually set diff --git a/client.cpp b/client.cpp index f5b8135e9b..9694d983cf 100644 --- a/client.cpp +++ b/client.cpp @@ -119,7 +119,6 @@ Client::Client() , allowed_actions(0) , shade_geometry_change(false) , sm_stacking_order(-1) - , m_electricMaximizingDelay(nullptr) , activitiesDefined(false) , needsSessionInteract(false) , needsXWindowMove(false) diff --git a/client.h b/client.h index 4e84e64be7..fdde6b88d1 100644 --- a/client.h +++ b/client.h @@ -445,7 +445,6 @@ private: bool buttonPressEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root, xcb_timestamp_t time = XCB_CURRENT_TIME); bool buttonReleaseEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root); bool motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x_root, int y_root); - void checkQuickTilingMaximizationZones(int xroot, int yroot); bool processDecorationButtonPress(int button, int state, int x, int y, int x_root, int y_root, bool ignoreMenu = false); @@ -673,8 +672,6 @@ private: int sm_stacking_order; friend struct ResetupRulesProcedure; - QTimer* m_electricMaximizingDelay; - friend bool performTransiencyCheck(); Xcb::StringProperty fetchActivities() const; diff --git a/events.cpp b/events.cpp index af5514b0a6..09ab7fbdb5 100644 --- a/events.cpp +++ b/events.cpp @@ -1314,69 +1314,6 @@ bool Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x, in return true; } -// Checks if the mouse cursor is near the edge of the screen and if so activates quick tiling or maximization -void Client::checkQuickTilingMaximizationZones(int xroot, int yroot) -{ - - QuickTileMode mode = QuickTileNone; - bool innerBorder = false; - for (int i=0; i < screens()->count(); ++i) { - - if (!screens()->geometry(i).contains(QPoint(xroot, yroot))) - continue; - - auto isInScreen = [i](const QPoint &pt) { - for (int j = 0; j < screens()->count(); ++j) { - if (j == i) - continue; - if (screens()->geometry(j).contains(pt)) { - return true; - } - } - return false; - }; - - QRect area = workspace()->clientArea(MaximizeArea, QPoint(xroot, yroot), desktop()); - if (options->electricBorderTiling()) { - if (xroot <= area.x() + 20) { - mode |= QuickTileLeft; - innerBorder = isInScreen(QPoint(area.x() - 1, yroot)); - } else if (xroot >= area.x() + area.width() - 20) { - mode |= QuickTileRight; - innerBorder = isInScreen(QPoint(area.right() + 1, yroot)); - } - } - - if (mode != QuickTileNone) { - if (yroot <= area.y() + area.height() * options->electricBorderCornerRatio()) - mode |= QuickTileTop; - else if (yroot >= area.y() + area.height() - area.height() * options->electricBorderCornerRatio()) - mode |= QuickTileBottom; - } else if (options->electricBorderMaximize() && yroot <= area.y() + 5 && isMaximizable()) { - mode = QuickTileMaximize; - innerBorder = isInScreen(QPoint(xroot, area.y() - 1)); - } - break; // no point in checking other screens to contain this... "point"... - } - if (mode != electricBorderMode()) { - setElectricBorderMode(mode); - if (innerBorder) { - if (!m_electricMaximizingDelay) { - m_electricMaximizingDelay = new QTimer(this); - m_electricMaximizingDelay->setInterval(250); - m_electricMaximizingDelay->setSingleShot(true); - connect(m_electricMaximizingDelay, &QTimer::timeout, [this]() { - if (isMove()) - setElectricBorderMaximizing(electricBorderMode() != QuickTileNone); - }); - } - m_electricMaximizingDelay->start(); - } else { - setElectricBorderMaximizing(mode != QuickTileNone); - } - } -} - // return value matters only when filtering events before decoration gets them bool Client::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x_root, int y_root) {