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

[WIP] Split out Surface from Window #3942

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

jgcodes2020
Copy link

@jgcodes2020 jgcodes2020 commented Oct 9, 2024

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

This PR splits some methods of Window into a new supertrait Surface, laying groundwork for the implementation of #3928.

As stated there, this split is needed because popups and subsurfaces may not necessarily allow the same operations as windows.

@kchibisov
Copy link
Member

Still wonder whether to use View/Subview for that instead of Surface/Subsurface, since the Subsurface doesn't make much sense for people not familiar with Wayland.

Also not sure about the set_cursor API and it's not clear how Ids should generally work here. Like our WindowId should become some kind of Surface/ViewId and then when it comes to events surface/window/desktop is not well established throughout the API, so I'd probably hold a bit on that.

@kchibisov
Copy link
Member

kchibisov commented Oct 10, 2024

I'd also add a as_window(&self) -> Option<&dyn Window> on Surface trait to help with upcasting when passing just Surface around and raw-window-handle should be for Surface.

@jgcodes2020
Copy link
Author

Still wonder whether to use View/Subview for that instead of Surface/Subsurface, since the Subsurface doesn't make much sense for people not familiar with Wayland.

I'll argue that Surface is used by graphics APIs and Wayland. I don't want this to devolve into bikeshedding, so I'll leave it as Surface unless the maintainers collectively agree that View is the better naming convention.

Also not sure about the set_cursor API

The set_cursor API is copied verbatim from the original window trait. It should be possible to have cursors per NSView; if not, that can be emulated by changing the cursor on PointerMoved events.

and it's not clear how Ids should generally work here. Like our WindowId should become some kind of Surface/ViewId and then when it comes to events surface/window/desktop is not well established throughout the API, so I'd probably hold a bit on that.

I already addressed event handling in my proposal. Summary:

  • I agree with WindowId becoming SurfaceId.
  • Pointer events can be received by any surface (window, popup, or subsurface), but keyboard events can only be received by windows.
  • Events aren't bubbled. Not every platform does this, and the platforms that do should be able to stop them from being bubbled.

@jgcodes2020
Copy link
Author

jgcodes2020 commented Oct 19, 2024

With the Windows commit, that's every platform I can test on my machine at the moment. I don't have a Mac nor do I have Android development set up at the moment.

@MarijnS95
Copy link
Member

Now that I'm assigned for review: I'd like this PR description and the resulting squashed commit to contain a description and justification of the respective changes, rather than merely mentioning that it addresses some part of a large discussion thread in an issue.

That should make it easier to review and backtrack.

@jgcodes2020
Copy link
Author

jgcodes2020 commented Oct 19, 2024

Now that I'm assigned for review: I'd like this PR description and the resulting squashed commit to contain a description and justification of the respective changes, rather than merely mentioning that it addresses some part of a large discussion thread in an issue.

That should make it easier to review and backtrack.

I've updated the PR description.

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

Successfully merging this pull request may close these issues.

3 participants