diff --git a/abstract_client.h b/abstract_client.h --- a/abstract_client.h +++ b/abstract_client.h @@ -619,13 +619,11 @@ enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet }; virtual void move(int x, int y, ForceGeometry_t force = NormalGeometrySet); void move(const QPoint &p, ForceGeometry_t force = NormalGeometrySet); - virtual void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) = 0; - void resizeWithChecks(const QSize& s, ForceGeometry_t force = NormalGeometrySet); + virtual void resizeWithChecks(const QSize& s, ForceGeometry_t force = NormalGeometrySet) = 0; void keepInArea(QRect area, bool partial = false); virtual QSize minSize() const; virtual QSize maxSize() const; - virtual void setFrameGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) = 0; - void setFrameGeometry(const QRect &rect, ForceGeometry_t force = NormalGeometrySet); + virtual void setFrameGeometry(const QRect &rect, ForceGeometry_t force = NormalGeometrySet) = 0; /** * How to resize the window in order to obey constraints (mainly aspect ratios). @@ -1312,16 +1310,6 @@ move(p.x(), p.y(), force); } -inline void AbstractClient::resizeWithChecks(const QSize& s, AbstractClient::ForceGeometry_t force) -{ - resizeWithChecks(s.width(), s.height(), force); -} - -inline void AbstractClient::setFrameGeometry(const QRect &rect, ForceGeometry_t force) -{ - setFrameGeometry(rect.x(), rect.y(), rect.width(), rect.height(), force); -} - inline const QList& AbstractClient::transients() const { return m_transients; diff --git a/abstract_client.cpp b/abstract_client.cpp --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -710,7 +710,7 @@ if (!partial) { // resize to fit into area if (area.width() < width() || area.height() < height()) - resizeWithChecks(qMin(area.width(), width()), qMin(area.height(), height())); + resizeWithChecks(size().boundedTo(area.size())); } int tx = x(), ty = y(); if (frameGeometry().right() > area.right() && width() <= area.width()) diff --git a/internal_client.h b/internal_client.h --- a/internal_client.h +++ b/internal_client.h @@ -69,10 +69,8 @@ bool isShown(bool shaded_is_shown) const override; bool isHiddenInternal() const override; void hideClient(bool hide) override; - using AbstractClient::resizeWithChecks; - void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override; - using AbstractClient::setFrameGeometry; - void setFrameGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) override; + void resizeWithChecks(const QSize &size, ForceGeometry_t force = NormalGeometrySet) override; + void setFrameGeometry(const QRect &rect, ForceGeometry_t force = NormalGeometrySet) override; bool supportsWindowRules() const override; AbstractClient *findModal(bool allow_itself = false) override; void setOnAllActivities(bool set) override; diff --git a/internal_client.cpp b/internal_client.cpp --- a/internal_client.cpp +++ b/internal_client.cpp @@ -299,27 +299,18 @@ Q_UNUSED(hide) } -void InternalClient::resizeWithChecks(int w, int h, ForceGeometry_t force) +void InternalClient::resizeWithChecks(const QSize &size, ForceGeometry_t force) { Q_UNUSED(force) if (!m_internalWindow) { return; } - QRect area = workspace()->clientArea(WorkArea, this); - // don't allow growing larger than workarea - if (w > area.width()) { - w = area.width(); - } - if (h > area.height()) { - h = area.height(); - } - setFrameGeometry(QRect(x(), y(), w, h)); + const QRect area = workspace()->clientArea(WorkArea, this); + setFrameGeometry(QRect{pos(), size.boundedTo(area.size())}, force); } -void InternalClient::setFrameGeometry(int x, int y, int w, int h, ForceGeometry_t force) +void InternalClient::setFrameGeometry(const QRect &rect, ForceGeometry_t force) { - const QRect rect(x, y, w, h); - if (areGeometryUpdatesBlocked()) { m_frameGeometry = rect; if (pendingGeometryUpdate() == PendingGeometryForced) { diff --git a/x11client.h b/x11client.h --- a/x11client.h +++ b/x11client.h @@ -187,14 +187,12 @@ using AbstractClient::move; void move(int x, int y, ForceGeometry_t force = NormalGeometrySet) override; - using AbstractClient::setFrameGeometry; - void setFrameGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) override; + void setFrameGeometry(const QRect &rect, ForceGeometry_t force = NormalGeometrySet) override; /// plainResize() simply resizes void plainResize(int w, int h, ForceGeometry_t force = NormalGeometrySet); void plainResize(const QSize& s, ForceGeometry_t force = NormalGeometrySet); /// resizeWithChecks() resizes according to gravity, and checks workarea position - using AbstractClient::resizeWithChecks; - void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override; + void resizeWithChecks(const QSize &size, ForceGeometry_t force = NormalGeometrySet) override; void resizeWithChecks(int w, int h, xcb_gravity_t gravity, ForceGeometry_t force = NormalGeometrySet); void resizeWithChecks(const QSize& s, xcb_gravity_t gravity, ForceGeometry_t force = NormalGeometrySet); QSize constrainClientSize(const QSize &size, SizeMode mode = SizeModeAny) const override; @@ -655,9 +653,9 @@ plainResize(s.width(), s.height(), force); } -inline void X11Client::resizeWithChecks(int w, int h, AbstractClient::ForceGeometry_t force) +inline void X11Client::resizeWithChecks(const QSize &s, AbstractClient::ForceGeometry_t force) { - resizeWithChecks(w, h, XCB_GRAVITY_BIT_FORGET, force); + resizeWithChecks(s.width(), s.height(), XCB_GRAVITY_BIT_FORGET, force); } inline void X11Client::resizeWithChecks(const QSize& s, xcb_gravity_t gravity, ForceGeometry_t force) diff --git a/x11client.cpp b/x11client.cpp --- a/x11client.cpp +++ b/x11client.cpp @@ -4097,7 +4097,7 @@ newy = newy + height() - h; break; } - setFrameGeometry(newx, newy, w, h, force); + setFrameGeometry(QRect{newx, newy, w, h}, force); } // _NET_MOVERESIZE_WINDOW @@ -4180,7 +4180,7 @@ /** * Reimplemented to inform the client about the new window position. */ -void X11Client::setFrameGeometry(int x, int y, int w, int h, ForceGeometry_t force) +void X11Client::setFrameGeometry(const QRect &rect, ForceGeometry_t force) { // this code is also duplicated in X11Client::plainResize() // Ok, the shading geometry stuff. Generally, code doesn't care about shaded geometry, @@ -4194,7 +4194,7 @@ // Such code is wrong and should be changed to handle the case when the window is shaded, // for example using X11Client::clientSize() - QRect frameGeometry(x, y, w, h); + QRect frameGeometry = rect; if (shade_geometry_change) ; // nothing diff --git a/xdgshellclient.h b/xdgshellclient.h --- a/xdgshellclient.h +++ b/xdgshellclient.h @@ -99,10 +99,8 @@ bool userCanSetNoBorder() const override; bool wantsInput() const override; bool dockWantsInput() const override; - using AbstractClient::resizeWithChecks; - void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override; - using AbstractClient::setFrameGeometry; - void setFrameGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) override; + void resizeWithChecks(const QSize &size, ForceGeometry_t force = NormalGeometrySet) override; + void setFrameGeometry(const QRect &rect, ForceGeometry_t force = NormalGeometrySet) override; bool hasStrut() const override; quint32 windowId() const override; pid_t pid() const override; diff --git a/xdgshellclient.cpp b/xdgshellclient.cpp --- a/xdgshellclient.cpp +++ b/xdgshellclient.cpp @@ -470,9 +470,9 @@ blockGeometryUpdates(false); } -void XdgShellClient::setFrameGeometry(int x, int y, int w, int h, ForceGeometry_t force) +void XdgShellClient::setFrameGeometry(const QRect &rect, ForceGeometry_t force) { - const QRect newGeometry = rules()->checkGeometry(QRect(x, y, w, h)); + const QRect newGeometry = rules()->checkGeometry(rect); if (areGeometryUpdatesBlocked()) { // when the GeometryUpdateBlocker exits the current geom is passed to setGeometry @@ -1310,17 +1310,11 @@ markAsMapped(); } -void XdgShellClient::resizeWithChecks(int w, int h, ForceGeometry_t force) +void XdgShellClient::resizeWithChecks(const QSize &size, ForceGeometry_t force) { - const QRect area = workspace()->clientArea(WorkArea, this); // don't allow growing larger than workarea - if (w > area.width()) { - w = area.width(); - } - if (h > area.height()) { - h = area.height(); - } - setFrameGeometry(x(), y(), w, h, force); + const QRect area = workspace()->clientArea(WorkArea, this); + setFrameGeometry(QRect{pos(), size.boundedTo(area.size())}, force); } void XdgShellClient::unmap()