Blender V4.3
wm_event_system.hh File Reference
#include "WM_api.hh"

Go to the source code of this file.

Classes

struct  wmEventHandler
 
struct  wmEventHandler_KeymapPost
 
struct  wmEventHandler_KeymapDynamic
 
struct  wmEventHandler_Keymap
 
struct  wmEventHandler_Gizmo
 
struct  wmEventHandler_UI
 
struct  wmEventHandler_Op
 
struct  wmEventHandler_Dropbox
 

Typedefs

using EventHandlerPoll = bool (*)(const ARegion *region, const wmEvent *event)
 

Enumerations

enum  eWM_EventHandlerType {
  WM_HANDLER_TYPE_GIZMO = 1 , WM_HANDLER_TYPE_UI , WM_HANDLER_TYPE_OP , WM_HANDLER_TYPE_DROPBOX ,
  WM_HANDLER_TYPE_KEYMAP
}
 

Functions

void wm_event_free_all (wmWindow *win)
 
void wm_event_free (wmEvent *event)
 
void wm_event_free_handler (wmEventHandler *handler)
 
void wm_event_do_handlers (bContext *C)
 
void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, const void *customdata, const uint64_t event_time_ms)
 
void wm_event_do_depsgraph (bContext *C, bool is_after_open_file)
 
void wm_event_do_refresh_wm_and_depsgraph (bContext *C)
 
void wm_event_do_notifiers (bContext *C)
 
void wm_event_handler_ui_cancel_ex (bContext *C, wmWindow *win, ARegion *region, bool reactivate_button)
 
float wm_pressure_curve (float raw_pressure)
 
void wm_tablet_data_from_ghost (const GHOST_TabletData *tablet_data, wmTabletData *wmtab)
 
void wm_dropbox_free ()
 
void wm_drags_exit (wmWindowManager *wm, wmWindow *win)
 
void wm_drop_prepare (bContext *C, wmDrag *drag, wmDropBox *drop)
 
void wm_drop_end (bContext *C, wmDrag *drag, wmDropBox *drop)
 
void wm_drags_check_ops (bContext *C, const wmEvent *event)
 
wmOperatorCallContext wm_drop_operator_context_get (const wmDropBox *drop)
 
void wm_drags_draw (bContext *C, wmWindow *win)
 

Typedef Documentation

◆ EventHandlerPoll

using EventHandlerPoll = bool (*)(const ARegion *region, const wmEvent *event)

Definition at line 37 of file wm_event_system.hh.

Enumeration Type Documentation

◆ eWM_EventHandlerType

Custom types for handlers, for signaling, freeing.

Enumerator
WM_HANDLER_TYPE_GIZMO 
WM_HANDLER_TYPE_UI 
WM_HANDLER_TYPE_OP 
WM_HANDLER_TYPE_DROPBOX 
WM_HANDLER_TYPE_KEYMAP 

Definition at line 29 of file wm_event_system.hh.

Function Documentation

◆ wm_drags_check_ops()

◆ wm_drags_draw()

◆ wm_drags_exit()

void wm_drags_exit ( wmWindowManager * wm,
wmWindow * win )

Additional work to cleanly end dragging. Additional because this doesn't actually remove the drag items. Should be called whenever dragging is stopped (successful or not, also when canceled).

Definition at line 321 of file wm_dragdrop.cc.

References ED_region_tag_redraw_no_rebuild(), wmWindow::eventstate, LISTBASE_FOREACH, wmWindow::tag_cursor_refresh, wmWindowManager::windows, WM_cursor_modal_restore(), WM_event_add_mousemove(), WM_window_find_under_cursor(), WM_window_get_active_screen(), and wmEvent::xy.

Referenced by wm_drop_prepare(), wm_event_drag_and_drop_test(), and wm_handlers_do_intern().

◆ wm_drop_end()

void wm_drop_end ( bContext * C,
wmDrag * drag,
wmDropBox * drop )

Definition at line 564 of file wm_dragdrop.cc.

References CTX_store_set().

Referenced by wm_handlers_do_intern().

◆ wm_drop_operator_context_get()

wmOperatorCallContext wm_drop_operator_context_get ( const wmDropBox * drop)

The operator of a dropbox should always be executed in the context determined by the mouse coordinates. The dropbox poll should check the context area and region as needed. So this always returns WM_OP_INVOKE_DEFAULT.

Definition at line 589 of file wm_dragdrop.cc.

References WM_OP_INVOKE_DEFAULT.

Referenced by dropbox_active(), wm_drop_prepare(), and wm_handlers_do_intern().

◆ wm_drop_prepare()

◆ wm_dropbox_free()

void wm_dropbox_free ( )

Definition at line 208 of file wm_dragdrop.cc.

References BLI_freelistN(), dropboxes, LISTBASE_FOREACH, and wm_drop_item_free_data().

Referenced by WM_exit_ex().

◆ wm_event_add_ghostevent()

void wm_event_add_ghostevent ( wmWindowManager * wm,
wmWindow * win,
int type,
const void * customdata,
const uint64_t event_time_ms )

Windows store their own event queues wmWindow.event_queue (no bContext here).

Having both, event and event_state, can be highly confusing to work with, but is necessary for our current event system, so let's clear things up a bit:

  • Data added to event only will be handled immediately, but will not be copied to the next event.
  • Data added to event_state only stays, but is handled with the next event -> execution delay.
  • Data added to event and event_state stays and is handled immediately.

Always support accessing the last key press/release. This is set from win->eventstate, so it will always be a valid event type to store in the previous state.

Note that these values are intentionally not set in the win->eventstate, as copying these values only makes sense when win->eventstate->{val/type} would be written to (which only happens for some kinds of events). If this was done it could leave win->eventstate previous and current value set to the same key press/release state which doesn't make sense.

Definition at line 5735 of file wm_event_system.cc.

References ARRAY_SIZE, BLI_assert, BLI_assert_unreachable, BLI_str_utf8_from_unicode(), BLI_str_utf8_size_or_error(), GHOST_TEventButtonData::button, CLOG_ERROR, CLOG_INFO, CLOG_WARN, copy_v2_v2_int(), GHOST_TEventTrackpadData::deltaX, GHOST_TEventTrackpadData::deltaY, e, EVENT_NONE, wmWindow::eventstate, wmWindow::eventstate_prev_press_time_ms, EVT_ESCKEY, EVT_LEFTALTKEY, EVT_LEFTCTRLKEY, EVT_LEFTSHIFTKEY, EVT_OSKEY, EVT_RIGHTALTKEY, EVT_RIGHTCTRLKEY, EVT_RIGHTSHIFTKEY, EVT_UNKNOWNKEY, wmEvent::flag, G, G_FLAG_EVENT_SIMULATE, GHOST_kEventButtonDown, GHOST_kEventButtonUp, GHOST_kEventCursorMove, GHOST_kEventImeComposition, GHOST_kEventImeCompositionEnd, GHOST_kEventImeCompositionStart, GHOST_kEventKeyDown, GHOST_kEventKeyUp, GHOST_kEventTrackpad, GHOST_kEventUnknown, GHOST_kEventWheel, GHOST_kEventWindowDeactivate, GHOST_kNumEventTypes, GHOST_kTrackpadEventMagnify, GHOST_kTrackpadEventRotate, GHOST_kTrackpadEventScroll, GHOST_kTrackpadEventSmartMagnify, wmWindow::ime_data, wmWindow::ime_data_is_composing, wmTabletData::is_motion_absolute, GHOST_TEventKeyData::is_repeat, GHOST_TEventTrackpadData::isDirectionInverted, ISKEYBOARD_OR_BUTTON, GHOST_TEventKeyData::key, wmEvent::keymodifier, KM_ALT, KM_CTRL, KM_NOTHING, KM_OSKEY, KM_PRESS, KM_RELEASE, KM_SHIFT, MIDDLEMOUSE, wmEvent::modifier, MOUSEMOVE, MOUSEPAN, MOUSEROTATE, MOUSESMARTZOOM, MOUSEZOOM, NDOF_MOTION, wmEvent::prev_type, wmEvent::prev_val, SET_FLAG_FROM_TEST, GHOST_TEventTrackpadData::subtype, GHOST_TEventButtonData::tablet, GHOST_TEventCursorData::tablet, wmEvent::tablet, wmEvent::type, UNLIKELY, USER_TRACKPAD_SCROLL_DIR_NATURAL, USER_TRACKPAD_SCROLL_DIR_TRADITIONAL, GHOST_TEventKeyData::utf8_buf, wmEvent::utf8_buf, wmEvent::val, WHEELDOWNMOUSE, WHEELUPMOUSE, wmWindowManager::winactive, WINDEACTIVATE, WM_capabilities_flag(), WM_CAPABILITY_TRACKPAD_PHYSICAL_DIRECTION, wm_cursor_position_from_ghost_screen_coords(), wm_event_add(), wm_event_add_mousemove(), wm_event_add_trackpad(), wm_event_cursor_other_windows(), wm_event_is_ignorable_key_press(), WM_EVENT_IS_REPEAT, WM_event_print(), WM_EVENT_SCROLL_INVERT, wm_event_state_update_and_click_set(), wm_event_type_from_ghost_button(), wm_event_type_from_ghost_key(), wm_eventemulation(), WM_IME_COMPOSITE_END, WM_IME_COMPOSITE_EVENT, WM_IME_COMPOSITE_START, WM_LOG_EVENTS, WM_LOG_HANDLERS, wm_stereo3d_mouse_offset_apply(), wm_tablet_data_from_ghost(), GHOST_TEventCursorData::x, GHOST_TEventTrackpadData::x, wmEvent::xy, and GHOST_TEventWheelData::z.

