Skip to content

Remove viewport focus check from MapView _process#673

Open
Catylist0 wants to merge 1 commit into
masterfrom
fix/map-province-hover-notifications
Open

Remove viewport focus check from MapView _process#673
Catylist0 wants to merge 1 commit into
masterfrom
fix/map-province-hover-notifications

Conversation

@Catylist0
Copy link
Copy Markdown

Summary

  • Remove the per-frame viewport focus / is_input_handled() check from MapView._process that was clearing province hover.
  • Track mouse presence over the map via NOTIFICATION_WM_MOUSE_ENTER and NOTIFICATION_WM_MOUSE_EXIT instead.

Made with Cursor

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>
@Catylist0 Catylist0 requested a review from a team as a code owner May 20, 2026 12:46
if _cardinal_movement_vector != Vector2.ZERO and get_window().gui_get_focus_owner() != null:
_cardinal_movement_vector = Vector2.ZERO

if _is_viewport_inactive():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this case handled via the NOTIFICATION_WM_MOUSE_EXIT?
The old code implies it wasn't.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(?)

@wvpm
Copy link
Copy Markdown
Contributor

wvpm commented May 25, 2026

From Devin:
_Missing window-focus-loss handling causes indefinite edge scrolling when alt-tabbing

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:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NOTIFICATION_WM_MOUSE_EXIT:
NOTIFICATION_WM_MOUSE_EXIT:
NOTIFICATION_WM_WINDOW_FOCUS_OUT:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants