diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-07 17:45:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-07 17:45:34 +0300 |
commit | f0815b1322dc4f04dd949fd92049a99479e5f61d (patch) | |
tree | 9388af5e754d416e3f9fac95a2cbc67e57531e9f /source/blender/windowmanager/intern | |
parent | fcc5d7c29e02eae1429009cc02eb9c75d159f245 (diff) | |
parent | 863e395ad8bc0c921a9c836018e2c17262340f46 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 28 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 58 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 66 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 392 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 46 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files_link.c | 8 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture.c | 20 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 40 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_jobs.c | 108 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 72 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 148 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 34 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 232 |
14 files changed, 631 insertions, 631 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 9100e47d820..6a42bf26a97 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -106,7 +106,7 @@ void WM_operator_free(wmOperator *op) WM_operator_free(opm); } } - + MEM_freeN(op); } @@ -192,11 +192,11 @@ void wm_operator_register(bContext *C, wmOperator *op) void WM_operator_stack_clear(wmWindowManager *wm) { wmOperator *op; - + while ((op = BLI_pophead(&wm->operators))) { WM_operator_free(op); } - + WM_main_add_notifier(NC_WM | ND_HISTORY, NULL); } @@ -372,7 +372,7 @@ void WM_keymap_init(bContext *C) wm->addonconf = WM_keyconfig_new(wm, "Blender Addon"); if (!wm->userconf) wm->userconf = WM_keyconfig_new(wm, "Blender User"); - + /* initialize only after python init is done, for keymaps that * use python operators */ if (CTX_py_init_get(C) && (wm->initialized & WM_KEYMAP_IS_INITIALIZED) == 0) { @@ -396,7 +396,7 @@ void WM_check(bContext *C) { Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); - + /* wm context */ if (wm == NULL) { wm = CTX_data_main(C)->wm.first; @@ -434,7 +434,7 @@ void wm_clear_default_size(bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win; - + /* wm context */ if (wm == NULL) { wm = CTX_data_main(C)->wm.first; @@ -444,7 +444,7 @@ void wm_clear_default_size(bContext *C) if (wm == NULL || BLI_listbase_is_empty(&wm->windows)) { return; } - + for (win = wm->windows.first; win; win = win->next) { win->sizex = 0; win->sizey = 0; @@ -490,7 +490,7 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) WM_window_set_active_workspace(win, NULL); /* prevent draw clear to use screen */ wm_window_free(C, wm, win); } - + while ((op = BLI_pophead(&wm->operators))) { WM_operator_free(op); } @@ -508,7 +508,7 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) BLI_freelistN(&wm->paintcursors); WM_drag_free_list(&wm->drags); - + wm_reports_free(wm); if (wm->undo_stack) { @@ -538,16 +538,16 @@ void WM_main(bContext *C) wm_event_do_refresh_wm_and_depsgraph(C); while (1) { - + /* get events from ghost, handle window events, add to window queues */ - wm_window_process_events(C); - + wm_window_process_events(C); + /* per window, all events to the window, screen, area and region handlers */ wm_event_do_handlers(C); - + /* events have left notes about changes, we handle and cache it */ wm_event_do_notifiers(C); - + /* execute cached changes draw */ wm_draw_update(C); } diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 67b04662154..f13dac9cb4c 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -41,7 +41,7 @@ #include "BLI_sys_types.h" #include "DNA_listBase.h" -#include "DNA_userdef_types.h" +#include "DNA_userdef_types.h" #include "DNA_workspace_types.h" #include "BKE_context.h" @@ -58,7 +58,7 @@ /* Some simple ghost <-> blender conversions */ -static GHOST_TStandardCursor convert_cursor(int curs) +static GHOST_TStandardCursor convert_cursor(int curs) { switch (curs) { default: @@ -79,23 +79,23 @@ static GHOST_TStandardCursor convert_cursor(int curs) } } -static void window_set_custom_cursor(wmWindow *win, unsigned char mask[16][2], +static void window_set_custom_cursor(wmWindow *win, unsigned char mask[16][2], unsigned char bitmap[16][2], int hotx, int hoty) { GHOST_SetCustomCursorShape(win->ghostwin, bitmap, mask, hotx, hoty); } -static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useBig) +static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useBig) { if (useBig) { - GHOST_SetCustomCursorShapeEx(win->ghostwin, + GHOST_SetCustomCursorShapeEx(win->ghostwin, (GHOST_TUns8 *)cursor->big_bm, (GHOST_TUns8 *)cursor->big_mask, cursor->big_sizex, cursor->big_sizey, cursor->big_hotx, cursor->big_hoty, cursor->fg_color, cursor->bg_color); } else { - GHOST_SetCustomCursorShapeEx(win->ghostwin, + GHOST_SetCustomCursorShapeEx(win->ghostwin, (GHOST_TUns8 *)cursor->small_bm, (GHOST_TUns8 *)cursor->small_mask, cursor->small_sizex, cursor->small_sizey, cursor->small_hotx, cursor->small_hoty, @@ -132,12 +132,12 @@ void WM_cursor_set(wmWindow *win, int curs) #endif GHOST_SetCursorVisibility(win->ghostwin, 1); - + if (curs == CURSOR_STD && win->modalcursor) curs = win->modalcursor; - + win->cursor = curs; - + /* detect if we use system cursor or Blender cursor */ if (curs >= BC_GHOST_CURSORS) { GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs)); @@ -196,7 +196,7 @@ void WM_cursor_wait(bool val) if (!G.background) { wmWindowManager *wm = G.main->wm.first; wmWindow *win = wm ? wm->windows.first : NULL; - + for (; win; win = win->next) { if (val) { WM_cursor_modal_set(win, BC_WAITCURSOR); @@ -214,7 +214,7 @@ void WM_cursor_wait(bool val) void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4]) { /* Only grab cursor when not running debug. - * It helps not to get a stuck WM when hitting a breakpoint + * It helps not to get a stuck WM when hitting a breakpoint * */ GHOST_TGrabCursorMode mode = GHOST_kGrabNormal; @@ -222,7 +222,7 @@ void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4]) wm_cursor_position_to_ghost(win, &bounds[0], &bounds[1]); wm_cursor_position_to_ghost(win, &bounds[2], &bounds[3]); } - + if (hide) { mode = GHOST_kGrabHide; } @@ -311,12 +311,12 @@ void WM_cursor_time(wmWindow *win, int nr) unsigned char mask[16][2]; unsigned char bitmap[16][2] = {{0}}; int i, idx; - + if (win->lastcursor == 0) win->lastcursor = win->cursor; - + memset(&mask, 0xFF, sizeof(mask)); - + /* print number bottom right justified */ for (idx = 3; nr && idx >= 0; idx--) { const char *digit = number_bitmaps[nr % 10]; @@ -327,7 +327,7 @@ void WM_cursor_time(wmWindow *win, int nr) bitmap[i + y * 8][x] = digit[i]; nr /= 10; } - + window_set_custom_cursor(win, mask, bitmap, 7, 7); } @@ -441,7 +441,7 @@ BEGIN_CURSOR_BLOCK }; BlenderCursor[BC_NS_ARROWCURSOR] = &NSArrowCursor; - + END_CURSOR_BLOCK /********************** EW_ARROW Cursor *************************/ BEGIN_CURSOR_BLOCK @@ -462,7 +462,7 @@ BEGIN_CURSOR_BLOCK static BCursor EWArrowCursor = { /*small*/ ew_sbm, ew_smsk, - 16, 16, + 16, 16, 7, 6, /*big*/ NULL, NULL, @@ -532,7 +532,7 @@ BEGIN_CURSOR_BLOCK static BCursor WaitCursor = { /*small*/ wait_sbm, wait_smsk, - 16, 16, + 16, 16, 7, 7, /*big*/ wait_lbm, wait_lmsk, @@ -601,7 +601,7 @@ BEGIN_CURSOR_BLOCK static BCursor CrossCursor = { /*small*/ cross_sbm, cross_smsk, - 16, 16, + 16, 16, 7, 7, /*big*/ cross_lbm, cross_lmsk, @@ -633,7 +633,7 @@ BEGIN_CURSOR_BLOCK static BCursor EditCrossCursor = { /*small*/ editcross_sbm, editcross_smsk, - 16, 16, + 16, 16, 9, 8, /*big*/ NULL, NULL, @@ -666,7 +666,7 @@ BEGIN_CURSOR_BLOCK static BCursor BoxSelCursor = { /*small*/ box_sbm, box_smsk, - 16, 16, + 16, 16, 9, 8, /*big*/ NULL, NULL, @@ -738,7 +738,7 @@ BEGIN_CURSOR_BLOCK static BCursor KnifeCursor = { /*small*/ knife_sbm, knife_smsk, - 16, 16, + 16, 16, 0, 15, /*big*/ knife_lbm, knife_lmsk, @@ -751,7 +751,7 @@ BEGIN_CURSOR_BLOCK BlenderCursor[BC_KNIFECURSOR] = &KnifeCursor; END_CURSOR_BLOCK - + /********************** Loop Select Cursor ***********************/ BEGIN_CURSOR_BLOCK @@ -814,7 +814,7 @@ BEGIN_CURSOR_BLOCK static BCursor VLoopCursor = { /*small*/ vloop_sbm, vloop_smsk, - 16, 16, + 16, 16, 0, 0, /*big*/ vloop_lbm, vloop_lmsk, @@ -827,7 +827,7 @@ BEGIN_CURSOR_BLOCK BlenderCursor[BC_VLOOPCURSOR] = &VLoopCursor; END_CURSOR_BLOCK - + /********************** TextEdit Cursor ***********************/ BEGIN_CURSOR_BLOCK @@ -848,7 +848,7 @@ BEGIN_CURSOR_BLOCK static BCursor TextEditCursor = { /*small*/ textedit_sbm, textedit_smsk, - 16, 16, + 16, 16, 9, 8, /*big*/ NULL, NULL, @@ -887,7 +887,7 @@ BEGIN_CURSOR_BLOCK static BCursor PaintBrushCursor = { /*small*/ paintbrush_sbm, paintbrush_smsk, - 16, 16, + 16, 16, 0, 15, /*big*/ NULL, NULL, @@ -1060,7 +1060,7 @@ BEGIN_CURSOR_BLOCK 0x7e, 0x00, 0x3f, 0x00, 0x0c, 0x00, 0x04, 0x00, }; - + static BCursor EyedropperCursor = { /*small*/ eyedropper_sbm, eyedropper_smsk, diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 319ce99f700..16ed51cbd80 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -69,29 +69,29 @@ static ListBase dropboxes = {NULL, NULL}; typedef struct wmDropBoxMap { struct wmDropBoxMap *next, *prev; - + ListBase dropboxes; short spaceid, regionid; char idname[KMAP_MAX_NAME]; - + } wmDropBoxMap; /* spaceid/regionid is zero for window drop maps */ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) { wmDropBoxMap *dm; - + for (dm = dropboxes.first; dm; dm = dm->next) if (dm->spaceid == spaceid && dm->regionid == regionid) if (STREQLEN(idname, dm->idname, KMAP_MAX_NAME)) return &dm->dropboxes; - + dm = MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list"); BLI_strncpy(dm->idname, idname, KMAP_MAX_NAME); dm->spaceid = spaceid; dm->regionid = regionid; BLI_addtail(&dropboxes, dm); - + return &dm->dropboxes; } @@ -101,31 +101,31 @@ wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext void (*copy)(wmDrag *, wmDropBox *)) { wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox"); - + drop->poll = poll; drop->copy = copy; drop->ot = WM_operatortype_find(idname, 0); drop->opcontext = WM_OP_INVOKE_DEFAULT; - + if (drop->ot == NULL) { MEM_freeN(drop); printf("Error: dropbox with unknown operator: %s\n", idname); return NULL; } WM_operator_properties_alloc(&(drop->ptr), &(drop->properties), idname); - + BLI_addtail(lb, drop); - + return drop; } void wm_dropbox_free(void) { wmDropBoxMap *dm; - + for (dm = dropboxes.first; dm; dm = dm->next) { wmDropBox *drop; - + for (drop = dm->dropboxes.first; drop; drop = drop->next) { if (drop->ptr) { WM_operator_properties_free(drop->ptr); @@ -134,7 +134,7 @@ void wm_dropbox_free(void) } BLI_freelistN(&dm->dropboxes); } - + BLI_freelistN(&dropboxes); } @@ -145,10 +145,10 @@ wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, { wmWindowManager *wm = CTX_wm_manager(C); wmDrag *drag = MEM_callocN(sizeof(struct wmDrag), "new drag"); - + /* keep track of future multitouch drag too, add a mousepointer id or so */ /* if multiple drags are added, they're drawn as list */ - + BLI_addtail(&wm->drags, drag); drag->flags = flags; drag->icon = icon; @@ -158,7 +158,7 @@ wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, else drag->poin = poin; drag->value = value; - + return drag; } @@ -211,13 +211,13 @@ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, const wmEvent *e ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); const char *name; - + name = dropbox_active(C, &win->handlers, drag, event); if (name) return name; - + name = dropbox_active(C, &sa->handlers, drag, event); if (name) return name; - + name = dropbox_active(C, &ar->handlers, drag, event); if (name) return name; @@ -234,16 +234,16 @@ static void wm_drop_operator_options(bContext *C, wmDrag *drag, const wmEvent *e /* for multiwin drags, we only do this if mouse inside */ if (event->x < 0 || event->y < 0 || event->x > winsize_x || event->y > winsize_y) return; - + drag->opname[0] = 0; - + /* check buttons (XXX todo rna and value) */ if (UI_but_active_drop_name(C)) { BLI_strncpy(drag->opname, IFACE_("Paste name"), sizeof(drag->opname)); } else { const char *opname = wm_dropbox_active(C, drag, event); - + if (opname) { BLI_strncpy(drag->opname, opname, sizeof(drag->opname)); // WM_cursor_modal_set(win, CURSOR_COPY); @@ -259,7 +259,7 @@ void wm_drags_check_ops(bContext *C, const wmEvent *event) { wmWindowManager *wm = CTX_wm_manager(C); wmDrag *drag; - + for (drag = wm->drags.first; drag; drag = drag->next) { wm_drop_operator_options(C, drag, event); } @@ -312,25 +312,25 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) wmDrag *drag; const int winsize_y = WM_window_pixels_y(win); int cursorx, cursory, x, y; - + cursorx = win->eventstate->x; cursory = win->eventstate->y; if (rect) { rect->xmin = rect->xmax = cursorx; rect->ymin = rect->ymax = cursory; } - + /* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */ glEnable(GL_BLEND); for (drag = wm->drags.first; drag; drag = drag->next) { int iconsize = UI_DPI_ICON_SIZE; int padding = 4 * UI_DPI_FAC; - + /* image or icon */ if (drag->imb) { x = cursorx - drag->sx / 2; y = cursory - drag->sy / 2; - + if (rect) drag_rect_minmax(rect, x, y, x + drag->sx, y + drag->sy); else { @@ -343,13 +343,13 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) else { x = cursorx - 2 * padding; y = cursory - 2 * UI_DPI_FAC; - + if (rect) drag_rect_minmax(rect, x, y, x + iconsize, y + iconsize); else UI_icon_draw_aspect(x, y, drag->icon, 1.0f / UI_DPI_FAC, 0.8); } - + /* item name */ if (drag->imb) { x = cursorx - drag->sx / 2; @@ -359,7 +359,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) x = cursorx + 10 * UI_DPI_FAC; y = cursory + 1 * UI_DPI_FAC; } - + if (rect) { int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag)); drag_rect_minmax(rect, x, y, x + w, y + iconsize); @@ -368,7 +368,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) const unsigned char col[] = {255, 255, 255, 255}; UI_fontstyle_draw_simple(fstyle, x, y, wm_drag_name(drag), col); } - + /* operator name with roundbox */ if (drag->opname[0]) { if (drag->imb) { @@ -389,14 +389,14 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) y = (cursory - iconsize) - padding; } } - + if (rect) { int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag)); drag_rect_minmax(rect, x, y, x + w, y + iconsize); } - else + else wm_drop_operator_draw(drag->opname, x, y); - + } } glDisable(GL_BLEND); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 3ce64926a95..df958f35e91 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -755,7 +755,7 @@ static bool wm_draw_update_test_window(wmWindow *win) if (do_draw) return true; - + if (screen->do_refresh) return true; if (screen->do_draw) @@ -766,7 +766,7 @@ static bool wm_draw_update_test_window(wmWindow *win) return true; if (screen->do_draw_drag) return true; - + return false; } @@ -788,7 +788,7 @@ void wm_draw_update(bContext *C) #endif GPU_free_unused_buffers(); - + for (win = wm->windows.first; win; win = win->next) { #ifdef WIN32 GHOST_TWindowState state = GHOST_GetWindowState(win->ghostwin); @@ -806,7 +806,7 @@ void wm_draw_update(bContext *C) bScreen *screen = WM_window_get_active_screen(win); CTX_wm_window_set(C, win); - + /* sets context window+screen */ wm_window_make_drawable(wm, win); @@ -818,7 +818,7 @@ void wm_draw_update(bContext *C) screen->do_draw_gesture = false; screen->do_draw_paintcursor = false; screen->do_draw_drag = false; - + wm_window_swap_buffers(win); CTX_wm_window_set(C, NULL); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 31b51fce858..b95eb099cce 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -105,7 +105,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA wmEvent *wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent *event_to_add_after) { wmEvent *event = MEM_mallocN(sizeof(wmEvent), "wmEvent"); - + *event = *event_to_add; update_tablet_data(win, event); @@ -157,7 +157,7 @@ void wm_event_free(wmEvent *event) void wm_event_free_all(wmWindow *win) { wmEvent *event; - + while ((event = BLI_pophead(&win->queue))) { wm_event_free(event); } @@ -180,7 +180,7 @@ static bool wm_test_duplicate_notifier(wmWindowManager *wm, unsigned int type, v for (note = wm->queue.first; note; note = note->next) if ((note->category | note->data | note->subtype | note->action) == type && note->reference == reference) return 1; - + return 0; } @@ -194,17 +194,17 @@ void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference return; note = MEM_callocN(sizeof(wmNotifier), "notifier"); - + note->wm = wm; BLI_addtail(¬e->wm->queue, note); - + note->window = CTX_wm_window(C); - + note->category = type & NOTE_CATEGORY; note->data = type & NOTE_DATA; note->subtype = type & NOTE_SUBTYPE; note->action = type & NOTE_ACTION; - + note->reference = reference; } @@ -218,15 +218,15 @@ void WM_main_add_notifier(unsigned int type, void *reference) return; note = MEM_callocN(sizeof(wmNotifier), "notifier"); - + note->wm = wm; BLI_addtail(¬e->wm->queue, note); - + note->category = type & NOTE_CATEGORY; note->data = type & NOTE_DATA; note->subtype = type & NOTE_SUBTYPE; note->action = type & NOTE_ACTION; - + note->reference = reference; } @@ -353,7 +353,7 @@ void wm_event_do_notifiers(bContext *C) wmWindowManager *wm = CTX_wm_manager(C); wmNotifier *note, *next; wmWindow *win; - + if (wm == NULL) return; @@ -363,9 +363,9 @@ void wm_event_do_notifiers(bContext *C) for (win = wm->windows.first; win; win = win->next) { Scene *scene = WM_window_get_active_scene(win); bool do_anim = false; - + CTX_wm_window_set(C, win); - + for (note = wm->queue.first; note; note = next) { next = note->next; @@ -443,7 +443,7 @@ void wm_event_do_notifiers(bContext *C) } } } - + /* the notifiers are sent without context, to keep it clean */ while ((note = BLI_pophead(&wm->queue))) { for (win = wm->windows.first; win; win = win->next) { @@ -484,7 +484,7 @@ void wm_event_do_notifiers(bContext *C) } } } - + MEM_freeN(note); } #endif /* if 1 (postpone disabling for in favor of message-bus), eventually. */ @@ -517,8 +517,8 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, const wmEven static bool do_wheel_ui = true; const bool is_wheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, MOUSEPAN); int retval; - - /* UI code doesn't handle return values - it just always returns break. + + /* UI code doesn't handle return values - it just always returns break. * to make the DBL_CLICK conversion work, we just don't send this to UI, except mouse clicks */ if (((handler->flag & WM_HANDLER_ACCEPT_DBL_CLICK) == 0) && (event->type != LEFTMOUSE) && @@ -526,7 +526,7 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, const wmEven { return WM_HANDLER_CONTINUE; } - + /* UI is quite aggressive with swallowing events, like scrollwheel */ /* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */ if (do_wheel_ui == false) { @@ -535,7 +535,7 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, const wmEven else if (wm_event_always_pass(event) == 0) do_wheel_ui = true; } - + /* we set context to where ui handler came from */ if (handler->ui_area) CTX_wm_area_set(C, handler->ui_area); if (handler->ui_region) CTX_wm_region_set(C, handler->ui_region); @@ -555,14 +555,14 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, const wmEven CTX_wm_region_set(C, NULL); CTX_wm_menu_set(C, NULL); } - + if (retval == WM_UI_HANDLER_BREAK) return WM_HANDLER_BREAK; - + /* event not handled in UI, if wheel then we temporarily disable it */ if (is_wheel) do_wheel_ui = false; - + return WM_HANDLER_CONTINUE; } @@ -593,14 +593,14 @@ static void wm_handler_ui_cancel(bContext *C) int WM_operator_poll(bContext *C, wmOperatorType *ot) { wmOperatorTypeMacro *otmacro; - + for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) { wmOperatorType *ot_macro = WM_operatortype_find(otmacro->idname, 0); - + if (0 == WM_operator_poll(C, ot_macro)) return 0; } - + /* python needs operator type, so we added exception for it */ if (ot->pyop_poll) return ot->pyop_poll(C, ot); @@ -807,7 +807,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, bool ca CTX_wm_region_set(C, ar_prev); } } - + if (retval & OPERATOR_FINISHED) { CLOG_STR_INFO_N(WM_LOG_OPERATORS, 1, WM_operator_pystring(C, op, false, true)); @@ -885,15 +885,15 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons { wmWindowManager *wm = CTX_wm_manager(C); int retval = OPERATOR_CANCELLED; - + CTX_wm_operator_poll_msg_set(C, NULL); - + if (op == NULL || op->type == NULL) return retval; - + if (0 == WM_operator_poll(C, op->type)) return retval; - + if (op->type->exec) { if (op->type->flag & OPTYPE_UNDO) { wm->op_undo_depth++; @@ -912,13 +912,13 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons wm->op_undo_depth--; } } - + /* XXX Disabled the repeat check to address part 2 of #31840. * Carefully checked all calls to wm_operator_exec and WM_operator_repeat, don't see any reason * why this was needed, but worth to note it in case something turns bad. (mont29) */ if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED) /* && repeat == 0 */) wm_operator_reports(C, op, retval, false); - + if (retval & OPERATOR_FINISHED) { wm_operator_finished(C, op, repeat, store && wm->op_undo_depth == 0); } @@ -928,9 +928,9 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons WM_operator_free(op); } } - + return retval | OPERATOR_HANDLED; - + } /* simply calls exec with basic checks */ @@ -1033,11 +1033,11 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, { /* XXX operatortype names are static still. for debug */ wmOperator *op = MEM_callocN(sizeof(wmOperator), ot->idname); - + /* XXX adding new operator could be function, only happens here now */ op->type = ot; BLI_strncpy(op->idname, ot->idname, OP_MAX_TYPENAME); - + /* initialize properties, either copy or create */ op->ptr = MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA"); if (properties && properties->data) { @@ -1057,20 +1057,20 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, op->reports = MEM_mallocN(sizeof(ReportList), "wmOperatorReportList"); BKE_reports_init(op->reports, RPT_STORE | RPT_FREE); } - + /* recursive filling of operator macro list */ if (ot->macro.first) { static wmOperator *motherop = NULL; wmOperatorTypeMacro *otmacro; int root = 0; - + /* ensure all ops are in execution order in 1 list */ if (motherop == NULL) { motherop = op; root = 1; } - + /* if properties exist, it will contain everything needed */ if (properties) { otmacro = ot->macro.first; @@ -1106,11 +1106,11 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, opm->opm = motherop; /* pointer to mom, for modal() */ } } - + if (root) motherop = NULL; } - + WM_operator_properties_sanitize(op->ptr, 0); return op; @@ -1250,7 +1250,7 @@ static int wm_operator_invoke( wmWindowManager *wm = CTX_wm_manager(C); wmOperator *op = wm_operator_create(wm, ot, properties, reports); /* if reports == NULL, they'll be initialized */ const bool is_nested_call = (wm->op_undo_depth != 0); - + if (event != NULL) { op->flag |= OP_IS_INVOKE; } @@ -1388,7 +1388,7 @@ static int wm_operator_call_internal( const short context, const bool poll_only) { wmEvent *event; - + int retval; CTX_wm_operator_poll_msg_set(C, NULL); @@ -1421,39 +1421,39 @@ static int wm_operator_call_internal( } switch (context) { - + case WM_OP_EXEC_REGION_WIN: - case WM_OP_INVOKE_REGION_WIN: + case WM_OP_INVOKE_REGION_WIN: case WM_OP_EXEC_REGION_CHANNELS: case WM_OP_INVOKE_REGION_CHANNELS: case WM_OP_EXEC_REGION_PREVIEW: case WM_OP_INVOKE_REGION_PREVIEW: { /* forces operator to go to the region window/channels/preview, for header menus - * but we stay in the same region if we are already in one + * but we stay in the same region if we are already in one */ ARegion *ar = CTX_wm_region(C); ScrArea *area = CTX_wm_area(C); int type = RGN_TYPE_WINDOW; - + switch (context) { case WM_OP_EXEC_REGION_CHANNELS: case WM_OP_INVOKE_REGION_CHANNELS: type = RGN_TYPE_CHANNELS; break; - + case WM_OP_EXEC_REGION_PREVIEW: case WM_OP_INVOKE_REGION_PREVIEW: type = RGN_TYPE_PREVIEW; break; - + case WM_OP_EXEC_REGION_WIN: - case WM_OP_INVOKE_REGION_WIN: + case WM_OP_INVOKE_REGION_WIN: default: type = RGN_TYPE_WINDOW; break; } - + if (!(ar && ar->regiontype == type) && area) { ARegion *ar1; if (type == RGN_TYPE_WINDOW) { @@ -1466,12 +1466,12 @@ static int wm_operator_call_internal( if (ar1) CTX_wm_region_set(C, ar1); } - + retval = wm_operator_invoke(C, ot, event, properties, reports, poll_only, true); - + /* set region back */ CTX_wm_region_set(C, ar); - + return retval; } case WM_OP_EXEC_AREA: @@ -1506,7 +1506,7 @@ static int wm_operator_call_internal( return wm_operator_invoke(C, ot, event, properties, reports, poll_only, true); } } - + return 0; } @@ -1582,7 +1582,7 @@ int WM_operator_call_py( if (!is_undo && wm) wm->op_undo_depth++; retval = wm_operator_call_internal(C, ot, properties, reports, context, false); - + if (!is_undo && wm && (wm == CTX_wm_manager(C))) wm->op_undo_depth--; return retval; @@ -1602,7 +1602,7 @@ static void wm_handler_op_context(bContext *C, wmEventHandler *handler, const wm { wmWindow *win = CTX_wm_window(C); bScreen *screen = CTX_wm_screen(C); - + if (screen && handler->op) { if (handler->op_area == NULL) CTX_wm_area_set(C, NULL); @@ -1659,7 +1659,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) { wmEventHandler *handler; wmWindowManager *wm = CTX_wm_manager(C); - + /* C is zero on freeing database, modal handlers then already were freed */ while ((handler = BLI_pophead(handlers))) { if (handler->op) { @@ -1667,7 +1667,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) if (handler->op->type->cancel) { ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - + wm_handler_op_context(C, handler, win->eventstate); if (handler->op->type->flag & OPTYPE_UNDO) @@ -1689,7 +1689,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); ARegion *menu = CTX_wm_menu(C); - + if (handler->ui_area) CTX_wm_area_set(C, handler->ui_area); if (handler->ui_region) CTX_wm_region_set(C, handler->ui_region); if (handler->ui_menu) CTX_wm_menu_set(C, handler->ui_menu); @@ -1722,7 +1722,7 @@ int WM_userdef_event_map(int kmitype) case WHEELINMOUSE: return (U.uiflag & USER_WHEELZOOMDIR) ? WHEELDOWNMOUSE : WHEELUPMOUSE; } - + return kmitype; } @@ -1768,13 +1768,13 @@ static int wm_eventmatch(const wmEvent *winevent, wmKeyMapItem *kmi) if (winevent->val == KM_PRESS) { /* prevent double clicks */ /* NOT using ISTEXTINPUT anymore because (at least on Windows) some key codes above 255 * could have printable ascii keys - BUG [#30479] */ - if (ISKEYBOARD(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1; + if (ISKEYBOARD(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1; } if (kmitype != KM_ANY) { if (ELEM(kmitype, TABLET_STYLUS, TABLET_ERASER)) { const wmTabletData *wmtab = winevent->tablet_data; - + if (wmtab == NULL) return 0; else if (winevent->type != LEFTMOUSE) /* tablet events can occur on hover + keypress */ @@ -1789,10 +1789,10 @@ static int wm_eventmatch(const wmEvent *winevent, wmKeyMapItem *kmi) return 0; } } - + if (kmi->val != KM_ANY) if (winevent->val != kmi->val) return 0; - + /* modifiers also check bits, so it allows modifier order */ if (kmi->shift != KM_ANY) if (winevent->shift != kmi->shift && !(winevent->shift & kmi->shift)) return 0; @@ -1802,12 +1802,12 @@ static int wm_eventmatch(const wmEvent *winevent, wmKeyMapItem *kmi) if (winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) return 0; if (kmi->oskey != KM_ANY) if (winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0; - + /* only keymap entry with keymodifier is checked, means all keys without modifier get handled too. */ /* that is currently needed to make overlapping events work (when you press A - G fast or so). */ if (kmi->keymodifier) if (winevent->keymodifier != kmi->keymodifier) return 0; - + return 1; } @@ -1825,12 +1825,12 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve for (kmi = keymap->items.first; kmi; kmi = kmi->next) { if (wm_eventmatch(event, kmi)) { - + event->prevtype = event->type; event->prevval = event->val; event->type = EVT_MODAL_MAP; event->val = kmi->propvalue; - + break; } } @@ -1883,7 +1883,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand wmEvent *event, PointerRNA *properties) { int retval = OPERATOR_PASS_THROUGH; - + /* derived, modal or blocking operator */ if (handler->op) { wmOperator *op = handler->op; @@ -1911,7 +1911,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand /* warning, after this call all context data and 'event' may be freed. see check below */ retval = ot->modal(C, op, event); OPERATOR_RETVAL_CHECK(retval); - + /* when this is _not_ the case the modal modifier may have loaded * a new blend file (demo mode does this), so we have to assume * the event, operator etc have all been freed. - campbell */ @@ -1979,7 +1979,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand bool use_last_properties = true; PointerRNA tool_properties = {{0}}; bool use_tool_properties = (handler->keymap_tool != NULL); - + if (use_tool_properties) { WM_toolsystem_ref_properties_init_for_keymap(handler->keymap_tool, &tool_properties, properties, ot); properties = &tool_properties; @@ -2058,11 +2058,11 @@ static int wm_handler_fileselect_do(bContext *C, ListBase *handlers, wmEventHand sfile->op = handler->op; ED_fileselect_set_params(sfile); - + action = WM_HANDLER_BREAK; break; } - + case EVT_FILESELECT_EXEC: case EVT_FILESELECT_CANCEL: case EVT_FILESELECT_EXTERNAL_CANCEL: @@ -2150,11 +2150,11 @@ static int wm_handler_fileselect_do(bContext *C, ListBase *handlers, wmEventHand wm->op_undo_depth++; handler->op->type->cancel(C, handler->op); - + if (handler->op->type->flag & OPTYPE_UNDO) wm->op_undo_depth--; } - + WM_operator_free(handler->op); } @@ -2166,19 +2166,19 @@ static int wm_handler_fileselect_do(bContext *C, ListBase *handlers, wmEventHand break; } } - + return action; } static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHandler *handler, const wmEvent *event) { int action = WM_HANDLER_CONTINUE; - + if (event->type != EVT_FILESELECT) return action; if (handler->op != (wmOperator *)event->customdata) return action; - + return wm_handler_fileselect_do(C, handlers, handler, event->val); } @@ -2239,7 +2239,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers for (handler = handlers->first; handler && handlers->first; handler = nexthandler) { nexthandler = handler->next; - + /* during this loop, ui handlers for nested menus can tag multiple handlers free */ if (handler->flag & WM_HANDLER_DO_FREE) { /* pass */ @@ -2247,7 +2247,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers else if (handler_boundbox_test(handler, event)) { /* optional boundbox */ /* in advance to avoid access to freed event on window close */ always_pass = wm_event_always_pass(event); - + /* modal+blocking handler */ if (handler->flag & WM_HANDLER_BLOCKING) action |= WM_HANDLER_BREAK; @@ -2272,7 +2272,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers event->keymap_idname = kmi->idname; action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr); - + if (action & WM_HANDLER_BREAK) { /* not always_pass here, it denotes removed handler */ CLOG_INFO(WM_LOG_HANDLERS, 2, "handled! '%s'", kmi->idname); @@ -2315,24 +2315,24 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers if (event->custom == EVT_DATA_DRAGDROP) { ListBase *lb = (ListBase *)event->customdata; wmDrag *drag; - + for (drag = lb->first; drag; drag = drag->next) { if (drop->poll(C, drag, event)) { drop->copy(drag, drop); - + /* free the drags before calling operator */ WM_drag_free_list(lb); event->customdata = NULL; event->custom = 0; - + WM_operator_name_call_ptr(C, drop->ot, drop->opcontext, drop->ptr); action |= WM_HANDLER_BREAK; - + /* XXX fileread case */ if (CTX_wm_window(C) == NULL) return action; - + /* escape from drag loop, got freed */ break; } @@ -2491,7 +2491,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers break; } } - + /* XXX fileread case, if the wm is freed then the handler's * will have been too so the code below need not run. */ if (CTX_wm_window(C) == NULL) { @@ -2499,8 +2499,8 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers } /* XXX code this for all modal ops, and ensure free only happens here */ - - /* modal ui handler can be tagged to be freed */ + + /* modal ui handler can be tagged to be freed */ if (BLI_findindex(handlers, handler) != -1) { /* could be freed already by regular modal ops */ if (handler->flag & WM_HANDLER_DO_FREE) { BLI_remlink(handlers, handler); @@ -2521,7 +2521,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) { int action = wm_handlers_do_intern(C, event, handlers); - + /* fileread case */ if (CTX_wm_window(C) == NULL) return action; @@ -2531,16 +2531,16 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) /* test for CLICK events */ if (wm_action_not_handled(action)) { wmWindow *win = CTX_wm_window(C); - - /* eventstate stores if previous event was a KM_PRESS, in case that + + /* eventstate stores if previous event was a KM_PRESS, in case that * wasn't handled, the KM_RELEASE will become a KM_CLICK */ - + if (win && event->val == KM_PRESS) { win->eventstate->check_click = true; } - + if (win && win->eventstate->prevtype == event->type) { - + if ((event->val == KM_RELEASE) && (win->eventstate->prevval == KM_PRESS) && (win->eventstate->check_click == true)) @@ -2551,7 +2551,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) event->val = KM_CLICK; CLOG_INFO(WM_LOG_HANDLERS, 1, "handling CLICK"); - + action |= wm_handlers_do_intern(C, event, handlers); event->val = KM_RELEASE; @@ -2563,7 +2563,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) else if (event->val == KM_DBL_CLICK) { event->val = KM_PRESS; action |= wm_handlers_do_intern(C, event, handlers); - + /* revert value if not handled */ if (wm_action_not_handled(action)) { event->val = KM_DBL_CLICK; @@ -2578,7 +2578,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) win->eventstate->check_click = 0; } } - + return action; } @@ -2595,7 +2595,7 @@ static ScrArea *area_event_inside(bContext *C, const int xy[2]) { wmWindow *win = CTX_wm_window(C); bScreen *screen = CTX_wm_screen(C); - + if (screen) { ED_screen_areas_iter(win, screen, sa) { if (BLI_rcti_isect_pt_v(&sa->totrct, xy)) @@ -2610,7 +2610,7 @@ static ARegion *region_event_inside(bContext *C, const int xy[2]) bScreen *screen = CTX_wm_screen(C); ScrArea *area = CTX_wm_area(C); ARegion *ar; - + if (screen && area) for (ar = area->regionbase.first; ar; ar = ar->next) if (BLI_rcti_isect_pt_v(&ar->winrct, xy)) @@ -2635,22 +2635,22 @@ static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *ar) static void wm_paintcursor_test(bContext *C, const wmEvent *event) { wmWindowManager *wm = CTX_wm_manager(C); - + if (wm->paintcursors.first) { ARegion *ar = CTX_wm_region(C); - + if (ar) wm_paintcursor_tag(C, wm->paintcursors.first, ar); - + /* if previous position was not in current region, we have to set a temp new context */ if (ar == NULL || !BLI_rcti_isect_pt_v(&ar->winrct, &event->prevx)) { ScrArea *sa = CTX_wm_area(C); - + CTX_wm_area_set(C, area_event_inside(C, &event->prevx)); CTX_wm_region_set(C, region_event_inside(C, &event->prevx)); wm_paintcursor_tag(C, wm->paintcursors.first, CTX_wm_region(C)); - + CTX_wm_area_set(C, sa); CTX_wm_region_set(C, ar); } @@ -2664,7 +2664,7 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even if (BLI_listbase_is_empty(&wm->drags)) { return; } - + if (event->type == MOUSEMOVE || ISKEYMODIFIER(event->type)) { screen->do_draw_drag = true; } @@ -2675,20 +2675,20 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even } else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { event->type = EVT_DROP; - + /* create customdata, first free existing */ if (event->customdata) { if (event->customdatafree) MEM_freeN(event->customdata); } - + event->custom = EVT_DATA_DRAGDROP; event->customdata = &wm->drags; event->customdatafree = 1; - + /* clear drop icon */ screen->do_draw_drag = true; - + /* restore cursor (disabled, see wm_dragdrop.c) */ // WM_cursor_modal_restore(win); } @@ -2738,12 +2738,12 @@ void wm_event_do_handlers(bContext *C) if (scene) { int is_playing_sound = BKE_sound_scene_playing(scene); - + if (is_playing_sound != -1) { bool is_playing_screen; CTX_wm_window_set(C, win); CTX_data_scene_set(C, scene); - + is_playing_screen = (ED_screen_animation_playing(wm) != NULL); if (((is_playing_sound == 1) && (is_playing_screen == 0)) || @@ -2751,7 +2751,7 @@ void wm_event_do_handlers(bContext *C) { ED_screen_animation_play(C, -1, 1); } - + if (is_playing_sound == 0) { const float time = BKE_sound_sync_scene(scene); if (isfinite(time)) { @@ -2764,14 +2764,14 @@ void wm_event_do_handlers(bContext *C) } } } - + CTX_data_scene_set(C, NULL); CTX_wm_screen_set(C, NULL); CTX_wm_window_set(C, NULL); } } } - + while ( (event = win->queue.first) ) { int action = WM_HANDLER_CONTINUE; @@ -2805,16 +2805,16 @@ void wm_event_do_handlers(bContext *C) /* we let modal handlers get active area/region, also wm_paintcursor_test needs it */ CTX_wm_area_set(C, area_event_inside(C, &event->x)); CTX_wm_region_set(C, region_event_inside(C, &event->x)); - + /* MVC demands to not draw in event handlers... but we need to leave it for ogl selecting etc */ wm_window_make_drawable(wm, win); - + wm_region_mouse_co(C, event); /* first we do priority handlers, modal + some limited keymaps */ action |= wm_handlers_do(C, event, &win->modalhandlers); - + /* fileread case */ if (CTX_wm_window(C) == NULL) return; @@ -2830,13 +2830,13 @@ void wm_event_do_handlers(bContext *C) /* check dragging, creates new event or frees, adds draw tag */ wm_event_drag_test(wm, win, event); - + /* builtin tweak, if action is break it removes tweak */ wm_tweakevent_test(C, event, action); if ((action & WM_HANDLER_BREAK) == 0) { ARegion *ar; - + /* Note: setting subwin active should be done here, after modal handlers have been done */ if (event->type == MOUSEMOVE) { /* state variables in screen, cursors. Also used in wm_draw.c, fails for modal handlers though */ @@ -2871,7 +2871,7 @@ void wm_event_do_handlers(bContext *C) for (ar = sa->regionbase.first; ar; ar = ar->next) { if (wm_event_inside_i(event, &ar->winrct)) { CTX_wm_region_set(C, ar); - + /* call even on non mouse events, since the */ wm_region_mouse_co(C, event); @@ -2945,7 +2945,7 @@ void wm_event_do_handlers(bContext *C) /* NOTE: do not escape on WM_HANDLER_BREAK, mousemove needs handled for previous area */ } } - + if ((action & WM_HANDLER_BREAK) == 0) { /* also some non-modal handlers need active area/region */ CTX_wm_area_set(C, area_event_inside(C, &event->x)); @@ -2969,9 +2969,9 @@ void wm_event_do_handlers(bContext *C) /* unlink and free here, blender-quit then frees all */ BLI_remlink(&win->queue, event); wm_event_free(event); - + } - + /* only add mousemove when queue was read entirely */ if (win->addmousemove && win->eventstate) { wmEvent tevent = *(win->eventstate); @@ -2982,7 +2982,7 @@ void wm_event_do_handlers(bContext *C) wm_event_add(win, &tevent); win->addmousemove = 0; } - + CTX_wm_window_set(C, NULL); } @@ -2997,10 +2997,10 @@ void WM_event_fileselect_event(wmWindowManager *wm, void *ophandle, int eventval { /* add to all windows! */ wmWindow *win; - + for (win = wm->windows.first; win; win = win->next) { wmEvent event = *win->eventstate; - + event.type = EVT_FILESELECT; event.val = eventval; event.customdata = ophandle; // only as void pointer type check @@ -3027,7 +3027,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) /* only allow 1 file selector open per window */ for (handler = win->modalhandlers.first; handler; handler = handlernext) { handlernext = handler->next; - + if (handler->type == WM_HANDLER_FILESELECT) { bScreen *screen = CTX_wm_screen(C); bool cancel_handler = true; @@ -3052,16 +3052,16 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) } } } - + handler = MEM_callocN(sizeof(wmEventHandler), "fileselect handler"); - + handler->type = WM_HANDLER_FILESELECT; handler->op = op; handler->op_area = CTX_wm_area(C); handler->op_region = CTX_wm_region(C); - + BLI_addhead(&win->modalhandlers, handler); - + /* check props once before invoking if check is available * ensures initial properties are valid */ if (op->type->check) { @@ -3083,7 +3083,7 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op) { wmEventHandler *handler = MEM_callocN(sizeof(wmEventHandler), "event modal handler"); wmWindow *win = CTX_wm_window(C); - + /* operator was part of macro */ if (op->opm) { /* give the mother macro to the handler */ @@ -3093,11 +3093,11 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op) } else handler->op = op; - + handler->op_area = CTX_wm_area(C); /* means frozen screen context for modal handlers! */ handler->op_region = CTX_wm_region(C); handler->op_region_type = handler->op_region ? handler->op_region->regiontype : -1; - + BLI_addhead(&win->modalhandlers, handler); return handler; @@ -3144,7 +3144,7 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap for (handler = handlers->first; handler; handler = handler->next) if (handler->keymap == keymap) return handler; - + handler = MEM_callocN(sizeof(wmEventHandler), "event keymap handler"); BLI_addtail(handlers, handler); handler->keymap = keymap; @@ -3156,20 +3156,20 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, wmKeyMap *keymap, int UNUSED(priority)) { wmEventHandler *handler; - + WM_event_remove_keymap_handler(handlers, keymap); - + handler = MEM_callocN(sizeof(wmEventHandler), "event keymap handler"); BLI_addhead(handlers, handler); handler->keymap = keymap; - + return handler; } wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *keymap, const rcti *bblocal, const rcti *bbwin) { wmEventHandler *handler = WM_event_add_keymap_handler(handlers, keymap); - + if (handler) { handler->bblocal = bblocal; handler->bbwin = bbwin; @@ -3180,7 +3180,7 @@ wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *key void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap) { wmEventHandler *handler; - + for (handler = handlers->first; handler; handler = handler->next) { if (handler->keymap == keymap) { BLI_remlink(handlers, handler); @@ -3221,9 +3221,9 @@ wmEventHandler *WM_event_add_ui_handler( BLI_assert((flag & WM_HANDLER_DO_FREE) == 0); handler->flag = flag; - + BLI_addhead(handlers, handler); - + return handler; } @@ -3234,7 +3234,7 @@ void WM_event_remove_ui_handler( void *userdata, const bool postpone) { wmEventHandler *handler; - + for (handler = handlers->first; handler; handler = handler->next) { if ((handler->ui_handle == ui_handle) && (handler->ui_remove == ui_remove) && @@ -3279,13 +3279,13 @@ wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropb for (handler = handlers->first; handler; handler = handler->next) if (handler->dropboxes == dropboxes) return handler; - + handler = MEM_callocN(sizeof(wmEventHandler), "dropbox handler"); - + /* dropbox stored static, no free or copy */ handler->dropboxes = dropboxes; BLI_addhead(handlers, handler); - + return handler; } @@ -3316,7 +3316,7 @@ static void WM_event_remove_handler(ListBase *handlers, wmEventHandler *handler) void WM_event_add_mousemove(const bContext *C) { wmWindow *window = CTX_wm_window(C); - + window->addmousemove = 1; } @@ -3324,7 +3324,7 @@ void WM_event_add_mousemove(const bContext *C) /* for modal callbacks, check configuration for how to interpret exit with tweaks */ bool WM_event_is_modal_tweak_exit(const wmEvent *event, int tweak_event) { - /* if the release-confirm userpref setting is enabled, + /* if the release-confirm userpref setting is enabled, * tweak events can be canceled when mouse is released */ if (U.flag & USER_RELEASECONFIRM) { @@ -3353,13 +3353,13 @@ bool WM_event_is_modal_tweak_exit(const wmEvent *event, int tweak_event) if (event->val != KM_RELEASE) return 1; } - + return 0; } /* ********************* ghost stuff *************** */ -static int convert_key(GHOST_TKey key) +static int convert_key(GHOST_TKey key) { if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) { return (AKEY + ((int) key - GHOST_kKeyA)); @@ -3438,7 +3438,7 @@ static int convert_key(GHOST_TKey key) case GHOST_kKeyMediaStop: return MEDIASTOP; case GHOST_kKeyMediaFirst: return MEDIAFIRST; case GHOST_kKeyMediaLast: return MEDIALAST; - + default: return UNKNOWNKEY; /* GHOST_kKeyUnknown */ } @@ -3450,11 +3450,11 @@ static void wm_eventemulation(wmEvent *event) /* Store last mmb/rmb event value to make emulation work when modifier keys * are released first. This really should be in a data structure somewhere. */ static int emulating_event = EVENT_NONE; - + /* middlemouse and rightmouse emulation */ if (U.flag & USER_TWOBUTTONMOUSE) { if (event->type == LEFTMOUSE) { - + if (event->val == KM_PRESS && event->alt) { event->type = MIDDLEMOUSE; event->alt = 0; @@ -3480,9 +3480,9 @@ static void wm_eventemulation(wmEvent *event) emulating_event = EVENT_NONE; } } - + } - + /* numpad emulation */ if (U.flag & USER_NONUMPAD) { switch (event->type) { @@ -3507,16 +3507,16 @@ static void wm_eventemulation(wmEvent *event) static void update_tablet_data(wmWindow *win, wmEvent *event) { const GHOST_TabletData *td = GHOST_GetTabletData(win->ghostwin); - + /* if there's tablet data from an active tablet device then add it */ if ((td != NULL) && td->Active != GHOST_kTabletModeNone) { struct wmTabletData *wmtab = MEM_mallocN(sizeof(wmTabletData), "customdata tablet"); - + wmtab->Active = (int)td->Active; wmtab->Pressure = td->Pressure; wmtab->Xtilt = td->Xtilt; wmtab->Ytilt = td->Ytilt; - + event->tablet_data = wmtab; // printf("%s: using tablet %.5f\n", __func__, wmtab->Pressure); } @@ -3559,40 +3559,40 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *event) { int mx = event->x, my = event->y; - + if (wm->windows.first == wm->windows.last) return NULL; - + /* in order to use window size and mouse position (pixels), we have to use a WM function */ - + /* check if outside, include top window bar... */ if (mx < 0 || my < 0 || mx > WM_window_pixels_x(win) || my > WM_window_pixels_y(win) + 30) { wmWindow *owin; wmEventHandler *handler; - + /* let's skip windows having modal handlers now */ /* potential XXX ugly... I wouldn't have added a modalhandlers list (introduced in rev 23331, ton) */ for (handler = win->modalhandlers.first; handler; handler = handler->next) if (handler->ui_handle || handler->op) return NULL; - + /* to desktop space */ mx += (int) (U.pixelsize * win->posx); my += (int) (U.pixelsize * win->posy); - + /* check other windows to see if it has mouse inside */ for (owin = wm->windows.first; owin; owin = owin->next) { - + if (owin != win) { int posx = (int) (U.pixelsize * owin->posx); int posy = (int) (U.pixelsize * owin->posy); - + if (mx - posx >= 0 && owin->posy >= 0 && mx - posx <= WM_window_pixels_x(owin) && my - posy <= WM_window_pixels_y(owin)) { event->x = mx - (int)(U.pixelsize * owin->posx); event->y = my - (int)(U.pixelsize * owin->posy); - + return owin; } } @@ -3671,7 +3671,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U copy_v2_v2_int(&evt->x, &event_new->x); evt->is_motion_absolute = event_new->is_motion_absolute; } - + /* also add to other window if event is there, this makes overdraws disappear nicely */ /* it remaps mousecoord to other window in event */ owin = wm_event_cursor_other_windows(wm, win, &event); @@ -3688,7 +3688,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U oevt->is_motion_absolute = event_new->is_motion_absolute; } } - + break; } case GHOST_kEventTrackpad: @@ -3712,11 +3712,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.x = evt->x = pd->x; event.y = evt->y = pd->y; event.val = KM_NOTHING; - + /* Use prevx/prevy so we can calculate the delta later */ event.prevx = event.x - pd->deltaX; event.prevy = event.y - (-pd->deltaY); - + wm_event_add(win, &event); break; } @@ -3725,10 +3725,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U case GHOST_kEventButtonUp: { GHOST_TEventButtonData *bd = customdata; - + /* get value and type from ghost */ event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE; - + if (bd->button == GHOST_kButtonMaskLeft) event.type = LEFTMOUSE; else if (bd->button == GHOST_kButtonMaskRight) @@ -3743,9 +3743,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.type = BUTTON7MOUSE; else event.type = MIDDLEMOUSE; - + wm_eventemulation(&event); - + /* copy previous state to prev event state (two old!) */ evt->prevval = evt->val; evt->prevtype = evt->type; @@ -3756,14 +3756,14 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U if (win->active == 0) { int cx, cy; - + /* entering window, update mouse pos. (ghost sends win-activate *after* the mouseclick in window!) */ wm_get_cursor_position(win, &cx, &cy); event.x = evt->x = cx; event.y = evt->y = cy; } - + /* double click test */ if (wm_event_is_double_click(&event, evt)) { CLOG_INFO(WM_LOG_HANDLERS, 1, "Send double click"); @@ -3774,23 +3774,23 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U evt->prevclickx = event.x; evt->prevclicky = event.y; } - + /* add to other window if event is there (not to both!) */ owin = wm_event_cursor_other_windows(wm, win, &event); if (owin) { wmEvent oevent = *(owin->eventstate); - + oevent.x = event.x; oevent.y = event.y; oevent.type = event.type; oevent.val = event.val; - + wm_event_add(owin, &oevent); } else { wm_event_add(win, &event); } - + break; } /* keyboard */ @@ -3803,9 +3803,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.ascii = kd->ascii; memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); /* might be not null terminated*/ event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE; - + wm_eventemulation(&event); - + /* copy previous state to prev event state (two old!) */ evt->prevval = evt->val; evt->prevtype = evt->type; @@ -3813,7 +3813,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* copy to event state */ evt->val = event.val; evt->type = event.type; - + /* exclude arrow keys, esc, etc from text input */ if (type == GHOST_kEventKeyUp) { event.ascii = '\0'; @@ -3887,19 +3887,19 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U CLOG_INFO(WM_LOG_HANDLERS, 1, "Send double click"); evt->val = event.val = KM_DBL_CLICK; } - + /* this case happens on holding a key pressed, it should not generate * press events events with the same key as modifier */ if (event.keymodifier == event.type) event.keymodifier = 0; - + /* this case happens with an external numpad, and also when using 'dead keys' (to compose complex latin * characters e.g.), it's not really clear why. * Since it's impossible to map a key modifier to an unknown key, it shouldn't harm to clear it. */ if (event.keymodifier == UNKNOWNKEY) { evt->keymodifier = event.keymodifier = 0; } - + /* if test_break set, it catches this. Do not set with modifier presses. XXX Keep global for now? */ if ((event.type == ESCKEY && event.val == KM_PRESS) && /* check other modifiers because ms-windows uses these to bring up the task manager */ @@ -3907,31 +3907,31 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U { G.is_break = true; } - + /* double click test - only for press */ if (event.val == KM_PRESS) { evt->prevclicktime = PIL_check_seconds_timer(); evt->prevclickx = event.x; evt->prevclicky = event.y; } - + wm_event_add(win, &event); - + break; } - + case GHOST_kEventWheel: { GHOST_TEventWheelData *wheelData = customdata; - + if (wheelData->z > 0) event.type = WHEELUPMOUSE; else event.type = WHEELDOWNMOUSE; - + event.val = KM_PRESS; wm_event_add(win, &event); - + break; } case GHOST_kEventTimer: diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 28c47a4ea8a..2060b1bf531 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -152,27 +152,27 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) { wmWindowManager *wm; wmWindow *win, *active_win; - + *wmlist = G.main->wm; BLI_listbase_clear(&G.main->wm); - + active_win = CTX_wm_window(C); /* first wrap up running stuff */ /* code copied from wm_init_exit.c */ for (wm = wmlist->first; wm; wm = wm->id.next) { - + WM_jobs_kill_all(wm); - + for (win = wm->windows.first; win; win = win->next) { - + CTX_wm_window_set(C, win); /* needed by operator close callbacks */ WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->modalhandlers); ED_screen_exit(C, win, WM_window_get_active_screen(win)); } } - + /* reset active window */ CTX_wm_window_set(C, active_win); @@ -341,7 +341,7 @@ static void wm_init_userdef(Main *bmain, const bool read_userdef_from_memory) { /* versioning is here */ UI_init_userdef(); - + MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024); BKE_sound_init(bmain); @@ -570,7 +570,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* it throws error box when file doesn't exist and returns -1 */ /* note; it should set some error message somewhere... (ton) */ retval = wm_read_exotic(filepath); - + /* we didn't succeed, now try to read Blender file */ if (retval == BKE_READ_EXOTIC_OK_BLEND) { int G_f = G.f; @@ -579,7 +579,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* put aside screens to match with persistent windows later */ /* also exit screens and editors */ wm_window_match_init(C, &wmbase); - + /* confusing this global... */ G.relbase_valid = 1; retval = BKE_blendfile_read(C, filepath, reports, 0); @@ -611,7 +611,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* in case a userdef is read from regular .blend */ wm_init_userdef(bmain, false); } - + if (retval != BKE_BLENDFILE_READ_FAIL) { if (do_history) { wm_history_file_update(); @@ -875,7 +875,7 @@ int wm_homefile_read( /* check userdef before open window, keymaps etc */ wm_init_userdef(bmain, read_userdef_from_memory); } - + /* match the read WM with current WM */ wm_window_match_do(C, &wmbase, &bmain->wm, &bmain->wm); WM_check(C); /* opens window(s), checks keymaps */ @@ -921,7 +921,7 @@ void wm_history_file_read(void) num++; } } - + BLI_file_free_lines(lines); } @@ -1076,7 +1076,7 @@ static ImBuf *blend_file_thumb(const bContext *C, Scene *scene, bScreen *screen, /* add pretty overlay */ IMB_thumb_overlay_blend(ibuf->rect, ibuf->x, ibuf->y, aspect); - + thumb = BKE_main_thumbnail_from_imbuf(NULL, ibuf); } else { @@ -1084,10 +1084,10 @@ static ImBuf *blend_file_thumb(const bContext *C, Scene *scene, bScreen *screen, fprintf(stderr, "blend_file_thumb failed to create thumbnail: %s\n", err_out); thumb = NULL; } - + /* must be freed by caller */ *thumb_pt = thumb; - + return ibuf; } @@ -1122,7 +1122,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor ImBuf *ibuf_thumb = NULL; len = strlen(filepath); - + if (len == 0) { BKE_report(reports, RPT_ERROR, "Path is empty, cannot save"); return ret; @@ -1132,7 +1132,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor BKE_report(reports, RPT_ERROR, "Path too long, cannot save"); return ret; } - + /* Check if file write permission is ok */ if (BLI_exists(filepath) && !BLI_file_is_writable(filepath)) { BKE_reportf(reports, RPT_ERROR, "Cannot save blend file, path '%s' is not writable", filepath); @@ -1142,7 +1142,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor /* note: used to replace the file extension (to ensure '.blend'), * no need to now because the operator ensures, * its handy for scripts to save to a predefined name without blender editing it */ - + /* send the OnSave event */ for (li = bmain->library.first; li; li = li->id.next) { if (BLI_path_cmp(li->filepath, filepath) == 0) { @@ -1170,7 +1170,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor /* don't forget not to return without! */ WM_cursor_wait(1); - + ED_editors_flush_edits(C, false); fileflags |= G_FILE_HISTORY; /* write file history */ @@ -1183,14 +1183,14 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor /* XXX temp solution to solve bug, real fix coming (ton) */ bmain->recovered = 0; - + if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) { const bool do_history = (G.background == false) && (CTX_wm_manager(C)->op_undo_depth == 0); if (!(fileflags & G_FILE_SAVE_COPY)) { G.relbase_valid = 1; BLI_strncpy(bmain->name, filepath, sizeof(bmain->name)); /* is guaranteed current file */ - + G.save_over = 1; /* disable untitled.blend convention */ } @@ -1275,7 +1275,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w wmWindow *win; wmEventHandler *handler; char filepath[FILE_MAX]; - + WM_event_remove_timer(wm, NULL, wm->autosavetimer); /* if a modal operator is running, don't autosave, but try again in 10 seconds */ @@ -1324,7 +1324,7 @@ void wm_autosave_timer_ended(wmWindowManager *wm) void wm_autosave_delete(void) { char filename[FILE_MAX]; - + wm_autosave_location(filename); if (BLI_exists(filename)) { diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index 8cbb3e0cb70..c7d55b290f5 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -372,7 +372,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) if (view_layer && RNA_boolean_get(op->ptr, "autoselect")) { BKE_view_layer_base_deselect_all(view_layer); } - + /* tag everything, all untagged data can be made local * its also generally useful to know what is new * @@ -531,18 +531,18 @@ void WM_OT_link(wmOperatorType *ot) ot->name = "Link from Library"; ot->idname = "WM_OT_link"; ot->description = "Link from a Library .blend file"; - + ot->invoke = wm_link_append_invoke; ot->exec = wm_link_append_exec; ot->poll = wm_link_append_poll; - + ot->flag |= OPTYPE_UNDO; WM_operator_properties_filesel( ot, FILE_TYPE_FOLDER | FILE_TYPE_BLENDER | FILE_TYPE_BLENDERLIB, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA); - + wm_link_append_properties_common(ot, true); } diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 2c3583a9f02..144bb38ae76 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -63,20 +63,20 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type) wmGesture *gesture = MEM_callocN(sizeof(wmGesture), "new gesture"); wmWindow *window = CTX_wm_window(C); ARegion *ar = CTX_wm_region(C); - + BLI_addtail(&window->gesture, gesture); - + gesture->type = type; gesture->event_type = event->type; gesture->winrct = ar->winrct; gesture->userdata_free = true; /* Free if userdata is set. */ gesture->modal_state = GESTURE_MODAL_NOP; - + if (ELEM(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK, WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE)) { rcti *rect = MEM_callocN(sizeof(rcti), "gesture rect new"); - + gesture->customdata = rect; rect->xmin = event->x - gesture->winrct.xmin; rect->ymin = event->y - gesture->winrct.ymin; @@ -96,14 +96,14 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type) lasso[1] = event->y - gesture->winrct.ymin; gesture->points = 1; } - + return gesture; } void WM_gesture_end(bContext *C, wmGesture *gesture) { wmWindow *win = CTX_wm_window(C); - + if (win->tweak == gesture) win->tweak = NULL; BLI_remlink(&win->gesture, gesture); @@ -117,7 +117,7 @@ void WM_gesture_end(bContext *C, wmGesture *gesture) void WM_gestures_remove(bContext *C) { wmWindow *win = CTX_wm_window(C); - + while (win->gesture.first) WM_gesture_end(C, win->gesture.first); } @@ -141,7 +141,7 @@ int wm_gesture_evaluate(wmGesture *gesture) else if (theta == -1) val = EVT_GESTURE_SE; else if (theta == -2) val = EVT_GESTURE_S; else if (theta == -3) val = EVT_GESTURE_SW; - + #if 0 /* debug */ if (val == 1) printf("tweak north\n"); @@ -421,7 +421,7 @@ void wm_gesture_draw(wmWindow *win) for (; gt; gt = gt->next) { /* all in subwindow space */ wmViewport(>->winrct); - + if (gt->type == WM_GESTURE_RECT) wm_gesture_draw_rect(gt); // else if (gt->type == WM_GESTURE_TWEAK) @@ -448,7 +448,7 @@ void wm_gesture_draw(wmWindow *win) void wm_gesture_tag_redraw(bContext *C) { bScreen *screen = CTX_wm_screen(C); - + if (screen) screen->do_draw_gesture = true; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 690f1c523e1..c5a57147dd6 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -197,7 +197,7 @@ void WM_init_opengl(void) /* only called once, for startup */ void WM_init(bContext *C, int argc, const char **argv) { - + if (!G.background) { wm_ghost_init(C); /* note: it assigns C to ghost! */ wm_init_cursor_data(); @@ -224,12 +224,12 @@ void WM_init(bContext *C, int argc, const char **argv) BKE_spacedata_callback_id_remap_set(ED_spacedata_id_remap); /* screen.c */ DEG_editors_set_update_cb(ED_render_id_flush_update, ED_render_scene_update); - + ED_spacetypes_init(); /* editors/space_api/spacetype.c */ - + ED_file_init(); /* for fsmenu */ ED_node_init_butfuncs(); - + BLF_init(); BLT_lang_init(); @@ -307,7 +307,7 @@ void WM_init(bContext *C, int argc, const char **argv) COM_linker_hack = COM_execute; } #endif - + /* load last session, uses regular file reading so it has to be in end (after init py etc) */ if (U.uiflag2 & USER_KEEP_SESSION) { /* calling WM_recover_last_session(C, NULL) has been moved to creator.c */ @@ -340,7 +340,7 @@ void WM_init_splash(bContext *C) if ((U.uiflag & USER_SPLASH_DISABLE) == 0) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *prevwin = CTX_wm_window(C); - + if (wm->windows.first) { CTX_wm_window_set(C, wm->windows.first); WM_operator_name_call(C, "WM_OT_splash", WM_OP_INVOKE_DEFAULT, NULL); @@ -353,10 +353,10 @@ void WM_init_splash(bContext *C) static void free_openrecent(void) { struct RecentFile *recent; - + for (recent = G.recent_files.first; recent; recent = recent->next) MEM_freeN(recent->filepath); - + BLI_freelistN(&(G.recent_files)); } @@ -439,11 +439,11 @@ void WM_exit_ext(bContext *C, const bool do_python) } } } - + WM_jobs_kill_all(wm); for (win = wm->windows.first; win; win = win->next) { - + CTX_wm_window_set(C, win); /* needed by operator close callbacks */ WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->modalhandlers); @@ -464,13 +464,13 @@ void WM_exit_ext(bContext *C, const bool do_python) ED_undosys_type_free(); free_openrecent(); - + BKE_mball_cubeTable_free(); - + /* render code might still access databases */ RE_FreeAllRender(); RE_engines_exit(); - + ED_preview_free_dbase(); /* frees a Main dbase, before BKE_blender_free! */ if (C && wm) @@ -480,7 +480,7 @@ void WM_exit_ext(bContext *C, const bool do_python) BKE_tracking_clipboard_free(); BKE_mask_clipboard_free(); BKE_vfont_clipboard_free(); - + #ifdef WITH_COMPOSITOR COM_deinitialize(); #endif @@ -494,7 +494,7 @@ void WM_exit_ext(bContext *C, const bool do_python) GPU_exit(); } - + BKE_blender_free(); /* blender.c, does entire library and spacetypes */ // free_matcopybuf(); ANIM_fcurves_copybuf_free(); @@ -523,11 +523,11 @@ void WM_exit_ext(bContext *C, const bool do_python) BLF_free_unifont_mono(); BLT_lang_free(); #endif - + ANIM_keyingset_infos_exit(); - + // free_txt_data(); - + #ifdef WITH_PYTHON /* option not to close python so we can use 'atexit' */ @@ -551,11 +551,11 @@ void WM_exit_ext(bContext *C, const bool do_python) BKE_blender_userdef_data_free(&U, false); RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */ - + wm_ghost_exit(); CTX_free(C); - + GHOST_DisposeSystemPaths(); DNA_sdna_current_free(); diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 28f978909f7..3a4195ae1ae 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -78,10 +78,10 @@ struct wmJob { struct wmJob *next, *prev; - + /* job originating from, keep track of this when deleting windows */ wmWindow *win; - + /* should store entire own context, for start, update, free */ void *customdata; /* to prevent cpu overhead, use this one which only gets called when job really starts, not in thread */ @@ -95,14 +95,14 @@ struct wmJob { void (*free)(void *); /* gets called when job is stopped, not in thread */ void (*endjob)(void *); - + /* running jobs each have own timer */ double timestep; wmTimer *wt; /* the notifier event timers should send */ unsigned int note, endnote; - - + + /* internal */ void *owner; int flag; @@ -115,7 +115,7 @@ struct wmJob { /* once running, we store this separately */ void *run_customdata; void (*run_free)(void *); - + /* we use BLI_threads api, but per job only 1 thread runs */ ListBase threads; @@ -152,7 +152,7 @@ static void wm_job_main_thread_yield(wmJob *wm_job) static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type) { wmJob *wm_job; - + if (owner && job_type) { for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) if (wm_job->owner == owner && wm_job->job_type == job_type) @@ -168,7 +168,7 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type) if (wm_job->job_type == job_type) return wm_job; } - + return NULL; } @@ -183,7 +183,7 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type) wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type) { wmJob *wm_job = wm_job_find(wm, owner, job_type); - + if (wm_job == NULL) { wm_job = MEM_callocN(sizeof(wmJob), "new job"); @@ -198,7 +198,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char * WM_job_main_thread_lock_acquire(wm_job); } /* else: a running job, be careful */ - + /* prevent creating a job with an invalid type */ BLI_assert(wm_job->job_type != WM_JOB_TYPE_ANY); @@ -209,7 +209,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char * bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type) { wmJob *wm_job; - + /* job can be running or about to run (suspended) */ for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { if (wm_job->owner == owner) { @@ -227,10 +227,10 @@ bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type) float WM_jobs_progress(wmWindowManager *wm, void *owner) { wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY); - + if (wm_job && wm_job->flag & WM_JOB_PROGRESS) return wm_job->progress; - + return 0.0; } @@ -248,30 +248,30 @@ double WM_jobs_starttime(wmWindowManager *wm, void *owner) char *WM_jobs_name(wmWindowManager *wm, void *owner) { wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY); - + if (wm_job) return wm_job->name; - + return NULL; } void *WM_jobs_customdata(wmWindowManager *wm, void *owner) { wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY); - + if (wm_job) return WM_jobs_customdata_get(wm_job); - + return NULL; } void *WM_jobs_customdata_from_type(wmWindowManager *wm, int job_type) { wmJob *wm_job = wm_job_find(wm, NULL, job_type); - + if (wm_job) return WM_jobs_customdata_get(wm_job); - + return NULL; } @@ -301,7 +301,7 @@ void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void * /* pending job? just free */ if (wm_job->customdata) wm_job->free(wm_job->customdata); - + wm_job->customdata = customdata; wm_job->free = free; @@ -333,10 +333,10 @@ void WM_jobs_callbacks(wmJob *wm_job, static void *do_job_thread(void *job_v) { wmJob *wm_job = job_v; - + wm_job->startjob(wm_job->run_customdata, &wm_job->stop, &wm_job->do_update, &wm_job->progress); wm_job->ready = true; - + return NULL; } @@ -345,7 +345,7 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) { wmJob *wm_job; bool suspend = false; - + /* job added with suspend flag, we wait 1 timer step before activating it */ if (test->flag & WM_JOB_SUSPEND) { suspend = true; @@ -358,12 +358,12 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) if (wm_job == test || !wm_job->running) { continue; } - + /* if new job is not render, then check for same startjob */ if (0 == (test->flag & WM_JOB_EXCL_RENDER)) if (wm_job->startjob != test->startjob) continue; - + /* if new job is render, any render job should be stopped */ if (test->flag & WM_JOB_EXCL_RENDER) if (0 == (wm_job->flag & WM_JOB_EXCL_RENDER)) @@ -378,7 +378,7 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) } } } - + /* Possible suspend ourselves, waiting for other jobs, or de-suspend. */ test->suspended = suspend; // if (suspend) printf("job suspended: %s\n", test->name); @@ -396,11 +396,11 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job) // printf("job started a running job, ending... %s\n", wm_job->name); } else { - + if (wm_job->customdata && wm_job->startjob) { - + wm_jobs_test_suspend_stop(wm, wm_job); - + if (wm_job->suspended == false) { /* copy to ensure proper free in end */ wm_job->run_customdata = wm_job->customdata; @@ -408,20 +408,20 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job) wm_job->free = NULL; wm_job->customdata = NULL; wm_job->running = true; - + if (wm_job->initjob) wm_job->initjob(wm_job->run_customdata); - + wm_job->stop = false; wm_job->ready = false; wm_job->progress = 0.0; // printf("job started: %s\n", wm_job->name); - + BLI_threadpool_init(&wm_job->threads, do_job_thread, 1); BLI_threadpool_insert(&wm_job->threads, wm_job); } - + /* restarted job has timer already */ if (wm_job->wt == NULL) wm_job->wt = WM_event_add_timer(wm, wm_job->win, TIMERJOBS, wm_job->timestep); @@ -456,14 +456,14 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job) if (wm_job->endjob) wm_job->endjob(wm_job->run_customdata); } - + if (wm_job->wt) WM_event_remove_timer(wm, wm_job->win, wm_job->wt); if (wm_job->customdata) wm_job->free(wm_job->customdata); if (wm_job->run_customdata) wm_job->run_free(wm_job->run_customdata); - + /* remove wm_job */ wm_job_free(wm, wm_job); } @@ -472,17 +472,17 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job) void WM_jobs_kill_all(wmWindowManager *wm) { wmJob *wm_job; - + while ((wm_job = wm->jobs.first)) wm_jobs_kill_job(wm, wm_job); - + } /* wait until every job ended, except for one owner (used in undo to keep screen job alive) */ void WM_jobs_kill_all_except(wmWindowManager *wm, void *owner) { wmJob *wm_job, *next_job; - + for (wm_job = wm->jobs.first; wm_job; wm_job = next_job) { next_job = wm_job->next; @@ -495,7 +495,7 @@ void WM_jobs_kill_all_except(wmWindowManager *wm, void *owner) void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type) { wmJob *wm_job, *next_job; - + for (wm_job = wm->jobs.first; wm_job; wm_job = next_job) { next_job = wm_job->next; @@ -509,7 +509,7 @@ void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type) void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob) { wmJob *wm_job; - + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { if (wm_job->owner == owner || wm_job->startjob == startjob) { if (wm_job->running) { @@ -523,7 +523,7 @@ void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob) void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, short int *, short int *, float *)) { wmJob *wm_job; - + wm_job = wm->jobs.first; while (wm_job) { if (wm_job->owner == owner || wm_job->startjob == startjob) { @@ -542,7 +542,7 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, sho void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt) { wmJob *wm_job; - + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { if (wm_job->wt == wt) { wm_jobs_kill_job(wm, wm_job); @@ -557,18 +557,18 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) wmJob *wm_job, *wm_jobnext; float total_progress = 0.f; float jobs_progress = 0; - + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_jobnext) { wm_jobnext = wm_job->next; - + if (wm_job->wt == wt) { - + /* running threads */ if (wm_job->threads.first) { /* let threads get temporary lock over main thread if needed */ wm_job_main_thread_yield(wm_job); - + /* always call note and update when ready */ if (wm_job->do_update || wm_job->ready) { if (wm_job->update) @@ -580,7 +580,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) WM_event_add_notifier(C, NC_WM | ND_JOB, NULL); wm_job->do_update = false; } - + if (wm_job->ready) { if (wm_job->endjob) wm_job->endjob(wm_job->run_customdata); @@ -589,7 +589,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) wm_job->run_free(wm_job->run_customdata); wm_job->run_customdata = NULL; wm_job->run_free = NULL; - + // if (wm_job->stop) printf("job ready but stopped %s\n", wm_job->name); // else printf("job finished %s\n", wm_job->name); @@ -603,10 +603,10 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) WM_job_main_thread_lock_release(wm_job); BLI_threadpool_end(&wm_job->threads); WM_job_main_thread_lock_acquire(wm_job); - + if (wm_job->endnote) WM_event_add_notifier(C, wm_job->endnote, NULL); - + WM_event_add_notifier(C, NC_WM | ND_JOB, NULL); /* new job added for wm_job? */ @@ -617,7 +617,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) else { WM_event_remove_timer(wm, wm_job->win, wm_job->wt); wm_job->wt = NULL; - + /* remove wm_job */ wm_job_free(wm, wm_job); } @@ -640,8 +640,8 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) } } } - - + + /* if there are running jobs, set the global progress indicator */ if (jobs_progress > 0) { wmWindow *win; @@ -656,7 +656,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) for (win = wm->windows.first; win; win = win->next) WM_progress_clear(win); } - + } bool WM_jobs_has_running(wmWindowManager *wm) diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 1fcfcee0a4c..67493454e8f 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -238,7 +238,7 @@ static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi) kmdin->add_item = wm_keymap_item_copy(kmdi->add_item); if (kmdi->remove_item) kmdin->remove_item = wm_keymap_item_copy(kmdi->remove_item); - + return kmdin; } @@ -261,7 +261,7 @@ static void wm_keymap_diff_item_free(wmKeyMapDiffItem *kmdi) wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname) { wmKeyConfig *keyconf; - + keyconf = MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig"); BLI_strncpy(keyconf->idname, idname, sizeof(keyconf->idname)); BLI_addtail(&wm->keyconfigs, keyconf); @@ -316,7 +316,7 @@ static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm) keyconf = BLI_findstring(&wm->keyconfigs, U.keyconfigstr, offsetof(wmKeyConfig, idname)); if (keyconf) return keyconf; - + /* otherwise use default */ return wm->defaultconf; } @@ -457,16 +457,16 @@ static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi) wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) { wmKeyMapItem *kmi; - + for (kmi = keymap->items.first; kmi; kmi = kmi->next) if (STREQLEN(kmi->idname, idname, OP_MAX_TYPENAME)) break; if (kmi == NULL) { kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); - + BLI_addtail(&keymap->items, kmi); BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); - + keymap_item_set_id(keymap, kmi); keymap_event_set(kmi, type, val, modifier, keymodifier); @@ -479,7 +479,7 @@ wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int ty wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier) { wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); - + BLI_addtail(&keymap->items, kmi); BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); @@ -557,7 +557,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals(wmKeyMap *km, wmKeyMapItem *need for (kmi = km->items.first; kmi; kmi = kmi->next) if (wm_keymap_item_equals(kmi, needle)) return kmi; - + return NULL; } @@ -568,7 +568,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapIte for (kmi = km->items.first; kmi; kmi = kmi->next) if (wm_keymap_item_equals_result(kmi, needle)) return kmi; - + return NULL; } @@ -731,7 +731,7 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe /* add to list */ BLI_addtail(lb, km); - + return km; } @@ -779,7 +779,7 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap * /* ****************** storage in WM ************ */ -/* name id's are for storing general or multiple keymaps, +/* name id's are for storing general or multiple keymaps, * space/region ids are same as DNA_space_types.h */ /* gets freed in wm.c */ @@ -791,21 +791,21 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int if (km->spaceid == spaceid && km->regionid == regionid) if (STREQLEN(idname, km->idname, KMAP_MAX_NAME)) return km; - + return NULL; } wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) { wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); - + if (km == NULL) { km = wm_keymap_new(idname, spaceid, regionid); BLI_addtail(&keyconf->keymaps, km); WM_keyconfig_update_tag(km, NULL); } - + return km; } @@ -838,19 +838,19 @@ wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, const Enu } } } - + return km; } wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname) { wmKeyMap *km; - + for (km = keyconf->keymaps.first; km; km = km->next) if (km->flag & KEYMAP_MODAL) if (STREQLEN(idname, km->idname, KMAP_MAX_NAME)) break; - + return km; } @@ -858,10 +858,10 @@ wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname) wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value) { wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); - + BLI_addtail(&km->items, kmi); kmi->propvalue = value; - + keymap_event_set(kmi, type, val, modifier, keymodifier); keymap_item_set_id(km, kmi); @@ -1129,7 +1129,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers( /* skip disabled keymap items [T38447] */ if (kmi->flag & KMI_INACTIVE) continue; - + if (STREQ(kmi->idname, opname) && WM_key_event_string(kmi->type, false)[0]) { if (is_hotkey) { if (!ISHOTKEY(kmi->type)) @@ -1197,7 +1197,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers( } } } - + /* ensure un-initialized keymap is never used */ if (r_keymap) *r_keymap = NULL; return NULL; @@ -1231,7 +1231,7 @@ static wmKeyMapItem *wm_keymap_item_find_props( if (sa) { if (!(ar && ar->regiontype == RGN_TYPE_WINDOW)) ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - + if (ar) found = wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, is_strict, is_hotkey, r_keymap); } @@ -1447,7 +1447,7 @@ static bool wm_keymap_test_and_clear_update(wmKeyMap *km) { wmKeyMapItem *kmi; int update; - + update = (km->flag & KEYMAP_UPDATE); km->flag &= ~KEYMAP_UPDATE; @@ -1455,7 +1455,7 @@ static bool wm_keymap_test_and_clear_update(wmKeyMap *km) update = update || (kmi->flag & KMI_UPDATE); kmi->flag &= ~KMI_UPDATE; } - + return (update != 0); } @@ -1513,7 +1513,7 @@ void WM_keyconfig_update(wmWindowManager *wm) if (wm_keymap_update_flag == 0) return; - + /* update operator properties for non-modal user keymaps */ for (km = U.user_keymaps.first; km; km = km->next) { if ((km->flag & KEYMAP_MODAL) == 0) { @@ -1586,7 +1586,7 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap) if (!keymap) return NULL; - + /* first user defined keymaps */ km = WM_keymap_list_find(&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid); @@ -1678,13 +1678,13 @@ void WM_keymap_restore_to_default(wmKeyMap *keymap, bContext *C) wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id) { wmKeyMapItem *kmi; - + for (kmi = keymap->items.first; kmi; kmi = kmi->next) { if (kmi->id == id) { return kmi; } } - + return NULL; } @@ -1708,7 +1708,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) wmKeyMap *km = NULL; SpaceLink *sl = CTX_wm_space_data(C); - + /* Window */ if (STRPREFIX(opname, "WM_OT")) { km = WM_keymap_find_all(C, "Window", 0, 0); @@ -1735,8 +1735,8 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) { km = WM_keymap_find_all(C, "Window", 0, 0); } - - + + /* 3D View */ else if (STRPREFIX(opname, "VIEW3D_OT")) { km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0); @@ -1756,11 +1756,11 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) { km = WM_keymap_find_all(C, "Object Mode", 0, 0); } - + /* Editing Modes */ else if (STRPREFIX(opname, "MESH_OT")) { km = WM_keymap_find_all(C, "Mesh", 0, 0); - + /* some mesh operators are active in object mode too, like add-prim */ if (km && !WM_keymap_poll((bContext *)C, km)) { km = WM_keymap_find_all(C, "Object Mode", 0, 0); @@ -1770,7 +1770,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) STRPREFIX(opname, "SURFACE_OT")) { km = WM_keymap_find_all(C, "Curve", 0, 0); - + /* some curve operators are active in object mode too, like add-prim */ if (km && !WM_keymap_poll((bContext *)C, km)) { km = WM_keymap_find_all(C, "Object Mode", 0, 0); @@ -1798,7 +1798,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) } else if (STRPREFIX(opname, "MBALL_OT")) { km = WM_keymap_find_all(C, "Metaball", 0, 0); - + /* some mball operators are active in object mode too, like add-prim */ if (km && !WM_keymap_poll((bContext *)C, km)) { km = WM_keymap_find_all(C, "Object Mode", 0, 0); @@ -1939,7 +1939,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname) break; } } - + return km; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 27344c8da75..a61a7dd4324 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -252,15 +252,15 @@ static int wm_macro_exec(bContext *C, wmOperator *op) { wmOperator *opm; int retval = OPERATOR_FINISHED; - + wm_macro_start(op); for (opm = op->macro.first; opm; opm = opm->next) { - + if (opm->type->exec) { retval = opm->type->exec(C, opm); OPERATOR_RETVAL_CHECK(retval); - + if (retval & OPERATOR_FINISHED) { MacroData *md = op->customdata; md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ @@ -273,7 +273,7 @@ static int wm_macro_exec(bContext *C, wmOperator *op) CLOG_WARN(WM_LOG_OPERATORS, "'%s' cant exec macro", opm->type->idname); } } - + return wm_macro_end(op, retval); } @@ -291,7 +291,7 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, const wmEvent * OPERATOR_RETVAL_CHECK(retval); BLI_movelisttolist(&op->reports->list, &opm->reports->list); - + if (retval & OPERATOR_FINISHED) { MacroData *md = op->customdata; md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */ @@ -314,7 +314,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event) { wmOperator *opm = op->opm; int retval = OPERATOR_FINISHED; - + if (opm == NULL) { CLOG_ERROR(WM_LOG_OPERATORS, "macro error, calling NULL modal()"); } @@ -389,20 +389,20 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam { wmOperatorType *ot; const char *i18n_context; - + if (WM_operatortype_find(idname, true)) { CLOG_ERROR(WM_LOG_OPERATORS, "operator %s exists, cannot create macro", idname); return NULL; } - + ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); - + ot->idname = idname; ot->name = name; ot->description = description; ot->flag = OPTYPE_MACRO | flag; - + ot->exec = wm_macro_exec; ot->invoke = wm_macro_invoke; ot->modal = wm_macro_modal; @@ -411,7 +411,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam if (!ot->description) /* XXX All ops should have a description but for now allow them not to. */ ot->description = UNDOCUMENTED_OPERATOR_TIP; - + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname); /* Use i18n context from ext.srna if possible (py operators). */ @@ -479,7 +479,7 @@ wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char static void wm_operatortype_free_macro(wmOperatorType *ot) { wmOperatorTypeMacro *otmacro; - + for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) { if (otmacro->ptr) { WM_operator_properties_free(otmacro->ptr); @@ -598,7 +598,7 @@ void WM_operator_py_idname(char *to, const char *from) const char *sep = strstr(from, "_OT_"); if (sep) { int ofs = (sep - from); - + /* note, we use ascii tolower instead of system tolower, because the * latter depends on the locale, and can lead to idname mismatch */ memcpy(to, from, sizeof(char) * ofs); @@ -1317,7 +1317,7 @@ int WM_operator_confirm_message_ex(bContext *C, wmOperator *op, layout = UI_popup_menu_layout(pup); uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0, NULL); UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -1522,7 +1522,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN, UI_TEMPLATE_OP_PROPS_SHOW_TITLE); } - + UI_block_bounds_set_popup(block, 4, 0, 0); return block; @@ -1588,10 +1588,10 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_NUMSELECT); layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style); - + uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN, UI_TEMPLATE_OP_PROPS_SHOW_TITLE); - + /* clear so the OK button is left alone */ UI_block_func_set(block, NULL, NULL, NULL); @@ -1663,7 +1663,7 @@ static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval) if (op && retval > 0) WM_operator_call_ex(C, op, true); - + MEM_freeN(data); } @@ -1739,7 +1739,7 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(e int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, int height) { wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"); - + data->op = op; data->width = width; data->height = height; @@ -1763,7 +1763,7 @@ int WM_operator_redo_popup(bContext *C, wmOperator *op) BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context", op->type->idname); return OPERATOR_CANCELLED; } - + UI_popup_block_invoke(C, wm_block_create_redo, op); return OPERATOR_CANCELLED; @@ -1791,11 +1791,11 @@ static void WM_OT_debug_menu(wmOperatorType *ot) ot->name = "Debug Menu"; ot->idname = "WM_OT_debug_menu"; ot->description = "Open a popup to set the debug level"; - + ot->invoke = wm_debug_menu_invoke; ot->exec = wm_debug_menu_exec; ot->poll = WM_operator_winactive; - + RNA_def_int(ot->srna, "debug_value", 0, SHRT_MIN, SHRT_MAX, "Debug Value", "", -10000, 10000); } @@ -1898,7 +1898,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar /* Builds made from tag only shows tag sha */ BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash); BLI_snprintf(date_buf, sizeof(date_buf), "Date: %s %s", build_commit_date, build_commit_time); - + BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi); hash_width = (int)BLF_width(style->widgetlabel.uifont_id, hash_buf, sizeof(hash_buf)) + U.widget_unit; date_width = (int)BLF_width(style->widgetlabel.uifont_id, date_buf, sizeof(date_buf)) + U.widget_unit; @@ -2011,9 +2011,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar UI_but_flag_enable(but, 1); } #endif /* WITH_BUILDINFO */ - + layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, U.pixelsize * 480, U.pixelsize * 110, 0, style); - + UI_block_emboss_set(block, UI_EMBOSS); /* show the splash menu (containing interaction presets), using python */ if (mt) { @@ -2022,10 +2022,10 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar // wmWindowManager *wm = CTX_wm_manager(C); // uiItemM(layout, C, "USERPREF_MT_keyconfigs", U.keyconfigstr, ICON_NONE); } - + UI_block_emboss_set(block, UI_EMBOSS_PULLDOWN); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); - + split = uiLayoutSplit(layout, 0.0f, false); col = uiLayoutColumn(split, false); uiItemL(col, IFACE_("Links"), ICON_NONE); @@ -2071,21 +2071,21 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemS(col); uiItemO(col, NULL, ICON_RECOVER_LAST, "WM_OT_recover_last_session"); uiItemL(col, "", ICON_NONE); - + mt = WM_menutype_find("USERPREF_MT_splash_footer", false); if (mt) { UI_menutype_draw(C, mt, uiLayoutColumn(layout, false)); } UI_block_bounds_set_centered(block, 0); - + return block; } static int wm_splash_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { UI_popup_block_invoke(C, wm_block_create_splash, NULL); - + return OPERATOR_FINISHED; } @@ -2094,7 +2094,7 @@ static void WM_OT_splash(wmOperatorType *ot) ot->name = "Splash Screen"; ot->idname = "WM_OT_splash"; ot->description = "Open the splash screen with release info"; - + ot->invoke = wm_splash_invoke; ot->poll = WM_operator_winactive; } @@ -2114,26 +2114,26 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *userdata) wmWindow *win = CTX_wm_window(C); uiBlock *block; uiBut *but; - + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); - + but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, init_data->size[0], UI_UNIT_Y, 0, 0, ""); UI_but_func_operator_search(but); - + /* fake button, it holds space for search items */ uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - init_data->size[1], init_data->size[0], init_data->size[1], NULL, 0, 0, 0, 0, NULL); - + UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ - + wm_event_init_from_window(win, &event); event.type = EVT_BUT_OPEN; event.val = KM_PRESS; event.customdata = but; event.customdatafree = false; wm_event_add(win, &event); - + return block; } @@ -2152,7 +2152,7 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv }; UI_popup_block_invoke(C, wm_block_search_menu, &data); - + return OPERATOR_INTERFACE; } @@ -2181,7 +2181,7 @@ static void WM_OT_search_menu(wmOperatorType *ot) ot->name = "Search Menu"; ot->idname = "WM_OT_search_menu"; ot->description = "Pop-up a search menu over all available operators in current context"; - + ot->invoke = wm_search_menu_invoke; ot->exec = wm_search_menu_exec; ot->poll = wm_search_menu_poll; @@ -2372,7 +2372,7 @@ static void WM_OT_console_toggle(wmOperatorType *ot) ot->name = CTX_N_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Toggle System Console"); ot->idname = "WM_OT_console_toggle"; ot->description = N_("Toggle System Console"); - + ot->exec = wm_console_toggle_exec; ot->poll = WM_operator_winactive; } @@ -2390,20 +2390,20 @@ void *WM_paint_cursor_activate(wmWindowManager *wm, int (*poll)(bContext *C), wmPaintCursorDraw draw, void *customdata) { wmPaintCursor *pc = MEM_callocN(sizeof(wmPaintCursor), "paint cursor"); - + BLI_addtail(&wm->paintcursors, pc); - + pc->customdata = customdata; pc->poll = poll; pc->draw = draw; - + return pc; } void WM_paint_cursor_end(wmWindowManager *wm, void *handle) { wmPaintCursor *pc; - + for (pc = wm->paintcursors.first; pc; pc = pc->next) { if (pc == (wmPaintCursor *)handle) { BLI_remlink(&wm->paintcursors, pc); @@ -2446,7 +2446,7 @@ static void radial_control_update_header(wmOperator *op, bContext *C) char msg[UI_MAX_DRAW_STR]; ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); - + if (sa) { if (hasNumInput(&rc->num_input)) { char num_str[NUM_STR_REP_LEN]; @@ -2563,7 +2563,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph RNA_property_float_get_array(fill_ptr, fill_prop, col); } - + Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -2600,10 +2600,10 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph immAttrib2f(texCoord, 1, 0); immVertex2f(pos, radius, -radius); - + immAttrib2f(texCoord, 1, 1); immVertex2f(pos, radius, radius); - + immAttrib2f(texCoord, 0, 1); immVertex2f(pos, -radius, radius); @@ -2619,7 +2619,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph immUniformColor3fvAlpha(col, alpha); imm_draw_circle_fill_2d(pos, 0.0f, 0.0f, radius, 40); } - + immUnbindProgram(); } @@ -2634,7 +2634,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void short strdrawlen = 0; float strwidth, strheight; float r1 = 0.0f, r2 = 0.0f, rmin = 0.0, tex_radius, alpha; - float zoom[2], col[3] = {1, 1, 1}; + float zoom[2], col[3] = {1, 1, 1}; switch (rc->subtype) { case PROP_NONE: @@ -2808,7 +2808,7 @@ static int radial_control_get_path( return 0; } } - + /* check property's array length */ if (*r_prop && (len = RNA_property_array_length(r_ptr, *r_prop)) != req_length) { MEM_freeN(str); @@ -2857,7 +2857,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) /* data path is required */ if (!rc->prop) return 0; - + if (!radial_control_get_path(&ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 0, RC_PROP_REQUIRE_FLOAT)) return 0; if (!radial_control_get_path(&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 3, RC_PROP_REQUIRE_FLOAT)) @@ -2892,7 +2892,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) { return 0; } - + if (!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0)) return 0; else if (rc->image_id_ptr.data) { @@ -3015,7 +3015,7 @@ static void radial_control_cancel(bContext *C, wmOperator *op) if (sa) { ED_area_headerprint(sa, NULL); } - + WM_paint_cursor_end(wm, rc->cursor); /* restore original paint cursors */ @@ -3056,10 +3056,10 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even if (numValue < 0.0f) numValue += 2.0f * (float)M_PI; } - + CLAMP(numValue, rc->min_value, rc->max_value); new_value = numValue; - + radial_control_set_value(rc, new_value); rc->current_value = new_value; radial_control_update_header(op, C); @@ -3210,9 +3210,9 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even CLAMP(numValue, rc->min_value, rc->max_value); new_value = numValue; - + radial_control_set_value(rc, new_value); - + rc->current_value = new_value; radial_control_update_header(op, C); return OPERATOR_RUNNING_MODAL; @@ -3416,7 +3416,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) a = 0; } } - + time_delta = (PIL_check_seconds_timer() - time_start) * 1000; RNA_enum_description(redraw_timer_type_items, type, &infostr); @@ -3426,7 +3426,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_WARNING, "%d x %s: %.4f ms, average: %.8f ms", iter_steps, infostr, time_delta, time_delta / iter_steps); - + return OPERATOR_FINISHED; } @@ -3460,7 +3460,7 @@ static void WM_OT_memory_statistics(wmOperatorType *ot) ot->name = "Memory Statistics"; ot->idname = "WM_OT_memory_statistics"; ot->description = "Print memory statistics to the console"; - + ot->exec = memory_statistics_exec; } @@ -3825,21 +3825,21 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf) {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""}, {0, NULL, 0, NULL, NULL} }; - + wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Straight Line"); - + /* this function is called for each spacetype, only needs to add map once */ if (keymap && keymap->modal_items) return; - + keymap = WM_modalkeymap_add(keyconf, "Gesture Straight Line", modal_items); - + /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, GESTURE_MODAL_CANCEL); - + WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT); - + /* assign map to operators */ WM_modalkeymap_assign(keymap, "IMAGE_OT_sample_line"); WM_modalkeymap_assign(keymap, "PAINT_OT_weight_gradient"); @@ -3867,7 +3867,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); - + /* Note: cancel only on press otherwise you cannot map this to RMB-gesture */ WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT); @@ -3879,10 +3879,10 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) /* any unhandled leftclick release handles select */ WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT); - + WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN); WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_DESELECT); - + /* assign map to operators */ WM_modalkeymap_assign(keymap, "ACTION_OT_select_border"); WM_modalkeymap_assign(keymap, "ANIM_OT_channels_select_border"); @@ -3936,7 +3936,7 @@ static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, GESTURE_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN); - WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_IN); + WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_IN); WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN); WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_OUT); @@ -3952,7 +3952,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0); wmKeyMapItem *kmi; - + /* note, this doesn't replace existing keymap items */ WM_keymap_verify_item(keymap, "WM_OT_window_new", WKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); #ifdef __APPLE__ @@ -3964,7 +3964,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "WM_OT_quit_blender", QKEY, KM_PRESS, KM_OSKEY, 0); #endif WM_keymap_add_item(keymap, "WM_OT_read_homefile", NKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "WM_OT_save_homefile", UKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "INFO_MT_file_open_recent", OKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_open_mainfile", OKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "WM_OT_open_mainfile", F1KEY, KM_PRESS, 0, 0); @@ -4037,7 +4037,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", F12KEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "area.type"); RNA_string_set(kmi->ptr, "value", "DOPESHEET_EDITOR"); - + #ifdef WITH_INPUT_NDOF /* ndof speed */ const char *data_path = "user_preferences.inputs.ndof_sensitivity"; diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index d6a1eb81981..d93d51df105 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -101,7 +101,7 @@ typedef struct PlayState { /* window and viewport size */ int win_x, win_y; - + /* current zoom level */ float zoom; @@ -122,7 +122,7 @@ typedef struct PlayState { bool loading; /* x/y image flip */ bool draw_flip[2]; - + int fstep; /* current picture */ @@ -134,7 +134,7 @@ typedef struct PlayState { /* saves passing args */ struct ImBuf *curframe_ibuf; - + /* restarts player for file drop */ char dropped_file[FILE_MAX]; } PlayState; @@ -946,13 +946,13 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) { GHOST_TEventButtonData *bd = GHOST_GetEventData(evt); int cx, cy, sizex, sizey, inside_window; - + GHOST_GetCursorPosition(g_WS.ghost_system, &cx, &cy); GHOST_ScreenToClient(g_WS.ghost_window, cx, cy, &cx, &cy); playanim_window_get_size(&sizex, &sizey); inside_window = (cx >= 0 && cx < sizex && cy >= 0 && cy <= sizey); - + if (bd->button == GHOST_kButtonMaskLeft) { if (type == GHOST_kEventButtonDown) { if (inside_window) { @@ -1016,23 +1016,23 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) case GHOST_kEventWindowMove: { float zoomx, zoomy; - + playanim_window_get_size(&ps->win_x, &ps->win_y); GHOST_ActivateWindowDrawingContext(g_WS.ghost_window); zoomx = (float) ps->win_x / ps->ibufx; zoomy = (float) ps->win_y / ps->ibufy; - + /* zoom always show entire image */ ps->zoom = MIN2(zoomx, zoomy); - + /* zoom steps of 2 for speed */ ps->zoom = floor(ps->zoom + 0.5f); if (ps->zoom < 1.0f) ps->zoom = 1.0f; - + glViewport(0, 0, ps->win_x, ps->win_y); glScissor(0, 0, ps->win_x, ps->win_y); - + playanim_gl_matrix(); ptottime = 0.0; @@ -1049,11 +1049,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) case GHOST_kEventDraggingDropDone: { GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt); - + if (ddd->dataType == GHOST_kDragnDropTypeFilenames) { GHOST_TStringArray *stra = ddd->data; int a; - + for (a = 0; a < stra->count; a++) { BLI_strncpy(ps->dropped_file, (char *)stra->strings[a], sizeof(ps->dropped_file)); ps->go = false; @@ -1120,7 +1120,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) int sfra = -1; int efra = -1; int totblock; - + PlayState ps = {0}; /* ps.doubleb = true;*/ /* UNUSED */ @@ -1271,14 +1271,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv) ps.ibufx = ibuf->x; ps.ibufy = ibuf->y; - + ps.win_x = ps.ibufx; ps.win_y = ps.ibufy; if (maxwinx % ibuf->x) maxwinx = ibuf->x * (1 + (maxwinx / ibuf->x)); if (maxwiny % ibuf->y) maxwiny = ibuf->y * (1 + (maxwiny / ibuf->y)); - + glClearColor(0.1, 0.1, 0.1, 0.0); glClear(GL_COLOR_BUFFER_BIT); @@ -1547,7 +1547,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) BLI_strncpy(filepath, ps.dropped_file, sizeof(filepath)); return filepath; } - + IMB_exit(); BKE_images_exit(); DEG_free_node_types(); @@ -1560,7 +1560,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) MEM_printmemlist(); #endif } - + return NULL; } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 676bcb1aa5c..5bc4b060425 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -35,7 +35,7 @@ #include <stdio.h> #include <string.h> -#include "DNA_listBase.h" +#include "DNA_listBase.h" #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" #include "DNA_workspace_types.h" @@ -113,7 +113,7 @@ static struct WMInitStruct { int windowstate; WinOverrideFlag override_flag; - + bool native_pixels; } wm_init_state = {0, 0, 0, 0, GHOST_kWindowStateNormal, 0, true}; @@ -125,7 +125,7 @@ void wm_get_screensize(int *r_width, int *r_height) { unsigned int uiwidth; unsigned int uiheight; - + GHOST_GetMainDisplayDimensions(g_system, &uiwidth, &uiheight); *r_width = uiwidth; *r_height = uiheight; @@ -147,9 +147,9 @@ void wm_get_desktopsize(int *r_width, int *r_height) static void wm_window_check_position(rcti *rect) { int width, height, d; - + wm_get_screensize(&width, &height); - + if (rect->xmin < 0) { rect->xmax -= rect->xmin; rect->xmin = 0; @@ -168,7 +168,7 @@ static void wm_window_check_position(rcti *rect) rect->ymax -= d; rect->ymin -= d; } - + if (rect->xmin < 0) rect->xmin = 0; if (rect->ymin < 0) rect->ymin = 0; } @@ -194,12 +194,12 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win) } } -/* including window itself, C can be NULL. +/* including window itself, C can be NULL. * ED_screen_exit should have been called */ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) { wmTimer *wt, *wtnext; - + /* update context */ if (C) { WM_event_remove_handlers(C, &win->handlers); @@ -217,7 +217,7 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) if (wt->win == win && wt->event_type == TIMERJOBS) wm_jobs_timer_ended(wm, wt); } - + /* timer removing, need to call this api function */ for (wt = wm->timers.first; wt; wt = wtnext) { wtnext = wt->next; @@ -226,7 +226,7 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) } if (win->eventstate) MEM_freeN(win->eventstate); - + wm_event_free_all(win); wm_ghostwindow_destroy(wm, win); @@ -241,11 +241,11 @@ static int find_free_winid(wmWindowManager *wm) { wmWindow *win; int id = 1; - + for (win = wm->windows.first; win; win = win->next) if (id <= win->winid) id = win->winid + 1; - + return id; } @@ -486,7 +486,7 @@ void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win) void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) { wmWindow *tmpwin; - + /* first check if we have to quit (there are non-temp remaining windows) */ for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) { if (tmpwin == win) @@ -504,7 +504,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) WorkSpaceLayout *layout = BKE_workspace_active_layout_get(win->workspace_hook); BLI_remlink(&wm->windows, win); - + CTX_wm_window_set(C, win); /* needed by handlers */ WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->modalhandlers); @@ -562,7 +562,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) * and to give hint of unsaved changes for a user warning mechanism * in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */ GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8) !wm->file_saved); - + } } @@ -628,7 +628,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm GHOST_WindowHandle ghostwin; GHOST_GLSettings glSettings = {0}; int scr_w, scr_h, posy; - + /* a new window is created when pageflip mode is required for a window */ if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) glSettings.flags |= GHOST_glStereoVisual; @@ -639,7 +639,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm wm_get_screensize(&scr_w, &scr_h); posy = (scr_h - win->posy - win->sizey); - + ghostwin = GHOST_CreateWindow(g_system, title, win->posx, posy, win->sizex, win->sizey, (GHOST_TWindowState)win->windowstate, @@ -655,16 +655,16 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm gpu_batch_presets_reset(); win->gwnctx = GWN_context_create(); - + /* the new window has already been made drawable upon creation */ wm->windrawable = win; /* needed so we can detect the graphics card below */ GPU_init(); - + win->ghostwin = ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ - + wm_window_ensure_eventstate(win); /* store actual window size in blender window */ @@ -676,7 +676,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm win->sizey = GHOST_GetHeightRectangle(bounds); } GHOST_DisposeRectangle(bounds); - + #ifndef __APPLE__ /* set the state here, so minimized state comes up correct on windows */ GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); @@ -687,14 +687,14 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); } - + /* needed here, because it's used before it reads userdef */ WM_window_set_dpi(win); - + wm_window_swap_buffers(win); - + //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified); - + /* standard state vars for window */ GPU_state_init(); } @@ -717,7 +717,7 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm) { wmKeyMap *keymap; wmWindow *win; - + BLI_assert(G.background == false); /* no commandline prefsize? then we set this. @@ -726,7 +726,7 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm) */ if (wm_init_state.size_x == 0) { wm_get_screensize(&wm_init_state.size_x, &wm_init_state.size_y); - + /* note!, this isnt quite correct, active screen maybe offset 1000s if PX, * we'd need a wm_get_screensize like function that gives offset, * in practice the window manager will likely move to the correct monitor */ @@ -744,7 +744,7 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm) wm_init_state.size_y -= WM_WIN_INIT_PAD * 2; #endif } - + for (win = wm->windows.first; win; win = win->next) { if (win->ghostwin == NULL) { if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) { @@ -775,13 +775,13 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm) /* add keymap handlers (1 handler for all keys in map!) */ keymap = WM_keymap_find(wm->defaultconf, "Window", 0, 0); WM_event_add_keymap_handler(&win->handlers, keymap); - + keymap = WM_keymap_find(wm->defaultconf, "Screen", 0, 0); WM_event_add_keymap_handler(&win->handlers, keymap); keymap = WM_keymap_find(wm->defaultconf, "Screen Editing", 0, 0); WM_event_add_keymap_handler(&win->modalhandlers, keymap); - + /* add drop boxes */ { ListBase *lb = WM_dropboxmap_find("Window", 0, 0); @@ -824,7 +824,7 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect) { wmWindow *win_prev = CTX_wm_window(C); wmWindow *win = wm_window_new(C); - + win->posx = rect->xmin; win->posy = rect->ymin; win->sizex = BLI_rcti_size_x(rect); @@ -875,16 +875,16 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i /* changes rect to fit within desktop */ wm_window_check_position(&rect); - + /* test if we have a temp screen already */ for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) if (WM_window_is_temp_screen(win)) break; - + /* add new window? */ if (win == NULL) { win = wm_window_new(C); - + win->posx = rect.xmin; win->posy = rect.ymin; } @@ -936,7 +936,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i /* ensure it shows the right spacetype editor */ sa = screen->areabase.first; CTX_wm_area_set(C, sa); - + if (type == WM_WINDOW_RENDER) { ED_area_newspace(C, sa, SPACE_IMAGE, false); } @@ -946,26 +946,26 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i else { ED_area_newspace(C, sa, SPACE_USERPREF, false); } - + ED_screen_change(C, screen); ED_screen_refresh(CTX_wm_manager(C), win); /* test scale */ - + /* do additional setup for specific editor type */ if (type == WM_WINDOW_DRIVERS) { /* Configure editor - mode, tabs, framing */ SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; sipo->mode = SIPO_MODE_DRIVERS; - + ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar_props) { UI_panel_category_active_set(ar_props, "Drivers"); - + ar_props->flag &= ~RGN_FLAG_HIDDEN; /* XXX: Adjust width of this too? */ - + ED_region_visibility_change_update(C, ar_props); } - + ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (ar_main) { /* XXX: Ideally we recenter based on the range instead... */ @@ -973,11 +973,11 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i ar_main->v2d.tot.ymin = -2.0f; ar_main->v2d.tot.xmax = 2.0f; ar_main->v2d.tot.ymax = 2.0f; - + ar_main->v2d.cur = ar_main->v2d.tot; } } - + if (sa->spacetype == SPACE_IMAGE) title = IFACE_("Blender Render"); else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF)) @@ -1133,7 +1133,7 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal); return OPERATOR_FINISHED; - + } @@ -1142,10 +1142,10 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) void wm_cursor_position_from_ghost(wmWindow *win, int *x, int *y) { float fac = GHOST_GetNativePixelSize(win->ghostwin); - + GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y); *x *= fac; - + *y = (win->sizey - 1) - *y; *y *= fac; } @@ -1175,11 +1175,11 @@ typedef enum { } modifierKeyType; /* check if specified modifier key type is pressed */ -static int query_qual(modifierKeyType qual) +static int query_qual(modifierKeyType qual) { GHOST_TModifierKeyMask left, right; int val = 0; - + switch (qual) { case SHIFT: left = GHOST_kModifierKeyLeftShift; @@ -1198,15 +1198,15 @@ static int query_qual(modifierKeyType qual) right = GHOST_kModifierKeyRightAlt; break; } - + GHOST_GetModifierKeyState(g_system, left, &val); if (!val) GHOST_GetModifierKeyState(g_system, right, &val); - + return val; } -void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) +void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) { BLI_assert(GPU_framebuffer_current_get() == 0); @@ -1260,7 +1260,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr wmWindowManager *wm = CTX_wm_manager(C); GHOST_TEventType type = GHOST_GetEventType(evt); int time = GHOST_GetEventTime(evt); - + if (type == GHOST_kEventQuit) { WM_exit(C); } @@ -1268,7 +1268,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr GHOST_WindowHandle ghostwin = GHOST_GetEventWindow(evt); GHOST_TEventDataPtr data = GHOST_GetEventData(evt); wmWindow *win; - + /* Ghost now can call this function for life resizes, but it should return if WM didn't initialize yet. * Can happen on file read (especially full size window) */ if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) { @@ -1289,12 +1289,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr else { win = GHOST_GetWindowUserData(ghostwin); } - + switch (type) { case GHOST_kEventWindowDeactivate: wm_event_add_ghostevent(wm, win, type, time, data); win->active = 0; /* XXX */ - + /* clear modifiers for inactive windows */ win->eventstate->alt = 0; win->eventstate->ctrl = 0; @@ -1303,7 +1303,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr win->eventstate->keymodifier = 0; break; - case GHOST_kEventWindowActivate: + case GHOST_kEventWindowActivate: { GHOST_TEventKeyData kdata; wmEvent event; @@ -1319,10 +1319,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr #endif wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */ - + win->active = 1; // window_handle(win, INPUTCHANGE, win->active); - + /* bad ghost support for modifier keys... so on activate we set the modifiers again */ /* TODO: This is not correct since a modifier may be held when a window is activated... @@ -1391,15 +1391,15 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr /* keymodifier zero, it hangs on hotkeys that open windows otherwise */ win->eventstate->keymodifier = 0; - + /* entering window, update mouse pos. but no event */ wm_get_cursor_position(win, &wx, &wy); win->eventstate->x = wx; win->eventstate->y = wy; - + win->addmousemove = 1; /* enables highlighted buttons */ - + wm_window_make_drawable(wm, win); /* window might be focused by mouse click in configuration of window manager @@ -1430,7 +1430,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr if (G.debug & G_DEBUG_EVENTS) { printf("%s: ghost redraw %d\n", __func__, win->winid); } - + wm_window_make_drawable(wm, win); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -1449,18 +1449,18 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr } WM_window_set_dpi(win); - + /* win32: gives undefined window size when minimized */ if (state != GHOST_kWindowStateMinimized) { GHOST_RectangleHandle client_rect; int l, t, r, b, scr_w, scr_h; int sizex, sizey, posx, posy; - + client_rect = GHOST_GetClientBounds(win->ghostwin); GHOST_GetRectangle(client_rect, &l, &t, &r, &b); - + GHOST_DisposeRectangle(client_rect); - + wm_get_desktopsize(&scr_w, &scr_h); sizex = r - l; sizey = b - t; @@ -1471,8 +1471,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr * Ghost sometimes send size or move events when the window hasn't changed. * One case of this is using compiz on linux. To alleviate the problem * we ignore all such event here. - * - * It might be good to eventually do that at Ghost level, but that is for + * + * It might be good to eventually do that at Ghost level, but that is for * another time. */ if (win->sizex != sizex || @@ -1515,12 +1515,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr win->posx, win->posy, win->sizex, win->sizey); } } - + wm_window_make_drawable(wm, win); BKE_icon_changed(screen->id.icon_id); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); - + #if defined(__APPLE__) || defined(WIN32) /* OSX and Win32 don't return to the mainloop while resize */ wm_event_do_notifiers(C); @@ -1551,19 +1551,19 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr PointerRNA props_ptr; wmWindow *oldWindow; const char *path = GHOST_GetEventData(evt); - + if (path) { wmOperatorType *ot = WM_operatortype_find("WM_OT_open_mainfile", false); /* operator needs a valid window in context, ensures * it is correctly set */ oldWindow = CTX_wm_window(C); CTX_wm_window_set(C, win); - + WM_operator_properties_create_ptr(&props_ptr, ot); RNA_string_set(&props_ptr, "filepath", path); WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &props_ptr); WM_operator_properties_free(&props_ptr); - + CTX_wm_window_set(C, oldWindow); } break; @@ -1573,53 +1573,53 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr wmEvent event; GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt); int wx, wy; - + /* entering window, update mouse pos */ wm_get_cursor_position(win, &wx, &wy); win->eventstate->x = wx; win->eventstate->y = wy; - + wm_event_init_from_window(win, &event); /* 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_DRAGDROP; event.customdata = &wm->drags; event.customdatafree = 1; - + wm_event_add(win, &event); - + /* printf("Drop detected\n"); */ - + /* add drag data to wm for paths: */ - + if (ddd->dataType == GHOST_kDragnDropTypeFilenames) { GHOST_TStringArray *stra = ddd->data; int a, icon; - + for (a = 0; a < stra->count; a++) { printf("drop file %s\n", stra->strings[a]); /* try to get icon type from extension */ icon = ED_file_extension_icon((char *)stra->strings[a]); - + WM_event_start_drag(C, icon, WM_DRAG_PATH, stra->strings[a], 0.0, WM_DRAG_NOP); /* void poin should point to string, it makes a copy */ break; /* only one drop element supported now */ } } - + break; } case GHOST_kEventNativeResolutionChange: @@ -1649,7 +1649,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr case GHOST_kEventTrackpad: { GHOST_TEventTrackpadData *pd = data; - + wm_cursor_position_from_ghost(win, &pd->x, &pd->y); wm_event_add_ghostevent(wm, win, type, time, data); break; @@ -1657,7 +1657,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr case GHOST_kEventCursorMove: { GHOST_TEventCursorData *cd = data; - + wm_cursor_position_from_ghost(win, &cd->x, &cd->y); wm_event_add_ghostevent(wm, win, type, time, data); break; @@ -1685,7 +1685,7 @@ static int wm_window_timer(const bContext *C) wmWindow *win; double time = PIL_check_seconds_timer(); int retval = 0; - + for (wt = wm->timers.first; wt; wt = wtnext) { wtnext = wt->next; /* in case timer gets removed */ win = wt->win; @@ -1706,7 +1706,7 @@ static int wm_window_timer(const bContext *C) else if (win) { wmEvent event; wm_event_init_from_window(win, &event); - + event.type = wt->event_type; event.val = KM_NOTHING; event.keymodifier = 0; @@ -1722,7 +1722,7 @@ static int wm_window_timer(const bContext *C) return retval; } -void wm_window_process_events(const bContext *C) +void wm_window_process_events(const bContext *C) { int hasevent; @@ -1732,7 +1732,7 @@ void wm_window_process_events(const bContext *C) if (hasevent) GHOST_DispatchEvents(g_system); - + hasevent |= wm_window_timer(C); /* no event, we sleep 5 milliseconds */ @@ -1740,7 +1740,7 @@ void wm_window_process_events(const bContext *C) PIL_sleep_ms(5); } -void wm_window_process_events_nosleep(void) +void wm_window_process_events_nosleep(void) { if (GHOST_ProcessEvents(g_system, 0)) GHOST_DispatchEvents(g_system); @@ -1759,10 +1759,10 @@ void wm_window_testbreak(void) */ if ((curtime - ltime) > 0.05) { int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ - + if (hasevent) GHOST_DispatchEvents(g_system); - + ltime = curtime; } } @@ -1779,13 +1779,13 @@ void wm_ghost_init(bContext *C) if (C != NULL) { consumer = GHOST_CreateEventConsumer(ghost_event_proc, C); } - + g_system = GHOST_CreateSystem(); if (C != NULL) { GHOST_AddEventConsumer(g_system, consumer); } - + if (wm_init_state.native_pixels) { GHOST_UseNativePixels(); } @@ -1806,7 +1806,7 @@ void wm_ghost_exit(void) void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer, bool do_sleep) { wmTimer *wt; - + for (wt = wm->timers.first; wt; wt = wt->next) if (wt == timer) break; @@ -1825,9 +1825,9 @@ wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, wt->stime = wt->ltime; wt->timestep = timestep; wt->win = win; - + BLI_addtail(&wm->timers, wt); - + return wt; } @@ -1852,23 +1852,23 @@ wmTimer *WM_event_add_timer_notifier(wmWindowManager *wm, wmWindow *win, unsigne void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer) { wmTimer *wt; - + /* extra security check */ for (wt = wm->timers.first; wt; wt = wt->next) if (wt == timer) break; if (wt) { wmWindow *win; - + if (wm->reports.reporttimer == wt) wm->reports.reporttimer = NULL; - + BLI_remlink(&wm->timers, wt); if (wt->customdata != NULL && (wt->flags & WM_TIMER_NO_FREE_CUSTOM_DATA) == 0) { MEM_freeN(wt->customdata); } MEM_freeN(wt); - + /* there might be events in queue with this timer as customdata */ for (win = wm->windows.first; win; win = win->next) { wmEvent *event; @@ -1905,7 +1905,7 @@ static char *wm_clipboard_text_get_ex(bool selection, int *r_len, *r_len = 0; return NULL; } - + /* always convert from \r\n to \n */ p2 = newbuf = MEM_mallocN(strlen(buf) + 1, __func__); @@ -1931,7 +1931,7 @@ static char *wm_clipboard_text_get_ex(bool selection, int *r_len, *p2 = '\0'; free(buf); /* ghost uses regular malloc */ - + *r_len = (p2 - newbuf); return newbuf; @@ -1963,16 +1963,16 @@ void WM_clipboard_text_set(const char *buf, bool selection) const char *p; char *p2, *newbuf; int newlen = 0; - + for (p = buf; *p; p++) { if (*p == '\n') newlen += 2; else newlen++; } - + newbuf = MEM_callocN(newlen + 1, "WM_clipboard_text_set"); - + for (p = buf, p2 = newbuf; *p; p++, p2++) { if (*p == '\n') { *(p2++) = '\r'; *p2 = '\n'; @@ -1982,7 +1982,7 @@ void WM_clipboard_text_set(const char *buf, bool selection) } } *p2 = '\0'; - + GHOST_putClipboard((GHOST_TInt8 *)newbuf, selection); MEM_freeN(newbuf); #else @@ -2011,17 +2011,17 @@ void wm_window_get_position(wmWindow *win, int *r_pos_x, int *r_pos_y) *r_pos_y = win->posy; } -void wm_window_set_size(wmWindow *win, int width, int height) +void wm_window_set_size(wmWindow *win, int width, int height) { GHOST_SetClientSize(win->ghostwin, width, height); } -void wm_window_lower(wmWindow *win) +void wm_window_lower(wmWindow *win) { GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderBottom); } -void wm_window_raise(wmWindow *win) +void wm_window_raise(wmWindow *win) { GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderTop); } @@ -2123,13 +2123,13 @@ float WM_cursor_pressure(const struct wmWindow *win) int WM_window_pixels_x(const wmWindow *win) { float f = GHOST_GetNativePixelSize(win->ghostwin); - + return (int)(f * (float)win->sizex); } int WM_window_pixels_y(const wmWindow *win) { float f = GHOST_GetNativePixelSize(win->ghostwin); - + return (int)(f * (float)win->sizey); } |