Make GeometryUpdatesBlocker X11-specific

It's used only by X11Window so move it there.
This commit is contained in:
Vlad Zahorodnii 2024-04-29 17:58:05 +03:00
parent b2193f370d
commit cdbe119789
4 changed files with 76 additions and 75 deletions

View file

@ -101,7 +101,6 @@ Window::Window()
Window::~Window()
{
Q_ASSERT(!m_tile);
Q_ASSERT(m_blockGeometryUpdates == 0);
}
void Window::ref()
@ -1134,23 +1133,6 @@ QSizeF Window::minSize() const
return rules()->checkMinSize(QSize(0, 0));
}
void Window::blockGeometryUpdates(bool block)
{
if (block) {
if (m_blockGeometryUpdates == 0) {
m_pendingMoveResizeMode = MoveResizeMode::None;
}
++m_blockGeometryUpdates;
} else {
if (--m_blockGeometryUpdates == 0) {
if (m_pendingMoveResizeMode != MoveResizeMode::None) {
moveResizeInternal(moveResizeGeometry(), m_pendingMoveResizeMode);
m_pendingMoveResizeMode = MoveResizeMode::None;
}
}
}
}
void Window::maximize(MaximizeMode mode)
{
qCWarning(KWIN_CORE, "%s doesn't support setting maximized state", metaObject()->className());

View file

@ -1550,18 +1550,12 @@ protected:
int borderTop() const;
int borderBottom() const;
void blockGeometryUpdates(bool block);
void blockGeometryUpdates();
void unblockGeometryUpdates();
bool areGeometryUpdatesBlocked() const;
enum class MoveResizeMode : uint {
None,
Move = 0x1,
Resize = 0x2,
MoveResize = Move | Resize,
};
MoveResizeMode pendingMoveResizeMode() const;
void setPendingMoveResizeMode(MoveResizeMode mode);
virtual void moveResizeInternal(const QRectF &rect, MoveResizeMode mode) = 0;
/**
@ -1787,9 +1781,6 @@ protected:
QTimer *m_electricMaximizingDelay = nullptr;
// geometry
int m_blockGeometryUpdates = 0; // > 0 = New geometry is remembered, but not actually set
MoveResizeMode m_pendingMoveResizeMode = MoveResizeMode::None;
friend class GeometryUpdatesBlocker;
Output *m_moveResizeOutput;
QRectF m_moveResizeGeometry;
QRectF m_keyboardGeometryRestore;
@ -1839,26 +1830,6 @@ protected:
QTimer m_offscreenFramecallbackTimer;
};
/**
* Helper for Window::blockGeometryUpdates() being called in pairs (true/false)
*/
class GeometryUpdatesBlocker
{
public:
explicit GeometryUpdatesBlocker(Window *c)
: cl(c)
{
cl->blockGeometryUpdates(true);
}
~GeometryUpdatesBlocker()
{
cl->blockGeometryUpdates(false);
}
private:
Window *cl;
};
inline QRectF Window::bufferGeometry() const
{
return m_bufferGeometry;
@ -2090,31 +2061,6 @@ inline const QList<Window *> &Window::transients() const
return m_transients;
}
inline bool Window::areGeometryUpdatesBlocked() const
{
return m_blockGeometryUpdates != 0;
}
inline void Window::blockGeometryUpdates()
{
m_blockGeometryUpdates++;
}
inline void Window::unblockGeometryUpdates()
{
m_blockGeometryUpdates--;
}
inline Window::MoveResizeMode Window::pendingMoveResizeMode() const
{
return m_pendingMoveResizeMode;
}
inline void Window::setPendingMoveResizeMode(MoveResizeMode mode)
{
m_pendingMoveResizeMode = MoveResizeMode(uint(m_pendingMoveResizeMode) | uint(mode));
}
KWIN_EXPORT QDebug operator<<(QDebug debug, const Window *window);
} // namespace KWin

View file

