Skip to content

Commit

Permalink
Update the height dynamically instead of using a hardcoded value.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamoca42 committed Sep 30, 2024
1 parent e3ab31e commit a25e54c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/platform_impl/linux/wayland/header.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use gtk::{prelude::*, ApplicationWindow, EventBox, HeaderBar};
use gtk::{
glib::{self},
prelude::*,
ApplicationWindow, EventBox, HeaderBar,
};

pub struct WlHeader;

Expand All @@ -14,9 +18,17 @@ impl WlHeader {
event_box.set_above_child(true);
event_box.set_visible(true);
event_box.set_can_focus(false);
event_box.set_height_request(40);
event_box.add(&header);

let header_clone = header.clone();
let event_box_clone = event_box.clone();
glib::idle_add_local(move || {
let allocated_height = header_clone.allocated_height();
event_box_clone.set_height_request(allocated_height);
header_clone.set_height_request(allocated_height);
glib::ControlFlow::Break
});

event_box.add(&header);
window.set_titlebar(Some(&event_box));
Self::connect_resize_window(&header, window);
}
Expand Down
8 changes: 6 additions & 2 deletions src/platform_impl/linux/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ impl Window {
.map(|size| size.to_logical::<f64>(win_scale_factor as f64).into())
.unwrap_or((800, 600));

window.set_default_size(1, 1);
window.resize(width, height);
let window_clone = window.clone();
glib::idle_add_local(move || {
window_clone.set_default_size(1, 1);
window_clone.resize(width, height);
glib::ControlFlow::Break
});

if attributes.maximized {
let maximize_process = util::WindowMaximizeProcess::new(window.clone(), attributes.resizable);
Expand Down

0 comments on commit a25e54c

Please sign in to comment.