Move checkQuickTilingMaximizationZones to AbstractClient

Implementation is moved to abstract_client.cpp as so far events.cpp
does not have any code from AbstractClient.

This includes moving the electricMaximizingDelay from Client to
AbstractClient.
This commit is contained in:
Martin Gräßlin 2015-10-23 13:32:18 +02:00
parent 7e23860957
commit dcff41ab40
5 changed files with 67 additions and 67 deletions

View file

@ -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);
}
}
}
}

View file

@ -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

View file

@ -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)

View file

@ -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;

View file

@ -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)
{