diff --git a/abstract_client.h b/abstract_client.h index fce6abc8d4..0356d7af70 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -696,9 +696,15 @@ public: */ QRect clientRectToFrameRect(const QRect &rect) const; + /** + * Returns @c true if the Client is being interactively moved; otherwise @c false. + */ bool isMove() const { return isMoveResize() && moveResizePointerMode() == PositionCenter; } + /** + * Returns @c true if the Client is being interactively resized; otherwise @c false. + */ bool isResize() const { return isMoveResize() && moveResizePointerMode() != PositionCenter; } diff --git a/deleted.cpp b/deleted.cpp index 2dbced2739..cee6bebaad 100644 --- a/deleted.cpp +++ b/deleted.cpp @@ -224,11 +224,6 @@ void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect bottom = decoration_bottom; } -QRect Deleted::decorationRect() const -{ - return rect(); -} - QRect Deleted::transparentRect() const { return transparent_rect; diff --git a/deleted.h b/deleted.h index bb7fe2f94c..22757677ca 100644 --- a/deleted.h +++ b/deleted.h @@ -62,7 +62,6 @@ public: return no_border; } void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const; - QRect decorationRect() const override; Layer layer() const override { return m_layer; } diff --git a/plugins/scenes/xrender/scene_xrender.cpp b/plugins/scenes/xrender/scene_xrender.cpp index acab174a56..e454244537 100644 --- a/plugins/scenes/xrender/scene_xrender.cpp +++ b/plugins/scenes/xrender/scene_xrender.cpp @@ -464,7 +464,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat X11Client *client = dynamic_cast(toplevel); Deleted *deleted = dynamic_cast(toplevel); - const QRect decorationRect = toplevel->decorationRect(); + const QRect decorationRect = toplevel->rect(); if (((client && !client->noBorder()) || (deleted && !deleted->noBorder())) && true) { // decorated client diff --git a/scene.cpp b/scene.cpp index f8facec29d..80ff338175 100644 --- a/scene.cpp +++ b/scene.cpp @@ -788,7 +788,7 @@ QRegion Scene::Window::clientShape() const QRegion Scene::Window::decorationShape() const { - return QRegion(toplevel->decorationRect()) - toplevel->transparentRect(); + return QRegion(toplevel->rect()) - toplevel->transparentRect(); } QPoint Scene::Window::bufferOffset() const diff --git a/toplevel.cpp b/toplevel.cpp index ca83f72d51..33c9020122 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -75,11 +75,6 @@ QDebug& operator<<(QDebug& stream, const Toplevel* cl) return stream; } -QRect Toplevel::decorationRect() const -{ - return rect(); -} - void Toplevel::detectShape(xcb_window_t id) { const bool wasShape = is_shape; diff --git a/toplevel.h b/toplevel.h index 3dea3204b5..2cf6bbc0ee 100644 --- a/toplevel.h +++ b/toplevel.h @@ -376,8 +376,10 @@ public: */ virtual QPoint clientContentPos() const; virtual QSize clientSize() const = 0; - virtual QRect visibleRect() const; // the area the window occupies on the screen - virtual QRect decorationRect() const; // rect including the decoration shadows + /** + * Returns a rectangle that the window occupies on the screen, including drop-shadows. + */ + virtual QRect visibleRect() const; virtual QRect transparentRect() const = 0; virtual bool isClient() const; virtual bool isDeleted() const; diff --git a/x11client.cpp b/x11client.cpp index 3abfa65e9e..16d412f48a 100644 --- a/x11client.cpp +++ b/x11client.cpp @@ -2562,11 +2562,6 @@ void X11Client::setSessionActivityOverride(bool needed) updateActivities(false); } -QRect X11Client::decorationRect() const -{ - return QRect(0, 0, width(), height()); -} - Xcb::Property X11Client::fetchFirstInTabBox() const { return Xcb::Property(false, m_client, atoms->kde_first_in_window_list, diff --git a/x11client.h b/x11client.h index 0c2453bc79..d0e67cd445 100644 --- a/x11client.h +++ b/x11client.h @@ -271,9 +271,6 @@ public: */ bool hasOffscreenXineramaStrut() const; - // Decorations <-> Effects - QRect decorationRect() const override; - QRect transparentRect() const override; bool isClientSideDecorated() const; diff --git a/xdgshellclient.cpp b/xdgshellclient.cpp index b36a4bbb81..1e3ca9458c 100644 --- a/xdgshellclient.cpp +++ b/xdgshellclient.cpp @@ -67,7 +67,7 @@ namespace KWin XdgShellClient::XdgShellClient(XdgShellSurfaceInterface *surface) : AbstractClient() - , m_xdgShellSurface(surface) + , m_xdgShellToplevel(surface) , m_xdgShellPopup(nullptr) { setSurface(surface->surface()); @@ -76,7 +76,7 @@ XdgShellClient::XdgShellClient(XdgShellSurfaceInterface *surface) XdgShellClient::XdgShellClient(XdgShellPopupInterface *surface) : AbstractClient() - , m_xdgShellSurface(nullptr) + , m_xdgShellToplevel(nullptr) , m_xdgShellPopup(surface) { setSurface(surface->surface()); @@ -106,36 +106,36 @@ void XdgShellClient::init() connect(surface(), &SurfaceInterface::unbound, this, &XdgShellClient::destroyClient); connect(surface(), &SurfaceInterface::destroyed, this, &XdgShellClient::destroyClient); - if (m_xdgShellSurface) { - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::destroyed, this, &XdgShellClient::destroyClient); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::configureAcknowledged, this, &XdgShellClient::handleConfigureAcknowledged); + if (m_xdgShellToplevel) { + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::destroyed, this, &XdgShellClient::destroyClient); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::configureAcknowledged, this, &XdgShellClient::handleConfigureAcknowledged); - m_caption = m_xdgShellSurface->title().simplified(); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::titleChanged, this, &XdgShellClient::handleWindowTitleChanged); + m_caption = m_xdgShellToplevel->title().simplified(); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::titleChanged, this, &XdgShellClient::handleWindowTitleChanged); QTimer::singleShot(0, this, &XdgShellClient::updateCaption); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::moveRequested, this, &XdgShellClient::handleMoveRequested); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::resizeRequested, this, &XdgShellClient::handleResizeRequested); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::moveRequested, this, &XdgShellClient::handleMoveRequested); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::resizeRequested, this, &XdgShellClient::handleResizeRequested); // Determine the resource name, this is inspired from ICCCM 4.1.2.5 // the binary name of the invoked client. - QFileInfo info{m_xdgShellSurface->client()->executablePath()}; + QFileInfo info{m_xdgShellToplevel->client()->executablePath()}; QByteArray resourceName; if (info.exists()) { resourceName = info.fileName().toUtf8(); } - setResourceClass(resourceName, m_xdgShellSurface->windowClass()); - setDesktopFileName(m_xdgShellSurface->windowClass()); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::windowClassChanged, this, &XdgShellClient::handleWindowClassChanged); + setResourceClass(resourceName, m_xdgShellToplevel->windowClass()); + setDesktopFileName(m_xdgShellToplevel->windowClass()); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::windowClassChanged, this, &XdgShellClient::handleWindowClassChanged); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::minimizeRequested, this, &XdgShellClient::handleMinimizeRequested); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::maximizedChanged, this, &XdgShellClient::handleMaximizeRequested); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::fullscreenChanged, this, &XdgShellClient::handleFullScreenRequested); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::windowMenuRequested, this, &XdgShellClient::handleWindowMenuRequested); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::transientForChanged, this, &XdgShellClient::handleTransientForChanged); - connect(m_xdgShellSurface, &XdgShellSurfaceInterface::windowGeometryChanged, this, &XdgShellClient::handleWindowGeometryChanged); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::minimizeRequested, this, &XdgShellClient::handleMinimizeRequested); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::maximizedChanged, this, &XdgShellClient::handleMaximizeRequested); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::fullscreenChanged, this, &XdgShellClient::handleFullScreenRequested); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::windowMenuRequested, this, &XdgShellClient::handleWindowMenuRequested); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::transientForChanged, this, &XdgShellClient::handleTransientForChanged); + connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::windowGeometryChanged, this, &XdgShellClient::handleWindowGeometryChanged); - auto global = static_cast(m_xdgShellSurface->global()); + auto global = static_cast(m_xdgShellToplevel->global()); connect(global, &XdgShellInterface::pingDelayed, this, &XdgShellClient::handlePingDelayed); connect(global, &XdgShellInterface::pingTimeout, this, &XdgShellClient::handlePingTimeout); connect(global, &XdgShellInterface::pongReceived, this, &XdgShellClient::handlePongReceived); @@ -147,7 +147,7 @@ void XdgShellClient::init() if (m_requestGeometryBlockCounter != 0 || areGeometryUpdatesBlocked()) { return; } - m_xdgShellSurface->configure(xdgSurfaceStates(), m_requestedClientSize); + m_xdgShellToplevel->configure(xdgSurfaceStates(), m_requestedClientSize); }; connect(this, &AbstractClient::activeChanged, this, configure); connect(this, &AbstractClient::clientStartUserMovedResized, this, configure); @@ -285,7 +285,7 @@ void XdgShellClient::destroyClient() deleted->unrefWindow(); - m_xdgShellSurface = nullptr; + m_xdgShellToplevel = nullptr; m_xdgShellPopup = nullptr; deleteClient(this); } @@ -490,7 +490,7 @@ void XdgShellClient::updateDecoration(bool check_workspace_pos, bool force) auto mode = isDecorated() || m_userNoBorder ? XdgDecorationInterface::Mode::ServerSide: XdgDecorationInterface::Mode::ClientSide; m_xdgDecoration->configure(mode); if (m_requestGeometryBlockCounter == 0) { - m_xdgShellSurface->configure(xdgSurfaceStates(), m_requestedClientSize); + m_xdgShellToplevel->configure(xdgSurfaceStates(), m_requestedClientSize); } } updateShadow(); @@ -650,10 +650,9 @@ void XdgShellClient::updateCaption() void XdgShellClient::closeWindow() { - if (m_xdgShellSurface && isCloseable()) { - m_xdgShellSurface->close(); - const qint32 pingSerial = static_cast(m_xdgShellSurface->global())->ping(m_xdgShellSurface); - m_pingSerials.insert(pingSerial, PingReason::CloseWindow); + if (m_xdgShellToplevel && isCloseable()) { + m_xdgShellToplevel->close(); + ping(PingReason::CloseWindow); } } @@ -668,7 +667,7 @@ bool XdgShellClient::isCloseable() const if (m_windowType == NET::Desktop || m_windowType == NET::Dock) { return false; } - if (m_xdgShellSurface) { + if (m_xdgShellToplevel) { return true; } return false; @@ -988,9 +987,8 @@ void XdgShellClient::setOnAllActivities(bool set) void XdgShellClient::takeFocus() { if (rules()->checkAcceptFocus(wantsInput())) { - if (m_xdgShellSurface) { - const qint32 pingSerial = static_cast(m_xdgShellSurface->global())->ping(m_xdgShellSurface); - m_pingSerials.insert(pingSerial, PingReason::FocusWindow); + if (m_xdgShellToplevel) { + ping(PingReason::FocusWindow); } setActive(true); } @@ -1011,7 +1009,7 @@ void XdgShellClient::doSetActive() bool XdgShellClient::userCanSetFullScreen() const { - if (m_xdgShellSurface) { + if (m_xdgShellToplevel) { return true; } return false; @@ -1057,7 +1055,7 @@ bool XdgShellClient::acceptsFocus() const // an unmapped window does not accept focus return false; } - if (m_xdgShellSurface) { + if (m_xdgShellToplevel) { // TODO: proper return true; } @@ -1101,8 +1099,8 @@ void XdgShellClient::requestGeometry(const QRect &rect) quint64 serialId = 0; - if (m_xdgShellSurface) { - serialId = m_xdgShellSurface->configure(xdgSurfaceStates(), size); + if (m_xdgShellToplevel) { + serialId = m_xdgShellToplevel->configure(xdgSurfaceStates(), size); } if (m_xdgShellPopup) { auto parent = transientFor(); @@ -1164,8 +1162,8 @@ void XdgShellClient::handleConfigureAcknowledged(quint32 serial) void XdgShellClient::handleTransientForChanged() { SurfaceInterface *transientSurface = nullptr; - if (m_xdgShellSurface) { - if (auto transient = m_xdgShellSurface->transientFor().data()) { + if (m_xdgShellToplevel) { + if (auto transient = m_xdgShellToplevel->transientFor().data()) { transientSurface = transient->surface(); } } @@ -1849,7 +1847,7 @@ void XdgShellClient::installServerSideDecoration(KWayland::Server::ServerSideDec void XdgShellClient::installXdgDecoration(XdgDecorationInterface *deco) { - Q_ASSERT(m_xdgShellSurface); + Q_ASSERT(m_xdgShellToplevel); m_xdgDecoration = deco; @@ -1971,11 +1969,11 @@ void XdgShellClient::popupDone() void XdgShellClient::updateClientOutputs() { - QVector clientOutputs; + QVector clientOutputs; const auto outputs = waylandServer()->display()->outputs(); - for (OutputInterface* output: qAsConst(outputs)) { - const QRect outputGeom(output->globalPosition(), output->pixelSize() / output->scale()); - if (frameGeometry().intersects(outputGeom)) { + for (OutputInterface *output : outputs) { + const QRect outputGeometry(output->globalPosition(), output->pixelSize() / output->scale()); + if (frameGeometry().intersects(outputGeometry)) { clientOutputs << output; } } @@ -1998,7 +1996,7 @@ bool XdgShellClient::supportsWindowRules() const if (m_plasmaShellSurface) { return false; } - return m_xdgShellSurface; + return m_xdgShellToplevel; } QRect XdgShellClient::adjustMoveGeometry(const QRect &rect) const @@ -2043,4 +2041,13 @@ QRect XdgShellClient::adjustResizeGeometry(const QRect &rect) const return geometry; } +void XdgShellClient::ping(PingReason reason) +{ + Q_ASSERT(m_xdgShellToplevel); + + XdgShellInterface *shell = static_cast(m_xdgShellToplevel->global()); + const quint32 serial = shell->ping(m_xdgShellToplevel); + m_pingSerials.insert(serial, reason); +} + } diff --git a/xdgshellclient.h b/xdgshellclient.h index 63ee79fc99..aa5bac43e9 100644 --- a/xdgshellclient.h +++ b/xdgshellclient.h @@ -188,12 +188,13 @@ private: void unmap(); void markAsMapped(); QRect determineBufferGeometry() const; + void ping(PingReason reason); static void deleteClient(XdgShellClient *c); QRect adjustMoveGeometry(const QRect &rect) const; QRect adjustResizeGeometry(const QRect &rect) const; - KWayland::Server::XdgShellSurfaceInterface *m_xdgShellSurface; + KWayland::Server::XdgShellSurfaceInterface *m_xdgShellToplevel; KWayland::Server::XdgShellPopupInterface *m_xdgShellPopup; QRect m_bufferGeometry; @@ -260,7 +261,7 @@ private: QRect m_blockedRequestGeometry; QString m_caption; QString m_captionSuffix; - QHash m_pingSerials; + QHash m_pingSerials; bool m_isInitialized = false;