diff --git a/src/backends/x11/windowed/x11_windowed_backend.cpp b/src/backends/x11/windowed/x11_windowed_backend.cpp index c8cf708f55..0417fa9c90 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.cpp +++ b/src/backends/x11/windowed/x11_windowed_backend.cpp @@ -8,7 +8,6 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "x11_windowed_backend.h" -#include "../common/kwinxrenderutils.h" #include "config-kwin.h" @@ -243,8 +242,8 @@ bool X11WindowedBackend::initialize() initXInput(); initDri3(); + initRender(); - XRenderUtils::init(m_connection, m_screen->root); createOutputs(); m_pointerDevice = std::make_unique(); @@ -339,6 +338,22 @@ void X11WindowedBackend::initDri3() } } +void X11WindowedBackend::initRender() +{ + xcb_render_query_pict_formats_cookie_t cookie = xcb_render_query_pict_formats(m_connection); + xcb_render_query_pict_formats_reply_t *reply = xcb_render_query_pict_formats_reply(m_connection, cookie, nullptr); + if (reply) { + for (xcb_render_pictforminfo_iterator_t it = xcb_render_query_pict_formats_formats_iterator(reply); it.rem; xcb_render_pictforminfo_next(&it)) { + xcb_render_pictforminfo_t *info = it.data; + if (info->depth == 32) { + m_pictureFormats.insert(info->depth, info->id); + break; + } + } + free(reply); + } +} + X11WindowedOutput *X11WindowedBackend::findOutput(xcb_window_t window) const { const auto it = std::ranges::find_if(m_outputs, [window](X11WindowedOutput *output) { @@ -744,6 +759,11 @@ bool X11WindowedBackend::hasXInput() const return m_hasXInput; } +xcb_render_pictformat_t X11WindowedBackend::pictureFormatForDepth(int depth) const +{ + return m_pictureFormats.value(depth); +} + QHash> X11WindowedBackend::driFormats() const { return m_driFormats; diff --git a/src/backends/x11/windowed/x11_windowed_backend.h b/src/backends/x11/windowed/x11_windowed_backend.h index 5e81e73390..10f84908f1 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.h +++ b/src/backends/x11/windowed/x11_windowed_backend.h @@ -19,6 +19,7 @@ #include #include +#include #include struct _XDisplay; @@ -107,6 +108,8 @@ public: bool hasXInput() const; + xcb_render_pictformat_t pictureFormatForDepth(int depth) const; + QHash> driFormats() const; uint32_t driFormatForDepth(int depth) const; int driMajorVersion() const; @@ -139,6 +142,7 @@ private: void updateSize(xcb_configure_notify_event_t *event); void initXInput(); void initDri3(); + void initRender(); X11WindowedOutput *findOutput(xcb_window_t window) const; void destroyOutputs(); @@ -178,6 +182,7 @@ private: std::unique_ptr m_eglDisplay; QList m_outputs; + QHash m_pictureFormats; }; } // namespace KWin diff --git a/src/backends/x11/windowed/x11_windowed_output.cpp b/src/backends/x11/windowed/x11_windowed_output.cpp index f116aeafbd..11c1b1ecab 100644 --- a/src/backends/x11/windowed/x11_windowed_output.cpp +++ b/src/backends/x11/windowed/x11_windowed_output.cpp @@ -9,7 +9,6 @@ #include "x11_windowed_output.h" #include "config-kwin.h" -#include "../common/kwinxrenderutils.h" #include "x11_windowed_backend.h" #include "x11_windowed_logging.h" @@ -113,8 +112,10 @@ void X11WindowedCursor::update(const QImage &image, const QPointF &hotspot) xcb_put_image(connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, img.width(), img.height(), 0, 0, 0, 32, img.sizeInBytes(), img.constBits()); - XRenderPicture pic(pix, 32); + xcb_render_picture_t pic = xcb_generate_id(connection); + xcb_render_create_picture(connection, pic, pix, backend->pictureFormatForDepth(32), 0, nullptr); xcb_render_create_cursor(connection, cid, pic, qRound(hotspot.x() * outputScale), qRound(hotspot.y() * outputScale)); + xcb_render_free_picture(connection, pic); } xcb_change_window_attributes(connection, m_output->window(), XCB_CW_CURSOR, &cid);