Blender  V3.3
Classes | Macros | Typedefs | Enumerations | Functions
wm_event_system.h File Reference

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
 

Macros

#define WM_HANDLER_CONTINUE   0
 
#define WM_HANDLER_BREAK   1
 
#define WM_HANDLER_HANDLED   2
 
#define WM_HANDLER_MODAL   4 /* MODAL|BREAK means unhandled */
 

Typedefs

typedef bool(* EventHandlerPoll) (const ARegion *region, const wmEvent *event)
 
typedef struct wmEventHandler wmEventHandler
 
typedef struct wmEventHandler_Keymap wmEventHandler_Keymap
 
typedef struct wmEventHandler_Gizmo wmEventHandler_Gizmo
 
typedef struct wmEventHandler_UI wmEventHandler_UI
 
typedef struct wmEventHandler_Op wmEventHandler_Op
 
typedef struct wmEventHandler_Dropbox wmEventHandler_Dropbox
 

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, void *customdata)
 
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 struct GHOST_TabletData *tablet_data, wmTabletData *wmtab)
 
void wm_dropbox_free (void)
 
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)
 

Macro Definition Documentation

◆ WM_HANDLER_BREAK

#define WM_HANDLER_BREAK   1

Definition at line 12 of file wm_event_system.h.

◆ WM_HANDLER_CONTINUE

#define WM_HANDLER_CONTINUE   0

Definition at line 11 of file wm_event_system.h.

◆ WM_HANDLER_HANDLED

#define WM_HANDLER_HANDLED   2

Definition at line 13 of file wm_event_system.h.

◆ WM_HANDLER_MODAL

#define WM_HANDLER_MODAL   4 /* MODAL|BREAK means unhandled */

Definition at line 14 of file wm_event_system.h.

Typedef Documentation

◆ EventHandlerPoll

typedef bool(* EventHandlerPoll) (const ARegion *region, const wmEvent *event)

Definition at line 40 of file wm_event_system.h.

◆ wmEventHandler

◆ wmEventHandler_Dropbox

◆ wmEventHandler_Gizmo

◆ wmEventHandler_Keymap

◆ wmEventHandler_Op

◆ wmEventHandler_UI

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 32 of file wm_event_system.h.

Function Documentation

◆ wm_drags_check_ops()

void wm_drags_check_ops ( bContext C,
const wmEvent event 
)

◆ wm_drags_draw()

void wm_drags_draw ( bContext C,
wmWindow win 
)

◆ 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 244 of file wm_dragdrop.cc.

References wmWindowManager::drags, LISTBASE_FOREACH, wmWindow::tag_cursor_refresh, WM_cursor_modal_restore(), and WM_event_add_mousemove().

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 
)

◆ 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.

◆ wm_drop_prepare()

void wm_drop_prepare ( bContext C,
wmDrag drag,
wmDropBox drop 
)

◆ wm_dropbox_free()

void wm_dropbox_free ( void  )

Definition at line 121 of file wm_dragdrop.cc.

References BLI_freelistN(), dropboxes, LISTBASE_FOREACH, MEM_freeN, and WM_operator_properties_free().

Referenced by WM_exit_ex().

◆ wm_event_add_ghostevent()

void wm_event_add_ghostevent ( wmWindowManager wm,
wmWindow win,
int  type,
void customdata 
)

Windows store 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 5193 of file wm_event_system.cc.

