Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some DisplayServer::mouse_get_position calls #78472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sauermann
Copy link
Contributor

@Sauermann Sauermann commented Jun 20, 2023

These functions can get called in situations, where there is no reasonable DisplayServer available (e.g. XR or Gui-in-3D Demo). This PR introduces Viewport::get_embedder_mouse_position() which verifies if DisplayServer::mouse_get_position can get called.

part of #77189
resolves no longer #86240 (this got fixed in #86304)

@akien-mga akien-mga added this to the 4.2 milestone Jun 20, 2023
@Sauermann Sauermann force-pushed the fix-ds-mouse-position branch from db279e3 to 5270c45 Compare June 20, 2023 20:43
@Sauermann Sauermann marked this pull request as ready for review June 20, 2023 20:49
@Sauermann Sauermann requested review from a team as code owners June 20, 2023 20:49
@@ -40,7 +40,7 @@ void EditorTitleBar::gui_input(const Ref<InputEvent> &p_event) {
if (mm->get_button_mask().has_flag(MouseButtonMask::LEFT)) {
Window *w = Object::cast_to<Window>(get_viewport());
if (w) {
Point2 mouse = DisplayServer::get_singleton()->mouse_get_position();
Copy link
Member

Choose a reason for hiding this comment

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

In this case, it should be global mouse position. EditorTitleBar is a custom editor window title bar used to move window, local coordinates will always go out of sync when window moves. It's used exclusively on macOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Viewport::get_embedder_mouse_position() returns for a non-embedded window the screen coordinates and not the viewport local coordinates.

I have verified, that this change works on Linux by setting EditorTitleBar::can_move = true.

@Sauermann Sauermann force-pushed the fix-ds-mouse-position branch from 5270c45 to ce0c968 Compare July 12, 2023 18:39
@Sauermann
Copy link
Contributor Author

I believe, that with the latest change, this PR makes all calls of DisplayServer::mouse_get_position safe.

@OverloadedOrama
Copy link
Contributor

This PR fixes #86240.

@akien-mga akien-mga requested a review from bruvzg January 9, 2024 16:03
These functions can get called in situations, where relying on
DisplayServer make no sense (e.g. XR or Gui-in-3D Demo).
This PR introduces `Viewport::get_embedder_mouse_position()` and adds
checks to verify if `DisplayServer::mouse_get_position` can get called.
@Sauermann Sauermann force-pushed the fix-ds-mouse-position branch from ce0c968 to fddf02b Compare January 26, 2024 18:19
@Sauermann Sauermann requested a review from a team as a code owner January 26, 2024 18:19
@Sauermann
Copy link
Contributor Author

This PR got partially superseded by #86304.
I have updated the PR to remove the changes, that were merged into master by the other PR.

@Sauermann Sauermann modified the milestones: 4.3, 4.4 May 4, 2024
@Sauermann Sauermann modified the milestones: 4.4, 4.5 Dec 19, 2024
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.

4 participants