Skip to content

Commit

Permalink
feat: allow creating apps with no main window on wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Aug 23, 2023
1 parent db8e791 commit 55416c8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,21 @@ pub fn run<App: Application>(settings: Settings, flags: App::Flags) -> iced::Res
{
use iced::wayland::actions::window::SctkWindowSettings;
use iced_sctk::settings::InitialSurface;
iced.initial_surface = InitialSurface::XdgWindow(SctkWindowSettings {
app_id: Some(App::APP_ID.to_owned()),
autosize: settings.autosize,
client_decorations: settings.client_decorations,
resizable: settings.resizable,
size: settings.size,
size_limits: settings.size_limits,
title: None,
transparent: settings.transparent,
..SctkWindowSettings::default()
});
iced.initial_surface = if settings.no_main_window {
InitialSurface::None
} else {
InitialSurface::XdgWindow(SctkWindowSettings {
app_id: Some(App::APP_ID.to_owned()),
autosize: settings.autosize,
client_decorations: settings.client_decorations,
resizable: settings.resizable,
size: settings.size,
size_limits: settings.size_limits,
title: None,
transparent: settings.transparent,
..SctkWindowSettings::default()
})
};
}

#[cfg(not(feature = "wayland"))]
Expand Down
6 changes: 6 additions & 0 deletions src/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ pub struct Settings {
#[cfg(feature = "wayland")]
pub(crate) autosize: bool,

/// Set the application to not create a main window
#[cfg(feature = "wayland")]
pub(crate) no_main_window: bool,

/// Whether the window should have a border, a title bar, etc. or not.
pub(crate) client_decorations: bool,

Expand Down Expand Up @@ -71,6 +75,8 @@ impl Default for Settings {
antialiasing: true,
#[cfg(feature = "wayland")]
autosize: false,
#[cfg(feature = "wayland")]
no_main_window: false,
client_decorations: true,
debug: false,
default_font: font::FONT,
Expand Down

0 comments on commit 55416c8

Please sign in to comment.