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 $
7 * Authors: Cyril Deguet <asmax@videolan.org>
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.
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.
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,
23 *****************************************************************************/
27 //--- X11 -------------------------------------------------------------------
30 //--- VLC -------------------------------------------------------------------
33 //--- SKIN ------------------------------------------------------------------
34 #include "../src/event.h"
35 #include "../os_api.h"
36 #include "x11_dragdrop.h"
39 //---------------------------------------------------------------------------
40 X11DropObject::X11DropObject( intf_thread_t *_p_intf )
44 //---------------------------------------------------------------------------
45 X11DropObject::~X11DropObject()
48 //---------------------------------------------------------------------------
49 void X11DropObject::DndEnter( ldata_t data )
51 fprintf(stderr,"dnd enter\n");
53 //---------------------------------------------------------------------------
54 void X11DropObject::DndPosition( ldata_t data )
56 fprintf(stderr,"dnd position\n");
58 //---------------------------------------------------------------------------
59 void X11DropObject::DndLeave( ldata_t data )
61 fprintf(stderr,"dnd leave\n");
63 //---------------------------------------------------------------------------
64 void X11DropObject::DndDrop( ldata_t data )
66 fprintf(stderr,"dnd drop\n");
69 void X11DropObject::HandleDropStart( GdkDragContext *context )
71 /* GdkAtom atom = gdk_drag_get_selection( context );
77 // Get the owner of the selection
78 GdkWindow *owner = gdk_selection_owner_get( atom );
80 // Find the possible targets for the selection
82 gdk_selection_convert( owner, atom, gdk_atom_intern("TARGETS", FALSE),
84 int len = gdk_selection_property_get( owner, &buffer, &prop_type,
86 for( int i = 0; i < len / sizeof(GdkAtom); i++ )
88 GdkAtom atom = ( (GdkAtom*)buffer )[i];
89 gchar *name = gdk_atom_name( atom );
92 string curTarget = name;
93 if( (curTarget == "text/plain" || curTarget == "STRING") )
103 msg_Warn( p_intf, "Drag&Drop: target not found\n" );
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,
111 OSAPI_PostMessage( NULL, VLC_DROP, (unsigned int)buffer, 0 );
114 /* // Get number of files that are dropped into vlc
115 int NbFiles = DragQueryFile( (HDROP)HDrop, 0xFFFFFFFF, NULL, 0 );
117 // For each dropped files
118 for( int i = 0; i < NbFiles; i++ )
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 );
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 );
130 DragFinish( (HDROP)HDrop );
133 // gdk_drop_finish( context, TRUE,OSAPI_GetTime() );