diff --git a/src/main.rs b/src/main.rs index 9ca2903b..7b9b5d3a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,7 @@ use data::config::{self, Config}; use data::version::Version; use data::{environment, history, server, version, Url, User}; use iced::widget::{column, container}; -use iced::{Length, Subscription, Task}; +use iced::{padding, Length, Subscription, Task}; use screen::{dashboard, help, migration, welcome}; use self::event::{events, Event}; @@ -789,7 +789,7 @@ impl Halloy { } fn view(&self, id: window::Id) -> Element { - if id == self.main_window.id { + let content = if id == self.main_window.id { let now = Instant::now(); let screen = match &self.screen { @@ -821,7 +821,16 @@ impl Halloy { .map(Message::Dashboard) } else { column![].into() - } + }; + + // The height margin varies across different operating systems due to design differences. + // For instance, on macOS, the menubar is hidden, resulting in a need for additional padding to accommodate the + // space occupied by the traffic light buttons. + let height_margin = if cfg!(target_os = "macos") { 20 } else { 0 }; + + container(content) + .padding(padding::top(height_margin)) + .into() } fn theme(&self, _window: window::Id) -> Theme { diff --git a/src/screen/dashboard.rs b/src/screen/dashboard.rs index d662fa4d..bc5b3074 100644 --- a/src/screen/dashboard.rs +++ b/src/screen/dashboard.rs @@ -9,7 +9,7 @@ use data::user::Nick; use data::{client, environment, history, Config, Server, User, Version}; use iced::widget::pane_grid::{self, PaneGrid}; use iced::widget::{column, container, row, Space}; -use iced::{clipboard, padding, Length, Task}; +use iced::{clipboard, Length, Task}; use self::command_bar::CommandBar; use self::pane::Pane; @@ -707,11 +707,6 @@ impl Dashboard { ) .map(|e| e.map(Message::Sidebar)); - // The height margin varies across different operating systems due to design differences. - // For instance, on macOS, the menubar is hidden, resulting in a need for additional padding to accommodate the - // space occupied by the traffic light buttons. - let height_margin = if cfg!(target_os = "macos") { 20 } else { 0 }; - let content = match config.sidebar.position { data::config::sidebar::Position::Left | data::config::sidebar::Position::Top => { vec![side_menu.unwrap_or_else(|| row![].into()), pane_grid.into()] @@ -725,13 +720,11 @@ impl Dashboard { Column::with_children(content) .width(Length::Fill) .height(Length::Fill) - .padding(padding::top(height_margin)) .into() } else { Row::with_children(content) .width(Length::Fill) .height(Length::Fill) - .padding(padding::top(height_margin)) .into() };