From 46d0c04f915a3d5a00bb547ecacb94b532cb30d8 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 29 Mar 2023 10:54:54 +0300 Subject: [PATCH] Move Window::{depth,hasAlpha,visual} to X11Window --- src/internalwindow.cpp | 2 -- src/waylandwindow.cpp | 1 - src/window.cpp | 14 -------------- src/window.h | 25 ------------------------- src/x11window.cpp | 14 ++++++++------ src/x11window.h | 21 +++++++++++++++++++++ 6 files changed, 29 insertions(+), 48 deletions(-) diff --git a/src/internalwindow.cpp b/src/internalwindow.cpp index 63e41e3b9d..96d15823aa 100644 --- a/src/internalwindow.cpp +++ b/src/internalwindow.cpp @@ -409,7 +409,6 @@ void InternalWindow::present(const std::shared_ptr fbo m_fbo = fbo; - setDepth(32); surfaceItem()->addDamage(surfaceItem()->rect().toAlignedRect()); } @@ -428,7 +427,6 @@ void InternalWindow::present(const QImage &image, const QRegion &damage) m_image = image; - setDepth(32); surfaceItem()->addDamage(damage); } diff --git a/src/waylandwindow.cpp b/src/waylandwindow.cpp index c0ec3bc792..5cc991d8d2 100644 --- a/src/waylandwindow.cpp +++ b/src/waylandwindow.cpp @@ -38,7 +38,6 @@ WaylandWindow::WaylandWindow(SurfaceInterface *surface) : m_isScreenLocker(surface->client() == waylandServer()->screenLockerClientConnection()) { setSurface(surface); - setDepth(32); connect(surface, &SurfaceInterface::shadowChanged, this, &WaylandWindow::updateShadow); diff --git a/src/window.cpp b/src/window.cpp index d531f74773..1af9fd8e9e 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -66,8 +66,6 @@ std::shared_ptr Window::s_defaultPalette; Window::Window() : m_output(workspace()->activeOutput()) - , m_visual(XCB_NONE) - , bit_depth(24) , info(nullptr) , ready_for_painting(false) , m_internalId(QUuid::createUuid()) @@ -555,18 +553,6 @@ QString Window::windowRole() const return QString::fromLatin1(info->windowRole()); } -void Window::setDepth(int depth) -{ - if (bit_depth == depth) { - return; - } - const bool oldAlpha = hasAlpha(); - bit_depth = depth; - if (oldAlpha != hasAlpha()) { - Q_EMIT hasAlphaChanged(); - } -} - QRegion Window::inputShape() const { if (m_surface) { diff --git a/src/window.h b/src/window.h index 1fb5c11353..78c23bb6c7 100644 --- a/src/window.h +++ b/src/window.h @@ -684,12 +684,9 @@ public: static bool resourceMatch(const Window *c1, const Window *c2); bool readyForPainting() const; // true if the window has been already painted its contents - xcb_visualid_t visual() const; QRegion inputShape() const; void setOpacity(qreal opacity); qreal opacity() const; - int depth() const; - bool hasAlpha() const; virtual bool setupCompositing(); virtual void finishCompositing(); EffectWindowImpl *effectWindow(); @@ -1403,10 +1400,6 @@ Q_SIGNALS: * @since 5.0 */ void windowClassChanged(); - /** - * @since 5.4 - */ - void hasAlphaChanged(); /** * Emitted whenever the Surface for this Window changes. @@ -1510,14 +1503,11 @@ protected: Xcb::Property fetchSkipCloseAnimation() const; void readSkipCloseAnimation(Xcb::Property &prop); void getSkipCloseAnimation(); - void setDepth(int depth); Output *m_output = nullptr; QRectF m_frameGeometry; QRectF m_clientGeometry; QRectF m_bufferGeometry; - xcb_visualid_t m_visual; - int bit_depth; NETWinInfo *info; bool ready_for_painting; @@ -2030,11 +2020,6 @@ inline bool Window::readyForPainting() const return ready_for_painting; } -inline xcb_visualid_t Window::visual() const -{ - return m_visual; -} - inline bool Window::isDesktop() const { return windowType() == NET::Desktop; @@ -2140,16 +2125,6 @@ inline bool Window::isInternal() const return false; } -inline int Window::depth() const -{ - return bit_depth; -} - -inline bool Window::hasAlpha() const -{ - return depth() == 32; -} - inline const QRegion &Window::opaqueRegion() const { return opaque_region; diff --git a/src/x11window.cpp b/src/x11window.cpp index c7e04f46ae..de7c449d99 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -197,13 +197,15 @@ void X11DecorationRenderer::render(const QRegion ®ion) return; } xcb_connection_t *c = kwinApp()->x11Connection(); + X11Window *window = static_cast(client()->window()); + if (m_gc == XCB_NONE) { m_gc = xcb_generate_id(c); - xcb_create_gc(c, m_gc, client()->window()->frameId(), 0, nullptr); + xcb_create_gc(c, m_gc, window->frameId(), 0, nullptr); } QRectF left, top, right, bottom; - client()->window()->layoutDecorationRects(left, top, right, bottom); + window->layoutDecorationRects(left, top, right, bottom); const QRect geometry = region.boundingRect(); left = left.intersected(geometry); @@ -211,14 +213,14 @@ void X11DecorationRenderer::render(const QRegion ®ion) right = right.intersected(geometry); bottom = bottom.intersected(geometry); - auto renderPart = [this, c](const QRect &geo) { + auto renderPart = [this, c, window](const QRect &geo) { if (!geo.isValid()) { return; } // Guess the pixel format of the X pixmap into which the QImage will be copied. QImage::Format format; - const int depth = client()->window()->depth(); + const int depth = window->depth(); switch (depth) { case 30: format = QImage::Format_A2RGB30_Premultiplied; @@ -241,8 +243,8 @@ void X11DecorationRenderer::render(const QRegion ®ion) p.setClipRect(geo); renderToPainter(&p, geo); - xcb_put_image(c, XCB_IMAGE_FORMAT_Z_PIXMAP, client()->window()->frameId(), m_gc, - image.width(), image.height(), geo.x(), geo.y(), 0, client()->window()->depth(), + xcb_put_image(c, XCB_IMAGE_FORMAT_Z_PIXMAP, window->frameId(), m_gc, + image.width(), image.height(), geo.x(), geo.y(), 0, window->depth(), image.sizeInBytes(), image.constBits()); }; renderPart(left.toRect()); diff --git a/src/x11window.h b/src/x11window.h index 8a4f9fad9d..68b7f6f5f7 100644 --- a/src/x11window.h +++ b/src/x11window.h @@ -90,6 +90,10 @@ public: QRectF frameRectToBufferRect(const QRectF &rect) const; QSizeF implicitSize() const; + xcb_visualid_t visual() const; + int depth() const; + bool hasAlpha() const; + QMatrix4x4 inputTransformation() const override; bool isTransient() const override; @@ -477,6 +481,8 @@ private: SyncRequest m_syncRequest; static bool check_active_modal; ///< \see X11Window::checkActiveModal() int sm_stacking_order; + xcb_visualid_t m_visual = XCB_NONE; + int bit_depth = 24; friend struct ResetupRulesProcedure; friend bool performTransiencyCheck(); @@ -509,6 +515,21 @@ private: quint64 m_surfaceSerial = 0; }; +inline xcb_visualid_t X11Window::visual() const +{ + return m_visual; +} + +inline int X11Window::depth() const +{ + return bit_depth; +} + +inline bool X11Window::hasAlpha() const +{ + return depth() == 32; +} + inline xcb_window_t X11Window::wrapperId() const { return m_wrapper;