backends/x11: Restore dedicated XRenderUtils::init function
Under kwin_wayland `kwinApp()->connection()` is for communicating with XWayland, but in X11Windowed backend we need to talk to the host XServer. Restore `XRenderUtils::init` and set it accordingly based on whether we're running standalone or windowed, so that `kwin_wayland` works running nested in an X session again. Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io> Tested-by: Merge Service <https://invent.kde.org/plasma/kwin/-/merge_requests/2457> Part-of: <https://invent.kde.org/plasma/kwin/-/merge_requests/2457>
This commit is contained in:
parent
8b644fee58
commit
cfd3676e96
4 changed files with 42 additions and 7 deletions
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include "kwinxrenderutils.h"
|
||||
#include "logging_p.h"
|
||||
#include "main.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QImage>
|
||||
|
@ -19,12 +18,31 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
namespace XRenderUtils
|
||||
{
|
||||
static xcb_connection_t *s_connection = nullptr;
|
||||
static xcb_window_t s_rootWindow = XCB_WINDOW_NONE;
|
||||
|
||||
void init(xcb_connection_t *connection, xcb_window_t rootWindow)
|
||||
{
|
||||
s_connection = connection;
|
||||
s_rootWindow = rootWindow;
|
||||
}
|
||||
|
||||
void cleanup()
|
||||
{
|
||||
s_connection = nullptr;
|
||||
s_rootWindow = XCB_WINDOW_NONE;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
static xcb_render_picture_t createPicture(xcb_pixmap_t pix, int depth)
|
||||
{
|
||||
if (pix == XCB_PIXMAP_NONE) {
|
||||
return XCB_RENDER_PICTURE_NONE;
|
||||
}
|
||||
xcb_connection_t *c = kwinApp()->x11Connection();
|
||||
xcb_connection_t *c = XRenderUtils::s_connection;
|
||||
static QHash<int, xcb_render_pictformat_t> s_renderFormats;
|
||||
if (!s_renderFormats.contains(depth)) {
|
||||
xcb_render_query_pict_formats_reply_t *formats = xcb_render_query_pict_formats_reply(c, xcb_render_query_pict_formats_unchecked(c), nullptr);
|
||||
|
@ -58,10 +76,10 @@ XRenderPicture::XRenderPicture(const QImage &img)
|
|||
|
||||
void XRenderPicture::fromImage(const QImage &img)
|
||||
{
|
||||
xcb_connection_t *c = kwinApp()->x11Connection();
|
||||
xcb_connection_t *c = XRenderUtils::s_connection;
|
||||
const int depth = img.depth();
|
||||
xcb_pixmap_t xpix = xcb_generate_id(c);
|
||||
xcb_create_pixmap(c, depth, xpix, kwinApp()->x11RootWindow(), img.width(), img.height());
|
||||
xcb_create_pixmap(c, depth, xpix, XRenderUtils::s_rootWindow, img.width(), img.height());
|
||||
|
||||
xcb_gcontext_t cid = xcb_generate_id(c);
|
||||
xcb_create_gc(c, cid, xpix, 0, nullptr);
|
||||
|
@ -82,7 +100,7 @@ XRenderPictureData::~XRenderPictureData()
|
|||
{
|
||||
if (picture != XCB_RENDER_PICTURE_NONE) {
|
||||
Q_ASSERT(qApp);
|
||||
xcb_render_free_picture(kwinApp()->x11Connection(), picture);
|
||||
xcb_render_free_picture(XRenderUtils::s_connection, picture);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +112,8 @@ struct PictFormatData
|
|||
PictFormatData()
|
||||
{
|
||||
// Fetch the render pict formats
|
||||
reply = xcb_render_query_pict_formats_reply(kwinApp()->x11Connection(),
|
||||
xcb_render_query_pict_formats_unchecked(kwinApp()->x11Connection()), nullptr);
|
||||
reply = xcb_render_query_pict_formats_reply(s_connection,
|
||||
xcb_render_query_pict_formats_unchecked(s_connection), nullptr);
|
||||
|
||||
// Init the visual ID -> format ID hash table
|
||||
for (auto screens = xcb_render_query_pict_formats_screens_iterator(reply); screens.rem; xcb_render_pictscreen_next(&screens)) {
|
||||
|
|
|
@ -83,6 +83,11 @@ inline XRenderPicture::operator xcb_render_picture_t()
|
|||
|
||||
namespace XRenderUtils
|
||||
{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
KWIN_EXPORT void init(xcb_connection_t *connection, xcb_window_t rootWindow);
|
||||
|
||||
/**
|
||||
* Returns the Xrender format that corresponds to the given visual ID.
|
||||
*/
|
||||
|
@ -93,6 +98,11 @@ KWIN_EXPORT xcb_render_pictformat_t findPictFormat(xcb_visualid_t visual);
|
|||
*/
|
||||
KWIN_EXPORT const xcb_render_directformat_t *findPictFormatInfo(xcb_render_pictformat_t format);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
KWIN_EXPORT void cleanup();
|
||||
|
||||
} // namespace XRenderUtils
|
||||
|
||||
} // namespace KWin
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "workspace.h"
|
||||
#include "x11_output.h"
|
||||
|
||||
#include "kwinxrenderutils.h"
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KCrash>
|
||||
#include <KGlobalAccel>
|
||||
|
@ -129,6 +131,9 @@ X11StandalonePlatform::~X11StandalonePlatform()
|
|||
if (sceneEglDisplay() != EGL_NO_DISPLAY) {
|
||||
eglTerminate(sceneEglDisplay());
|
||||
}
|
||||
if (isReady()) {
|
||||
XRenderUtils::cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
bool X11StandalonePlatform::initialize()
|
||||
|
@ -136,6 +141,7 @@ bool X11StandalonePlatform::initialize()
|
|||
if (!QX11Info::isPlatformX11()) {
|
||||
return false;
|
||||
}
|
||||
XRenderUtils::init(kwinApp()->x11Connection(), kwinApp()->x11RootWindow());
|
||||
setReady(true);
|
||||
initOutputs();
|
||||
|
||||
|
|
|
@ -210,6 +210,7 @@ bool X11WindowedBackend::initialize()
|
|||
}
|
||||
}
|
||||
initXInput();
|
||||
XRenderUtils::init(m_connection, m_screen->root);
|
||||
createOutputs();
|
||||
connect(kwinApp(), &Application::workspaceCreated, this, &X11WindowedBackend::startEventReading);
|
||||
connect(Cursors::self(), &Cursors::currentCursorChanged, this, [this]() {
|
||||
|
|
Loading…
Reference in a new issue