Remove viewport focus check from MapView _process#673
Conversation
Stop clearing province hover based on window focus and input handling in _process; use mouse enter/exit notifications instead. Co-authored-by: Cursor <cursoragent@cursor.com>
| if _cardinal_movement_vector != Vector2.ZERO and get_window().gui_get_focus_owner() != null: | ||
| _cardinal_movement_vector = Vector2.ZERO | ||
|
|
||
| if _is_viewport_inactive(): |
There was a problem hiding this comment.
Is this case handled via the NOTIFICATION_WM_MOUSE_EXIT?
The old code implies it wasn't.
There was a problem hiding this comment.
It should be now, in the old code we weren't catching the on exit stuff iirc, it was just doing a check each tick. Not sure why it was like that, this system should be more correct(?)
|
From Devin: The old code checked _is_viewport_inactive() every frame in _process, which returned true when not get_window().has_focus(). This set _mouse_over_viewport = false whenever the game window lost focus (e.g., alt-tab). The new code replaces this per-frame check with NOTIFICATION_WM_MOUSE_ENTER/NOTIFICATION_WM_MOUSE_EXIT notifications, but these only fire when the mouse cursor physically enters/leaves the window rect — they do not fire when the window merely loses focus while the cursor remains inside it. Consequently, if the user alt-tabs away while the mouse cursor is near a window edge, _mouse_over_viewport stays true and _mouse_pos_viewport freezes at the last known position. Since _process continues running, edge_scrolling_vector() (MapView.gd:316-323) returns a non-zero vector every frame, causing the camera to scroll indefinitely until the user returns to the game. To be fair, that is what Paradox games also do, so I suppose you nailed it. |
| NOTIFICATION_WM_MOUSE_ENTER: | ||
| _mouse_over_viewport = true | ||
| queue_province_hover_update() | ||
| NOTIFICATION_WM_MOUSE_EXIT: |
There was a problem hiding this comment.
| NOTIFICATION_WM_MOUSE_EXIT: | |
| NOTIFICATION_WM_MOUSE_EXIT: | |
| NOTIFICATION_WM_WINDOW_FOCUS_OUT: |
Summary
is_input_handled()check fromMapView._processthat was clearing province hover.NOTIFICATION_WM_MOUSE_ENTERandNOTIFICATION_WM_MOUSE_EXITinstead.Made with Cursor