]> git.sesse.net Git - vlc/commitdiff
* implemented double click event for X11 skins. The delay is hard-coded
authorCyril Deguet <asmax@videolan.org>
Sat, 7 Jun 2003 00:36:28 +0000 (00:36 +0000)
committerCyril Deguet <asmax@videolan.org>
Sat, 7 Jun 2003 00:36:28 +0000 (00:36 +0000)
  (400ms) , maybe it could be stored in the vlc config file

modules/gui/skins/x11/x11_api.cpp
modules/gui/skins/x11/x11_window.cpp
modules/gui/skins/x11/x11_window.h

index d39722847e92a1f2737c0eb48ab8f88a2ad22646..90f7ace781171721d97231ed7700e6b71f013404 100644 (file)
@@ -2,7 +2,7 @@
  * x11_api.cpp: Various x11-specific functions
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_api.cpp,v 1.7 2003/06/04 18:47:57 asmax Exp $
+ * $Id: x11_api.cpp,v 1.8 2003/06/07 00:36:28 asmax Exp $
  *
  * Authors: Cyril Deguet  <asmax@videolan.org>
  *
@@ -105,7 +105,7 @@ int OSAPI_GetTime()
 {
     struct timeval time;
     gettimeofday( &time, NULL );
-    return( time.tv_sec * 1000 + time.tv_usec / 1000 );
+    return( (time.tv_sec&0xffffff) * 1000 + time.tv_usec / 1000 );
 }
 //---------------------------------------------------------------------------
 void OSAPI_GetScreenSize( int &w, int &h )
index 20e5ce7ef418e95778d3926d04a31231a72edf37..ed3153faa84ef4dd9a0461c911653b88605443b1 100644 (file)
@@ -2,7 +2,7 @@
  * x11_window.cpp: X11 implementation of the Window class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_window.cpp,v 1.10 2003/06/06 23:34:35 asmax Exp $
+ * $Id: x11_window.cpp,v 1.11 2003/06/07 00:36:28 asmax Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -98,7 +98,6 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y,
                     (LPARAM)(LPTOOLINFO) &ToolTipInfo );
 */
 
-
     if( DragDrop )
     {
         // register the listview as a drop target
@@ -108,6 +107,14 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y,
 
     // Create Tool Tip window
     ToolTipWindow = XCreateSimpleWindow( display, wnd, 0, 0, 1, 1, 0, 0, 0 );
+
+    // Double-click handling
+    ClickedX = 0;
+    ClickedY = 0;
+    ClickedTime = 0;
+    // TODO: can be retrieved somewhere ?
+    DblClickDelay = 400;
+   
 }
 //---------------------------------------------------------------------------
 X11Window::~X11Window()
@@ -119,10 +126,8 @@ X11Window::~X11Window()
     {
         DestroyWindow( hWnd );
     }*/
-    if( ToolTipWindow != NULL )
-    {
-        XDestroyWindow( display, ToolTipWindow );
-    }/*
+    XDestroyWindow( display, ToolTipWindow );
+    /*
     if( DragDrop )
     {
         // Remove the listview from the list of drop targets
@@ -159,6 +164,8 @@ bool X11Window::ProcessOSEvent( Event *evt )
     unsigned int msg = evt->GetMessage();
     unsigned int p1  = evt->GetParam1();
     int          p2  = evt->GetParam2();
+    int          time;
+    int          posX, posY;
 
     switch( msg )
     {
@@ -194,9 +201,25 @@ bool X11Window::ProcessOSEvent( Event *evt )
             {
                 case 1:
                     // Left button
-                    LButtonDown = true;
-                    MouseDown( (int)( (XButtonEvent *)p2 )->x,
-                               (int)( (XButtonEvent *)p2 )->y, 1 );
+                    time = OSAPI_GetTime();
+                    OSAPI_GetMousePos( posX, posY );
+                    if( time - ClickedTime < DblClickDelay && 
+                        posX == ClickedX && posY == ClickedY )
+                    {
+                        // Double-click
+                        ClickedTime = 0; 
+                        MouseDblClick( (int)( (XButtonEvent *)p2 )->x,
+                                       (int)( (XButtonEvent *)p2 )->y, 1 );
+                    }
+                    else
+                    {
+                        ClickedTime = time;
+                        ClickedX = posX;
+                        ClickedY = posY;
+                        LButtonDown = true;
+                        MouseDown( (int)( (XButtonEvent *)p2 )->x,
+                                   (int)( (XButtonEvent *)p2 )->y, 1 );
+                    }
                     break;
 
                 case 3:
@@ -251,12 +274,7 @@ bool X11Window::ProcessOSEvent( Event *evt )
             OSAPI_PostMessage( this, WINDOW_LEAVE, 0, 0 );
             return true;
 
-/*        case GDK_2BUTTON_PRESS:
-            MouseDblClick( (int)( (GdkEventButton *)p2 )->x,
-                           (int)( (GdkEventButton *)p2 )->y, 1 );
-            return true;
-
-        case GDK_DROP_START:
+/*        case GDK_DROP_START:
             DropObject->HandleDropStart( ( (GdkEventDND *)p2 )->context );
             return true;
 */
index 2de92e27e9c86ac4e31d604ca2585eb1997f2d9e..9af118a0d6224625b082b693388f1ccec0a32b08 100644 (file)
@@ -2,7 +2,7 @@
  * x11_window.h: X11 implementation of the Window class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: x11_window.h,v 1.2 2003/05/13 20:36:29 asmax Exp $
+ * $Id: x11_window.h,v 1.3 2003/06/07 00:36:28 asmax Exp $
  *
  * Authors: Cyril Deguet     <asmax@videolan.org>
  *
@@ -54,8 +54,15 @@ class X11Window : public SkinWindow
         Window ToolTipWindow;
 //        TOOLINFO ToolTipInfo;
 
+        // Double-click handling
+        int ClickedX;
+        int ClickedY;
+        int ClickedTime;
+        int DblClickDelay;
+
         // Left button down
         bool LButtonDown;
+        // Right button down
         bool RButtonDown;
 
     public: