[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin] /: Do not hard runtime depend on X11 in composite startup
From:       Martin_Flöser <null () kde ! org>
Date:       2017-09-01 16:06:14
Message-ID: E1dnoSU-0008Ko-2n () code ! kde ! org
[Download RAW message or body]

Git commit 2892fad5b6c5d3eccd946a6aa24d0f77b40f0058 by Martin Flöser.
Committed on 01/09/2017 at 16:05.
Pushed by graesslin into branch 'master'.

Do not hard runtime depend on X11 in composite startup

Summary:
The compositor needs to claim the X11 compositor selection and redirect
the X11 windows. This of course only makes sense when having X11 support.

This change refactors the code so that if X11 support is missing the code
is not executed, but as soon as X11 support comes available the selection
gets claimed.

Also if the connection goes away the selection is deleted, though it
might be that this does not work as KSelectionOwner might call into xcb
and cause a crash. This needs to be tested once we start supporting
XWayland going away.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7504

M  +19   -5    composite.cpp
M  +1    -0    composite.h

https://commits.kde.org/kwin/2892fad5b6c5d3eccd946a6aa24d0f77b40f0058

diff --git a/composite.cpp b/composite.cpp
index 705c6d5bf..9c5d9e441 100644
--- a/composite.cpp
+++ b/composite.cpp
@@ -190,7 +190,7 @@ extern bool is_multihead;
 
 void Compositor::slotCompositingOptionsInitialized()
 {
-    claimCompositorSelection();
+    setupX11Support();
 
     // There might still be a deleted around, needs to be cleared before creating \
the scene (BUG 333275)  if (Workspace::self()) {
@@ -290,7 +290,7 @@ void Compositor::slotCompositingOptionsInitialized()
 
 void Compositor::claimCompositorSelection()
 {
-    if (!cm_selection && kwinApp()->x11Connection()) {
+    if (!cm_selection) {
         char selection_name[ 100 ];
         sprintf(selection_name, "_NET_WM_CM_S%d", Application::x11ScreenNumber());
         cm_selection = new CompositorSelectionOwner(selection_name);
@@ -306,15 +306,28 @@ void Compositor::claimCompositorSelection()
     }
 }
 
+void Compositor::setupX11Support()
+{
+    auto c = kwinApp()->x11Connection();
+    if (!c) {
+        delete cm_selection;
+        cm_selection = nullptr;
+        return;
+    }
+    claimCompositorSelection();
+    xcb_composite_redirect_subwindows(c, kwinApp()->x11RootWindow(), \
XCB_COMPOSITE_REDIRECT_MANUAL); +}
+
 void Compositor::startupWithWorkspace()
 {
     if (!m_starting) {
         return;
     }
+    connect(kwinApp(), &Application::x11ConnectionChanged, this, \
&Compositor::setupX11Support, Qt::UniqueConnection);  \
Workspace::self()->markXStackingOrderAsDirty();  Q_ASSERT(m_scene);
     connect(workspace(), &Workspace::destroyed, this, [this] { \
                compositeTimer.stop(); });
-    claimCompositorSelection();
+    setupX11Support();
     m_xrrRefreshRate = KWin::currentRefreshRate();
     fpsInterval = options->maxFpsInterval();
     if (m_scene->syncsToVBlank()) {  // if we do vsync, set the fps to the next \
multiple of the vblank rate @@ -324,7 +337,6 @@ void \
                Compositor::startupWithWorkspace()
         vBlankInterval = milliToNano(1); // no sync - DO NOT set "0", would cause \
                div-by-zero segfaults.
     m_timeSinceLastVBlank = fpsInterval - (options->vBlankTime() + 1); // means \
"start now" - we don't have even a slight idea when the first vsync will occur  \
                scheduleRepaint();
-    xcb_composite_redirect_subwindows(connection(), rootWindow(), \
                XCB_COMPOSITE_REDIRECT_MANUAL);
     new EffectsHandlerImpl(this, m_scene);   // sets also the 'effects' pointer
     connect(Workspace::self(), &Workspace::deletedRemoved, m_scene, \
                &Scene::windowDeleted);
     connect(effects, SIGNAL(screenGeometryChanged(QSize)), SLOT(addRepaintFull()));
@@ -392,7 +404,9 @@ void Compositor::finish()
         c->finishCompositing();
         foreach (Deleted * c, Workspace::self()->deletedList())
         c->finishCompositing();
-        xcb_composite_unredirect_subwindows(connection(), rootWindow(), \
XCB_COMPOSITE_REDIRECT_MANUAL); +        if (auto c = kwinApp()->x11Connection()) {
+            xcb_composite_unredirect_subwindows(c, kwinApp()->x11RootWindow(), \
XCB_COMPOSITE_REDIRECT_MANUAL); +        }
     }
     if (waylandServer()) {
         foreach (ShellClient *c, waylandServer()->clients()) {
diff --git a/composite.h b/composite.h
index ccff306a9..9f6590cfc 100644
--- a/composite.h
+++ b/composite.h
@@ -207,6 +207,7 @@ private:
      * Continues the startup after Scene And Workspace are created
      **/
     void startupWithWorkspace();
+    void setupX11Support();
 
     /**
      * Whether the Compositor is currently suspended, 8 bits encoding the reason


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic