Skip to content

Commit

Permalink
fix(linux): make menubar background transparent (rust-windowing#389)
Browse files Browse the repository at this point in the history
* fix(linux): make menubar background transparent

* fix build

* use css provider

* remove shadow

* add changefile

* only when window is transparent

* update change file

* fix typo in changefile

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
  • Loading branch information
amrbashir and FabianLars authored May 14, 2022
1 parent b7e41fe commit a0d9408
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/linux-transparent-menubar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

Change menubar background color to transparent on Linux when the window is transparent.
13 changes: 13 additions & 0 deletions src/platform_impl/linux/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,19 @@ impl Window {
window.add(&window_box);

let mut menu_bar = gtk::MenuBar::new();

if attributes.transparent {
let style_context = menu_bar.style_context();
let css_provider = gtk::CssProvider::new();
let theme = r#"
menubar {
background-color: transparent;
box-shadow: none;
}
"#;
css_provider.load_from_data(theme.as_bytes());
style_context.add_provider(&css_provider, 600);
}
window_box.pack_start(&menu_bar, false, false, 0);
if let Some(window_menu) = attributes.window_menu {
window_menu.generate_menu(&mut menu_bar, &window_requests_tx, &accel_group, window_id);
Expand Down

0 comments on commit a0d9408

Please sign in to comment.