[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kolor-manager/kded-ku] kolor-server: improve window tracking - 2
From: Kai-Uwe Behrmann <ku.b () gmx ! de>
Date: 2015-05-08 20:40:06
Message-ID: E1Yqp42-0000mg-71 () scm ! kde ! org
[Download RAW message or body]
Git commit fac1279f9993d7f806bdcfbe8fe4d5dbddf5a668 by Kai-Uwe Behrmann.
Committed on 15/03/2013 at 21:26.
Pushed by behrmann into branch 'kded-ku'.
improve window tracking - 2
M +8 -5 kolor-server/display.cpp
M +28 -0 kolor-server/screen.cpp
M +9 -0 kolor-server/screen.h
http://commits.kde.org/kolor-manager/fac1279f9993d7f806bdcfbe8fe4d5dbddf5a668
diff --git a/kolor-server/display.cpp b/kolor-server/display.cpp
index f43c0c7..709f424 100644
--- a/kolor-server/display.cpp
+++ b/kolor-server/display.cpp
@@ -42,7 +42,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace KolorServer
{
-static const int X11_EVENTS_POLL_INTERVAL = 4000; //ms
+static const int X11_EVENTS_POLL_INTERVAL = 50; //ms
/*
* Display
@@ -354,6 +354,9 @@ void Display::handleEvent(X11::XEvent* event)
} else if (event->xproperty.atom == iccDisplayAdvanced) {
kDebug() << "ICC Display Advanced atom changed";
m_screen->updateOutputConfiguration(false);
+ } else if (strstr(atomName, "_NET_CLIENT_LIST") != 0) {
+ kDebug() << "_NET_CLIENT_LIST atom changed";
+ m_screen->updateWindows();
}
break;
@@ -381,11 +384,11 @@ void Display::handleEvent(X11::XEvent* event)
void Display::checkX11Events()
{
X11::XEvent event;
- long eventMask = ExposureMask | PropertyChangeMask;
- while (X11::XCheckMaskEvent(m_display, eventMask, &event) == True) {
- X11::XcmeContext_InLoop(m_xcmeContext, &event);
- handleEvent(&event);
+ while (X11::XPending(m_display)) {
+ XNextEvent(m_display, &event);
+ if(X11::XcmeContext_InLoop(m_xcmeContext, &event) == 0)
+ handleEvent(&event);
}
}
diff --git a/kolor-server/screen.cpp b/kolor-server/screen.cpp
index 40fec23..1512cf2 100644
--- a/kolor-server/screen.cpp
+++ b/kolor-server/screen.cpp
@@ -339,6 +339,34 @@ void Screen::updateWindowRegions(uint windowId)
emit regionClutsChanged();
}
+void Screen::updateWindows()
+{
+ unsigned long nWindows = 0;
+ X11::Window * windows = (X11::Window*)X11::fetchProperty(m_display, rootWindow(),
+ X11::XInternAtom( m_display, "_NET_CLIENT_LIST", False),
+ XA_WINDOW, &nWindows, False);
+
+ if (windows) {
+ QList<Window*>::iterator it = m_windows.begin();
+ while (it != m_windows.end()) {
+ bool found = false;
+ for (unsigned i = 0; i < nWindows; ++i) {
+ if (windows[i] == (*it)->id()) {
+ found = true;
+ break;
+ }
+ }
+ if (found == false)
+ it = m_windows.erase(it);
+ else
+ ++it;
+ }
+
+ kDebug() << "Windows found: " << nWindows << "|" << m_windows.size();
+ X11::XFree(windows);
+ }
+}
+
} // KolorServer namespace
#include "moc_screen.cpp"
diff --git a/kolor-server/screen.h b/kolor-server/screen.h
index 85cdb0f..a136a11 100644
--- a/kolor-server/screen.h
+++ b/kolor-server/screen.h
@@ -184,6 +184,15 @@ public:
*/
void updateWindowRegions(uint windowId);
+ /**
+ * The window list can change as new windows appear and disappear.
+ * In order to see only existing windows the _NET_CLIENT_LIST must be
+ * examined upon their change and the window list must be updated.
+ *
+ * This function is to be called upon _NET_CLIENT_LIST property changes.
+ */
+ void updateWindows();
+
signals:
void outputClutsChanged();
void regionClutsChanged();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic