Remove overloads on virtual methods
Summary: Prefer virtual methods that take QRect and QSize rather than multi-int versions. Makes for clearer API and reduces the amount of code that was taking all of the components and turn it into a class. Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: zzag, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D28283
This commit is contained in:
parent
7fc05f1cf6
commit
5eb84af469
8 changed files with 23 additions and 56 deletions
|
@ -710,7 +710,7 @@ void AbstractClient::keepInArea(QRect area, bool partial)
|
|||
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())
|
||||
|
|
|
@ -619,13 +619,11 @@ public:
|
|||
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 @@ inline void AbstractClient::move(const QPoint& p, ForceGeometry_t force)
|
|||
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*>& AbstractClient::transients() const
|
||||
{
|
||||
return m_transients;
|
||||
|
|
|
@ -299,27 +299,18 @@ void InternalClient::hideClient(bool hide)
|
|||
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) {
|
||||
|
|
|
@ -69,10 +69,8 @@ public:
|
|||
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;
|
||||
|
|
|
@ -4097,7 +4097,7 @@ void X11Client::resizeWithChecks(int w, int h, xcb_gravity_t gravity, ForceGeome
|
|||
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 @@ bool X11Client::isMaximizable() const
|
|||
/**
|
||||
* 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 @@ void X11Client::setFrameGeometry(int x, int y, int w, int h, ForceGeometry_t for
|
|||
// 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
|
||||
|
|
10
x11client.h
10
x11client.h
|
@ -187,14 +187,12 @@ public:
|
|||
|
||||
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 @@ inline void X11Client::plainResize(const QSize& s, ForceGeometry_t force)
|
|||
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)
|
||||
|
|
|
@ -470,9 +470,9 @@ void XdgShellClient::updateDecoration(bool check_workspace_pos, bool force)
|
|||
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 @@ void XdgShellClient::handleCommitted()
|
|||
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()
|
||||
|
|
|
@ -99,10 +99,8 @@ public:
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue