diff options
| author | Dana Jansens <danakj@orodu.net> | 2007-03-28 01:52:06 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2007-03-28 01:52:06 +0000 |
| commit | 339d76704400a6ea514817d91a2e935a13ecc928 (patch) | |
| tree | a8a9a44bd6a83fc9b8e4b3f698de3eca78f4e47e /openbox/grab.c | |
| parent | 0ec2282e2ca6b80fa8c85dc366596cd009acc8a9 (diff) | |
handle time wrapping around.
Diffstat (limited to 'openbox/grab.c')
| -rw-r--r-- | openbox/grab.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/openbox/grab.c b/openbox/grab.c index f63da5e9..991956da 100644 --- a/openbox/grab.c +++ b/openbox/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 @@ gboolean grab_keyboard(gboolean grab) 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 @@ gboolean grab_pointer(gboolean grab, ObCursor cur) 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 @@ gboolean grab_pointer_window(gboolean grab, ObCursor cur, Window win) 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; } |
