diff options
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 25 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 76 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 21 |
6 files changed, 74 insertions, 65 deletions
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 0cf59a9b598..f9c1d800c02 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -90,12 +90,12 @@ endif() if(WITH_CODEC_QUICKTIME) list(APPEND INC ../quicktime) - list(APPEND INC_SYS ${QUICKTIME_INC}) + list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS}) add_definitions(-DWITH_QUICKTIME) endif() if(WITH_CODEC_FFMPEG) - list(APPEND INC_SYS ${FFMPEG_INC}) + list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS}) add_definitions(-DWITH_FFMPEG) endif() diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 2613cb8f14f..83ef46d109c 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2365,18 +2365,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U if(win->active) { GHOST_TEventCursorData *cd= customdata; wmEvent *lastevent= win->queue.last; - -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom, and returns inwindow coordinates on mouse moved event - evt->x= cd->x; - evt->y= cd->y; -#else int cx, cy; GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy); evt->x= cx; evt->y= (win->sizey-1) - cy; -#endif event.x= evt->x; event.y= evt->y; @@ -2423,21 +2416,17 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.type= MOUSEPAN; break; } -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa already uses coordinates with y=0 at bottom, and returns inwindow coordinates on mouse moved event - event.x= evt->x = pd->x; - event.y = evt->y = pd->y; -#else + { - int cx, cy; - GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy); - event.x= evt->x= cx; - event.y= evt->y= (win->sizey-1) - cy; + int cx, cy; + GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy); + event.x= evt->x= cx; + event.y= evt->y= (win->sizey-1) - cy; } -#endif + // Use prevx/prevy so we can calculate the delta later event.prevx= event.x - pd->deltaX; - event.prevy= event.y - pd->deltaY; + event.prevy= event.y - (-pd->deltaY); update_tablet_data(win, &event); wm_event_add(win, &event); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index c088d0d2d43..4693c8079d2 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -57,6 +57,7 @@ #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_utildefines.h" +#include "BLI_callbacks.h" #include "DNA_anim_types.h" #include "DNA_ipo_types.h" // XXX old animation system @@ -342,6 +343,8 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) WM_cursor_wait(1); + BLI_exec_cb(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE); + /* first try to append data from exotic file formats... */ /* it throws error box when file doesnt exist and returns -1 */ /* note; it should set some error message somewhere... (ton) */ @@ -392,6 +395,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) #ifdef WITH_PYTHON /* run any texts that were loaded in and flagged as modules */ BPY_driver_reset(); + BPY_app_handlers_reset(); BPY_modules_load_user(C); #endif CTX_wm_window_set(C, NULL); /* exits queues */ @@ -411,7 +415,8 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) // XXX undo_editmode_clear(); BKE_reset_undo(); BKE_write_undo(C, "original"); /* save current state */ - + + BLI_exec_cb(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); } else if(retval == BKE_READ_EXOTIC_OK_OTHER) BKE_write_undo(C, "Import file"); @@ -518,6 +523,7 @@ int WM_read_homefile(bContext *C, ReportList *reports, short from_memory) BPY_string_exec(C, "__import__('addon_utils').reset_all()"); BPY_driver_reset(); + BPY_app_handlers_reset(); BPY_modules_load_user(C); } #endif @@ -716,6 +722,8 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re } } + BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_PRE); + /* operator now handles overwrite checks */ if (G.fileflags & G_AUTOPACK) { @@ -752,6 +760,8 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re write_history(); } + BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_POST); + /* run this function after because the file cant be written before the blend is */ if (ibuf_thumb) { ibuf_thumb= IMB_thumb_create(filepath, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index c61db1d653e..0bc2e5da1c5 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -155,6 +155,7 @@ void WM_init(bContext *C, int argc, const char **argv) BPY_python_start(argc, argv); BPY_driver_reset(); + BPY_app_handlers_reset(); BPY_modules_load_user(C); #else (void)argc; /* unused */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 06d049d2cb5..f65485b84dd 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -938,13 +938,28 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) return block; } -/* Only invoked by OK button in popups created with wm_block_create_dialog() */ +typedef struct wmOpPopUp +{ + wmOperator *op; + int width; + int height; + int free_op; +} wmOpPopUp; + +/* Only invoked by OK button in popups created with wm_block_dialog_create() */ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) { - wmOperator *op= arg1; + wmOpPopUp *data= arg1; uiBlock *block= arg2; - WM_operator_call(C, op); + WM_operator_call(C, data->op); + + /* let execute handle freeing it */ + //data->free_op= FALSE; + //data->op= NULL; + + /* in this case, wm_operator_ui_popup_cancel wont run */ + MEM_freeN(data); uiPupBlockClose(C, block); } @@ -960,9 +975,9 @@ static void dialog_check_cb(bContext *C, void *op_ptr, void *UNUSED(arg)) } /* Dialogs are popups that require user verification (click OK) before exec */ -static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData) +static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) { - struct { wmOperator *op; int width; int height; } * data = userData; + wmOpPopUp *data= userData; wmOperator *op= data->op; uiBlock *block; uiLayout *layout; @@ -991,7 +1006,7 @@ static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData) col_block= uiLayoutGetBlock(col); /* Create OK button, the callback of which will execute op */ btn= uiDefBut(col_block, BUT, 0, "OK", 0, -30, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); - uiButSetFunc(btn, dialog_exec_cb, op, col_block); + uiButSetFunc(btn, dialog_exec_cb, data, col_block); } /* center around the mouse */ @@ -1001,9 +1016,9 @@ static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData) return block; } -static uiBlock *wm_operator_create_ui(bContext *C, ARegion *ar, void *userData) +static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) { - struct { wmOperator *op; int width; int height; } * data = userData; + wmOpPopUp *data= userData; wmOperator *op= data->op; uiBlock *block; uiLayout *layout; @@ -1024,6 +1039,28 @@ static uiBlock *wm_operator_create_ui(bContext *C, ARegion *ar, void *userData) return block; } +static void wm_operator_ui_popup_cancel(void *userData) +{ + wmOpPopUp *data= userData; + if(data->free_op && data->op) { + wmOperator *op= data->op; + WM_operator_free(op); + } + + MEM_freeN(data); +} + +int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) +{ + wmOpPopUp *data= MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"); + data->op= op; + data->width= width; + data->height= height; + data->free_op= TRUE; /* if this runs and gets registered we may want not to free it */ + uiPupBlockEx(C, wm_operator_ui_create, wm_operator_ui_popup_cancel, data); + return OPERATOR_RUNNING_MODAL; +} + /* operator menu needs undo, for redo callback */ int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { @@ -1043,28 +1080,19 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height) { - struct { wmOperator *op; int width; int height; } data; + wmOpPopUp *data= MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); - data.op= op; - data.width= width; - data.height= height; + data->op= op; + data->width= width; + data->height= height; + data->free_op= TRUE; /* if this runs and gets registered we may want not to free it */ /* op is not executed until popup OK but is clicked */ - uiPupBlock(C, wm_block_create_dialog, &data); + uiPupBlockEx(C, wm_block_dialog_create, wm_operator_ui_popup_cancel, data); return OPERATOR_RUNNING_MODAL; } -int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) -{ - struct { wmOperator *op; int width; int height; } data; - data.op = op; - data.width = width; - data.height = height; - uiPupBlock(C, wm_operator_create_ui, &data); - return OPERATOR_RUNNING_MODAL; -} - int WM_operator_redo_popup(bContext *C, wmOperator *op) { /* CTX_wm_reports(C) because operator is on stack, not active in event system */ @@ -1219,7 +1247,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar col = uiLayoutColumn(split, 0); uiItemL(col, "Links", ICON_NONE); uiItemStringO(col, "Donations", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment/"); - uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-257/"); + uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-258/"); uiItemStringO(col, "Manual", ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.5/Manual"); uiItemStringO(col, "Blender Website", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/"); uiItemStringO(col, "User Community", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community/"); // diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 9ee39132521..9b1695be67a 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -673,13 +673,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) 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 win->addmousemove= 1; /* enables highlighted buttons */ @@ -796,20 +790,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) 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 */ @@ -1149,12 +1136,7 @@ void wm_get_cursor_position(wmWindow *win, int *x, int *y) { GHOST_GetCursorPosition(g_system, x, y); GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y); -#if defined(__APPLE__) && defined(GHOST_COCOA) - //Cocoa has silly exception that should be fixed at the ghost level - //(ghost is an allegory for an invisible system specific code) -#else *y = (win->sizey-1) - *y; -#endif } /* ******************* exported api ***************** */ @@ -1187,9 +1169,8 @@ void WM_cursor_warp(wmWindow *win, int x, int y) if (win && win->ghostwin) { int oldx=x, oldy=y; -#if !defined(__APPLE__) || !defined(GHOST_COCOA) y= win->sizey -y - 1; -#endif + GHOST_ClientToScreen(win->ghostwin, x, y, &x, &y); GHOST_SetCursorPosition(g_system, x, y); |