From 1016f0deb6320f742ee17de375d38f4159acc7ab Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 16 Mar 2002 15:46:44 +0000 Subject: [PATCH] Added timeout to Dispatch(); attempted implementation of wxSTAY_ON_TOP git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14637 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/x11/evtloop.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/x11/toplevel.cpp | 18 ++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/src/x11/evtloop.cpp b/src/x11/evtloop.cpp index 483c4683f0..14ae85eec9 100644 --- a/src/x11/evtloop.cpp +++ b/src/x11/evtloop.cpp @@ -32,6 +32,9 @@ #include "wx/x11/private.h" #include "X11/Xlib.h" +#include +#include + // ---------------------------------------------------------------------------- // wxEventLoopImpl // ---------------------------------------------------------------------------- @@ -223,7 +226,41 @@ bool wxEventLoop::Dispatch() // TODO allowing for threads, as per e.g. wxMSW +#if 0 XNextEvent((Display*) wxGetDisplay(), & event); +#endif + + // This now waits until either an X event is received, + // or the select times out. So we should now process + // wxTimers in a reasonably timely fashion. However it + // does also mean that idle processing will happen more + // often, so we should probably limit idle processing to + // not be repeated more than every N milliseconds. + + if (XPending((Display*) wxGetDisplay()) == 0) + { + struct timeval tv; + tv.tv_sec=0; + tv.tv_usec=10000; // TODO make this configurable + int fd = ConnectionNumber(dsp); + fd_set readset; + FD_ZERO(&readset); + FD_SET(fd, &readset); + if (select(fd+1, &readset, NULL, NULL, & tv) == 0) + { + // Timed out, so no event to process + return TRUE; + } + else + { + // An event was pending, so get it + XNextEvent((Display*) wxGetDisplay(), & event); + } + } else + { + XNextEvent((Display*) wxGetDisplay(), & event); + } + (void) m_impl->ProcessEvent(& event); return TRUE; } diff --git a/src/x11/toplevel.cpp b/src/x11/toplevel.cpp index e63799559c..9be69bcdad 100644 --- a/src/x11/toplevel.cpp +++ b/src/x11/toplevel.cpp @@ -201,6 +201,24 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent, wm_protocols[0] = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False ); wm_protocols[1] = XInternAtom( xdisplay, "WM_TAKE_FOCUS", False ); XSetWMProtocols( xdisplay, xwindow, wm_protocols, 2); + +#if 0 // TODO + // You will need a compliant window manager for this to work + // (e.g. sawfish/enlightenment/kde/icewm/windowmaker) + if (style & wxSTAY_ON_TOP) + { + CARD32 data = 4; // or should this be 6? According to http://developer.gnome.org/doc/standards/wm/c44.html + XChangeProperty (xdisplay, + xwindow, + XInternAtom (xdisplay, "_WIN_LAYER", False), + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&data, + 1); + } +#endif + #endif wxSetWMDecorations( xwindow, style); -- 2.45.2