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

Clean up IWindow and remove platform-agnostic code probing ISDLWindow #6438

Merged
merged 7 commits into from
Nov 29, 2024

Conversation

Susko3
Copy link
Member

@Susko3 Susko3 commented Nov 28, 2024

Focused, PointToClient() and PointToScreen() in IWindow are made obsolete as they are not useful. See commits for more details.

Moves some members from ISDLWindow to IWindow. This makes it so platform-agnostic code no longer needs to cast to ISDLWindow (in UserInputManager and tests).

It's equivalent to `IsActive`.
Only implemented on Windows, and have no real use.
ISDLWindow.Position can be used for the same purpose.
Moves those that were used in platform-agnostic code and tests.
Comment on lines 88 to 99
Point windowLocation;

switch (Host.Window.WindowMode.Value)
{
case WindowMode.Windowed:
windowLocation = Host.Window is ISDLWindow sdlWindow ? sdlWindow.Position : Point.Empty;
break;

default:
windowLocation = Host.Window.CurrentDisplayBindable.Value.Bounds.Location;
break;
}
Copy link
Member

@frenzibyte frenzibyte Nov 28, 2024

Choose a reason for hiding this comment

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

I think it's best to do this change in a separate PR and keep this PR as a completely code-quality change. I wouldn't be comfortable to merge this without seeing it being tested on all platforms we have (testing the fact that host.Window.Position = host.Window.CurrentDisplayBindable.Value.Bounds.Location on non-windowed mode).

@frenzibyte
Copy link
Member

If we're obsoleting PointToScreen then this usage should probably be inlined with the underlying implementation or something?

var pt = PointToScreen(new Point((int)LastMousePosition.Value.X, (int)LastMousePosition.Value.Y));

Usually the CIs would've errored out if an obsolete member is being used somewhere, but it looks like applying the attribute to an interface member does not make that happen for some reason. The attribute should be copied to the class implementations as well in order to be effective.

Copy link
Member

@frenzibyte frenzibyte left a comment

Choose a reason for hiding this comment

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

^

@Susko3
Copy link
Member Author

Susko3 commented Nov 29, 2024

This inner usage is fine, I would like to remove it just from the interface (and the base SDL{2,3}Window). No need to copy the obsolete attribute to implementation as they're internal.

@frenzibyte
Copy link
Member

Sure, didn't notice the implementations were internal.

@frenzibyte frenzibyte merged commit 902be06 into ppy:master Nov 29, 2024
14 checks passed
@Susko3 Susko3 deleted the clean-up-IWindow branch November 29, 2024 00:26
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.

2 participants