Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Migrate away from individual handlers for each Window #176

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

DJMcNab
Copy link
Member

@DJMcNab DJMcNab commented Dec 28, 2023

Implements a new API/implementation for Glazier, in a parallel v2 folder

Resolves #44
Resolves #168

Also incidentally:
Fixes #23
Fixes #78
Fixes #95

This is a massive refactor, but I think it makes things much cleaner. There are a few key differences:

  1. There is only one1 handler trait you need to implement, which is PlatformHandler
  2. Each method on this PlatformHandler is passed a Glazier, which is the root of all interaction with the platform
  3. There are no more individual handles to each Window and the application hanging around, instead things are referred to with just Ids (e.g. WindowId)2

This massively reduces the number of locks/sharing required both:

  1. Between multiple WindowHandlers and the AppHandler
  2. Between the different window handles and the state of the application

Indeed, as an example, the type of the Glazier on the Wayland backend is an exclusive reference to the entire state of the backend, except for only the user's handler.

Progress:

  • Design the shape of the API
  • Implement this API to the smallest possible form to get working behaviour on Wayland
  • Port a selection of examples
  • Implement more features of the backend
  • Merge this PR

Steps after that:

  • Bring to other backends
    • Windows
    • mac
    • x11
    • (Web?)
  • Ensure all documentation is correct
  • Port remaining examples
  • Remove the old integrations, and move the new V2 as the source folder

Footnotes

  1. The design for text fields is as-yet unclear, whether these are also included in PlatformHandler (which intuitively is my preference)

  2. There will still be ways to access raw-window-handles, exact API to be determined

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant