Fix #112462: Panel buttons remain active after redrawing #112503

Merged
Lukas Tönne merged 3 commits from LukasTonne/blender:fix-panel-button-sticky-state into main 2023-09-21 12:05:15 +02:00
Member

This seems to be an issue deep inside UI drawing code. The nodes render
the panel button in the correct place,
but it doesn't correctly update the button state after a redraw, unless
the mouse is moved. The button is still in a BUTTON_STATE_HIGHLIGHT
state after drawing, and a mouse press will trigger it regardless of
where the mouse cursor actually is.

A common hack to force a reset of the button state is to add a fake
mouse move event using WM_event_add_mousemove.

This seems to be an issue deep inside UI drawing code. The nodes render the panel button in the correct place, but it doesn't correctly update the button state after a redraw, unless the mouse is moved. The button is still in a `BUTTON_STATE_HIGHLIGHT` state after drawing, and a mouse press will trigger it regardless of where the mouse cursor actually is. A common hack to force a reset of the button state is to add a fake mouse move event using `WM_event_add_mousemove`.
Lukas Tönne added 1 commit 2023-09-18 11:28:45 +02:00
4b9fa425ce Fix #112462: Panel buttons remain active after redrawing.
This seems to be an issue deep inside UI drawing code. The nodes render
the panel button in the correct place ([code](64976a396b/source/blender/editors/space_node/node_draw.cc (L2033-L2050))),
but it doesn't correctly update the button state after a redraw, unless
the mouse is moved. The button is still in a `BUTTON_STATE_HIGHLIGHT`
state after drawing, and a mouse press will trigger it regardless of
where the mouse cursor actually is.

A common hack to force a reset of the button state is to add a fake
mouse move event using `WM_event_add_mousemove`.
Lukas Tönne requested review from Jacques Lucke 2023-09-18 11:28:54 +02:00
Lukas Tönne requested review from Julian Eisel 2023-09-18 11:29:02 +02:00
Member

Never knew about this hack, but indeed looks reasonable given how this is used elsewhere. Will leave this to a UI dev to review though.

Never knew about this hack, but indeed looks reasonable given how this is used elsewhere. Will leave this to a UI dev to review though.
Jacques Lucke refused to review 2023-09-18 13:10:09 +02:00

Does this mean that you are now just always redrawing the editor?

Does this mean that you are now just always redrawing the editor?
Lukas Tönne added this to the Nodes & Physics project 2023-09-18 13:47:59 +02:00
Author
Member

Does this mean that you are now just always redrawing the editor?

No, the WM_event_add_mousemove does not trigger a redraw, it just resets the button state so that a click event won't toggle the button.

> Does this mean that you are now just always redrawing the editor? No, the `WM_event_add_mousemove` does not trigger a redraw, it just resets the button state so that a click event won't toggle the button.
Hans Goudey reviewed 2023-09-18 14:26:25 +02:00
Hans Goudey left a comment
Member

Hmm, I don't see this hack used in other drawing code.

but it doesn't correctly update the button state after a redraw, unless the mouse is moved

Any idea why this is a problem now, or why it isn't a problem elsewhere?

Hmm, I don't see this hack used in other drawing code. >but it doesn't correctly update the button state after a redraw, unless the mouse is moved Any idea why this is a problem now, or why it isn't a problem elsewhere?
Author
Member

Any idea why this is a problem now, or why it isn't a problem elsewhere?

It's only a problem when you don't move the mouse after hiding sockets and click, which is probably quite rare in practice. The issue only happens when buttons change location on redraw. This workaround was suggested by @JulianEisel who maybe knows other places this is used.

> Any idea why this is a problem now, or why it isn't a problem elsewhere? It's only a problem when you don't move the mouse after hiding sockets and click, which is probably quite rare in practice. The issue only happens when buttons change location on redraw. This workaround was suggested by @JulianEisel who maybe knows other places this is used.
Member

Could the workaround be applied in the place that hide sockets then, rather than being in every node redraw? Just think it being a bit more localized and close to the source of the problem might be better.

TBH, I wonder why BUTTON_STATE_HIGHLIGHT isn't cleared if the mouse isn't over the button anymore. But maybe that question is out of scope here :P

Could the workaround be applied in the place that hide sockets then, rather than being in every node redraw? Just think it being a bit more localized and close to the source of the problem might be better. TBH, I wonder why `BUTTON_STATE_HIGHLIGHT` isn't cleared if the mouse isn't over the button anymore. But maybe that question is out of scope here :P
Lukas Tönne added 2 commits 2023-09-21 11:54:52 +02:00
Member

Agreed with Hans here, this shouldn't be done in drawing. If it is really necessary it should be done by the handling, ie the operator in this case.

Agreed with Hans here, this shouldn't be done in drawing. If it is really necessary it should be done by the handling, ie the operator in this case.
Julian Eisel approved these changes 2023-09-21 12:03:34 +02:00
Lukas Tönne merged commit fdf1040532 into main 2023-09-21 12:05:15 +02:00
Lukas Tönne deleted branch fix-panel-button-sticky-state 2023-09-21 12:05:17 +02:00
Sign in to join this conversation.
No reviewers
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 Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#112503
No description provided.