Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_event_system.c
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| #include "GHOST_C-api.h" | #include "GHOST_C-api.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_dynstr.h" | #include "BLI_dynstr.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #ifdef WITH_IM_ONTHESPOT | |||||
| # include "BLT_lang.h" | |||||
| #endif | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| ▲ Show 20 Lines • Show All 2,354 Lines • ▼ Show 20 Lines | while ( (event = win->queue.first) ) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| CTX_wm_window_set(C, win); | CTX_wm_window_set(C, win); | ||||
| /* we let modal handlers get active area/region, also wm_paintcursor_test needs it */ | /* 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_area_set(C, area_event_inside(C, &event->x)); | ||||
| CTX_wm_region_set(C, region_event_inside(C, &event->x)); | CTX_wm_region_set(C, region_event_inside(C, &event->x)); | ||||
| #ifdef WITH_IM_OVERTHESPOT | |||||
| if (event->type == WM_IM_COMPOSITE_EVENT) { | |||||
| /* if spot location is not set yet, redraw active region to calculate it. | |||||
| * normally, redrawing is triggered by first key stroke after changing active region. | |||||
| * note: on-the-spot style doesn't need this redraw because updating preedit text | |||||
| * causes redraw so the spot location is always set. */ | |||||
| if (WM_window_IM_is_spot_needed(win)) | |||||
| ED_region_tag_redraw(CTX_wm_region(C)); | |||||
| BLI_remlink(&win->queue, event); | |||||
| wm_event_free(event); | |||||
| continue; | |||||
| } | |||||
| #endif | |||||
| /* MVC demands to not draw in event handlers... but we need to leave it for ogl selecting etc */ | /* 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_window_make_drawable(wm, win); | ||||
| wm_region_mouse_co(C, event); | wm_region_mouse_co(C, event); | ||||
| /* first we do priority handlers, modal + some limited keymaps */ | /* first we do priority handlers, modal + some limited keymaps */ | ||||
| action |= wm_handlers_do(C, event, &win->modalhandlers); | action |= wm_handlers_do(C, event, &win->modalhandlers); | ||||
| ▲ Show 20 Lines • Show All 1,086 Lines • ▼ Show 20 Lines | #endif /* WITH_INPUT_NDOF */ | ||||
| case GHOST_kEventWindowDeactivate: | case GHOST_kEventWindowDeactivate: | ||||
| { | { | ||||
| event.type = WINDEACTIVATE; | event.type = WINDEACTIVATE; | ||||
| wm_event_add(win, &event); | wm_event_add(win, &event); | ||||
| break; | break; | ||||
| } | } | ||||
| #ifdef WITH_INPUT_IME | #if defined(WITH_IM_OVERTHESPOT) || defined(WITH_IM_ONTHESPOT) | ||||
| case GHOST_kEventImeCompositionStart: | case GHOST_kEventIMComposition: | ||||
| { | { | ||||
| event.val = KM_PRESS; | event.val = KM_PRESS; | ||||
| win->ime_data = customdata; | event.type = WM_IM_COMPOSITE_EVENT; | ||||
| win->ime_data->is_ime_composing = true; | |||||
| event.type = WM_IME_COMPOSITE_START; | |||||
| wm_event_add(win, &event); | wm_event_add(win, &event); | ||||
| break; | break; | ||||
| } | } | ||||
| case GHOST_kEventImeComposition: | #endif /* defined(WITH_IM_OVERTHESPOT) || defined(WITH_IM_ONTHESPOT) */ | ||||
| #ifdef WITH_IM_ONTHESPOT | |||||
| case GHOST_kEventIMCompositionStart: | |||||
| { | { | ||||
| event.val = KM_PRESS; | event.val = KM_PRESS; | ||||
| event.type = WM_IME_COMPOSITE_EVENT; | win->im_data = customdata; | ||||
| win->im_data->is_im_composing = true; | |||||
| event.type = WM_IM_COMPOSITE_START; | |||||
| wm_event_add(win, &event); | wm_event_add(win, &event); | ||||
| break; | break; | ||||
| } | } | ||||
| case GHOST_kEventImeCompositionEnd: | case GHOST_kEventIMCompositionEnd: | ||||
| { | { | ||||
| event.val = KM_PRESS; | event.val = KM_PRESS; | ||||
| if (win->ime_data) { | if (win->im_data) { | ||||
| win->ime_data->is_ime_composing = false; | win->im_data->is_im_composing = false; | ||||
| } | } | ||||
| event.type = WM_IME_COMPOSITE_END; | event.type = WM_IM_COMPOSITE_END; | ||||
| wm_event_add(win, &event); | wm_event_add(win, &event); | ||||
| break; | break; | ||||
| } | } | ||||
| #endif /* WITH_INPUT_IME */ | #endif /* WITH_IM_ONTHESPOT */ | ||||
| } | } | ||||
| #if 0 | #if 0 | ||||
| WM_event_print(&event); | WM_event_print(&event); | ||||
| #endif | #endif | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | float WM_event_tablet_data(const wmEvent *event, int *pen_flip, float tilt[2]) | ||||
| return pressure; | return pressure; | ||||
| } | } | ||||
| bool WM_event_is_tablet(const struct wmEvent *event) | bool WM_event_is_tablet(const struct wmEvent *event) | ||||
| { | { | ||||
| return (event->tablet_data) ? true : false; | return (event->tablet_data) ? true : false; | ||||
| } | } | ||||
| #ifdef WITH_INPUT_IME | #ifdef WITH_IM_ONTHESPOT | ||||
| /* most os using ctrl/oskey + space to switch ime, avoid added space */ | /* most os using ctrl/oskey + space to switch IM, avoid added space */ | ||||
| bool WM_event_is_ime_switch(const struct wmEvent *event) | bool WM_event_is_im_switch(const struct wmEvent *event) | ||||
| { | { | ||||
| return event->val == KM_PRESS && event->type == SPACEKEY && | return (BLT_lang_is_im_supported() && | ||||
| (event->ctrl || event->oskey || event->shift || event->alt); | event->val == KM_PRESS && event->type == SPACEKEY && | ||||
| (event->ctrl || event->oskey || event->shift || event->alt)); | |||||
| } | } | ||||
| #endif | #endif | ||||
| /** \} */ | /** \} */ | ||||