all repos — openbox @ d647de97bec82fa6c229a4801908b847f631f031

openbox fork - make it a bit more like ryudo

add the new '-remote' option. let the dispatchEvents loop work in 'local' or 'remote' mode.
Dana Jansens danakj@orodu.net
commit

d647de97bec82fa6c229a4801908b847f631f031

parent

d8429b31b450c41973947eeec1f27af3b2807409

4 files changed, 45 insertions(+), 6 deletions(-)

jump to
M otk/eventdispatcher.ccotk/eventdispatcher.cc

@@ -34,11 +34,32 @@ {

_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)
M otk/eventdispatcher.hhotk/eventdispatcher.hh

@@ -19,7 +19,17 @@

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.<br> + 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; }
M src/openbox.ccsrc/openbox.cc

@@ -95,6 +95,7 @@ _scriptfilepath = otk::expandTilde("~/.openbox/user.py");

_focused_client = 0; _sync = false; _single = false; + _remote = false; parseCommandLine(argc, argv);

@@ -274,6 +275,8 @@ } else if (arg == "-sync") {

_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 @@

// print program usage and command line options printf(_("Usage: %s [OPTIONS...]\n\ Options:\n\ - -display <string> 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 <string> use alternate resource file.\n\ -menu <string> use alternate menu file.\n\

@@ -349,8 +353,10 @@

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
M src/openbox.hhsrc/openbox.hh

@@ -94,6 +94,8 @@ //! Run the application in synchronous mode? (for debugging)

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;