Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_event_system.c
| Show First 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Notifiers & Listeners | /** \name Notifiers & Listeners | ||||
| * \{ */ | * \{ */ | ||||
| static bool wm_test_duplicate_notifier(const wmWindowManager *wm, uint type, void *reference) | static bool wm_test_duplicate_notifier(const wmWindowManager *wm, uint type, void *reference) | ||||
| { | { | ||||
| for (wmNotifier *note = wm->queue.first; note; note = note->next) { | LISTBASE_FOREACH (wmNotifier *, note, &wm->queue) { | ||||
| if ((note->category | note->data | note->subtype | note->action) == type && | if ((note->category | note->data | note->subtype | note->action) == type && | ||||
| note->reference == reference) { | note->reference == reference) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | void wm_event_do_depsgraph(bContext *C, bool is_after_open_file) | ||||
| * thread to modify the same data. Because of this, we can not perform | * thread to modify the same data. Because of this, we can not perform | ||||
| * dependency graph update. | * dependency graph update. | ||||
| */ | */ | ||||
| if (wm->is_interface_locked) { | if (wm->is_interface_locked) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* Combine datamasks so 1 win doesn't disable UV's in another [#26448]. */ | /* Combine datamasks so 1 win doesn't disable UV's in another [#26448]. */ | ||||
| CustomData_MeshMasks win_combine_v3d_datamask = {0}; | CustomData_MeshMasks win_combine_v3d_datamask = {0}; | ||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| const Scene *scene = WM_window_get_active_scene(win); | const Scene *scene = WM_window_get_active_scene(win); | ||||
| const bScreen *screen = WM_window_get_active_screen(win); | const bScreen *screen = WM_window_get_active_screen(win); | ||||
| ED_view3d_screen_datamask(C, scene, screen, &win_combine_v3d_datamask); | ED_view3d_screen_datamask(C, scene, screen, &win_combine_v3d_datamask); | ||||
| } | } | ||||
| /* Update all the dependency graphs of visible view layers. */ | /* Update all the dependency graphs of visible view layers. */ | ||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| Scene *scene = WM_window_get_active_scene(win); | Scene *scene = WM_window_get_active_scene(win); | ||||
| ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| /* Copied to set's in scene_update_tagged_recursive() */ | /* Copied to set's in scene_update_tagged_recursive() */ | ||||
| scene->customdata_mask = win_combine_v3d_datamask; | scene->customdata_mask = win_combine_v3d_datamask; | ||||
| /* XXX, hack so operators can enforce datamasks [#26482], gl render */ | /* XXX, hack so operators can enforce datamasks [#26482], gl render */ | ||||
| CustomData_MeshMasks_update(&scene->customdata_mask, &scene->customdata_mask_modal); | CustomData_MeshMasks_update(&scene->customdata_mask, &scene->customdata_mask_modal); | ||||
| /* TODO(sergey): For now all dependency graphs which are evaluated from | /* TODO(sergey): For now all dependency graphs which are evaluated from | ||||
| Show All 16 Lines | |||||
| * Was part of #wm_event_do_notifiers, | * Was part of #wm_event_do_notifiers, | ||||
| * split out so it can be called once before entering the #WM_main loop. | * split out so it can be called once before entering the #WM_main loop. | ||||
| * This ensures operators don't run before the UI and depsgraph are initialized. | * This ensures operators don't run before the UI and depsgraph are initialized. | ||||
| */ | */ | ||||
| void wm_event_do_refresh_wm_and_depsgraph(bContext *C) | void wm_event_do_refresh_wm_and_depsgraph(bContext *C) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| /* cached: editor refresh callbacks now, they get context */ | /* cached: editor refresh callbacks now, they get context */ | ||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| const bScreen *screen = WM_window_get_active_screen(win); | const bScreen *screen = WM_window_get_active_screen(win); | ||||
| ScrArea *area; | ScrArea *area; | ||||
| CTX_wm_window_set(C, win); | CTX_wm_window_set(C, win); | ||||
| for (area = screen->areabase.first; area; area = area->next) { | for (area = screen->areabase.first; area; area = area->next) { | ||||
| if (area->do_refresh) { | if (area->do_refresh) { | ||||
| CTX_wm_area_set(C, area); | CTX_wm_area_set(C, area); | ||||
| ED_area_do_refresh(C, area); | ED_area_do_refresh(C, area); | ||||
| ▲ Show 20 Lines • Show All 1,481 Lines • ▼ Show 20 Lines | static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi) | ||||
| return true; | return true; | ||||
| } | } | ||||
| static wmKeyMapItem *wm_eventmatch_modal_keymap_items(const wmKeyMap *keymap, | static wmKeyMapItem *wm_eventmatch_modal_keymap_items(const wmKeyMap *keymap, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const wmEvent *event) | const wmEvent *event) | ||||
| { | { | ||||
| for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { | LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { | ||||
| /* Should already be handled by #wm_user_modal_keymap_set_items. */ | /* Should already be handled by #wm_user_modal_keymap_set_items. */ | ||||
| BLI_assert(kmi->propvalue_str[0] == '\0'); | BLI_assert(kmi->propvalue_str[0] == '\0'); | ||||
| if (wm_eventmatch(event, kmi)) { | if (wm_eventmatch(event, kmi)) { | ||||
| if ((keymap->poll_modal_item == NULL) || (keymap->poll_modal_item(op, kmi->propvalue))) { | if ((keymap->poll_modal_item == NULL) || (keymap->poll_modal_item(op, kmi->propvalue))) { | ||||
| return kmi; | return kmi; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 521 Lines • ▼ Show 20 Lines | static int wm_handlers_do_keymap_with_keymap_handler( | ||||
| } | } | ||||
| else { | else { | ||||
| PRINT("%s: checking '%s' ...", __func__, keymap->idname); | PRINT("%s: checking '%s' ...", __func__, keymap->idname); | ||||
| if (WM_keymap_poll(C, keymap)) { | if (WM_keymap_poll(C, keymap)) { | ||||
| PRINT("pass\n"); | PRINT("pass\n"); | ||||
| for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { | LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { | ||||
| if (wm_eventmatch(event, kmi)) { | if (wm_eventmatch(event, kmi)) { | ||||
| struct wmEventHandler_KeymapPost keymap_post = handler->post; | struct wmEventHandler_KeymapPost keymap_post = handler->post; | ||||
| PRINT("%s: item matched '%s'\n", __func__, kmi->idname); | PRINT("%s: item matched '%s'\n", __func__, kmi->idname); | ||||
| action |= wm_handler_operator_call( | action |= wm_handler_operator_call( | ||||
| C, handlers, &handler->head, event, kmi->ptr, kmi->idname); | C, handlers, &handler->head, event, kmi->ptr, kmi->idname); | ||||
| ▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | #ifdef USE_GIZMO_MOUSE_PRIORITY_HACK | ||||
| wmEvent event_test_click_drag = *event; | wmEvent event_test_click_drag = *event; | ||||
| event_test_click_drag.val = KM_CLICK_DRAG; | event_test_click_drag.val = KM_CLICK_DRAG; | ||||
| wmEvent event_test_tweak = *event; | wmEvent event_test_tweak = *event; | ||||
| event_test_tweak.type = EVT_TWEAK_L + (event->type - LEFTMOUSE); | event_test_tweak.type = EVT_TWEAK_L + (event->type - LEFTMOUSE); | ||||
| event_test_tweak.val = KM_ANY; | event_test_tweak.val = KM_ANY; | ||||
| for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { | LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { | ||||
| if ((kmi->flag & KMI_INACTIVE) == 0) { | if ((kmi->flag & KMI_INACTIVE) == 0) { | ||||
| if (wm_eventmatch(&event_test_click, kmi) || | if (wm_eventmatch(&event_test_click, kmi) || | ||||
| wm_eventmatch(&event_test_click_drag, kmi) || | wm_eventmatch(&event_test_click_drag, kmi) || | ||||
| wm_eventmatch(&event_test_tweak, kmi)) { | wm_eventmatch(&event_test_tweak, kmi)) { | ||||
| wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); | wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); | ||||
| if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) { | if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) { | ||||
| is_event_handle_all = true; | is_event_handle_all = true; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif /* USE_GIZMO_MOUSE_PRIORITY_HACK */ | #endif /* USE_GIZMO_MOUSE_PRIORITY_HACK */ | ||||
| } | } | ||||
| /* Don't use from now on. */ | /* Don't use from now on. */ | ||||
| gz = NULL; | gz = NULL; | ||||
| /* Fallback to selected gizmo (when un-handled). */ | /* Fallback to selected gizmo (when un-handled). */ | ||||
| if ((action & WM_HANDLER_BREAK) == 0) { | if ((action & WM_HANDLER_BREAK) == 0) { | ||||
| if (WM_gizmomap_is_any_selected(gzmap)) { | if (WM_gizmomap_is_any_selected(gzmap)) { | ||||
| const ListBase *groups = WM_gizmomap_group_list(gzmap); | const ListBase *groups = WM_gizmomap_group_list(gzmap); | ||||
| for (wmGizmoGroup *gzgroup = groups->first; gzgroup; gzgroup = gzgroup->next) { | LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, groups) { | ||||
| if (wm_gizmogroup_is_any_selected(gzgroup)) { | if (wm_gizmogroup_is_any_selected(gzgroup)) { | ||||
| wmKeyMap *keymap = WM_keymap_active(wm, gzgroup->type->keymap); | wmKeyMap *keymap = WM_keymap_active(wm, gzgroup->type->keymap); | ||||
| action |= wm_handlers_do_keymap_with_gizmo_handler( | action |= wm_handlers_do_keymap_with_gizmo_handler( | ||||
| C, event, handlers, handler, gzgroup, keymap, do_debug_handler, NULL); | C, event, handlers, handler, gzgroup, keymap, do_debug_handler, NULL); | ||||
| if (action & WM_HANDLER_BREAK) { | if (action & WM_HANDLER_BREAK) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 962 Lines • ▼ Show 20 Lines | wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm, | ||||
| bToolRef_Runtime *tref_rt = area->runtime.tool ? area->runtime.tool->runtime : NULL; | bToolRef_Runtime *tref_rt = area->runtime.tool ? area->runtime.tool->runtime : NULL; | ||||
| if (tref_rt && tref_rt->keymap_fallback[0]) { | if (tref_rt && tref_rt->keymap_fallback[0]) { | ||||
| const char *keymap_id = NULL; | const char *keymap_id = NULL; | ||||
| /* Support for the gizmo owning the tool keymap. */ | /* Support for the gizmo owning the tool keymap. */ | ||||
| if (tref_rt->gizmo_group[0] != '\0' && tref_rt->keymap_fallback[0] != '\n') { | if (tref_rt->gizmo_group[0] != '\0' && tref_rt->keymap_fallback[0] != '\n') { | ||||
| wmGizmoMap *gzmap = NULL; | wmGizmoMap *gzmap = NULL; | ||||
| wmGizmoGroup *gzgroup = NULL; | wmGizmoGroup *gzgroup = NULL; | ||||
| for (ARegion *region = area->regionbase.first; region; region = region->next) { | LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | ||||
| if (region->gizmo_map != NULL) { | if (region->gizmo_map != NULL) { | ||||
| gzmap = region->gizmo_map; | gzmap = region->gizmo_map; | ||||
| gzgroup = WM_gizmomap_group_find(gzmap, tref_rt->gizmo_group); | gzgroup = WM_gizmomap_group_find(gzmap, tref_rt->gizmo_group); | ||||
| if (gzgroup != NULL) { | if (gzgroup != NULL) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,143 Lines • ▼ Show 20 Lines | else { | ||||
| keymap = WM_keymap_active(wm, handler->keymap); | keymap = WM_keymap_active(wm, handler->keymap); | ||||
| BLI_assert(keymap != NULL); | BLI_assert(keymap != NULL); | ||||
| } | } | ||||
| return keymap; | return keymap; | ||||
| } | } | ||||
| wmKeyMapItem *WM_event_match_keymap_item(bContext *C, wmKeyMap *keymap, const wmEvent *event) | wmKeyMapItem *WM_event_match_keymap_item(bContext *C, wmKeyMap *keymap, const wmEvent *event) | ||||
| { | { | ||||
| for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { | LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { | ||||
| if (wm_eventmatch(event, kmi)) { | if (wm_eventmatch(event, kmi)) { | ||||
| wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); | wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); | ||||
| if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) { | if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) { | ||||
| return kmi; | return kmi; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | |||||
| * use here since the area is stored in the window manager. | * use here since the area is stored in the window manager. | ||||
| */ | */ | ||||
| ScrArea *WM_window_status_area_find(wmWindow *win, bScreen *screen) | ScrArea *WM_window_status_area_find(wmWindow *win, bScreen *screen) | ||||
| { | { | ||||
| if (screen->state == SCREENFULL) { | if (screen->state == SCREENFULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| ScrArea *area_statusbar = NULL; | ScrArea *area_statusbar = NULL; | ||||
| for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) { | LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { | ||||
| if (area->spacetype == SPACE_STATUSBAR) { | if (area->spacetype == SPACE_STATUSBAR) { | ||||
| area_statusbar = area; | area_statusbar = area; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return area_statusbar; | return area_statusbar; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 233 Lines • Show Last 20 Lines | |||||