--- kdelibs-3.5.1/kdeui/ksystemtray.cpp 2005-10-10 11:06:38.000000000 -0400 +++ kdelibs-3.5.1-patched/kdeui/ksystemtray.cpp 2006-02-18 11:52:01.000000000 -0500 @@ -32,6 +32,7 @@ #include #include #include +#include #endif #include @@ -39,6 +40,8 @@ #include +extern Time qt_x_time; + class KSystemTrayPrivate { public: @@ -63,6 +66,43 @@ QXEmbed::initialize(); #endif + { + XGrabServer (qt_xdisplay()); + static Atom selection = XInternAtom( qt_xdisplay(), "_NET_SYSTEM_TRAY_S" + QCString().setNum( qt_xscreen()), False ); + + /* look for the system tray window */ + Window tray = XGetSelectionOwner (qt_xdisplay(), selection); + + if (tray != None) + { + /* found it */ + XSelectInput (qt_xdisplay(), tray, StructureNotifyMask); + } + + XUngrabServer (qt_xdisplay()); + XFlush (qt_xdisplay()); + + if ( tray != None ) + { + XEvent ev; + memset(&ev, 0, sizeof( ev )); + static Atom atom = XInternAtom( qt_xdisplay(), "_NET_SYSTEM_TRAY_OPCODE", False ); + ev.xclient.type = ClientMessage; + ev.xclient.window = tray; + ev.xclient.message_type = atom; + ev.xclient.format = 32; + ev.xclient.data.l[ 0 ] = qt_x_time; + ev.xclient.data.l[ 1 ] = 0; // SYSTEM_TRAY_REQUEST_DOCK + ev.xclient.data.l[ 2 ] = winId(); + ev.xclient.data.l[ 3 ] = 0; // unused + ev.xclient.data.l[ 4 ] = 0; // unused + + XSendEvent( qt_xdisplay(), tray, False, NoEventMask, (XEvent *)&ev ); + XSync(qt_xdisplay(), FALSE ); + } + } + + d = new KSystemTrayPrivate; d->actionCollection = new KActionCollection(this);