[Bf-blender-cvs] [4653d253b39] master: Fix T67805: Cursor doesn't update when switching tools via shortcuts

Campbell Barton noreply at git.blender.org
Fri Feb 21 16:01:44 CET 2020


Commit: 4653d253b390fbb61163610d60ac4c0d21db23ae
Author: Campbell Barton
Date:   Sat Feb 22 01:59:36 2020 +1100
Branches: master
https://developer.blender.org/rB4653d253b390fbb61163610d60ac4c0d21db23ae

Fix T67805: Cursor doesn't update when switching tools via shortcuts

===================================================================

M	source/blender/editors/screen/screen_edit.c
M	source/blender/makesdna/DNA_screen_types.h
M	source/blender/windowmanager/intern/wm_toolsystem.c

===================================================================

diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 1520566cd9d..216f36775b2 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -406,7 +406,9 @@ static void region_cursor_set(wmWindow *win, bool swin_changed)
   {
     for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
       if (ar == screen->active_region) {
-        if (swin_changed || (ar->type && ar->type->event_cursor)) {
+        if (swin_changed || (sa->flag & AREA_FLAG_CURSOR_UPDATE) ||
+            (ar->type && ar->type->event_cursor)) {
+          sa->flag &= ~AREA_FLAG_CURSOR_UPDATE;
           if (ar->gizmo_map != NULL) {
             if (WM_gizmomap_cursor_set(ar->gizmo_map, win)) {
               return;
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 483e5c4a952..c0e62f01e66 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -474,8 +474,8 @@ enum {
   /** Update size of regions within the area. */
   AREA_FLAG_REGION_SIZE_UPDATE = (1 << 3),
   AREA_FLAG_ACTIVE_TOOL_UPDATE = (1 << 4),
+  AREA_FLAG_CURSOR_UPDATE = (1 << 5),
 
-  //  AREA_FLAG_UNUSED_5           = (1 << 5),
   AREA_FLAG_UNUSED_6 = (1 << 6), /* cleared */
 
   /**
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index 616cb7613ba..24e9aa0028c 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -374,6 +374,16 @@ void WM_toolsystem_ref_set_from_runtime(struct bContext *C,
 
   toolsystem_refresh_screen_from_active_tool(bmain, workspace, tref);
 
+  /* Set the cursor if possible, if not - it's fine as entering the region will refresh it. */
+  {
+    wmWindow *win = CTX_wm_window(C);
+    ScrArea *sa = CTX_wm_area(C);
+    if (win && sa) {
+      win->addmousemove = true;
+      sa->flag |= AREA_FLAG_CURSOR_UPDATE;
+    }
+  }
+
   {
     struct wmMsgBus *mbus = CTX_wm_message_bus(C);
     WM_msg_publish_rna_prop(mbus, &workspace->id, workspace, WorkSpace, tools);
@@ -651,6 +661,10 @@ static void toolsystem_refresh_screen_from_active_tool(Main *bmain,
             if (mode == tref->mode) {
               sa->runtime.tool = tref;
               sa->runtime.is_tool_set = true;
+              /* We only need to do this for the active area,
+               * however at this point the context isn't available.
+               * Set this here since it doesn't cause any extra work. */
+              sa->flag |= AREA_FLAG_CURSOR_UPDATE;
             }
           }
         }



More information about the Bf-blender-cvs mailing list