Commit 9f91431e authored by Martin Flöser's avatar Martin Flöser

Move quick tiling from Client to AbstractClient

In order to make it possible to quick tile also ShellClients.
parent 9f2b4c7d
......@@ -1006,15 +1006,6 @@ bool AbstractClient::isActiveFullScreen() const
return ac && (ac == this || ac->screen() != screen());
}
AbstractClient::QuickTileMode AbstractClient::quickTileMode() const
{
return QuickTileNone;
}
void AbstractClient::updateQuickTileMode(QuickTileMode)
{
}
int AbstractClient::borderBottom() const
{
return 0;
......
......@@ -391,8 +391,10 @@ public:
* This will also handle preserving and restoring of window geometry as necessary.
* @param mode The tile mode (left/right) to give this window.
*/
virtual void setQuickTileMode(QuickTileMode mode, bool keyboard = false) = 0;
virtual QuickTileMode quickTileMode() const;
void setQuickTileMode(QuickTileMode mode, bool keyboard = false);
QuickTileMode quickTileMode() const {
return QuickTileMode(m_quickTileMode);
}
Layer layer() const override;
void updateLayer();
......@@ -552,7 +554,9 @@ protected:
return m_electricMaximizing;
}
QRect electricBorderMaximizeGeometry(QPoint pos, int desktop);
virtual void updateQuickTileMode(QuickTileMode newMode);
void updateQuickTileMode(QuickTileMode newMode) {
m_quickTileMode = newMode;
}
// geometry handling
void checkOffscreenPosition(QRect *geom, const QRect &screenArea);
......@@ -609,6 +613,9 @@ private:
// electric border/quick tiling
QuickTileMode m_electricMode = QuickTileNone;
bool m_electricMaximizing = false;
/** The quick tile mode of this window.
*/
int m_quickTileMode = QuickTileNone;
// geometry
int m_blockGeometryUpdates = 0; // > 0 = New geometry is remembered, but not actually set
......
......@@ -139,7 +139,6 @@ Client::Client()
// Set the initial mapping state
mapping_state = Withdrawn;
quick_tile_mode = QuickTileNone;
mode = PositionCenter;
buttonDown = false;
......
......@@ -227,7 +227,6 @@ public:
QRect geometryRestore() const override;
MaximizeMode maximizeMode() const override;
QuickTileMode quickTileMode() const override;
bool isMinimizable() const override;
QRect iconGeometry() const;
......@@ -279,12 +278,6 @@ public:
void resizeWithChecks(const QSize& s, xcb_gravity_t gravity, ForceGeometry_t force = NormalGeometrySet);
QSize sizeForClientSize(const QSize&, Sizemode mode = SizemodeAny, bool noframe = false) const override;
/** Set the quick tile mode ("snap") of this window.
* This will also handle preserving and restoring of window geometry as necessary.
* @param mode The tile mode (left/right) to give this window.
*/
void setQuickTileMode(QuickTileMode mode, bool keyboard = false) override;
void growHorizontal() override;
void shrinkHorizontal() override;
void growVertical() override;
......@@ -496,7 +489,6 @@ protected:
bool belongsToDesktop() const override;
bool isActiveFullScreen() const override;
void setGeometryRestore(const QRect &geo) override;
void updateQuickTileMode(QuickTileMode newMode) override;
private Q_SLOTS:
void delayedSetShortcut();
......@@ -663,10 +655,6 @@ private:
};
MappingState mapping_state;
/** The quick tile mode of this window.
*/
int quick_tile_mode;
Xcb::TransientFor fetchTransient() const;
void readTransientProperty(Xcb::TransientFor &transientFor);
void readTransient();
......@@ -824,16 +812,6 @@ inline MaximizeMode Client::maximizeMode() const
return max_mode;
}
inline Client::QuickTileMode Client::quickTileMode() const
{
return (Client::QuickTileMode)quick_tile_mode;
}
inline void Client::updateQuickTileMode(QuickTileMode newMode)
{
quick_tile_mode = newMode;
}
inline bool Client::isFullScreen() const
{
return fullscreen_mode != FullScreenNone;
......
......@@ -3222,7 +3222,7 @@ QRect AbstractClient::electricBorderMaximizeGeometry(QPoint pos, int desktop)
return ret;
}
void Client::setQuickTileMode(QuickTileMode mode, bool keyboard)
void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
{
// Only allow quick tile on a regular or maximized window
if (!isResizable() && maximizeMode() != MaximizeFull)
......@@ -3234,7 +3234,7 @@ void Client::setQuickTileMode(QuickTileMode mode, bool keyboard)
if (mode == QuickTileMaximize) {
TabSynchronizer syncer(this, TabGroup::QuickTile|TabGroup::Geometry|TabGroup::Maximized);
quick_tile_mode = QuickTileNone;
m_quickTileMode = QuickTileNone;
if (maximizeMode() == MaximizeFull) {
setMaximize(false, false);
} else {
......@@ -3246,7 +3246,7 @@ void Client::setQuickTileMode(QuickTileMode mode, bool keyboard)
r.moveTop(clientArea.top());
setGeometry(r);
}
quick_tile_mode = QuickTileMaximize;
m_quickTileMode = QuickTileMaximize;
setGeometryRestore(prev_geom_restore);
}
emit quickTileModeChanged();
......@@ -3269,14 +3269,14 @@ void Client::setQuickTileMode(QuickTileMode mode, bool keyboard)
setMaximize(false, false);
if (mode != QuickTileNone) {
quick_tile_mode = mode;
m_quickTileMode = mode;
// decorations may turn off some borders when tiled
const ForceGeometry_t geom_mode = isDecorated() ? ForceGeometrySet : NormalGeometrySet;
quick_tile_mode = QuickTileNone; // Temporary, so the maximize code doesn't get all confused
m_quickTileMode = QuickTileNone; // Temporary, so the maximize code doesn't get all confused
setGeometry(electricBorderMaximizeGeometry(keyboard ? geometry().center() : Cursor::pos(), desktop()), geom_mode);
}
// Store the mode change
quick_tile_mode = mode;
m_quickTileMode = mode;
emit quickTileModeChanged();
return;
......@@ -3334,22 +3334,22 @@ void Client::setQuickTileMode(QuickTileMode mode, bool keyboard)
}
if (mode != QuickTileNone) {
quick_tile_mode = mode;
m_quickTileMode = mode;
// decorations may turn off some borders when tiled
const ForceGeometry_t geom_mode = isDecorated() ? ForceGeometrySet : NormalGeometrySet;
// Temporary, so the maximize code doesn't get all confused
quick_tile_mode = QuickTileNone;
m_quickTileMode = QuickTileNone;
setGeometry(electricBorderMaximizeGeometry(whichScreen, desktop()), geom_mode);
}
// Store the mode change
quick_tile_mode = mode;
m_quickTileMode = mode;
}
if (mode == QuickTileNone) {
TabSynchronizer syncer(this, TabGroup::QuickTile|TabGroup::Geometry);
quick_tile_mode = QuickTileNone;
m_quickTileMode = QuickTileNone;
// Untiling, so just restore geometry, and we're done.
if (!geometryRestore().isValid()) // invalid if we started maximized and wait for placement
setGeometryRestore(geometry());
......
......@@ -430,12 +430,6 @@ void ShellClient::setOnAllActivities(bool set)
Q_UNUSED(set)
}
void ShellClient::setQuickTileMode(AbstractClient::QuickTileMode mode, bool keyboard)
{
Q_UNUSED(mode)
Q_UNUSED(keyboard)
}
void ShellClient::setShortcut(const QString &cut)
{
Q_UNUSED(cut)
......
......@@ -81,7 +81,6 @@ public:
void setFullScreen(bool set, bool user = true) override;
void setNoBorder(bool set) override;
void setOnAllActivities(bool set) override;
void setQuickTileMode(QuickTileMode mode, bool keyboard = false) override;
void setShortcut(const QString &cut) override;
const QKeySequence &shortcut() const override;
void takeFocus() override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment