From kde-commits Fri May 08 20:40:06 2015 From: Kai-Uwe Behrmann Date: Fri, 08 May 2015 20:40:06 +0000 To: kde-commits Subject: [kolor-manager/kded-ku] kolor-server: improve window tracking - 2 Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=143111761915085 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/fac1279f9993d7f806bdcfbe8fe4d5dbddf5a6= 68 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 =3D 4000; //ms +static const int X11_EVENTS_POLL_INTERVAL =3D 50; //ms = /* * Display @@ -354,6 +354,9 @@ void Display::handleEvent(X11::XEvent* event) } else if (event->xproperty.atom =3D=3D iccDisplayAdvanced) { kDebug() << "ICC Display Advanced atom changed"; m_screen->updateOutputConfiguration(false); + } else if (strstr(atomName, "_NET_CLIENT_LIST") !=3D 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 =3D ExposureMask | PropertyChangeMask; = - while (X11::XCheckMaskEvent(m_display, eventMask, &event) =3D=3D 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) =3D=3D 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 =3D 0; + X11::Window * windows =3D (X11::Window*)X11::fetchProperty(m_display, = rootWindow(), + X11::XInternAtom( m_display, "_N= ET_CLIENT_LIST", False), + XA_WINDOW, &nWindows, False); + + if (windows) { + QList::iterator it =3D m_windows.begin(); + while (it !=3D m_windows.end()) { + bool found =3D false; + for (unsigned i =3D 0; i < nWindows; ++i) { + if (windows[i] =3D=3D (*it)->id()) { + found =3D true; + break; + } + } + if (found =3D=3D false) + it =3D 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 change= s. + */ + void updateWindows(); + signals: void outputClutsChanged(); void regionClutsChanged();