]> git.sesse.net Git - vlc/blob - modules/gui/skins/x11/x11_dragdrop.cpp
* very beginning of drag and drop support in X11 skins
[vlc] / modules / gui / skins / x11 / x11_dragdrop.cpp
1 /*****************************************************************************
2  * x11_dragdrop.cpp: X11 implementation of the drag & drop
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: x11_dragdrop.cpp,v 1.2 2003/06/08 18:17:50 asmax Exp $
6  *
7  * Authors: Cyril Deguet     <asmax@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,
22  * USA.
23  *****************************************************************************/
24
25 #ifdef X11_SKINS
26
27 //--- X11 -------------------------------------------------------------------
28 #include <X11/Xlib.h>
29
30 //--- VLC -------------------------------------------------------------------
31 #include <vlc/intf.h>
32
33 //--- SKIN ------------------------------------------------------------------
34 #include "../src/event.h"
35 #include "../os_api.h"
36 #include "x11_dragdrop.h"
37
38
39 //---------------------------------------------------------------------------
40 X11DropObject::X11DropObject( intf_thread_t *_p_intf )
41 {
42     p_intf = _p_intf;
43 }
44 //---------------------------------------------------------------------------
45 X11DropObject::~X11DropObject()
46 {
47 }
48 //---------------------------------------------------------------------------
49 void X11DropObject::DndEnter( ldata_t data )
50 {
51     fprintf(stderr,"dnd enter\n");
52 }
53 //---------------------------------------------------------------------------
54 void X11DropObject::DndPosition( ldata_t data )
55 {
56     fprintf(stderr,"dnd position\n");
57 }
58 //---------------------------------------------------------------------------
59 void X11DropObject::DndLeave( ldata_t data )
60 {
61     fprintf(stderr,"dnd leave\n");
62 }
63 //---------------------------------------------------------------------------
64 void X11DropObject::DndDrop( ldata_t data )
65 {
66     fprintf(stderr,"dnd drop\n");
67 }
68 #if 0
69 void X11DropObject::HandleDropStart( GdkDragContext *context )
70 {
71 /*    GdkAtom atom = gdk_drag_get_selection( context );
72     
73     guchar *buffer;
74     GdkAtom prop_type;
75     gint prop_format;
76     
77     // Get the owner of the selection
78     GdkWindow *owner = gdk_selection_owner_get( atom ); 
79
80     // Find the possible targets for the selection
81     string target = "";
82     gdk_selection_convert( owner, atom, gdk_atom_intern("TARGETS", FALSE), 
83                            OSAPI_GetTime() );
84     int len = gdk_selection_property_get( owner, &buffer, &prop_type, 
85                                           &prop_format );
86     for( int i = 0; i < len / sizeof(GdkAtom); i++ )
87     {
88         GdkAtom atom = ( (GdkAtom*)buffer )[i];
89         gchar *name = gdk_atom_name( atom );
90         if( name )
91         {
92             string curTarget = name;
93             if( (curTarget == "text/plain" || curTarget == "STRING") )
94             {
95                 target = curTarget;
96                 break;
97             }
98         }
99     }
100
101     if( target == "" )
102     {
103         msg_Warn( p_intf, "Drag&Drop: target not found\n" );
104     }
105     else
106     {
107         gdk_selection_convert( owner, atom, gdk_atom_intern(target.c_str(), 
108                                FALSE), OSAPI_GetTime() );
109         len = gdk_selection_property_get( owner, &buffer, &prop_type, 
110                                           &prop_format);
111         OSAPI_PostMessage( NULL, VLC_DROP, (unsigned int)buffer, 0 );
112     }
113 */
114 /*    // Get number of files that are dropped into vlc
115     int NbFiles = DragQueryFile( (HDROP)HDrop, 0xFFFFFFFF, NULL, 0 );
116
117     // For each dropped files
118     for( int i = 0; i < NbFiles; i++ )
119     {
120         // Get the name of the file
121         int NameLength = DragQueryFile( (HDROP)HDrop, i, NULL, 0 ) + 1;
122         char *FileName = new char[NameLength];
123         DragQueryFile( (HDROP)HDrop, i, FileName, NameLength );
124
125         // The pointer must not be deleted here because it will be deleted
126         // in the VLC specific messages processing function
127         PostMessage( NULL, VLC_DROP, (WPARAM)FileName, 0 );
128     }
129
130     DragFinish( (HDROP)HDrop );
131     
132 */
133   //  gdk_drop_finish( context, TRUE,OSAPI_GetTime() );
134 }
135 #endif
136 #endif