Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorWilliam Reynish <william@reynish.com>2010-05-06 21:45:02 +0400
committerWilliam Reynish <william@reynish.com>2010-05-06 21:45:02 +0400
commit263cc930061b1926712e4058bc8d04ce7d076681 (patch)
tree063f9477c017973769d08447858636f44fa4e2a1 /source
parentc8a05922882f7638b91ebcb1cd7a4e89cdf16222 (diff)
Make drop images work from external desktop into Blender image window.
Still has work todo, like detecting filetype on drop event itself. Ton will continue...
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_image/space_image.c2
-rw-r--r--source/blender/windowmanager/intern/wm_window.c39
2 files changed, 37 insertions, 4 deletions
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index af35fa4f5a9..3d9f802d0d7 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -537,7 +537,7 @@ void image_keymap(struct wmKeyConfig *keyconf)
static int image_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
{
if(drag->type==WM_DRAG_PATH)
- if(ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */
+ if(ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */
return 1;
return 0;
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 9bff2af9ac5..b4270aa9a94 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -739,15 +739,47 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
}
case GHOST_kEventDraggingDropDone:
{
- wmEvent event= *(win->eventstate); /* copy last state, like mouse coords */
+ wmEvent event;
GHOST_TEventDragnDropData *ddd= GHOST_GetEventData(evt);
+ int cx, cy, wx, wy;
+
+
+ /* entering window, update mouse pos */
+ GHOST_GetCursorPosition(g_system, &wx, &wy);
+
+ GHOST_ScreenToClient(win->ghostwin, wx, wy, &cx, &cy);
+ win->eventstate->x= cx;
+
+#if defined(__APPLE__) && defined(GHOST_COCOA)
+ //Cocoa already uses coordinates with y=0 at bottom
+ win->eventstate->y= cy;
+#else
+ win->eventstate->y= (win->sizey-1) - cy;
+#endif
+
+ event= *(win->eventstate); /* copy last state, like mouse coords */
+
+ // activate region
+ event.type= MOUSEMOVE;
+ event.prevx= event.x;
+ event.prevy= event.y;
+
+ wm->winactive= win; /* no context change! c->wm->windrawable is drawable, or for area queues */
+ win->active= 1;
+
+ wm_event_add(win, &event);
+
/* make blender drop event with custom data pointing to wm drags */
event.type= EVT_DROP;
+ event.val= KM_RELEASE;
event.custom= EVT_DATA_LISTBASE;
event.customdata= &wm->drags;
+ event.customdatafree= 1;
+
+ wm_event_add(win, &event);
- printf("Drop detected\n");
+ /* printf("Drop detected\n"); */
/* add drag data to wm for paths: */
/* need icon type, some dropboxes check for that... see filesel code for this */
@@ -760,10 +792,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
printf("drop file %s\n", stra->strings[a]);
WM_event_start_drag(C, 0, WM_DRAG_PATH, stra->strings[a], 0.0);
/* void poin should point to string, it makes a copy */
+ break; // only one drop element supported now
}
}
- wm_event_add(win, &event);
+
break;
}