summaryrefslogtreecommitdiffstats
path: root/Gui
diff options
context:
space:
mode:
authorpontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-08-11 19:12:09 +0000
committerpontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-08-11 19:12:09 +0000
commitafdbb16a2f91f7b0ea7f6b53522e2447407d6917 (patch)
treed03407065e9a579f0cde9899b7b83ade4530c862 /Gui
parent98c903c162d6b7e12daff0d0fbfef10b986f9d2f (diff)
downloadmpv-afdbb16a2f91f7b0ea7f6b53522e2447407d6917.tar.bz2
mpv-afdbb16a2f91f7b0ea7f6b53522e2447407d6917.tar.xz
kde3 dnd fix from Gregory Kovriga and file name handling fix in dnd callback
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6978 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'Gui')
-rw-r--r--Gui/mplayer/mw.h26
-rw-r--r--Gui/wm/wsxdnd.c43
2 files changed, 59 insertions, 10 deletions
diff --git a/Gui/mplayer/mw.h b/Gui/mplayer/mw.h
index bf86bd8edd..8cc410403e 100644
--- a/Gui/mplayer/mw.h
+++ b/Gui/mplayer/mw.h
@@ -665,26 +665,42 @@ void mplDandDHandler(int num,const char** files)
/* now fill it with new items */
for(f=0; f < num; f++){
- char* str = files[f];
+ char* str = strdup( files[f] );
plItem* item;
+
+ if ( strchr( str,'%' ) )
+ {
+ char * t = calloc( 1,strlen( str ) );
+ int i,c = 0;
+ for ( i=0;i < strlen( str );i++ )
+ if ( str[i] != '%' ) t[c++]=str[i];
+ else
+ {
+ char tmp[4] = "0xXX";
+// if ( str[++i] == '%' ) { t[c++]='%'; continue; };
+ tmp[2]=str[++i]; tmp[3]=str[++i]; t[c++]=(char)strtol( tmp,(char **)NULL,16 );
+ }
+ free( str ); str=t;
+ }
+
if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) {
/* this is not a directory so try to play it */
printf("Received D&D %s\n",str);
item = calloc(1,sizeof(plItem));
+
/* FIXME: decompose file name ? */
/* yes -- Pontscho */
if ( strrchr( str,'/' ) )
{
- char * t = strdup( str );
- char * s = strrchr( t,'/' ); *s=0; s++;
+ char * s = strrchr( str,'/' ); *s=0; s++;
item->name = gstrdup( s );
- item->path = gstrdup( t );
- free( t );
+ item->path = gstrdup( str );
} else { item->name = strdup(str); item->path = strdup(""); }
gtkSet(gtkAddPlItem,0,(void*)item);
} else {
printf("Received not a file: %s !\n",str);
}
+ free( str );
}
mplSetFileName( NULL,files[0] );
diff --git a/Gui/wm/wsxdnd.c b/Gui/wm/wsxdnd.c
index 90c2e95e97..0e6da01349 100644
--- a/Gui/wm/wsxdnd.c
+++ b/Gui/wm/wsxdnd.c
@@ -22,6 +22,7 @@ Atom _XA_XdndStatus;
Atom _XA_XdndActionCopy;
Atom _XA_XdndSelection;
Atom _XA_XdndFinished;
+Atom _XA_XdndTypeList;
Atom atom_support;
@@ -37,6 +38,7 @@ void wsXDNDInitialize()
_XA_XdndActionCopy = XInternAtom(wsDisplay, "XdndActionCopy", False);
_XA_XdndSelection = XInternAtom(wsDisplay, "XdndSelection", False);
_XA_XdndFinished = XInternAtom(wsDisplay, "XdndFinished", False);
+ _XA_XdndTypeList = XInternAtom(wsDisplay, "XdndTypeList", False);
}
void wsXDNDMakeAwareness(wsTWindow* window) {
@@ -87,9 +89,7 @@ wsXDNDProcessSelection(wsTWindow* wnd, XEvent *event)
char * retain = delme;
char * files[MAX_DND_FILES];
int num = 0;
- /*
- printf("Got: %s\n",delme);
- */
+
while(retain < delme + ret_items) {
if (!strncmp(retain,"file:",5)) {
/* add more 2 chars while removing 5 is harmless */
@@ -152,7 +152,40 @@ wsXDNDProcessClientMessage(wsTWindow* wnd, XClientMessageEvent *event)
printf("This doesn't seem as a file...\n");
}
} else {
- /* FIXME: need something else here */
+ /* need to check the whole list here */
+ int ret_left = 1;
+ int offset = 0;
+ Atom* ret_buff;
+ int ret_type,ret_format,ret_items;
+ /* while there is data left...*/
+ while(ret_left){
+ XGetWindowProperty(wsDisplay,event->data.l[0],_XA_XdndTypeList,
+ offset,256,False,XA_ATOM,&ret_type,
+ &ret_format,&ret_items,&ret_left,
+ (unsigned char**)&ret_buff);
+
+ /* sanity checks...*/
+ if(ret_buff == NULL || ret_type != XA_ATOM || ret_format != 8*sizeof(Atom)){
+ XFree(ret_buff);
+ break;
+ }
+ /* now chek what we've got */
+ {
+ int i;
+ for(i=0; i<ret_items; i++){
+ if(ret_buff[i] == ok){
+ atom_support = ok;
+ break;
+ }
+ }
+ /* found it ! */
+ if (atom_support != None)
+ break;
+ }
+ /* maybe next time ... */
+ XFree(ret_buff);
+ offset += 256;
+ }
}
return True;
}
@@ -163,7 +196,7 @@ wsXDNDProcessClientMessage(wsTWindow* wnd, XClientMessageEvent *event)
if (event->message_type == _XA_XdndDrop) {
if (event->data.l[0] != XGetSelectionOwner(wsDisplay, _XA_XdndSelection)){
- puts("wierd selection owner? QT?");
+ puts("Wierd selection owner... QT?");
}
if (atom_support != None) {
XConvertSelection(wsDisplay, _XA_XdndSelection, atom_support,