Python: Event.mouse_prev_x/y broken #48173
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
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#48173
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
System Information
Windows 10 64 bit
Nvidia Quadro 600
Blender Version
Broken:
9c916b0
Short description of error
The event.mouse_prev_x and event.mouse_prev_y properties are wrong in the modal function when I press the a mouse button.
Exact steps for others to reproduce the error
Now you should see the mouse coordinates in the console. The problem appears when I press the a mouse button. I don't know why but it does print the start location of the mouse then.
btw: Can someone tell me what 'prev' in 'mouse_prev_x' stands for?
Changed status to: 'Open'
Added subscriber: @JacquesLucke
Added subscriber: @lichtwerk
can confirm this.
P350 is a 'stab in the dark' diff that makes this better [even though this may horribly break elsewhere -- not very familiar with the event system :/]
Added subscriber: @ideasman42
@lichtwerk, checked on this and it fixes the case for mouse clicks.
but this doesn't work for keyboard presses.
Thinking this could be done in a more generic way, otherwise its quite precarious where we copy previous values when handling every event.
Added subscriber: @brecht
The issue is this hack in
wm_event_do_handlers
from d27c9f9d7:Originally this previous mouse coordinate was used for one specific purpose, which is passing mousemove events on to handlers and operators in areas that the mouse is leaving. That's how
prevx
is used inwm_event_inside_i
. To make that case work specific exceptions were added.But then these coordinates got exposed to Python and now you'd expect it to be generally useful previous mouse coordinates. For that these previous coordinates should be updated whenever an event is handled, regardless if a modal handler is running, if the mouse is over area borders, etc. Ideally this code could be cleaned up and all these exceptions removed. But doing that might break some handlers or operators, it would need to be carefully tested.
Added subscriber: @JulianEisel
Another case where we don't sync a value with
win->eventstate
correctly (missing copy towmEvent *evt
inwm_event_add_ghostevent
). This should be a proper fix:Note that the issue wasn't visible because the hack @brecht mentioned usually runs on most mouse moves. It doesn't run if a handler returns
WM_HANDLER_BREAK
, which is the default return value for modal operators.I didn't test any of these patches, but note that operators probably expect
prevx
to be the mouse coordinates of the previousMOUSEMOVE
event that was actually handled.When ghost events come in quicker than the operators can handle, the window manager converts events to type
INBETWEEN_MOUSEMOVE
which most operators will ignore. Soprevx
would be expected to be the delta to the previousMOUSEMOVE
event even if there were more ghost mouse move events in between.Previous patch was wrong, didn't check carefully enough. This should be better:
Didn't check on treating
INBETWEEN_MOUSEMOVE
nicely, but will try to do tomorrow.I wonder how many operators actually use this property?
I mean it would be easy to store the previous mouse position in the operator itself, there is no need for this to be in the Event.
If it will stay a property (for compability) the documentation should give some more information about it. At least it should say in which last event type the mouse position has been recorded (eg
MOUSEMOVE
).This issue was referenced by
ab3c1de56d
Changed status from 'Open' to: 'Resolved'
I looked into the history of this code further, and couldn't find a good reason to have this hack. This was added early in 2.5 development, and the event handling system changed a lot since then. So I just removed it and simplified setting of
prevx
andprevy
.