-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
add monitor_selection
to window
#8178
base: main
Are you sure you want to change the base?
add monitor_selection
to window
#8178
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer putting MonitorSelection on the WindowMode variants that it applies to instead of having it be top level.
E.g.
pub enum WindowMode {
Windowed,
BorderlessFullscreen(MonitorSelection),
SizedFullscreen(MonitorSelection),
Fullscreen(MonitorSelection),
}
This makes it more clear what it affects. For example, if the monitor selection is a top level field, does it affect WindowPosition::at
too? What about WindowPosition::Automatic
? It seems like it would make sense that automatic would automatically position the window on the selected window, but currently in this PR it still positions it on the main monitor, and WindowPosition::at
is also relative to the primary monitor.
I also think we really need to support being able to change which monitor fullscreen is using at runtime, this is something we need the user to be able to configure, we have no idea which monitor they want to use if they don't want to use the primary. Could do this in a PR later if that's easier though.
fn main() { | ||
App::new() | ||
.add_plugins(DefaultPlugins) | ||
.add_systems(Update, bevy::window::close_on_esc) | ||
.add_systems(Startup, spawn_window) | ||
.run(); | ||
} | ||
|
||
fn spawn_window(mut commands: Commands) { | ||
commands.spawn(Window { | ||
monitor_selection: MonitorSelection::Index(1), | ||
mode: WindowMode::BorderlessFullscreen, | ||
..default() | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two suggestions for the example:
- Set the monitor of the primary window instead of creating a second window
- Add our standard bevy logo scene. Having something shown makes it clear that the example is working as intended.
Honestly my brain thought my second monitor randomly turned off when I ran this example the first time since the first bevy window showed up on the main screen windowed (thought this was the example) and the full-screen window covered my secondary monitor with black.
fn main() { | |
App::new() | |
.add_plugins(DefaultPlugins) | |
.add_systems(Update, bevy::window::close_on_esc) | |
.add_systems(Startup, spawn_window) | |
.run(); | |
} | |
fn spawn_window(mut commands: Commands) { | |
commands.spawn(Window { | |
monitor_selection: MonitorSelection::Index(1), | |
mode: WindowMode::BorderlessFullscreen, | |
..default() | |
}); | |
} | |
fn main() { | |
App::new() | |
.add_plugins(DefaultPlugins.set(WindowPlugin { | |
primary_window: Some(Window { | |
monitor_selection: MonitorSelection::Index(1), | |
mode: WindowMode::BorderlessFullscreen, | |
..default() | |
}), | |
..default() | |
})) | |
.add_systems(Update, bevy::window::close_on_esc) | |
.add_systems(Startup, setup) | |
.run(); | |
} | |
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { | |
commands.spawn(Camera2dBundle::default()); | |
commands.spawn(SpriteBundle { | |
texture: asset_server.load("branding/icon.png"), | |
..default() | |
}); | |
} |
This was added before but was yoten by windows-as-entities. For reference: #5878 Things are trickier this time around with how
|
Ah yeah that PR has more changes that would make this more of a complete solution. E.g. |
Objective
make
work
Solution
monitor_selection
field toWindow
Windowed
modesOpen questions
WindowPosition::Centered(MonitorSelection)
change? we couldMonitorSelection
and always use theMonitorSelection
from the window itselfMonitorSelection
so that you can spawn onPrimary
, then later move toCentered(MonitorSelection::At(1))
.Changelog
monitor_selection
toWindow
. Windows can now specify which monitor they want to be spawned on.Migration Guide
WindowPosition::Centered(MonitorSelection)