Referenced by ghost_event_proc(), wm_window_update_eventstate_modifiers(), and wm_window_update_eventstate_modifiers_clear().

◆ wm_event_do_depsgraph()

◆ wm_event_do_handlers()

void wm_event_do_handlers ( bContext * C)

Goes over entire hierarchy: events -> window -> screen -> area -> region.

Note
Called in main loop.

Definition at line 4002 of file wm_event_system.cc.

References wmWindow::addmousemove, area_event_inside(), AREA_FLAG_ACTIONZONES_UPDATE, BKE_scene_get_depsgraph(), BKE_sound_scene_playing(), BKE_sound_sync_scene(), BLI_assert, BLI_remlink(), CLOG_INFO, copy_v2_v2_int(), CTX_data_main(), CTX_data_scene(), CTX_data_scene_set(), CTX_wm_area_set(), CTX_wm_manager(), CTX_wm_region_set(), CTX_wm_screen(), CTX_wm_screen_set(), CTX_wm_window(), CTX_wm_window_set(), wmEvent::customdata, DEG_get_evaluated_scene(), depsgraph, ED_area_azones_update(), ED_screen_animation_play(), ED_screen_animation_playing(), ED_screen_areas_iter, ED_screen_set_active_region(), ED_undo_is_state_valid(), ED_update_for_newframe(), wmWindow::event_queue, wmWindow::event_queue_check_click, wmWindow::event_queue_check_drag, wmWindow::event_queue_check_drag_handled, wmWindow::event_queue_consecutive_gesture_type, wmWindow::event_queue_consecutive_gesture_xy, wmWindow::eventstate, EVT_XR_ACTION, ListBase::first, wmEvent::flag, FPS, G, G_DEBUG_EVENTS, G_DEBUG_HANDLERS, GPU_render_begin(), GPU_render_end(), wmWindow::handlers, Scene::id, ID_RECALC_FRAME_CHANGE, ISKEYBOARD_OR_BUTTON, ISMOUSE_BUTTON, ISMOUSE_MOTION, KM_NOTHING, KM_PRESS, len_manhattan_v2v2_int(), LISTBASE_FOREACH, wmWindow::modalhandlers, MOUSEMOVE, NC_WINDOW, NDOF_MOTION, wmEvent::prev_press_type, wmEvent::prev_xy, printf, ID::recalc, region_event_inside(), TIMER, wmEvent::type, wmEvent::val, wmWindowManager::windows, wm_action_not_handled(), wm_event_add(), wm_event_add_mousemove_to_head(), WM_event_add_notifier(), WM_event_consecutive_data_free(), WM_event_consecutive_gesture_test(), WM_event_consecutive_gesture_test_break(), WM_EVENT_CURSOR_MOTION_THRESHOLD, wm_event_do_handlers_area_regions(), wm_event_drag_and_drop_test(), WM_EVENT_FORCE_DRAG_THRESHOLD, wm_event_free_all(), wm_event_free_and_remove_from_queue_if_valid(), wm_event_free_last_handled(), wm_event_inside_rect(), WM_EVENT_IS_CONSECUTIVE, WM_EVENT_IS_REPEAT, wm_event_pie_filter(), WM_event_print(), WM_gizmoconfig_update(), WM_HANDLER_CONTINUE, wm_handlers_do(), WM_keyconfig_update(), WM_LOG_HANDLERS, wm_paintcursor_test(), wm_region_mouse_co(), wm_region_tag_draw_on_gizmo_delay_refresh_for_tweak(), WM_tooltip_clear(), WM_tooltip_init(), WM_window_get_active_scene(), WM_window_get_active_screen(), WM_window_get_active_view_layer(), WM_window_get_active_workspace(), wm_window_make_drawable(), and wmEvent::xy.

