abc7304
commit c885c9a676e4860a68f0bdce4b926902f6597ebb
abc7304
Author: Mikael Magnusson <mikachu@gmail.com>
abc7304
Date:   Thu Aug 4 18:34:54 2011 +0200
abc7304
abc7304
    Change default doubleclick timeout to 500ms and keep track of where last click was
abc7304
    
abc7304
    Bug #5152 - "mouse double-click time is too low by default - 200ms"
abc7304
    
abc7304
    We only use the doubleclick in one place in the default configuration,
abc7304
    for doubleclicking titlebars to maximize windows, so any negative impact
abc7304
    of increasing the timeout should be minimal, especially with the
abc7304
    addition of requiring the two clicks to be in the same place.
abc7304
    
abc7304
    Doubleclicks are hardcoded to occur within 8 pixels for now, it doesn't
abc7304
    seem worth it to add a config until someone complains. A possibility is
abc7304
    using the drag threshold, but some people have that set very low so it
abc7304
    could be hard to doubleclick then.
abc7304
abc7304
diff --git a/data/rc.xml b/data/rc.xml
abc7304
index 7598a72..209cc2d 100644
abc7304
--- a/data/rc.xml
abc7304
+++ b/data/rc.xml
abc7304
@@ -313,7 +313,7 @@
abc7304
 <mouse>
abc7304
   <dragThreshold>1</dragThreshold>
abc7304
   
abc7304
-  <doubleClickTime>200</doubleClickTime>
abc7304
+  <doubleClickTime>500</doubleClickTime>
abc7304
   
abc7304
   <screenEdgeWarpTime>400</screenEdgeWarpTime>
abc7304
   
abc7304
diff --git a/doc/rc-mouse-focus.xml b/doc/rc-mouse-focus.xml
abc7304
index 06c3ce5..dc7f2e9 100644
abc7304
--- a/doc/rc-mouse-focus.xml
abc7304
+++ b/doc/rc-mouse-focus.xml
abc7304
@@ -226,7 +226,7 @@
abc7304
 <mouse>
abc7304
   <dragThreshold>8</dragThreshold>
abc7304
   
abc7304
-  <doubleClickTime>200</doubleClickTime>
abc7304
+  <doubleClickTime>500</doubleClickTime>
abc7304
   
abc7304
 
abc7304
   <context name="Frame">
abc7304
diff --git a/openbox/config.c b/openbox/config.c
abc7304
index debd9fb..8e0e5ac 100644
abc7304
--- a/openbox/config.c
abc7304
+++ b/openbox/config.c
abc7304
@@ -1070,7 +1070,7 @@ void config_startup(ObtXmlInst *i)
abc7304
     obt_xml_register(i, "keyboard", parse_keyboard, NULL);
abc7304
 
abc7304
     config_mouse_threshold = 8;
abc7304
-    config_mouse_dclicktime = 200;
abc7304
+    config_mouse_dclicktime = 500;
abc7304
     config_mouse_screenedgetime = 400;
abc7304
     config_mouse_screenedgewarp = FALSE;
abc7304
 
abc7304
diff --git a/openbox/mouse.c b/openbox/mouse.c
abc7304
index ddf6851..2f0c8f5 100644
abc7304
--- a/openbox/mouse.c
abc7304
+++ b/openbox/mouse.c
abc7304
@@ -211,7 +211,7 @@ gboolean mouse_event(ObClient *client, XEvent *e)
abc7304
     static Time ltime;
abc7304
     static guint button = 0, state = 0, lbutton = 0;
abc7304
     static Window lwindow = None;
abc7304
-    static gint px, py, pwx = -1, pwy = -1;
abc7304
+    static gint px, py, pwx = -1, pwy = -1, lx = -10, ly = -10;
abc7304
     gboolean used = FALSE;
abc7304
 
abc7304
     ObFrameContext context;
abc7304
@@ -290,18 +290,24 @@ gboolean mouse_event(ObClient *client, XEvent *e)
abc7304
                 if (e->xbutton.x >= (signed)-b &&
abc7304
                     e->xbutton.y >= (signed)-b &&
abc7304
                     e->xbutton.x < (signed)(w+b) &&
abc7304
-                    e->xbutton.y < (signed)(h+b)) {
abc7304
+                    e->xbutton.y < (signed)(h+b))
abc7304
+                {
abc7304
                     click = TRUE;
abc7304
                     /* double clicks happen if there were 2 in a row! */
abc7304
                     if (lbutton == button &&
abc7304
                         lwindow == e->xbutton.window &&
abc7304
                         e->xbutton.time - config_mouse_dclicktime <=
abc7304
-                        ltime) {
abc7304
+                        ltime &&
abc7304
+                        ABS(e->xbutton.x - lx) < 8 &&
abc7304
+                        ABS(e->xbutton.y - ly) < 8)
abc7304
+                    {
abc7304
                         dclick = TRUE;
abc7304
                         lbutton = 0;
abc7304
                     } else {
abc7304
                         lbutton = button;
abc7304
                         lwindow = e->xbutton.window;
abc7304
+                        lx = e->xbutton.x;
abc7304
+                        ly = e->xbutton.y;
abc7304
                     }
abc7304
                 } else {
abc7304
                     lbutton = 0;