all repos — openbox @ 339d76704400a6ea514817d91a2e935a13ecc928

openbox fork - make it a bit more like ryudo

handle time wrapping around.
Dana Jansens danakj@orodu.net
commit

339d76704400a6ea514817d91a2e935a13ecc928

parent

0ec2282e2ca6b80fa8c85dc366596cd009acc8a9

4 files changed, 31 insertions(+), 14 deletions(-)

jump to
M openbox/client.copenbox/client.c

@@ -3031,9 +3031,11 @@ ob_debug("Want to activate window 0x%x with time %u (last time %u), "

"source=%s\n", self->window, event_curtime, client_last_user_time, (user ? "user" : "application")); - if (!user && event_curtime && event_curtime < client_last_user_time) + if (!user && event_curtime && + !event_time_after(event_curtime, client_last_user_time)) + { client_hilite(self, TRUE); - else { + } else { if (client_normal(self) && screen_showing_desktop) screen_show_desktop(FALSE); if (self->iconic)
M openbox/event.copenbox/event.c

@@ -1376,3 +1376,15 @@ g_free(it->data);

} g_slist_free(saved); } + +gboolean event_time_after(Time t1, Time t2) +{ + /* + Timestamp values wrap around (after about 49.7 days). The server, given + its current time is represented by timestamp T, always interprets + timestamps from clients by treating half of the timestamp space as being + later in time than T. + - http://tronche.com/gui/x/xlib/input/pointer-grabbing.html + */ + return t1 >= t2 && t1 <= t2 + (1 << (sizeof(Time)*8-1)); +}
M openbox/event.hopenbox/event.h

@@ -47,4 +47,8 @@ /* Halts any focus delay in progress, use this when the user is selecting a

window for focus */ void event_halt_focus_delay(); +/*! Compare t1 and t2, taking into account wraparound. True if t1 + comes at the same time or later than t2. */ +gboolean event_time_after(Time t1, Time t2); + #endif
M openbox/grab.copenbox/grab.c

@@ -38,6 +38,14 @@ static guint pgrabs = 0;

/*! The time at which the last grab was made */ static Time grab_time = CurrentTime; +static Time ungrab_time() +{ + Time t = event_curtime; + if (!(t == 0 || event_time_after(t, grab_time))) + t = grab_time; + return t; +} + gboolean grab_on_keyboard() { return kgrabs > 0;

@@ -65,10 +73,7 @@ } else

ret = TRUE; } else if (kgrabs > 0) { if (--kgrabs == 0) { - Time t = event_curtime; - if (t != 0 && t < grab_time) - t = grab_time; - XUngrabKeyboard(ob_display, t); + XUngrabKeyboard(ob_display, ungrab_time()); } ret = TRUE; }

@@ -94,10 +99,7 @@ } else

ret = TRUE; } else if (pgrabs > 0) { if (--pgrabs == 0) { - Time t = event_curtime; - if (t != 0 && t < grab_time) - t = grab_time; - XUngrabPointer(ob_display, event_curtime); + XUngrabPointer(ob_display, ungrab_time()); } ret = TRUE; }

@@ -122,10 +124,7 @@ } else

ret = TRUE; } else if (pgrabs > 0) { if (--pgrabs == 0) { - Time t = event_curtime; - if (t != 0 && t < grab_time) - t = grab_time; - XUngrabPointer(ob_display, event_curtime); + XUngrabPointer(ob_display, ungrab_time()); } ret = TRUE; }