_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)
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; }
_focused_client = 0;
_sync = false;
_single = false;
+ _remote = false;
parseCommandLine(argc, argv);
_sync = true;
} else if (arg == "-single") {
_single = true;
+ } else if (arg == "-remote") {
+ _remote = true;
} else if (arg == "-version") {
showVersion();
::exit(0);
// 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\
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
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;