1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 05:42:03 +03:00

integrated-title-bar: Ignore style config on macos and windows

This commit is contained in:
YuraIz 2022-11-13 19:55:07 +03:00 committed by Wez Furlong
parent fc7a8a8914
commit 7d79933d28
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
3 changed files with 26 additions and 6 deletions

View File

@ -79,6 +79,9 @@ pub struct Config {
#[dynamic(default)] #[dynamic(default)]
pub window_decorations: WindowDecorations, pub window_decorations: WindowDecorations,
/// Controls window buttons position and style
/// for fancy window decorations.
/// Has no effect on macOS or Windows.
#[dynamic(default)] #[dynamic(default)]
pub log_unknown_escape_sequences: bool, pub log_unknown_escape_sequences: bool,

View File

@ -246,7 +246,12 @@ impl TabBarState {
remove_hide_button, remove_hide_button,
remove_maximize_button, remove_maximize_button,
.. ..
} = config.fancy_window_decorations; } = if cfg!(any(windows, target_os = "macos")) {
// Ignore changes to config on windows and macos
window::FancyWindowDecorations::default()
} else {
config.fancy_window_decorations.clone()
};
let button_order = if is_left { let button_order = if is_left {
['X', '.', '-'] ['X', '.', '-']
@ -401,7 +406,7 @@ impl TabBarState {
let mut x = 0; let mut x = 0;
let mut items = vec![]; let mut items = vec![];
if fancy_window_decorations && config.fancy_window_decorations.is_left { if fancy_window_decorations && config.fancy_window_decorations.is_left && !cfg!(widnows) {
Self::fancy_window_decorations(mouse_x, &mut x, config, &mut items, &mut line, &colors); Self::fancy_window_decorations(mouse_x, &mut x, config, &mut items, &mut line, &colors);
} }
@ -499,7 +504,10 @@ impl TabBarState {
} }
// Reserve place for buttons // Reserve place for buttons
let title_width = if fancy_window_decorations && !config.fancy_window_decorations.is_left { let title_width = if fancy_window_decorations
&& !config.fancy_window_decorations.is_left
&& !cfg!(target_os = "macos")
{
let window_hide = let window_hide =
parse_status_text(&config.tab_bar_style.window_hide, CellAttributes::default()); parse_status_text(&config.tab_bar_style.window_hide, CellAttributes::default());
let window_hide_hover = parse_status_text( let window_hide_hover = parse_status_text(
@ -552,7 +560,10 @@ impl TabBarState {
line.insert_cell(x, black_cell.clone(), title_width, SEQ_ZERO); line.insert_cell(x, black_cell.clone(), title_width, SEQ_ZERO);
} }
if fancy_window_decorations && !config.fancy_window_decorations.is_left { if fancy_window_decorations
&& !config.fancy_window_decorations.is_left
&& !cfg!(target_os = "macos")
{
x = title_width; x = title_width;
Self::fancy_window_decorations(mouse_x, &mut x, config, &mut items, &mut line, &colors); Self::fancy_window_decorations(mouse_x, &mut x, config, &mut items, &mut line, &colors);
} }

View File

@ -308,6 +308,9 @@ fn window_button_element(
) -> Element { ) -> Element {
use window::FancyWindowDecorationsStyle as Style; use window::FancyWindowDecorationsStyle as Style;
#[cfg(any(windows, targer_os = "macos"))]
let style = Style::default();
let poly = match style { let poly = match style {
Style::Windows => { Style::Windows => {
use window_buttons::windows::{CLOSE, HIDE, MAXIMIZE, RESTORE}; use window_buttons::windows::{CLOSE, HIDE, MAXIMIZE, RESTORE};
@ -1180,7 +1183,9 @@ impl super::TermWindow {
TabBarItem::WindowHideButton TabBarItem::WindowHideButton
| TabBarItem::WindowMaximizeButton | TabBarItem::WindowMaximizeButton
| TabBarItem::WindowCloseButton => { | TabBarItem::WindowCloseButton => {
if self.config.fancy_window_decorations.is_left { if (self.config.fancy_window_decorations.is_left || cfg!(target_os = "macos"))
&& cfg!(not(windows))
{
left_eles.push(item_to_elem(item)) left_eles.push(item_to_elem(item))
} else { } else {
right_eles.push(item_to_elem(item)) right_eles.push(item_to_elem(item))
@ -1270,7 +1275,8 @@ impl super::TermWindow {
let window_buttons_at_left = self.config.window_decorations let window_buttons_at_left = self.config.window_decorations
== window::WindowDecorations::FANCY == window::WindowDecorations::FANCY
&& self.config.fancy_window_decorations.is_left; && (self.config.fancy_window_decorations.is_left
|| cfg!(target_os = "macos") && cfg!(not(windows)));
let left_padding = if window_buttons_at_left { 0.0 } else { 0.5 }; let left_padding = if window_buttons_at_left { 0.0 } else { 0.5 };