References BLI_assert, BLI_assert_unreachable, BLI_str_utf8_from_unicode(), BLI_str_utf8_size(), GHOST_TEventButtonData::button, BUTTON4MOUSE, BUTTON5MOUSE, BUTTON6MOUSE, BUTTON7MOUSE, Freestyle::c, CLOG_ERROR, CLOG_INFO, CLOG_WARN, convert_key(), copy_v2_v2_int(), GHOST_TEventTrackpadData::deltaX, GHOST_TEventTrackpadData::deltaY, e, EVENT_NONE, wmWindow::eventstate, EVT_DATA_TIMER, 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_kButtonMaskButton4, GHOST_kButtonMaskButton5, GHOST_kButtonMaskButton6, GHOST_kButtonMaskButton7, GHOST_kButtonMaskLeft, GHOST_kButtonMaskRight, GHOST_kEventButtonDown, GHOST_kEventButtonUp, GHOST_kEventCursorMove, GHOST_kEventImeComposition, GHOST_kEventImeCompositionEnd, GHOST_kEventImeCompositionStart, GHOST_kEventKeyDown, GHOST_kEventKeyUp, GHOST_kEventTimer, GHOST_kEventTrackpad, GHOST_kEventUnknown, GHOST_kEventWheel, GHOST_kEventWindowDeactivate, GHOST_kNumEventTypes, GHOST_kTrackpadEventMagnify, GHOST_kTrackpadEventRotate, GHOST_kTrackpadEventScroll, GHOST_kTrackpadEventSmartMagnify, wmWindow::ime_data, 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, LEFTMOUSE, MIDDLEMOUSE, wmEvent::modifier, MOUSEMOVE, MOUSEPAN, MOUSEROTATE, MOUSESMARTZOOM, MOUSEZOOM, NDOF_BUTTON_NONE, NDOF_MOTION, wmEvent::prev_type, wmEvent::prev_val, RIGHTMOUSE, SET_FLAG_FROM_TEST, GHOST_TEventTrackpadData::subtype, GHOST_TEventCursorData::tablet, GHOST_TEventButtonData::tablet, wmEvent::tablet, TIMER, type, wmEvent::type, UNLIKELY, GHOST_TEventKeyData::utf8_buf, wmEvent::utf8_buf, wmEvent::val, WHEELDOWNMOUSE, WHEELUPMOUSE, WINDEACTIVATE, 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_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, GHOST_TEventTrackpadData::y, and GHOST_TEventWheelData::z.

Referenced by ghost_event_proc().

◆ wm_event_do_depsgraph()

void wm_event_do_depsgraph ( bContext C,
bool  is_after_open_file 
)

◆ 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 3744 of file wm_event_system.cc.

References wmWindow::addmousemove, blender::compositor::area(), area_event_inside(), AREA_FLAG_ACTIONZONES_UPDATE, BKE_scene_get_depsgraph(), BKE_sound_scene_playing(), BKE_sound_sync_scene(), BLI_assert, BLI_remlink(), C, RenderData::cfra, 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, wmTooltipState::event_xy, wmWindow::eventstate, EVT_XR_ACTION, wmTooltipState::exit_on_event, ListBase::first, wmEvent::flag, FPS, G, G_DEBUG_EVENTS, G_DEBUG_HANDLERS, wmWindow::handlers, Scene::id, ID_RECALC_FRAME_CHANGE, CCL_NAMESPACE_BEGIN::isfinite(), 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, Scene::r, ID::recalc, region_event_inside(), scene, bScreen::skip_handling, time, TIMER, wmTooltipState::timer, bScreen::tool_tip, 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_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_REPEAT, wm_event_pie_filter(), WM_event_print(), WM_gizmoconfig_update(), WM_HANDLER_BREAK, 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 456 of file wm_event_system.cc.

References blender::compositor::area(), BKE_workspace_layout_screen_get(), BLI_pophead(), C, wmNotifier::category, 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_layout_delete(), ELEM, wmWindowManager::file_saved, G, G_DEBUG_EVENTS, LISTBASE_FOREACH, LISTBASE_FOREACH_MUTABLE, 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, wmWindowManager::notifier_queue, wmNotifier::reference, bScreen::regionbase, scene, wmWindow::scene, UI_popup_handlers_remove_all(), wmWindowManager::winactive, wmSpaceTypeListenerParams::window, wmRegionListenerParams::window, wmWindowManager::windows, WM_event_add_notifier(), wm_event_do_refresh_wm_and_depsgraph(), wm_event_execute_timers(), WM_msgbus_handle(), wm_test_autorun_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 420 of file wm_event_system.cc.

References blender::compositor::area(), bScreen::areabase, C, 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()

void wm_event_free ( wmEvent event)

◆ wm_event_free_all()

void wm_event_free_all ( wmWindow win)

Definition at line 236 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()

void wm_event_free_handler ( wmEventHandler handler)

◆ wm_event_handler_ui_cancel_ex()

void wm_event_handler_ui_cancel_ex ( bContext C,
wmWindow win,
ARegion region,
bool  reactivate_button 
)

◆ wm_pressure_curve()

float wm_pressure_curve ( float  raw_pressure)

Applies the global tablet pressure correction curve.

Definition at line 508 of file wm_event_query.c.

References CLAMP, and powf.

Referenced by wm_tablet_data_from_ghost().

◆ wm_tablet_data_from_ghost()

void wm_tablet_data_from_ghost ( const struct GHOST_TabletData tablet_data,
wmTabletData wmtab 
)