[Bf-blender-cvs] [f2385a3f057] xr-actions-D9124: Merge branch 'master' into xr-actions-D9124
Peter Kim
noreply at git.blender.org
Sat Oct 17 16:43:54 CEST 2020
Commit: f2385a3f05743dd0b0f9d7e120e0c3ec7c7c0d16
Author: Peter Kim
Date: Sat Oct 17 23:42:47 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBf2385a3f05743dd0b0f9d7e120e0c3ec7c7c0d16
Merge branch 'master' into xr-actions-D9124
# Conflicts:
# source/blender/windowmanager/intern/wm_event_system.c
===================================================================
===================================================================
diff --cc source/blender/windowmanager/intern/wm_event_system.c
index daeeb56c334,07d5ffa1b82..d6271667413
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@@ -2032,8 -1993,8 +2008,8 @@@ static int wm_handler_operator_call(bCo
* nothing to do in this case.
*/
}
- else if (ot->modal) {
+ else if (ot->modal || ot->modal_3d) {
- /* we set context to where modal handler came from */
+ /* We set context to where modal handler came from. */
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
@@@ -2047,19 -2008,11 +2023,19 @@@
wm->op_undo_depth++;
}
- /* warning, after this call all context data and 'event' may be freed. see check below */
+ /* Warning, after this call all context data and 'event' may be freed. see check below. */
- retval = ot->modal(C, op, event);
+ if (ot->modal_3d && event->type == EVT_XR_ACTION) {
+ retval = ot->modal_3d(C, op, event);
+ }
+ else if (ot->modal) {
+ retval = ot->modal(C, op, event);
+ }
+ else {
+ /* Pass through. An "XR operator" (only modal_3d) received a non-XR event.*/
+ }
OPERATOR_RETVAL_CHECK(retval);
- /* when this is _not_ the case the modal modifier may have loaded
+ /* When this is _not_ the case the modal modifier may have loaded
* a new blend file (demo mode does this), so we have to assume
* the event, operator etc have all been freed. - campbell */
if (CTX_wm_manager(C) == wm) {
@@@ -3195,99 -3144,8 +3167,99 @@@ static void wm_event_free_and_remove_fr
* Handle events for all windows, run from the #WM_main event loop.
* \{ */
+static void wm_event_surface_free_all(wmXrSurfaceData *surface_data)
+{
+ ListBase *events = &surface_data->events;
+ if (!BLI_listbase_is_empty(events)) {
+ LISTBASE_FOREACH (wmEvent *, event, events) {
+ MEM_freeN(event->customdata);
+ }
+ BLI_freelistN(events);
+ }
+}
+
+static void wm_event_do_surface_handlers(bContext *C, wmSurface *surface)
+{
+ /* TODO_XR: Currently assumes that the XR surface is the
+ * same as the one for the XR runtime. In the future this
+ * might not always be the case. */
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmXrData *xr = &wm->xr;
+ if (!xr->runtime || !surface->is_xr) {
+ return;
+ }
+
+ wmXrSurfaceData *surface_data = surface->customdata;
+ if (!surface_data || BLI_listbase_is_empty(&surface_data->events)) {
+ return;
+ }
+
+ wmWindow *win = wm_xr_session_root_window_or_fallback_get(wm, xr->runtime);
+ bScreen *screen = WM_window_get_active_screen(win);
+
+ BLI_assert(WM_window_get_active_scene(win));
+ BLI_assert(WM_window_get_active_screen(win));
+ BLI_assert(WM_window_get_active_workspace(win));
+
+ if (!screen) {
+ if (surface_data) {
+ wm_event_surface_free_all(surface_data);
+ }
+ return;
+ }
+
+ ARegion *xr_region = NULL;
+
+ CTX_wm_window_set(C, win);
+ wm_window_make_drawable(wm, win);
+
+ /* Set up a valid context for executing XR operations. */
+ ED_screen_areas_iter (win, screen, area) {
+ CTX_wm_area_set(C, area);
+
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
+ if (WM_region_use_viewport(area, region)) {
+ CTX_wm_region_set(C, region);
+
+ ListBase *events = &surface_data->events;
+
+ LISTBASE_FOREACH (wmEvent *, event, events) {
+ wmXrActionData *action_data = event->customdata;
+ if (action_data->ot->invoke) {
+ /* Invoke operator, either executing operator or transferring responsibility to window
+ * modal handlers. */
+ wm_operator_invoke(C, action_data->ot, event, NULL, NULL, false, false);
+ }
+ else {
+ /* Execute operator. */
+ wmOperator *op = wm_operator_create(wm, action_data->ot, NULL, NULL);
+ if ((WM_operator_call(C, op) & OPERATOR_HANDLED) == 0) {
+ WM_operator_free(op);
+ }
+ }
+
+ MEM_freeN(action_data);
+ }
+
+ BLI_freelistN(events);
+
+ CTX_wm_region_set(C, NULL);
+ xr_region = region;
+ break;
+ }
+ }
+
+ CTX_wm_area_set(C, area);
+ if (xr_region) {
+ break;
+ }
+ }
+
+ CTX_wm_window_set(C, NULL);
+}
+
- /* called in main loop */
- /* goes over entire hierarchy: events -> window -> screen -> area -> region */
+ /* Called in main loop. */
+ /* Goes over entire hierarchy: events -> window -> screen -> area -> region. */
void wm_event_do_handlers(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@@ -3552,10 -3408,7 +3522,10 @@@
CTX_wm_window_set(C, NULL);
}
+ /* Handle surface events. */
+ wm_surfaces_iter(C, wm_event_do_surface_handlers);
+
- /* update key configuration after handling events */
+ /* Update key configuration after handling events. */
WM_keyconfig_update(wm);
WM_gizmoconfig_update(CTX_data_main(C));
}
More information about the Bf-blender-cvs
mailing list