Add X11 composite window property in Application

This allows checking if the given override redirect is the composite
overlay window without resorting to platform specific implementation of
Compositor.
This commit is contained in:
Vlad Zahorodnii 2023-09-19 11:51:42 +03:00
parent c9547071ea
commit dba29ece4b
4 changed files with 17 additions and 23 deletions

View file

@ -149,6 +149,7 @@ void X11Compositor::start()
// Internal setup failed, abort.
return;
}
kwinApp()->setX11CompositeWindow(backend()->overlayWindow()->window());
startupWithWorkspace();
m_syncManager.reset(X11SyncManager::create());
}
@ -157,6 +158,7 @@ void X11Compositor::stop()
{
m_syncManager.reset();
Compositor::stop();
kwinApp()->setX11CompositeWindow(XCB_WINDOW_NONE);
}
void X11Compositor::composite(RenderLoop *renderLoop)
@ -215,20 +217,6 @@ void X11Compositor::composite(RenderLoop *renderLoop)
}
}
bool X11Compositor::checkForOverlayWindow(WId w) const
{
if (!backend()) {
// No backend, so it cannot be the overlay window.
return false;
}
if (!backend()->overlayWindow()) {
// No overlay window, it cannot be the overlay.
return false;
}
// Compare the window ID's.
return w == backend()->overlayWindow()->window();
}
bool X11Compositor::isOverlayWindowVisible() const
{
if (!backend()) {

View file

@ -80,11 +80,6 @@ public:
bool openGLCompositingIsBroken() const override;
void createOpenGLSafePoint(OpenGLSafePoint safePoint) override;
/**
* Checks whether @p w is the Scene's overlay window.
*/
bool checkForOverlayWindow(WId w) const;
/**
* @returns Whether the Scene's Overlay X Window is visible.
*/

View file

@ -181,6 +181,14 @@ public:
return m_rootWindow;
}
/**
* @returns the X11 composite overlay window handle.
*/
xcb_window_t x11CompositeWindow() const
{
return m_compositeWindow;
}
/**
* @returns the X11 xcb connection
*/
@ -205,6 +213,10 @@ public:
{
m_connection = c;
}
void setX11CompositeWindow(xcb_window_t window)
{
m_compositeWindow = window;
}
qreal xwaylandScale() const
{
@ -368,6 +380,7 @@ private:
OperationMode m_operationMode;
xcb_timestamp_t m_x11Time = XCB_TIME_CURRENT_TIME;
xcb_window_t m_rootWindow = XCB_WINDOW_NONE;
xcb_window_t m_compositeWindow = XCB_WINDOW_NONE;
xcb_connection_t *m_connection = nullptr;
#if KWIN_BUILD_ACTIVITIES
bool m_useKActivities = true;

View file

@ -661,10 +661,8 @@ X11Window *Workspace::createX11Window(xcb_window_t windowId, bool is_mapped)
X11Window *Workspace::createUnmanaged(xcb_window_t windowId)
{
if (X11Compositor *compositor = X11Compositor::self()) {
if (compositor->checkForOverlayWindow(windowId)) {
return nullptr;
}
if (kwinApp()->x11CompositeWindow() == windowId) {
return nullptr;
}
X11Window *window = new X11Window();
if (!window->track(windowId)) {