Hello Casian,

can you review and possibly amend the attached patch. It fixes running
two color servers in parallel, when KWin is switched off.

Thanks
Kai-Uwe
>From 872c441bd82e2dee67b38dea4d202e16a0d9fac9 Mon Sep 17 00:00:00 2001
From: Kai-Uwe Behrmann <k...@gmx.de>
Date: Mon, 16 Jan 2017 17:17:19 +0100
Subject: [PATCH] fix KolorServer running without KWin

both, KolorServer and KWin are tightly integrated in their
functionality. Other window managers can not make use of KolorServer.
Thus it should be switched off as soon as KWin stops to run.

fixes CompICC failed take over of the XCM color service from KolorServer

Signed-off-by: Kai-Uwe Behrmann <k...@gmx.de>
---
 daemon/display.cpp | 26 ++++++++++++++++++++++++++
 daemon/display.h   | 17 +++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/daemon/display.cpp b/daemon/display.cpp
index 7b91863..f0e03f8 100644
--- a/daemon/display.cpp
+++ b/daemon/display.cpp
@@ -129,6 +129,7 @@ void Display::initialize()
     iccColorDesktop     = X11::XInternAtom(m_display, XCM_COLOR_DESKTOP, False);
     netDesktopGeometry  = X11::XInternAtom(m_display, "_NET_DESKTOP_GEOMETRY", False);
     iccDisplayAdvanced  = X11::XInternAtom(m_display, XCM_COLOUR_DESKTOP_ADVANCED, False);
+    kwinRunning         = X11::XInternAtom(m_display, "KWIN_RUNNING", False);
 
     // Get the default screen
     int screenNumber = X11::defaultScreen(m_display);
@@ -315,6 +316,24 @@ bool Display::isAdvancedIccDisplay()
     return advanced;
 }
 
+bool Display::isOnKWin()
+{
+    unsigned long nBytes;
+    char *opt = 0;
+    bool active = false;
+    X11::Window rootWindow = X11::rootWindow(m_display, 0);
+
+    // check our environment
+    opt = (char*) X11::fetchProperty(m_display, rootWindow, kwinRunning, AnyPropertyType, &nBytes, False);
+    qCDebug(KOLORSERVER) << "KWIN_RUNNING, nBytes:" << nBytes;
+    if (opt && nBytes)
+        active = 1;
+    if (opt)
+        X11::XFree(opt);
+
+    return active;
+}
+
 void Display::handleEvent(X11::XEvent* event)
 {
     const char *atomName = 0;
@@ -322,6 +341,13 @@ void Display::handleEvent(X11::XEvent* event)
     if (!colorDesktopActivated())
         return;
 
+
+    if(!isOnKWin()) {
+        /* switch off the plugin */
+        X11::changeProperty(m_display, iccColorDesktop, XA_STRING, (const unsigned char*) NULL, 0);
+        activateColorDesktop(false);
+    }
+
     switch (event->type) {
     case PropertyNotify:
         atomName = X11::XGetAtomName(event->xany.display, event->xproperty.atom);
diff --git a/daemon/display.h b/daemon/display.h
index ff6e4c1..fe5409e 100644
--- a/daemon/display.h
+++ b/daemon/display.h
@@ -144,6 +144,22 @@ public:
      */
     bool isAdvancedIccDisplay();
 
+    /**
+     * \note check if KWin is active
+     * - determine if some iccDispla atom is present
+     * - return the result
+     *
+     * Used by: handleEvent
+     *
+     *  KWIN_RUNNING:
+     * The atom is mandatory attached to the root window by KWin. As KolorServer
+     * and KWin are in different processes, it is needed to check if KolorServer
+     * can work for KWin. KolorServer is designed to work with KWin only. If a 
+     * different color server is running, then KolorServer shall unset XCM 
+     * atoms to allow take over of XCM color server handling.
+     */
+    bool isOnKWin();
+
 private:
     /**
      * \note pluginInitDisplay
@@ -199,6 +215,7 @@ private:
     X11::Atom iccColorDesktop;
     X11::Atom netDesktopGeometry;
     X11::Atom iccDisplayAdvanced;
+    X11::Atom kwinRunning;
 
     /**
      * Initially, the color desktop functionality is enabled, but
-- 
2.11.0

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Oyranos-devel mailing list
Oyranos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oyranos-devel

Reply via email to