X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fgrab.c;h=991956da622b291e9ab4a05f5a02a10f086a9de5;hb=58be283e94c062377c86e23beb4d3ac51dc57fb8;hp=f63da5e94f3829b72b68a8f3c9f13c353538ec2a;hpb=0ec2282e2ca6b80fa8c85dc366596cd009acc8a9;p=chaz%2Fopenbox 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; }