Skip to content

Fetch Monitor Index #6993

@meanbeanmachine

Description

@meanbeanmachine

What problem does this solve or what need does it fill?

Prior to 0.9, it was possible to have "window persistence" for a multi-monitor setup. By window persistence I mean that the app will boot in the exact place you left it when you closed it. This was achieved by saving the window position to a file before app exit, then loading that file on app boot and injecting the saved window position coordinates with WindowPlugin.

As of 0.9+, this is no longer possible on a multi-monitor setup because of the introduction of 'MonitorSelection'. It looks like window position is no longer considered a global/desktop "area", and instead uses monitor index along with the coordinates. This means you now have to manually set the Monitor Index for a multi-monitor setup.

Setting the Monitor Index makes sense and is now possible with MonitorSelection, however, there doesn't seem to be a way to actually GET the Monitor Index. window::Window::position() only returns the Vec2 coordinates, and I don't see a new method related to fetching the monitor index. With this change, window persistence only works on single monitor setups; it no longer works on multi-monitor setups because you have no idea what to set the Monitor Index to.

What solution would you like?

create window::Window::monitor() => returns Monitor Index

or

window::Window::position() now returns Monitor Index in addition to the Vec2 coordinates

What alternative(s) have you considered?

There is no alternative solution unless you decide to build window persistence into Bevy core and make it an optional feature, and of course works on multi-monitor setups.

Additional context

Here is an example repo of window persistence. The Monitor stuff is commented out because there is no point setting the index if there is no way to fetch it and save it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-WindowingPlatform-agnostic interface layer to run your app inC-BugAn unexpected or incorrect behaviorC-UsabilityA targeted quality-of-life change that makes Bevy easier to useP-RegressionFunctionality that used to work but no longer does. Add a test for this!

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions