From d647de97bec82fa6c229a4801908b847f631f031 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 19 Feb 2003 00:58:59 +0000 Subject: [PATCH] add the new '-remote' option. let the dispatchEvents loop work in 'local' or 'remote' mode. --- otk/eventdispatcher.cc | 25 +++++++++++++++++++++++-- otk/eventdispatcher.hh | 12 +++++++++++- src/openbox.cc | 12 +++++++++--- src/openbox.hh | 2 ++ 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/otk/eventdispatcher.cc b/otk/eventdispatcher.cc index 0560eec8..1b90dbc0 100644 --- a/otk/eventdispatcher.cc +++ b/otk/eventdispatcher.cc @@ -34,11 +34,32 @@ void EventDispatcher::clearHandler(Window id) _map.erase(id); } -void EventDispatcher::dispatchEvents(void) +void EventDispatcher::dispatchEvents(bool remote) { XEvent e; - while (XPending(**display)) { + while (true) { + /* + There are slightly different event retrieval semantics here for local (or + high bandwidth) versus remote (or low bandwidth) connections to the + display/Xserver. + */ + if (remote) { + if (!XPending(**display)) + return; + } else { + /* + This XSync allows for far more compression of events, which makes + things like Motion events perform far far better. Since it also means + network traffic for every event instead of every X events (where X is + the number retrieved at a time), it probably should not be used for + setups where Openbox is running on a remote/low bandwidth + display/Xserver. + */ + XSync(**display, false); + if (!XEventsQueued(**display, QueuedAlready)) + return; + } XNextEvent(**display, &e); #if 0//defined(DEBUG) diff --git a/otk/eventdispatcher.hh b/otk/eventdispatcher.hh index 03f36299..35c3722e 100644 --- a/otk/eventdispatcher.hh +++ b/otk/eventdispatcher.hh @@ -19,7 +19,17 @@ public: virtual void clearAllHandlers(void); virtual void registerHandler(Window id, EventHandler *handler); virtual void clearHandler(Window id); - virtual void dispatchEvents(void); + //! Dispatch events from the X server to the appropriate EventHandlers + /*! + @param remote Is the Xserver on a remote (low bandwidth) connection or on a + local (high bandwidth) connection. This allows you to specify + 'false' in which case slightly different semantics are used + for event retrieval.
+ The default is 'true' since this should generally be used, + only the Openbox window manager should need to specify + 'false' here. + */ + virtual void dispatchEvents(bool remote = true); inline void setFallbackHandler(EventHandler *fallback) { _fallback = fallback; } diff --git a/src/openbox.cc b/src/openbox.cc index 60db5d83..951d4ab4 100644 --- a/src/openbox.cc +++ b/src/openbox.cc @@ -95,6 +95,7 @@ Openbox::Openbox(int argc, char **argv) _focused_client = 0; _sync = false; _single = false; + _remote = false; parseCommandLine(argc, argv); @@ -274,6 +275,8 @@ void Openbox::parseCommandLine(int argc, char **argv) _sync = true; } else if (arg == "-single") { _single = true; + } else if (arg == "-remote") { + _remote = true; } else if (arg == "-version") { showVersion(); ::exit(0); @@ -305,7 +308,8 @@ void Openbox::showHelp() // print program usage and command line options printf(_("Usage: %s [OPTIONS...]\n\ Options:\n\ - -display use display connection.\n\ + -remote optimize for a remote (low bandwidth) connection to the\n\ + display/Xserver.\n\ -single run on a single screen (default is to run every one).\n\ -rc use alternate resource file.\n\ -menu use alternate menu file.\n\ @@ -349,8 +353,10 @@ void Openbox::showHelp() void Openbox::eventLoop() { while (true) { - dispatchEvents(); // from otk::EventDispatcher - XFlush(**otk::display); // flush here before we go wait for timers + dispatchEvents(false); // from otk::EventDispatcher +// XFlush(**otk::display); // flush here before we go wait for timers + // .. the XPending() should have done this last + // already, it does a flush when it returns 0 // don't wait if we're to shutdown if (_shutdown) break; otk::Timer::dispatchTimers(!_sync); // wait if not in sync mode diff --git a/src/openbox.hh b/src/openbox.hh index 77b39ce5..eb3914aa 100644 --- a/src/openbox.hh +++ b/src/openbox.hh @@ -94,6 +94,8 @@ private: bool _sync; //! Should Openbox run on a single screen or on all available screens? bool _single; + //! Optimize for a remote/low-bandwidth connection to the display? + bool _remote; //! A list of all managed clients ClientMap _clients; -- 2.39.2