[Xfce4-commits] <xfwm4:master> Reintroduce the double-click timeout, this is unrelated to events being lost, Remove the active grab for the double-click detection.

Olivier Fourdan noreply at xfce.org
Fri Nov 18 18:36:01 CET 2011


Updating branch refs/heads/master
         to d7273d90a46c328cfdc26ff7f000cefb10000271 (commit)
       from 18199db7428b4bd1a0c5aaa60ebdea3e96178006 (commit)

commit d7273d90a46c328cfdc26ff7f000cefb10000271
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Thu Nov 17 13:13:48 2011 +0100

    Reintroduce the double-click timeout, this is unrelated to events being lost,
    Remove the active grab for the double-click detection.

 src/events.c |   46 +++++++++++++++++++++++++++++++---------------
 src/focus.c  |    7 ++++++-
 2 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/src/events.c b/src/events.c
index 917523e..5ddad9a 100644
--- a/src/events.c
+++ b/src/events.c
@@ -123,6 +123,7 @@ struct _XfwmButtonClickData
     Window w;
     guint button;
     guint clicks;
+    guint timeout;
     gint  x0;
     gint  y0;
     guint t0;
@@ -134,6 +135,23 @@ struct _XfwmButtonClickData
     gboolean allow_double_click;
 };
 
+static gboolean
+typeOfClick_end (gpointer data)
+{
+    XfwmButtonClickData *passdata;
+
+    passdata = (XfwmButtonClickData *) data;
+    if (passdata->timeout)
+    {
+        g_source_remove (passdata->timeout);
+        passdata->timeout = 0;
+    }
+
+    gtk_main_quit ();
+
+    return (FALSE);
+}
+
 static eventFilterStatus
 typeOfClick_event_filter (XEvent * xevent, gpointer data)
 {
@@ -199,7 +217,7 @@ typeOfClick_event_filter (XEvent * xevent, gpointer data)
         TRACE ("time=%ims (timeout=%ims)", (gint) passdata->tcurrent - (gint) passdata->t0, passdata->double_click_time);
         TRACE ("dist x=%i (max=%i)", ABS (passdata->x0 - passdata->xcurrent), passdata->double_click_distance);
         TRACE ("dist y=%i (max=%i)", ABS (passdata->y0 - passdata->ycurrent), passdata->double_click_distance);
-        gtk_main_quit ();
+        typeOfClick_end (data);
     }
 
     return status;
@@ -217,16 +235,6 @@ typeOfClick (ScreenInfo *screen_info, Window w, XEvent * ev, gboolean allow_doub
     g_return_val_if_fail (w != None, XFWM_BUTTON_UNDEFINED);
 
     display_info = screen_info->display_info;
-    g = myScreenGrabPointer (screen_info, DOUBLE_CLICK_GRAB, None, ev->xbutton.time);
-
-    if (!g)
-    {
-        TRACE ("grab failed in typeOfClick");
-        gdk_beep ();
-        myScreenUngrabPointer (screen_info, ev->xbutton.time);
-        return XFWM_BUTTON_UNDEFINED;
-    }
-
     passdata.display_info = display_info;
     passdata.button = ev->xbutton.button;
     passdata.w = w;
@@ -242,14 +250,17 @@ typeOfClick (ScreenInfo *screen_info, Window w, XEvent * ev, gboolean allow_doub
     passdata.double_click_distance = display_info->double_click_distance;
     TRACE ("Double click time= %i, distance=%i\n", display_info->double_click_time,
                                                    display_info->double_click_distance);
+    passdata.timeout = g_timeout_add_full (G_PRIORITY_HIGH,
+                                           display_info->double_click_time,
+                                           (GSourceFunc) typeOfClick_end,
+                                           (gpointer) &passdata, NULL);
+
     TRACE ("entering typeOfClick loop");
     eventFilterPush (display_info->xfilter, typeOfClick_event_filter, &passdata);
     gtk_main ();
     eventFilterPop (display_info->xfilter);
     TRACE ("leaving typeOfClick loop");
 
-    myScreenUngrabPointer (screen_info, myDisplayGetCurrentTime (display_info));
-
     return (XfwmButtonClickType) passdata.clicks;
 }
 
@@ -896,8 +907,13 @@ handleButtonPress (DisplayInfo *display_info, XButtonEvent * ev)
             {
                 XfwmButtonClickType tclick;
 
-                tclick = typeOfClick (screen_info, c->window, (XEvent *) ev, FALSE);
-                if (tclick != XFWM_BUTTON_UNDEFINED)
+                tclick = typeOfClick (screen_info, c->window, (XEvent *) ev, TRUE);
+
+                if (tclick == XFWM_BUTTON_DOUBLE_CLICK)
+                {
+                    clientClose (c);
+                }
+                else if (tclick != XFWM_BUTTON_UNDEFINED)
                 {
                     if (!(c->type & WINDOW_TYPE_DONT_FOCUS))
                     {
diff --git a/src/focus.c b/src/focus.c
index 85c0441..5b02c59 100644
--- a/src/focus.c
+++ b/src/focus.c
@@ -176,11 +176,16 @@ clientFocusNew(Client * c)
         }
         else if (client_focus->win_layer < c->win_layer)
         {
-            /* We short don't use focus stealing prevention against upper layers */
+            /* We don't use focus stealing prevention against upper layers */
             TRACE ("Ignoring startup prevention because the current focused window is on a lower layer");
             give_focus = TRUE;
             prevented = FALSE;
         }
+        else if (FLAG_TEST (client_focus->xfwm_flags, XFWM_FLAG_MOVING_RESIZING))
+        {
+            give_focus = FALSE;
+            prevented = TRUE;
+        }
         else if (FLAG_TEST (c->flags, CLIENT_FLAG_HAS_STARTUP_TIME | CLIENT_FLAG_HAS_USER_TIME))
         {
             TRACE ("Current time is %u, time for \"%s\" is %u",


More information about the Xfce4-commits mailing list