From 87bfdcf1d68fc452f8ab01939e0a537203650298 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 28 Mar 2023 21:30:58 +0300 Subject: [PATCH] scene: Port WindowItemX11 to X11Window --- src/scene/surfaceitem_wayland.cpp | 3 ++- src/scene/surfaceitem_wayland.h | 6 ++++-- src/scene/surfaceitem_x11.cpp | 6 +++--- src/scene/surfaceitem_x11.h | 8 +++++--- src/scene/windowitem.cpp | 7 ++++--- src/scene/windowitem.h | 3 ++- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/scene/surfaceitem_wayland.cpp b/src/scene/surfaceitem_wayland.cpp index 4715a2b947..8364482b39 100644 --- a/src/scene/surfaceitem_wayland.cpp +++ b/src/scene/surfaceitem_wayland.cpp @@ -11,6 +11,7 @@ #include "wayland/subcompositor_interface.h" #include "wayland/surface_interface.h" #include "window.h" +#include "x11window.h" namespace KWin { @@ -202,7 +203,7 @@ void SurfacePixmapWayland::setBuffer(KWaylandServer::ClientBuffer *buffer) } } -SurfaceItemXwayland::SurfaceItemXwayland(Window *window, Scene *scene, Item *parent) +SurfaceItemXwayland::SurfaceItemXwayland(X11Window *window, Scene *scene, Item *parent) : SurfaceItemWayland(window->surface(), scene, parent) , m_window(window) { diff --git a/src/scene/surfaceitem_wayland.h b/src/scene/surfaceitem_wayland.h index c73a256d33..d74b077f01 100644 --- a/src/scene/surfaceitem_wayland.h +++ b/src/scene/surfaceitem_wayland.h @@ -18,6 +18,8 @@ class SurfaceInterface; namespace KWin { +class X11Window; + /** * The SurfaceItemWayland class represents a Wayland surface in the scene. */ @@ -85,12 +87,12 @@ class KWIN_EXPORT SurfaceItemXwayland : public SurfaceItemWayland Q_OBJECT public: - explicit SurfaceItemXwayland(Window *window, Scene *scene, Item *parent = nullptr); + explicit SurfaceItemXwayland(X11Window *window, Scene *scene, Item *parent = nullptr); QVector shape() const override; private: - Window *m_window; + X11Window *m_window; }; } // namespace KWin diff --git a/src/scene/surfaceitem_x11.cpp b/src/scene/surfaceitem_x11.cpp index 0a90000886..ed4d65b074 100644 --- a/src/scene/surfaceitem_x11.cpp +++ b/src/scene/surfaceitem_x11.cpp @@ -13,7 +13,7 @@ namespace KWin { -SurfaceItemX11::SurfaceItemX11(Window *window, Scene *scene, Item *parent) +SurfaceItemX11::SurfaceItemX11(X11Window *window, Scene *scene, Item *parent) : SurfaceItem(scene, parent) , m_window(window) { @@ -42,7 +42,7 @@ SurfaceItemX11::~SurfaceItemX11() destroyDamage(); } -Window *SurfaceItemX11::window() const +X11Window *SurfaceItemX11::window() const { return m_window; } @@ -212,7 +212,7 @@ xcb_visualid_t SurfacePixmapX11::visual() const void SurfacePixmapX11::create() { - const Window *window = m_item->window(); + const X11Window *window = m_item->window(); if (window->isDeleted()) { return; } diff --git a/src/scene/surfaceitem_x11.h b/src/scene/surfaceitem_x11.h index fcc669572d..cf3754a84b 100644 --- a/src/scene/surfaceitem_x11.h +++ b/src/scene/surfaceitem_x11.h @@ -14,6 +14,8 @@ namespace KWin { +class X11Window; + /** * The SurfaceItemX11 class represents an X11 surface in the scene. */ @@ -22,10 +24,10 @@ class KWIN_EXPORT SurfaceItemX11 : public SurfaceItem Q_OBJECT public: - explicit SurfaceItemX11(Window *window, Scene *scene, Item *parent = nullptr); + explicit SurfaceItemX11(X11Window *window, Scene *scene, Item *parent = nullptr); ~SurfaceItemX11() override; - Window *window() const; + X11Window *window() const; void preprocess() override; @@ -46,7 +48,7 @@ protected: std::unique_ptr createPixmap() override; private: - Window *m_window; + X11Window *m_window; xcb_damage_damage_t m_damageHandle = XCB_NONE; xcb_xfixes_fetch_region_cookie_t m_damageCookie; bool m_isDamaged = false; diff --git a/src/scene/windowitem.cpp b/src/scene/windowitem.cpp index bea5442d4c..5a272518f5 100644 --- a/src/scene/windowitem.cpp +++ b/src/scene/windowitem.cpp @@ -15,6 +15,7 @@ #include "wayland_server.h" #include "window.h" #include "workspace.h" +#include "x11window.h" #include @@ -285,7 +286,7 @@ void WindowItem::markDamaged() Q_EMIT m_window->damaged(m_window); } -WindowItemX11::WindowItemX11(Window *window, Scene *scene, Item *parent) +WindowItemX11::WindowItemX11(X11Window *window, Scene *scene, Item *parent) : WindowItem(window, scene, parent) { initialize(); @@ -298,13 +299,13 @@ void WindowItemX11::initialize() { switch (kwinApp()->operationMode()) { case Application::OperationModeX11: - updateSurfaceItem(new SurfaceItemX11(window(), scene(), this)); + updateSurfaceItem(new SurfaceItemX11(static_cast(window()), scene(), this)); break; case Application::OperationModeXwayland: if (!window()->surface()) { updateSurfaceItem(nullptr); } else { - updateSurfaceItem(new SurfaceItemXwayland(window(), scene(), this)); + updateSurfaceItem(new SurfaceItemXwayland(static_cast(window()), scene(), this)); } break; case Application::OperationModeWaylandOnly: diff --git a/src/scene/windowitem.h b/src/scene/windowitem.h index 031cf12de5..414f931f12 100644 --- a/src/scene/windowitem.h +++ b/src/scene/windowitem.h @@ -21,6 +21,7 @@ class InternalWindow; class Shadow; class ShadowItem; class SurfaceItem; +class X11Window; /** * The WindowItem class represents a window in the scene. @@ -96,7 +97,7 @@ class KWIN_EXPORT WindowItemX11 : public WindowItem Q_OBJECT public: - explicit WindowItemX11(Window *window, Scene *scene, Item *parent = nullptr); + explicit WindowItemX11(X11Window *window, Scene *scene, Item *parent = nullptr); private Q_SLOTS: void initialize();