add the new '-remote' option. let the dispatchEvents loop work in 'local' or 'remote' mode.
This commit is contained in:
parent
d8429b31b4
commit
d647de97be
4 changed files with 45 additions and 6 deletions
|
@ -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)
|
||||
|
|
|
@ -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.<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; }
|
||||
|
|
|
@ -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 <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::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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue