Fix #118694: snap cursor sometimes doesn't update when dragging and dropping assets #120475
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#120475
Loading…
Reference in New Issue
No description provided.
Delete Branch "mano-wii/blender:fix_118694"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The problem happens because, on some OSs,
wm->winactive
isnullptr
or
wm->winactive->eventstate
does not update when the mouse moves.So the snap cursor state doesn't update because event modifiers did not
change.
The solution in this commit is to use the
eventstate
of the window inthe context (
CTX_wm_window(C)->eventstate
).This matches other code snippets where
eventstate
is used.The behavior on each OS apparently happens like this:
Windows:
wm->winactive
is updated if the cursor is over the window for a little less than 1 secondMacOS:
wm->winactive
is the last one selectedLinux:
wm->winactive
is the last one selectedTherefore, we cannot trust the eventstate of
wm->winactive
.The fix seems fine, requesting to pass the modifier on it's own instead of the events.
@ -490,3 +490,3 @@
static bool v3d_cursor_eventstate_has_changed(SnapCursorDataIntern *data_intern,
V3DSnapCursorState *state,
const wmWindowManager *wm,
const wmEvent *event,
I'd rather the
event_modifier
flag is passed in here, so it's clearer which values are intended to control the updates.@ -606,3 +608,3 @@
static void v3d_cursor_snap_update(V3DSnapCursorState *state,
const bContext *C,
wmWindowManager *wm,
const wmEvent *event,
This can replaced by
event_modifier
and moved after x,y arguments.In fact, this change of passing
event_state
makes the code clearer.It became clear that the problem happens because
wm->winactive
orwm->winactive->eventstate
isnullptr
(not becausewm->winactive->eventstate
does not update).@ -867,2 +857,4 @@
wmWindow *win = CTX_wm_window(C);
ScrArea *area = CTX_wm_area(C);
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
uint8_t event_modifier = win->eventstate ? win->eventstate->modifier : KM_NOTHING;
The previous logic returned when
event
was null, I think it'd be better to skip runningv3d_cursor_eventstate_has_changed
ifwin->eventstate
is null, because the logic here implies thatKM_NOTHING
is a valid fallback, when it could actually change the state if the user had modifiers held.I'm not sure when
win->eventstate
isnullptr
, but that should never happen, and should be a rare situation.In these cases, we don't exactly know if modifier keys have changed :\
I changed the code to reuse the last stored modifier key. It's as if the Ctrl state remains untouched.
@blender-bot package
Package build started. Download here when ready.
@mano-wii we could even remove the
We could even remove the null check on
win->eventstate
the cases where it is null are on file load where this logic wont run.My concern with the change you made was as follows:
event
couldn't be accessed.The current patch seems OK, although as noted already, we could assume the eventstate to be set and avoid having to comments and fallbacks for something which never happens in practice.
Or, if this seems too risky, simply not call functions when the eventstate is null, as this is what's done currently.
Good to know that
win->eventstate
is never null in these cases.I added the check still in any case. But I can study it better and remove it later.