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

Fix mouse position not being scaled when window size is changed #57082

Merged
merged 1 commit into from
Jan 23, 2022

Conversation

madmiraal
Copy link
Contributor

Currently, when the window size is changed, the Viewport's to_screen_rect variable is not updated. Furthermore, when it is updated, the ratio of windows size to viewport size is calculated using integer division, which generally results in a value of 0 or 1 for each dimension. This PR fixes both issues.

Fixes #44915
Fixes #50802
Fixes #52295

@madmiraal madmiraal requested a review from a team as a code owner January 23, 2022 13:50
@Calinou Calinou added this to the 4.0 milestone Jan 23, 2022
@madmiraal madmiraal changed the title Fix nmouse position not being scaled when window size is changed Fix mouse position not being scaled when window size is changed Jan 23, 2022
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Good catch! Thanks!

@akien-mga akien-mga merged commit dda6d26 into godotengine:master Jan 23, 2022
@madmiraal madmiraal deleted the fix-50802 branch January 23, 2022 17:09
@xaqbr
Copy link

xaqbr commented Feb 9, 2022

Is there a possible workaround available until this gets backported?

@madmiraal
Copy link
Contributor Author

@kinesivan This PR won't be backported. The issues that this PR fixed only affected the master branch. If you have a separate issue that affects the 3.x branch that hasn't already been raised then you should raise a new issue.

@Calinou Calinou mentioned this pull request Feb 16, 2022
@Whimfoome
Copy link

@kinesivan you have to manipulate the mouse coordinates, here is how I did it in Godot 3.x

func _unhandled_input(event):
	if event is InputEventMouseButton:
		event.position = event.position * scale_factor

@kidinashell
Copy link
Contributor

@madmiraal Well, on the first issue on the matter #52295 the version of the OP may have been 4.0, though there is more than one comment mentioning different versions of 3.x where the problem persists. To be honest could have been handled in the same swoop.

@Calinou Should I open a new Issue for 3.5 onwards? Just ran into the same problem while working on my project on 3.x versions of the engine.

@Calinou
Copy link
Member

Calinou commented Apr 2, 2022

@Calinou Should I open a new Issue for 3.5 onwards? Just ran into the same problem while working on my project on 3.x versions of the engine.

Yes, please open a separate issue with a minimal reproduction project attached.

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