Improve sharing of maximize between Client and ShellClient
The changeMaximize method is added as a pure virtual protected method to AbstractClient. This replaces the previous pure virtual maximize method. Which is now directly implemented in AbstractClient (reusing the implementation previously in Client).
This commit is contained in:
parent
60342d44e3
commit
eacaf25acf
5 changed files with 23 additions and 24 deletions
|
@ -303,7 +303,8 @@ public:
|
|||
virtual bool isCurrentTab() const;
|
||||
virtual QRect geometryRestore() const = 0;
|
||||
virtual MaximizeMode maximizeMode() const = 0;
|
||||
virtual void maximize(MaximizeMode) = 0;
|
||||
void maximize(MaximizeMode);
|
||||
void setMaximize(bool vertically, bool horizontally);
|
||||
virtual bool noBorder() const = 0;
|
||||
virtual void setNoBorder(bool set) = 0;
|
||||
virtual void blockActivityUpdates(bool b = true) = 0;
|
||||
|
@ -550,6 +551,7 @@ protected:
|
|||
virtual int borderRight() const;
|
||||
virtual int borderTop() const;
|
||||
virtual int borderBottom() const;
|
||||
virtual void changeMaximize(bool horizontal, bool vertical, bool adjust) = 0;
|
||||
|
||||
private:
|
||||
void handlePaletteChange();
|
||||
|
|
4
client.h
4
client.h
|
@ -234,7 +234,6 @@ public:
|
|||
|
||||
QuickTileMode quickTileMode() const override;
|
||||
bool isMinimizable() const override;
|
||||
void setMaximize(bool vertically, bool horizontally);
|
||||
QRect iconGeometry() const;
|
||||
|
||||
void setFullScreen(bool set, bool user = true) override;
|
||||
|
@ -345,7 +344,6 @@ public:
|
|||
static bool sameAppWindowRoleMatch(const Client* c1, const Client* c2, bool active_hack);
|
||||
|
||||
void killWindow();
|
||||
void maximize(MaximizeMode) override;
|
||||
void toggleShade();
|
||||
void showContextHelp();
|
||||
void cancelShadeHoverTimer();
|
||||
|
@ -563,7 +561,7 @@ private:
|
|||
bool isManaged() const; ///< Returns false if this client is not yet managed
|
||||
void updateAllowedActions(bool force = false);
|
||||
QRect fullscreenMonitorsArea(NETFullscreenMonitors topology) const;
|
||||
void changeMaximize(bool horizontal, bool vertical, bool adjust);
|
||||
void changeMaximize(bool horizontal, bool vertical, bool adjust) override;
|
||||
int checkFullScreenHack(const QRect& geom) const; // 0 - None, 1 - One xinerama screen, 2 - Full area
|
||||
void updateFullScreenHack(const QRect& geom);
|
||||
void getWmNormalHints();
|
||||
|
|
15
geometry.cpp
15
geometry.cpp
|
@ -2111,7 +2111,7 @@ void Client::blockGeometryUpdates(bool block)
|
|||
}
|
||||
}
|
||||
|
||||
void Client::maximize(MaximizeMode m)
|
||||
void AbstractClient::maximize(MaximizeMode m)
|
||||
{
|
||||
setMaximize(m & MaximizeVertical, m & MaximizeHorizontal);
|
||||
}
|
||||
|
@ -2119,16 +2119,17 @@ void Client::maximize(MaximizeMode m)
|
|||
/*!
|
||||
Sets the maximization according to \a vertically and \a horizontally
|
||||
*/
|
||||
void Client::setMaximize(bool vertically, bool horizontally)
|
||||
void AbstractClient::setMaximize(bool vertically, bool horizontally)
|
||||
{
|
||||
// changeMaximize() flips the state, so change from set->flip
|
||||
MaximizeMode oldMode = maximizeMode();
|
||||
const MaximizeMode oldMode = maximizeMode();
|
||||
changeMaximize(
|
||||
max_mode & MaximizeVertical ? !vertically : vertically,
|
||||
max_mode & MaximizeHorizontal ? !horizontally : horizontally,
|
||||
oldMode & MaximizeVertical ? !vertically : vertically,
|
||||
oldMode & MaximizeHorizontal ? !horizontally : horizontally,
|
||||
false);
|
||||
if (oldMode != maximizeMode()) {
|
||||
emit clientMaximizedStateChanged(this, max_mode);
|
||||
const MaximizeMode newMode = maximizeMode();
|
||||
if (oldMode != newMode) {
|
||||
emit clientMaximizedStateChanged(this, newMode);
|
||||
emit clientMaximizedStateChanged(this, vertically, horizontally);
|
||||
}
|
||||
|
||||
|
|
|
@ -367,16 +367,18 @@ void ShellClient::hideClient(bool hide)
|
|||
Q_UNUSED(hide)
|
||||
}
|
||||
|
||||
void ShellClient::maximize(MaximizeMode mode)
|
||||
void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust)
|
||||
{
|
||||
if (m_maximizeMode == mode) {
|
||||
return;
|
||||
}
|
||||
// TODO: check rules
|
||||
StackingUpdatesBlocker blocker(workspace());
|
||||
const MaximizeMode oldMode = m_maximizeMode;
|
||||
m_maximizeMode = mode;
|
||||
// 'adjust == true' means to update the size only, e.g. after changing workspace size
|
||||
if (!adjust) {
|
||||
if (vertical)
|
||||
m_maximizeMode = MaximizeMode(m_maximizeMode ^ MaximizeVertical);
|
||||
if (horizontal)
|
||||
m_maximizeMode = MaximizeMode(m_maximizeMode ^ MaximizeHorizontal);
|
||||
}
|
||||
|
||||
// TODO: check rules
|
||||
if (m_maximizeMode == MaximizeFull) {
|
||||
m_geomMaximizeRestore = geometry();
|
||||
requestGeometry(workspace()->clientArea(MaximizeArea, this));
|
||||
|
@ -388,11 +390,7 @@ void ShellClient::maximize(MaximizeMode mode)
|
|||
requestGeometry(workspace()->clientArea(PlacementArea, this));
|
||||
}
|
||||
}
|
||||
if (oldMode != maximizeMode()) {
|
||||
emit clientMaximizedStateChanged(this, m_maximizeMode);
|
||||
const bool set = m_maximizeMode == MaximizeFull;
|
||||
emit clientMaximizedStateChanged(this, set, set);
|
||||
}
|
||||
// TODO: add more checks as in Client
|
||||
}
|
||||
|
||||
MaximizeMode ShellClient::maximizeMode() const
|
||||
|
|
|
@ -72,7 +72,6 @@ public:
|
|||
bool isResizable() const override;
|
||||
bool isShown(bool shaded_is_shown) const override;
|
||||
void hideClient(bool hide) override;
|
||||
void maximize(MaximizeMode) override;
|
||||
MaximizeMode maximizeMode() const override;
|
||||
QRect geometryRestore() const override {
|
||||
return m_geomMaximizeRestore;
|
||||
|
@ -122,6 +121,7 @@ protected:
|
|||
bool belongsToSameApplication(const AbstractClient *other, bool active_hack) const override;
|
||||
void doSetActive() override;
|
||||
Layer layerForDock() const override;
|
||||
void changeMaximize(bool horizontal, bool vertical, bool adjust) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void clientFullScreenChanged(bool fullScreen);
|
||||
|
|
Loading…
Reference in a new issue