From 955f04ae8e7172e2cb9c38d0fff09268a50d9169 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Wed, 23 Sep 2009 22:44:35 +0000 Subject: [PATCH] simplified x11util::isSupported( Atom ) code, needed for the size grip, so that it calls XGetWindowProperty only once, in a way that is similar to what netwm.cpp does. svn path=/trunk/KDE/kdebase/workspace/; revision=1027369 --- clients/oxygen/x11util.cpp | 46 ++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/clients/oxygen/x11util.cpp b/clients/oxygen/x11util.cpp index e4b232fc80..3fe43e5ab3 100644 --- a/clients/oxygen/x11util.cpp +++ b/clients/oxygen/x11util.cpp @@ -52,39 +52,31 @@ namespace Oxygen Atom net_supported( findAtom( _NET_SUPPORTED ) ); Atom searched( findAtom( atom ) ); - Atom actual; + Atom type; int format; unsigned char *data; - unsigned long offset = 0; + unsigned long count; + unsigned long unused; - while( 1 ) - { - unsigned long n, left; - XGetWindowProperty( display, QX11Info::appRootWindow(), - net_supported, offset, 1L, - false, XA_ATOM, &actual, - &format, &n, &left, - (unsigned char **) &data); + // get window property + if( XGetWindowProperty( + display, QX11Info::appRootWindow(), + net_supported, 0l, 2048l, + false, XA_ATOM, &type, + &format, &count, &unused, (unsigned char **) &data) != Success ) + { return false; } - if( data == None ) break; + if( type != XA_ATOM || format != 32 || count <= 0 || data == None ) + { return false; } - // try cast data to atom - Atom found( *(Atom*)data ); + long *states = (long *) data; + bool found = false; + static bool first( true ); + for( unsigned long i = 0; i