@ -363,6 +363,7 @@ X11Window::~X11Window()
Q_ASSERT(!isInteractiveMoveResize());
Q_ASSERT(!check_active_modal);
Q_ASSERT(m_blockGeometryUpdates == 0);
}
std::unique_ptr<WindowItem> X11Window::createItem(Item *parentItem)
@ -4072,7 +4073,7 @@ void X11Window::configureRequest(int value_mask, qreal rx, qreal ry, qreal rw, q
}
QRectF origClientGeometry = m_clientGeometry;
GeometryUpdatesBlocker blocker(this);
X11GeometryUpdatesBlocker blocker(this);
move(new_pos);
resize(requestedFrameSize);
QRectF area = workspace()->clientArea(WorkArea, this, moveResizeOutput());
@ -4105,7 +4106,7 @@ void X11Window::configureRequest(int value_mask, qreal rx, qreal ry, qreal rw, q
if (requestedFrameSize != size()) { // don't restore if some app sets its own size again
QRectF origClientGeometry = m_clientGeometry;
GeometryUpdatesBlocker blocker(this);
X11GeometryUpdatesBlocker blocker(this);
moveResize(resizeWithChecks(moveResizeGeometry(), requestedFrameSize, xcb_gravity_t(gravity)));
if (!from_tool && (!isSpecialWindow() || isToolbar()) && !isFullScreen()) {
// try to keep the window in its xinerama screen if possible,
@ -4298,6 +4299,23 @@ bool X11Window::isMaximizable() const
return false;
}
void X11Window::blockGeometryUpdates(bool block)
{
if (block) {
if (m_blockGeometryUpdates == 0) {
m_pendingMoveResizeMode = MoveResizeMode::None;
}
++m_blockGeometryUpdates;
} else {
if (--m_blockGeometryUpdates == 0) {
if (m_pendingMoveResizeMode != MoveResizeMode::None) {
moveResizeInternal(moveResizeGeometry(), m_pendingMoveResizeMode);
m_pendingMoveResizeMode = MoveResizeMode::None;
}
}
}
}
/**
* Reimplemented to inform the client about the new window position.
*/
@ -4657,7 +4675,7 @@ void X11Window::setFullScreen(bool set)
}
StackingUpdatesBlocker blocker1(workspace());
GeometryUpdatesBlocker blocker2(this);
X11GeometryUpdatesBlocker blocker2(this);
// active fullscreens get different layer
updateLayer();

View file

@ -103,6 +103,11 @@ public:
QPointF wrapperPos() const;
QSizeF implicitSize() const;
void blockGeometryUpdates(bool block);
void blockGeometryUpdates();
void unblockGeometryUpdates();
bool areGeometryUpdatesBlocked() const;
xcb_visualid_t visual() const;
int depth() const;
bool hasAlpha() const;
@ -469,6 +474,8 @@ private:
void cleanGrouping();
void checkGroupTransients();
void setTransient(xcb_window_t new_transient_for_id);
MoveResizeMode pendingMoveResizeMode() const;
void setPendingMoveResizeMode(MoveResizeMode mode);
NETWinInfo *info = nullptr;
xcb_window_t m_transientForId;
@ -526,6 +533,9 @@ private:
QRectF m_lastBufferGeometry;
QRectF m_lastFrameGeometry;
QRectF m_lastClientGeometry;
int m_blockGeometryUpdates = 0; // > 0 = New geometry is remembered, but not actually set
MoveResizeMode m_pendingMoveResizeMode = MoveResizeMode::None;
std::unique_ptr<X11DecorationRenderer> m_decorationRenderer;
bool m_unmanaged = false;
@ -534,6 +544,26 @@ private:
quint64 m_surfaceSerial = 0;
};
/**
* Helper for X11Window::blockGeometryUpdates() being called in pairs (true/false)
*/
class X11GeometryUpdatesBlocker
{
public:
explicit X11GeometryUpdatesBlocker(X11Window *c)
: cl(c)
{
cl->blockGeometryUpdates(true);
}
~X11GeometryUpdatesBlocker()
{
cl->blockGeometryUpdates(false);
}
private:
X11Window *cl;
};
inline xcb_visualid_t X11Window::visual() const
{
return m_visual;
@ -639,6 +669,31 @@ inline quint32 X11Window::pendingSurfaceId() const
return m_pendingSurfaceId;
}
inline bool X11Window::areGeometryUpdatesBlocked() const
{
return m_blockGeometryUpdates != 0;
}
inline void X11Window::blockGeometryUpdates()
{
m_blockGeometryUpdates++;
}
inline void X11Window::unblockGeometryUpdates()
{
m_blockGeometryUpdates--;
}
inline Window::MoveResizeMode X11Window::pendingMoveResizeMode() const
{
return m_pendingMoveResizeMode;
}
inline void X11Window::setPendingMoveResizeMode(MoveResizeMode mode)
{
m_pendingMoveResizeMode = MoveResizeMode(uint(m_pendingMoveResizeMode) | uint(mode));
}
} // namespace
Q_DECLARE_METATYPE(KWin::X11Window *)
Q_DECLARE_METATYPE(QList<KWin::X11Window *>)