Referenced by ghost_event_proc(), and WM_main().

◆ wm_event_do_notifiers()

void wm_event_do_notifiers ( bContext * C)

Called in main-loop.

Definition at line 560 of file wm_event_system.cc.

References BKE_workspace_layout_screen_get(), BLI_assert, BLI_gset_remove(), BLI_pophead(), BLI_remlink(), CTX_data_depsgraph_pointer(), CTX_data_main(), CTX_data_view_layer(), CTX_wm_manager(), CTX_wm_window_set(), depsgraph, ED_area_do_listen(), ED_info_stats_clear(), ED_preview_restart_queue_work(), ED_region_do_listen(), ED_screen_areas_iter, ED_screen_change(), ED_screen_do_listen(), ED_update_for_newframe(), ED_workspace_delete(), ED_workspace_do_listen(), ED_workspace_layout_delete(), ELEM, wmWindowManager::file_saved, ListBase::first, G, G_DEBUG_EVENTS, GPU_render_begin(), GPU_render_end(), LISTBASE_FOREACH, MEM_freeN(), wmWindowManager::message_bus, NC_GEOM, NC_OBJECT, NC_SCENE, NC_SCREEN, NC_SPACE, NC_WM, ND_DATACHANGED, ND_FILEREAD, ND_FILESAVE, ND_FRAME, ND_LAYOUTBROWSE, ND_LAYOUTDELETE, ND_SPACE_INFO, ND_UNDO, ND_WORKSPACE_DELETE, ND_WORKSPACE_SET, wmNotifier::next, wmWindowManager::notifier_current, wmWindowManager::notifier_queue, wmWindowManager::notifier_queue_set, printf, RE_FreeUnusedGPUResources(), scene, wmWindow::scene, UI_popup_handlers_remove_all(), UNUSED_VARS_NDEBUG, wmWindowManager::winactive, wmRegionListenerParams::window, wmSpaceTypeListenerParams::window, wmWindowManager::windows, WM_event_add_notifier(), wm_event_do_refresh_wm_and_depsgraph(), wm_event_timers_execute(), WM_msgbus_handle(), wm_notifier_is_clear(), wm_test_autorun_warning(), wm_test_gpu_backend_fallback(), wm_test_opengl_deprecation_warning(), WM_window_cursor_keymap_status_refresh(), WM_window_get_active_layout(), WM_window_get_active_scene(), WM_window_get_active_screen(), WM_window_get_active_workspace(), WM_window_set_active_workspace(), and WM_window_title().

Referenced by ghost_event_proc(), and WM_main().

◆ wm_event_do_refresh_wm_and_depsgraph()

void wm_event_do_refresh_wm_and_depsgraph ( bContext * C)

Was part of wm_event_do_notifiers, 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.

Definition at line 524 of file wm_event_system.cc.

References CTX_wm_area_set(), CTX_wm_manager(), CTX_wm_window_set(), ED_area_do_refresh(), LISTBASE_FOREACH, wmWindowManager::windows, wm_event_do_depsgraph(), and WM_window_get_active_screen().

Referenced by redraw_timer_step(), wm_event_do_notifiers(), and WM_main().

◆ wm_event_free()

◆ wm_event_free_all()

void wm_event_free_all ( wmWindow * win)

Definition at line 306 of file wm_event_system.cc.

References BLI_pophead(), wmWindow::event_queue, and wm_event_free().

Referenced by wm_event_do_handlers(), and wm_window_free().

◆ wm_event_free_handler()

◆ wm_event_handler_ui_cancel_ex()

◆ wm_pressure_curve()

float wm_pressure_curve ( float raw_pressure)

Applies the global tablet pressure correction curve.

Definition at line 544 of file wm_event_query.cc.

References CLAMP, and powf.

Referenced by wm_tablet_data_from_ghost().

◆ wm_tablet_data_from_ghost()