diff options
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 51 | ||||
-rw-r--r-- | source/blender/windowmanager/xr/intern/wm_xr_session.c | 4 |
5 files changed, 44 insertions, 43 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 48ade798364..a29559e904e 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -925,12 +925,14 @@ char *WM_prop_pystring_assign(struct bContext *C, int index); /** * Convert: `some.op` -> `SOME_OT_op` or leave as-is. + * \return the length of `dst`. */ -void WM_operator_bl_idname(char *to, const char *from); +size_t WM_operator_bl_idname(char *dst, const char *src) ATTR_NONNULL(1, 2); /** * Convert: `SOME_OT_op` -> `some.op` or leave as-is. + * \return the length of `dst`. */ -void WM_operator_py_idname(char *to, const char *from); +size_t WM_operator_py_idname(char *dst, const char *src) ATTR_NONNULL(1, 2); /** * Sanity check to ensure #WM_operator_bl_idname won't fail. * \returns true when there are no problems with \a idname, otherwise report an error. @@ -1226,7 +1228,7 @@ struct ID *WM_drag_get_local_ID_from_event(const struct wmEvent *event, short id bool WM_drag_is_ID_type(const struct wmDrag *drag, int idcode); /** - * \note: Does not store \a asset in any way, so it's fine to pass a temporary. + * \note Does not store \a asset in any way, so it's fine to pass a temporary. */ wmDragAsset *WM_drag_create_asset_data(const struct AssetHandle *asset, struct AssetMetaData *metadata, @@ -1258,7 +1260,7 @@ void WM_drag_free_imported_drag_ID(struct Main *bmain, struct wmDragAssetCatalog *WM_drag_get_asset_catalog_data(const struct wmDrag *drag); /** - * \note: Does not store \a asset in any way, so it's fine to pass a temporary. + * \note Does not store \a asset in any way, so it's fine to pass a temporary. */ void WM_drag_add_asset_list_item(wmDrag *drag, const struct bContext *C, diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index a9b8d91ca03..9e9f195c430 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -812,6 +812,10 @@ typedef struct wmXrActionData { char action_set[64]; /** Action name. */ char action[64]; + /** User path. E.g. "/user/hand/left" */ + char user_path[64]; + /** Other user path, for bimanual actions. E.g. "/user/hand/right" */ + char user_path_other[64]; /** Type. */ eXrActionType type; /** State. Set appropriately based on type. */ @@ -1193,8 +1197,9 @@ typedef struct wmDropBox { struct wmDrag *drag, const int xy[2]); - /** Called with the draw buffer (#GPUViewport) set up for drawing into the region's view. - * \note Only setups the drawing buffer for drawing in view, not the GPU transform matricies. + /** + * Called with the draw buffer (#GPUViewport) set up for drawing into the region's view. + * \note Only setups the drawing buffer for drawing in view, not the GPU transform matrices. * The callback has to do that itself, with for example #UI_view2d_view_ortho. * \param xy: Cursor location in window coordinates (#wmEvent.xy compatible). */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 1648bdfb9d4..3ff3117dafe 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1960,12 +1960,9 @@ static void wm_handler_op_context_get_if_valid(bContext *C, region = NULL; } - if (region == NULL) { - LISTBASE_FOREACH (ARegion *, region_iter, &area->regionbase) { - region = region_iter; - if (region == handler->context.region) { - break; - } + if ((region == NULL) && handler->context.region) { + if (BLI_findindex(&area->regionbase, handler->context.region) != -1) { + region = handler->context.region; } } @@ -4022,6 +4019,7 @@ void WM_event_fileselect_event(wmWindowManager *wm, void *ophandle, int eventval event.type = EVT_FILESELECT; event.val = eventval; + event.flag = 0; event.customdata = ophandle; /* Only as void pointer type check. */ wm_event_add(win, &event); @@ -5848,6 +5846,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) wmEvent test_event = *win->eventstate; test_event.type = event_data[data_index].event_type; test_event.val = event_data[data_index].event_value; + test_event.flag = 0; wm_eventemulation(&test_event, true); wmKeyMapItem *kmi = NULL; for (int handler_index = 0; handler_index < ARRAY_SIZE(handlers); handler_index++) { @@ -5914,7 +5913,7 @@ bool WM_window_modal_keymap_status_draw(bContext *C, wmWindow *win, uiLayout *la bool show_text = true; { - /* Warning: O(n^2). */ + /* WARNING: O(n^2). */ wmKeyMapItem *kmi = NULL; for (kmi = keymap->items.first; kmi; kmi = kmi->next) { if (kmi->propvalue == items[i].value) { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b8107a49a4c..f455f7f2719 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -106,47 +106,38 @@ /** \name Operator API * \{ */ -void WM_operator_py_idname(char *to, const char *from) +size_t WM_operator_py_idname(char *dst, const char *src) { - const char *sep = strstr(from, "_OT_"); + const char *sep = strstr(src, "_OT_"); if (sep) { - int ofs = (sep - from); + int ofs = (sep - src); /* 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); - BLI_str_tolower_ascii(to, ofs); + memcpy(dst, src, sizeof(char) * ofs); + BLI_str_tolower_ascii(dst, ofs); - to[ofs] = '.'; - BLI_strncpy(to + (ofs + 1), sep + 4, OP_MAX_TYPENAME - (ofs + 1)); - } - else { - /* should not happen but support just in case */ - BLI_strncpy(to, from, OP_MAX_TYPENAME); + dst[ofs] = '.'; + return BLI_strncpy_rlen(dst + (ofs + 1), sep + 4, OP_MAX_TYPENAME - (ofs + 1)) + (ofs + 1); } + /* Should not happen but support just in case. */ + return BLI_strncpy_rlen(dst, src, OP_MAX_TYPENAME); } -void WM_operator_bl_idname(char *to, const char *from) +size_t WM_operator_bl_idname(char *dst, const char *src) { - if (from) { - const char *sep = strchr(from, '.'); - - int from_len; - if (sep && (from_len = strlen(from)) < OP_MAX_TYPENAME - 3) { - const int ofs = (sep - from); - memcpy(to, from, sizeof(char) * ofs); - BLI_str_toupper_ascii(to, ofs); - memcpy(to + ofs, "_OT_", 4); - memcpy(to + (ofs + 4), sep + 1, (from_len - ofs)); - } - else { - /* should not happen but support just in case */ - BLI_strncpy(to, from, OP_MAX_TYPENAME); - } - } - else { - to[0] = 0; + const char *sep = strchr(src, '.'); + int from_len; + if (sep && (from_len = strlen(src)) < OP_MAX_TYPENAME - 3) { + const int ofs = (sep - src); + memcpy(dst, src, sizeof(char) * ofs); + BLI_str_toupper_ascii(dst, ofs); + memcpy(dst + ofs, "_OT_", 4); + memcpy(dst + (ofs + 4), sep + 1, (from_len - ofs)); + return (from_len - ofs) - 1; } + /* Should not happen but support just in case. */ + return BLI_strncpy_rlen(dst, src, OP_MAX_TYPENAME); } bool WM_operator_py_idname_ok_or_report(ReportList *reports, diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c index 0a76fd0a25f..2a829e274d9 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_session.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c @@ -1025,6 +1025,10 @@ static wmXrActionData *wm_xr_session_event_create(const char *action_set_name, wmXrActionData *data = MEM_callocN(sizeof(wmXrActionData), __func__); strcpy(data->action_set, action_set_name); strcpy(data->action, action->name); + strcpy(data->user_path, action->subaction_paths[subaction_idx]); + if (bimanual) { + strcpy(data->user_path_other, action->subaction_paths[subaction_idx_other]); + } data->type = action->type; switch (action->type) { |