A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
Polish cross-platform UI scaling and Linux window chrome
RoversX2cf474850f1b
diff --git a/wezterm-gui/src/glyph-frag.glsl b/wezterm-gui/src/glyph-frag.glslindex c335ea58..3484640a 100644--- a/wezterm-gui/src/glyph-frag.glsl+++ b/wezterm-gui/src/glyph-frag.glsl@@ -21,6 +21,8 @@ uniform sampler2D atlas_nearest_sampler;uniform sampler2D atlas_linear_sampler;uniform bool subpixel_aa;uniform uint milliseconds;+uniform vec3 window_clip;+uniform vec4 window_border;struct ColorEase {vec4 in_function;@@ -84,6 +86,45 @@ vec4 apply_hsv(vec4 c, vec3 transform)return vec4(hsv2rgb(hsv).rgb, c.a);}+float rounded_window_coverage(vec2 position)+{+ float radius = window_clip.z;+ if (radius <= 0.0) {+ return 1.0;+ }++ bool in_corner_x = position.x < radius || position.x > window_clip.x - radius;+ bool in_corner_y = position.y < radius || position.y > window_clip.y - radius;+ if (!in_corner_x || !in_corner_y) {+ return 1.0;+ }++ vec2 center = vec2(+ position.x > window_clip.x * 0.5 ? window_clip.x - radius : radius,+ position.y > window_clip.y * 0.5 ? window_clip.y - radius : radius+ );+ return 1.0 - smoothstep(radius - 1.0, radius, distance(position, center));+}++float rounded_window_signed_distance(vec2 position)+{+ vec2 viewport = window_clip.xy;+ vec2 half_size = viewport * 0.5;+ float radius = min(max(window_clip.z, 0.0), min(half_size.x, half_size.y));+ vec2 q = abs(position - half_size) - (half_size - vec2(radius));+ return length(max(q, vec2(0.0))) + min(max(q.x, q.y), 0.0) - radius;+}++float rounded_window_border_coverage(vec2 position)+{+ float width = window_border.w;+ if (width <= 0.0) {+ return 0.0;+ }+ float signed_distance = rounded_window_signed_distance(position);+ return smoothstep(-width - 0.5, -width + 0.5, signed_distance);+}+/*float to_srgb(float x) {if (x <= 0.0031308) {@@ -155,6 +196,19 @@ void main() {color = apply_hsv(color, o_hsv);+ float border_coverage = rounded_window_border_coverage(gl_FragCoord.xy);+ color = mix(color, vec4(window_border.rgb, 1.0), border_coverage);+ if (subpixel_aa) {+ colorMask = mix(colorMask, vec4(1.0), border_coverage);+ }++ float coverage = rounded_window_coverage(gl_FragCoord.xy);+ if (coverage <= 0.0) {+ discard;+ }+ color.a *= coverage;+ colorMask *= coverage;+// We MUST output SRGB and tell glium that we do that (outputs_srgb),// otherwise something in glium over-gamma-corrects depending on the gl setup.color = to_srgb(color);diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rsindex 12b0b315..c5a50703 100644--- a/wezterm-gui/src/native_settings.rs+++ b/wezterm-gui/src/native_settings.rs@@ -6,17 +6,23 @@ use std::path::PathBuf;use std::sync::OnceLock;use window::{Appearance, Connection, ConnectionOps};-pub(crate) const DEFAULT_SETTINGS_FONT_SIZE: f64 = 14.0;-pub(crate) const DEFAULT_SETTINGS_FONT_WEIGHT: u16 = 600;-#[cfg(target_os = "windows")]-pub(crate) const DEFAULT_HOME_FONT_SIZE: f64 = 14.0;-#[cfg(not(target_os = "windows"))]-pub(crate) const DEFAULT_HOME_FONT_SIZE: f64 = 15.0;-pub(crate) const DEFAULT_SIDEBAR_FONT_SIZE: f64 = 15.0;-pub(crate) const DEFAULT_TAB_FONT_SIZE: f64 = 14.0;-pub(crate) const DEFAULT_PANE_HEADER_FONT_SIZE: f64 = 14.0;+// One point is one logical pixel on macOS but 4/3 px at 96dpi, so the+// non-mac size is 0.75x for the same visual size (14px UI text).+pub(crate) const DEFAULT_SETTINGS_FONT_SIZE: f64 =+ if cfg!(target_os = "macos") { 14.0 } else { 10.5 };+pub(crate) const DEFAULT_SETTINGS_FONT_WEIGHT: u16 =+ if cfg!(target_os = "macos") { 600 } else { 500 };+pub(crate) const DEFAULT_HOME_FONT_SIZE: f64 =+ if cfg!(target_os = "macos") { 15.0 } else { 11.25 };+pub(crate) const DEFAULT_SIDEBAR_FONT_SIZE: f64 =+ if cfg!(target_os = "macos") { 15.0 } else { 11.25 };+pub(crate) const DEFAULT_TAB_FONT_SIZE: f64 =+ if cfg!(target_os = "macos") { 14.0 } else { 10.5 };+pub(crate) const DEFAULT_PANE_HEADER_FONT_SIZE: f64 =+ if cfg!(target_os = "macos") { 14.0 } else { 10.5 };pub(crate) const DEFAULT_BOTTOM_QUOTE_INTERVAL_MINUTES: u32 = 60;-pub(crate) const DEFAULT_BOTTOM_QUOTE_FONT_SIZE: f64 = 10.0;+pub(crate) const DEFAULT_BOTTOM_QUOTE_FONT_SIZE: f64 =+ if cfg!(target_os = "macos") { 10.0 } else { 7.5 };pub(crate) const ONBOARDING_VERSION: u32 = 1;#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rsindex 1b1d2c71..cbe0d765 100644--- a/wezterm-gui/src/settings_window.rs+++ b/wezterm-gui/src/settings_window.rs@@ -15,7 +15,7 @@ use crate::ui::{use crate::utilsprites::RenderMetrics;use anyhow::Context;use config::{configuration, Dimension, GeometryOrigin};-use std::cell::RefCell;+use std::cell::{Cell, RefCell};use std::fs;use std::path::{Path, PathBuf};use std::process::Command;@@ -39,9 +39,20 @@ use crate::native_settings::{DEFAULT_SIDEBAR_FONT_SIZE, DEFAULT_TAB_FONT_SIZE,};+// All chrome geometry below is authored in 2x macOS backing pixels.+// settings_ui_scale_for_dpi maps it onto other platforms by treating the+// design as a 192dpi surface, which halves everything at a 1x/96dpi+// display and keeps the proportions identical to macOS.const DEFAULT_WIDTH: usize = 1840;const DEFAULT_HEIGHT: usize = 1205;-const SIDEBAR_BRAND_FONT_SIZE: f64 = 17.0;+// Font sizes are points, not scaled pixels: on macOS one point renders as+// one logical pixel, while at 96dpi it renders as 4/3 px, so non-mac+// sizes are 0.75x to come out at the same visual size.+const SIDEBAR_BRAND_FONT_SIZE: f64 = if cfg!(target_os = "macos") {+ 17.0+} else {+ 12.75+};const SIDEBAR_BRAND_FONT_WEIGHT: u16 = 750;const CONTROL_HEIGHT: f32 = 56.0;const CONTROL_RADIUS: f32 = 14.0;@@ -51,7 +62,11 @@ const NAV_ROW_STEP: f32 = 68.0;const HEADER_HEIGHT: f32 = 132.0;const SIDEBAR_TITLE_Y: f32 = 78.0;const SIDEBAR_TITLE_Y_WITH_CUSTOM_CHROME: f32 = 34.0;-const SIDEBAR_BRAND_FONT_SIZE_WITH_CUSTOM_CHROME: f64 = 22.0;+const SIDEBAR_BRAND_FONT_SIZE_WITH_CUSTOM_CHROME: f64 = if cfg!(target_os = "macos") {+ 22.0+} else {+ 16.5+};const SIDEBAR_SEARCH_Y: f32 = 142.0;const SIDEBAR_LIST_TOP: f32 = 222.0;const CONTENT_TITLE_Y: f32 = 82.0;@@ -66,7 +81,58 @@ const SETTINGS_WINDOW_BUTTON_GAP: f32 = 4.0;const SETTINGS_WINDOW_BUTTON_ICON_SIZE: f32 = 26.0;thread_local! {- static SETTINGS_WINDOW: RefCell<Option<Rc<RefCell<SettingsWindow>>>> = RefCell::new(None);+ static SETTINGS_WINDOW: RefCell<SettingsWindowSlot> =+ RefCell::new(SettingsWindowSlot::Closed);+ static SETTINGS_WINDOW_NEXT_ID: Cell<u64> = const { Cell::new(1) };+}++enum SettingsWindowSlot {+ Closed,+ Opening(u64),+ Open {+ instance_id: u64,+ settings: Rc<RefCell<SettingsWindow>>,+ },+}++enum SettingsShowAction {+ Start(u64),+ Focus(Window),+ Ignore,+}++fn next_settings_window_id() -> u64 {+ SETTINGS_WINDOW_NEXT_ID.with(|next| {+ let id = next.get().max(1);+ next.set(id.wrapping_add(1).max(1));+ id+ })+}++fn settings_window_for_instance(instance_id: u64) -> Option<Rc<RefCell<SettingsWindow>>> {+ SETTINGS_WINDOW.with(|slot| match &*slot.borrow() {+ SettingsWindowSlot::Open {+ instance_id: current_id,+ settings,+ } if *current_id == instance_id => Some(Rc::clone(settings)),+ SettingsWindowSlot::Closed | SettingsWindowSlot::Opening(_) => None,+ SettingsWindowSlot::Open { .. } => None,+ })+}++fn settings_window_pixel_size(+ dpi: usize,+ active_screen_size: Option<(usize, usize)>,+) -> (usize, usize) {+ let mut width = scale_ui_usize(DEFAULT_WIDTH, dpi);+ let mut height = scale_ui_usize(DEFAULT_HEIGHT, dpi);+ if !cfg!(target_os = "macos") {+ if let Some((screen_width, screen_height)) = active_screen_size {+ width = width.min(screen_width.max(1).saturating_mul(9) / 10);+ height = height.min(screen_height.max(1).saturating_mul(9) / 10);+ }+ }+ (width, height)}#[derive(Debug, Clone, Copy, PartialEq, Eq)]@@ -966,6 +1032,26 @@ mod config_candidate_tests {dir.path().join("wezterm.lua"));}++ #[test]+ fn non_macos_settings_window_fits_the_active_screen() {+ if !cfg!(target_os = "macos") {+ // 2x-authored 1840x1205 halves to 920x603 on a 96dpi display+ assert_eq!(settings_window_pixel_size(96, None), (920, 603));+ assert_eq!(+ settings_window_pixel_size(96, Some((1920, 1080))),+ (920, 603)+ );+ assert_eq!(+ settings_window_pixel_size(96, Some((1366, 768))),+ (920, 603)+ );+ assert_eq!(+ settings_window_pixel_size(96, Some((900, 620))),+ (810, 558)+ );+ }+ }}#[derive(Debug, Clone, Copy)]@@ -1081,30 +1167,69 @@ struct SettingsPalette {}pub fn show() {- let already_open = SETTINGS_WINDOW.with(|slot| {- if let Some(settings) = slot.borrow().as_ref() {- if let Some(window) = settings.borrow().window.as_ref() {- window.show();- window.focus();- return true;+ let action = SETTINGS_WINDOW.with(|slot| {+ let mut slot = slot.borrow_mut();+ match std::mem::replace(&mut *slot, SettingsWindowSlot::Closed) {+ SettingsWindowSlot::Closed => {+ let instance_id = next_settings_window_id();+ *slot = SettingsWindowSlot::Opening(instance_id);+ SettingsShowAction::Start(instance_id)+ }+ SettingsWindowSlot::Opening(instance_id) => {+ *slot = SettingsWindowSlot::Opening(instance_id);+ SettingsShowAction::Ignore+ }+ SettingsWindowSlot::Open {+ instance_id,+ settings,+ } => {+ let window = settings.borrow().window.clone();+ *slot = SettingsWindowSlot::Open {+ instance_id,+ settings,+ };+ match window {+ Some(window) => SettingsShowAction::Focus(window),+ None => {+ let instance_id = next_settings_window_id();+ *slot = SettingsWindowSlot::Opening(instance_id);+ SettingsShowAction::Start(instance_id)+ }+ }}}- false});- if already_open {- return;- }-- promise::spawn::spawn(async {- if let Err(err) = SettingsWindow::open().await {- log::error!("failed to open settings window: {err:#}");+ match action {+ SettingsShowAction::Focus(window) => {+ window.show();+ window.focus();}- })- .detach();+ SettingsShowAction::Ignore => {}+ SettingsShowAction::Start(instance_id) => {+ promise::spawn::spawn(async move {+ if let Err(err) = SettingsWindow::open(instance_id).await {+ SETTINGS_WINDOW.with(|slot| {+ let mut slot = slot.borrow_mut();+ if matches!(+ *slot,+ SettingsWindowSlot::Opening(opening_id)+ if opening_id == instance_id+ ) {+ *slot = SettingsWindowSlot::Closed;+ }+ });+ log::error!("failed to open settings window: {err:#}");+ }+ })+ .detach();+ }+ }}struct SettingsWindow {+ instance_id: u64,+ cleaned_up: bool,window: Option<Window>,dimensions: Dimensions,window_state: WindowState,@@ -1134,7 +1259,7 @@ impl SettingsWindow {scale_ui_usize(value, self.dimensions.dpi)}- async fn open() -> anyhow::Result<()> {+ async fn open(instance_id: u64) -> anyhow::Result<()> {let config = configuration();let dpi = window::default_dpi() as usize;let fonts = Rc::new(FontConfiguration::new(Some(config.clone()), dpi)?);@@ -1155,9 +1280,23 @@ impl SettingsWindow {let appearance = Connection::get().map(|conn| conn.get_appearance()).unwrap_or(Appearance::Dark);+ let active_screen_size = if cfg!(target_os = "macos") {+ None+ } else {+ Connection::get()+ .and_then(|conn| conn.screens().ok())+ .map(|screens| {+ (+ screens.active.rect.size.width.max(1) as usize,+ screens.active.rect.size.height.max(1) as usize,+ )+ })+ };+ let (pixel_width, pixel_height) =+ settings_window_pixel_size(dpi, active_screen_size);let dimensions = Dimensions {- pixel_width: scale_ui_usize(DEFAULT_WIDTH, dpi),- pixel_height: scale_ui_usize(DEFAULT_HEIGHT, dpi),+ pixel_width,+ pixel_height,dpi,};@@ -1174,6 +1313,8 @@ impl SettingsWindow {.unwrap_or_else(|| Self::effective_font_family(&config));let settings = Rc::new(RefCell::new(Self {+ instance_id,+ cleaned_up: false,window: None,dimensions,window_state: WindowState::default(),@@ -1219,18 +1360,45 @@ impl SettingsWindow {.await?;window.set_title("ThinkTerm Settings");- let webgpu = Rc::new(WebGpuState::new(&window, dimensions, &config).await?);+ let webgpu = match WebGpuState::new(&window, dimensions, &config).await {+ Ok(webgpu) => Rc::new(webgpu),+ Err(err) => {+ window.close();+ return Err(err);+ }+ };webgpu.resize(dimensions);let dimensions = *webgpu.dimensions.borrow();{let mut settings = settings.borrow_mut();settings.dimensions = dimensions;- settings.created(RenderContext::WebGpu(Rc::clone(&webgpu)))?;+ if let Err(err) = settings.created(RenderContext::WebGpu(Rc::clone(&webgpu))) {+ window.close();+ return Err(err);+ }settings.webgpu.replace(webgpu);settings.window.replace(window.clone());}- SETTINGS_WINDOW.with(|slot| slot.replace(Some(settings)));+ let installed = SETTINGS_WINDOW.with(|slot| {+ let mut slot = slot.borrow_mut();+ if matches!(+ *slot,+ SettingsWindowSlot::Opening(opening_id) if opening_id == instance_id+ ) {+ *slot = SettingsWindowSlot::Open {+ instance_id,+ settings,+ };+ true+ } else {+ false+ }+ });+ if !installed {+ window.close();+ return Ok(());+ }window.show();window.invalidate();@@ -1244,24 +1412,41 @@ impl SettingsWindow {Ok(())}+ fn cleanup(&mut self) {+ if self.cleaned_up {+ return;+ }+ self.cleaned_up = true;+ self.commit_focused_input();+ self.ui.memory_monitoring = false;+ self.ui.memory_monitor_generation = self.ui.memory_monitor_generation.wrapping_add(1);+ self.render_state.take();+ self.webgpu.take();+ self.window.take();++ let instance_id = self.instance_id;+ SETTINGS_WINDOW.with(|slot| {+ let mut slot = slot.borrow_mut();+ let current = std::mem::replace(&mut *slot, SettingsWindowSlot::Closed);+ match current {+ SettingsWindowSlot::Open {+ instance_id: current_id,+ ..+ } if current_id == instance_id => {}+ other => *slot = other,+ }+ });+ }+fn dispatch(&mut self, event: WindowEvent, window: &Window) -> anyhow::Result<bool> {match event {WindowEvent::CloseRequested => {- self.commit_focused_input();+ self.cleanup();window.close();Ok(true)}WindowEvent::Destroyed => {- self.commit_focused_input();- self.ui.memory_monitoring = false;- self.ui.memory_monitor_generation =- self.ui.memory_monitor_generation.wrapping_add(1);- self.render_state.take();- self.webgpu.take();- self.window.take();- SETTINGS_WINDOW.with(|slot| {- slot.borrow_mut().take();- });+ self.cleanup();Ok(true)}WindowEvent::Resized {@@ -1493,12 +1678,10 @@ impl SettingsWindow {fn schedule_memory_monitor_tick(&self, window: &Window, generation: u64) {let window = window.clone();+ let instance_id = self.instance_id;promise::spawn::spawn_into_main_thread(async move {smol::Timer::after(Duration::from_millis(1500)).await;- SETTINGS_WINDOW.with(|slot| {- let Some(settings) = slot.borrow().as_ref().cloned() else {- return;- };+ if let Some(settings) = settings_window_for_instance(instance_id) {let mut settings = settings.borrow_mut();if !settings.ui.memory_monitoring|| settings.ui.memory_monitor_generation != generation@@ -1510,7 +1693,7 @@ impl SettingsWindow {settings.ui.memory_snapshot = Some(snapshot);window.invalidate();settings.schedule_memory_monitor_tick(&window, generation);- });+ }}).detach();}@@ -1578,6 +1761,7 @@ impl SettingsWindow {self.ui.main_window_resource_lines =vec![format!("Main windows: {} pending", windows.len())];+ let instance_id = self.instance_id;for (idx, gui_window) in windows.into_iter().enumerate() {let label = format!("Main window {}", idx + 1);gui_window@@ -1585,10 +1769,7 @@ impl SettingsWindow {.notify(crate::termwindow::TermWindowNotif::Apply(Box::new(move |term_window| {let lines = term_window.memory_resource_lines(&label);- SETTINGS_WINDOW.with(|slot| {- let Some(settings) = slot.borrow().as_ref().cloned() else {- return;- };+ if let Some(settings) = settings_window_for_instance(instance_id) {let mut settings = settings.borrow_mut();settings.ui@@ -1598,7 +1779,7 @@ impl SettingsWindow {if let Some(window) = settings.window.as_ref() {window.invalidate();}- });+ }},)));}@@ -1606,12 +1787,10 @@ impl SettingsWindow {fn schedule_copied_state_clear(&self, window: &Window) {let window = window.clone();+ let instance_id = self.instance_id;promise::spawn::spawn_into_main_thread(async move {smol::Timer::after(Duration::from_millis(1450)).await;- SETTINGS_WINDOW.with(|slot| {- let Some(settings) = slot.borrow().as_ref().cloned() else {- return;- };+ if let Some(settings) = settings_window_for_instance(instance_id) {let mut settings = settings.borrow_mut();if settings.ui@@ -1629,7 +1808,7 @@ impl SettingsWindow {settings.ui.input_diagnostics_copied_until = None;window.invalidate();}- });+ }}).detach();}@@ -1746,20 +1925,18 @@ impl SettingsWindow {) -> bool {let future = window.get_clipboard(Clipboard::Clipboard);let window = window.clone();+ let instance_id = self.instance_id;promise::spawn::spawn(async move {if let Ok(text) = future.await {promise::spawn::spawn_into_main_thread(async move {- SETTINGS_WINDOW.with(|slot| {- let Some(settings) = slot.borrow().as_ref().cloned() else {- return;- };+ if let Some(settings) = settings_window_for_instance(instance_id) {let mut settings = settings.borrow_mut();if settings.ui.interaction.focused == Some(focused)&& settings.push_focused_input(focused, &text){window.invalidate();}- });+ }}).detach();}@@ -2212,7 +2389,7 @@ impl SettingsWindow {}fn settings_content_extent(&self, bottom_y: f32) -> f32 {- (bottom_y + 65.0).max(self.content_bottom())+ (bottom_y + self.ui_px(65.0)).max(self.content_bottom())}fn developer_mode_enabled(&self) -> bool {@@ -2261,7 +2438,11 @@ impl SettingsWindow {}}SettingsAction::WindowClose => {- self.commit_focused_input();+ // Run cleanup before closing: on X11 the window is removed+ // from the event map inside close(), so the Destroyed event+ // never reaches us and the singleton slot would stay Open,+ // pointing at a dead window.+ self.cleanup();window.close();}SettingsAction::Select(section) => {@@ -2757,7 +2938,23 @@ impl SettingsWindow {}}- let clear_color = wgpu_color(self.palette().window_bg);+ let corner_radius =+ crate::termwindow::render::draw::effective_window_corner_radius(+ configuration().window_decorations,+ self.window_state,+ self.dimensions.dpi,+ );+ let window_border = crate::termwindow::render::draw::effective_window_border(+ configuration().window_decorations,+ self.window_state,+ self.dimensions.dpi,+ self.effective_appearance(),+ );+ let clear_color = if corner_radius > 0.0 {+ wgpu::Color::TRANSPARENT+ } else {+ wgpu_color(self.palette().window_bg)+ };let render_state = self.render_state.as_ref()@@ -2769,6 +2966,8 @@ impl SettingsWindow {[1.0, 1.0, 1.0],0,clear_color,+ corner_radius,+ window_border,)?;Ok(true)}@@ -2803,7 +3002,11 @@ impl SettingsWindow {}let config = configuration();- Self::settings_window_shows_window_buttons_for_config(&config)+ crate::termwindow::ui::platform_chrome::uses_integrated_window_buttons(+ config.window_decorations,+ self.window_state,+ ) && config.integrated_title_button_style != IntegratedTitleButtonStyle::MacOsNative+ && !config.integrated_title_buttons.is_empty()}fn settings_window_shows_window_buttons_for_config(config: &config::ConfigHandle) -> bool {@@ -3018,7 +3221,7 @@ impl SettingsWindow {let nav_font = Rc::clone(&self.ui_font);let tokens = self.ui.tokens;let sidebar_width = self.ui.sidebar.width;- let sidebar_icon_size = ((self.metrics.cell_size.height as f32 + 8.0)+ let sidebar_icon_size = ((self.metrics.cell_size.height as f32 + self.ui_px(8.0)).clamp(self.ui_px(24.0), self.ui_px(34.0)).round()) as usize;@@ -3053,16 +3256,16 @@ impl SettingsWindow {self.draw_svg_icon(layers,SettingsIcon::Search.svg(),- search_rect.origin.x + 15.0,+ search_rect.origin.x + self.ui_px(15.0),search_rect.origin.y + (search_rect.size.height - sidebar_icon_size as f32) / 2.0,sidebar_icon_size as f32,palette.muted_text,)?;if !self.ui.search.is_empty() {- let clear_size = 34.0;+ let clear_size = self.ui_px(34.0);let clear_icon_size = self.ui_px(24.0);let clear_rect = rect(- search_rect.origin.x + search_rect.size.width - clear_size - 10.0,+ search_rect.origin.x + search_rect.size.width - clear_size - self.ui_px(10.0),search_rect.origin.y + (search_rect.size.height - clear_size) / 2.0,clear_size,clear_size,@@ -3080,7 +3283,7 @@ impl SettingsWindow {clear_rect.size.width,clear_rect.size.height,palette.control_hover_bg,- 14.0,+ self.ui_px(14.0),)?;}self.draw_svg_icon(@@ -3123,7 +3326,7 @@ impl SettingsWindow {let sections = self.filtered_sections();let list_top = self.ui_px(SIDEBAR_LIST_TOP);- let list_bottom = (self.dimensions.pixel_height as f32 - 16.0).max(list_top);+ let list_bottom = (self.dimensions.pixel_height as f32 - self.ui_px(16.0)).max(list_top);let list_height = list_bottom - list_top;let content_extent = sections.len() as f32 * self.ui_px(NAV_ROW_STEP) + 8.0;self.ui@@ -3142,7 +3345,7 @@ impl SettingsWindow {layers,&ui_font,tokens.sidebar_padding + 12.0,- list_top + 18.0,+ list_top + self.ui_px(18.0),"No settings found",palette.muted_text,sidebar_width - tokens.sidebar_padding * 2.0 - 24.0,@@ -3158,7 +3361,7 @@ impl SettingsWindow {let selected = section == self.selected;let hovered = self.ui.interaction.hovered == Some(action);let pressed = self.ui.interaction.pressed == Some(action);- let row_y = y - 6.0;+ let row_y = y - self.ui_px(6.0);let row_x = tokens.sidebar_padding;let row_width = sidebar_width - tokens.sidebar_padding * 2.0;let row_bg = if selected {@@ -3196,7 +3399,7 @@ impl SettingsWindow {self.draw_svg_icon(layers,section.icon().svg(),- row_x + 14.0,+ row_x + self.ui_px(14.0),row_y + (self.ui_px(NAV_ROW_HEIGHT) - sidebar_icon_size as f32) / 2.0,sidebar_icon_size as f32,text_color,@@ -3204,11 +3407,11 @@ impl SettingsWindow {self.draw_text(layers,&nav_font,- row_x + 56.0,+ row_x + self.ui_px(56.0),self.control_text_y(row_y, self.ui_px(NAV_ROW_HEIGHT)),section.label(),text_color,- row_width - 76.0,+ row_width - self.ui_px(76.0),)?;y += self.ui_px(NAV_ROW_STEP);}@@ -3232,7 +3435,7 @@ impl SettingsWindow {let content_gap = if window_width < 980.0 { 30.0 } else { 46.0 };let right_margin = if window_width < 980.0 { 34.0 } else { 50.0 };let x = sidebar_width + content_gap;- let max_width = (window_width - x - right_margin).max(280.0);+ let max_width = (window_width - x - right_margin).max(self.ui_px(280.0));let content_top = self.content_scroll_area_top();let content_area = rect(sidebar_width + 1.0,@@ -3414,7 +3617,7 @@ impl SettingsWindow {let section_y = self.ui_px(CONTENT_SECTION_Y) - scroll;let theme_row_count = 4;let typography_row_count = 6;- let app_icon_note_space = self.metrics.cell_size.height as f32 + 10.0;+ let app_icon_note_space = self.metrics.cell_size.height as f32 + self.ui_px(10.0);let (theme_card_y, mut y) = self.settings_card_geometry(section_y, theme_row_count);let theme_card_height = self.settings_card_height(theme_row_count) + app_icon_note_space;let typography_title_y =@@ -3816,7 +4019,7 @@ impl SettingsWindow {)?;self.draw_button(layers,- x + developer_width + 14.0,+ x + developer_width + self.ui_px(14.0),button_y,self.button_width_for_label("Show Onboarding Now", 300.0),"Show Onboarding Now",@@ -3861,7 +4064,7 @@ impl SettingsWindow {)?;let preview_width = if two_column {- (max_width * 0.52).min(620.0)+ (max_width * 0.52).min(self.ui_px(620.0))} else {max_width};@@ -3871,7 +4074,7 @@ impl SettingsWindow {x};let notes_width = if two_column {- (max_width - preview_width - 42.0).max(280.0)+ (max_width - preview_width - self.ui_px(42.0)).max(self.ui_px(280.0))} else {max_width};@@ -3928,9 +4131,9 @@ impl SettingsWindow {self.paint_preview_button(layers, x, 578.0 - scroll, 250.0, "Normal Button", false)?;self.paint_preview_button(layers,- x + 270.0,+ x + self.ui_px(270.0),578.0 - scroll,- 220.0,+ self.ui_px(220.0),"Accent Button",true,)?;@@ -4051,7 +4254,7 @@ impl SettingsWindow {self.paint_style_group(layers,notes_x,- notes_top + 330.0 - scroll,+ notes_top + self.ui_px(330.0) - scroll,notes_width,"Typography",&type_tokens,@@ -4059,7 +4262,7 @@ impl SettingsWindow {self.paint_style_group(layers,notes_x,- notes_top + 590.0 - scroll,+ notes_top + self.ui_px(590.0) - scroll,notes_width,"Layout",&layout_tokens,@@ -4352,7 +4555,7 @@ impl SettingsWindow {primary_label,SettingsAction::ToggleMemoryMonitoring,)?;- let refresh_x = x + self.button_width_for_label(primary_label, 300.0) + 16.0;+ let refresh_x = x + self.button_width_for_label(primary_label, 300.0) + self.ui_px(16.0);self.draw_button(layers,refresh_x,@@ -4366,7 +4569,7 @@ impl SettingsWindow {.memory_snapshot_copied_until.is_some_and(|until| Instant::now() < until);let copy_label = if copied { "Copied" } else { "Copy" };- let copy_x = refresh_x + self.button_width_for_label("Refresh Now", 210.0) + 16.0;+ let copy_x = refresh_x + self.button_width_for_label("Refresh Now", 210.0) + self.ui_px(16.0);self.draw_button(layers,copy_x,@@ -4388,7 +4591,7 @@ impl SettingsWindow {input_primary_label,SettingsAction::ToggleInputDiagnostics,)?;- let reset_input_x = x + self.button_width_for_label(input_primary_label, 250.0) + 16.0;+ let reset_input_x = x + self.button_width_for_label(input_primary_label, 250.0) + self.ui_px(16.0);self.draw_button(layers,reset_input_x,@@ -4402,7 +4605,7 @@ impl SettingsWindow {.input_diagnostics_copied_until.is_some_and(|until| Instant::now() < until);let input_copy_label = if input_copied { "Copied" } else { "Copy Input" };- let copy_input_x = reset_input_x + self.button_width_for_label("Reset Input", 190.0) + 16.0;+ let copy_input_x = reset_input_x + self.button_width_for_label("Reset Input", 190.0) + self.ui_px(16.0);self.draw_button(layers,copy_input_x,@@ -4417,7 +4620,7 @@ impl SettingsWindow {layers,&ui_font,row_x,- resource_card_y + 28.0,+ resource_card_y + self.ui_px(28.0),"Renderer Resources",palette.title,row_width,@@ -4427,7 +4630,7 @@ impl SettingsWindow {layers,&ui_font,row_x,- resource_card_y + 66.0 + resource_line_height * idx as f32,+ resource_card_y + self.ui_px(66.0) + resource_line_height * idx as f32,line,palette.secondary_text,row_width,@@ -4451,8 +4654,8 @@ impl SettingsWindow {layers,0,x,- y + 28.0,- width.min(420.0),+ y + self.ui_px(28.0),+ width.min(self.ui_px(420.0)),self.ui_px(CONTROL_HEIGHT),palette.search_bg,palette.search_border,@@ -4461,11 +4664,11 @@ impl SettingsWindow {self.draw_text(layers,&ui_font,- x + 18.0,+ x + self.ui_px(18.0),self.control_text_y(y + 28.0, self.ui_px(CONTROL_HEIGHT)),"Search settings...",palette.muted_text,- width.min(420.0) - 36.0,+ width.min(self.ui_px(420.0)) - self.ui_px(36.0),)?;Ok(())}@@ -4481,7 +4684,7 @@ impl SettingsWindow {) -> anyhow::Result<()> {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);- let row_width = width.min(420.0);+ let row_width = width.min(self.ui_px(420.0));if selected {self.draw_rounded_rect(layers,@@ -4508,7 +4711,7 @@ impl SettingsWindow {self.draw_text(layers,&ui_font,- x + 16.0,+ x + self.ui_px(16.0),self.control_text_y(y, self.ui_px(NAV_ROW_HEIGHT)),label,if selected {@@ -4551,7 +4754,7 @@ impl SettingsWindow {self.draw_text(layers,&Rc::clone(&self.ui_font),- x + 18.0,+ x + self.ui_px(18.0),self.control_text_y(y, self.ui_px(CONTROL_HEIGHT)),label,if accent {@@ -4559,7 +4762,7 @@ impl SettingsWindow {} else {palette.text},- width - 36.0,+ width - self.ui_px(36.0),)?;Ok(())}@@ -4587,7 +4790,7 @@ impl SettingsWindow {self.draw_text(layers,&Rc::clone(&self.ui_font),- x + 14.0,+ x + self.ui_px(14.0),self.control_text_y(y, self.ui_px(CONTROL_HEIGHT)),value,palette.text,@@ -4596,11 +4799,11 @@ impl SettingsWindow {self.draw_text(layers,&Rc::clone(&self.ui_font),- x + width - 28.0,+ x + width - self.ui_px(28.0),self.control_text_y(y, self.ui_px(CONTROL_HEIGHT)),"v",palette.muted_text,- 14.0,+ self.ui_px(14.0),)?;Ok(())}@@ -4624,9 +4827,9 @@ impl SettingsWindow {palette.title,width,)?;- self.paint_separator(layers, x, y + 28.0, width)?;+ self.paint_separator(layers, x, y + self.ui_px(28.0), width)?;- let mut row_y = y + 58.0;+ let mut row_y = y + self.ui_px(58.0);for token in tokens {self.paint_style_token(layers,@@ -4850,7 +5053,7 @@ impl SettingsWindow {"Load WezTerm Source",SettingsAction::LoadWezTermSource,)?;- let second_x = x + self.button_width_for_label("Load WezTerm Source", 290.0) + 16.0;+ let second_x = x + self.button_width_for_label("Load WezTerm Source", 290.0) + self.ui_px(16.0);self.draw_button(layers,second_x,@@ -4859,7 +5062,7 @@ impl SettingsWindow {"Select All",SettingsAction::SelectAllImportFields,)?;- let third_x = second_x + self.button_width_for_label("Select All", 180.0) + 16.0;+ let third_x = second_x + self.button_width_for_label("Select All", 180.0) + self.ui_px(16.0);self.draw_button(layers,third_x,@@ -4868,7 +5071,7 @@ impl SettingsWindow {"Clear",SettingsAction::ClearImportFields,)?;- let fourth_x = third_x + self.button_width_for_label("Clear", 150.0) + 16.0;+ let fourth_x = third_x + self.button_width_for_label("Clear", 150.0) + self.ui_px(16.0);self.draw_button(layers,fourth_x,@@ -4886,7 +5089,7 @@ impl SettingsWindow {"Open WezTerm Source",SettingsAction::OpenWezTermConfigFile,)?;- let fifth_x = x + self.button_width_for_label("Open WezTerm Source", 300.0) + 16.0;+ let fifth_x = x + self.button_width_for_label("Open WezTerm Source", 300.0) + self.ui_px(16.0);self.draw_button(layers,fifth_x,@@ -4910,7 +5113,7 @@ impl SettingsWindow {let palette = self.palette();self.ui.content_scroll- .set_extents(self.content_bottom(), 240.0);+ .set_extents(self.content_bottom(), self.ui_px(240.0));let scroll = self.ui.content_scroll.offset;self.draw_text(layers,@@ -4947,7 +5150,7 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let control_width = if width >= 680.0 {280.0_f32.min(width * 0.36)@@ -4955,7 +5158,7 @@ impl SettingsWindow {220.0_f32.min(width * 0.44)};let control_x = x + width - control_width;- let control_y = y + 4.0;+ let control_y = y + self.ui_px(4.0);let text_width = (control_x - x - 24.0).max(width * 0.45);self.draw_text(layers, &ui_font, x, y, label, palette.text, text_width)?;self.draw_text(@@ -4981,11 +5184,11 @@ impl SettingsWindow {self.draw_text(layers,&ui_font,- control_x + 14.0,+ control_x + self.ui_px(14.0),self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),value,palette.text,- control_width - 26.0,+ control_width - self.ui_px(26.0),)?;Ok(())}@@ -5005,7 +5208,7 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let control_width = if width >= 680.0 {280.0_f32.min(width * 0.36)@@ -5013,7 +5216,7 @@ impl SettingsWindow {220.0_f32.min(width * 0.44)};let control_x = x + width - control_width;- let control_y = y + 4.0;+ let control_y = y + self.ui_px(4.0);let text_width = (control_x - x - 24.0).max(width * 0.45);let control_rect = rect(control_x,@@ -5063,11 +5266,11 @@ impl SettingsWindow {self.draw_text(layers,&ui_font,- control_x + 14.0,+ control_x + self.ui_px(14.0),self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),if enabled { "On" } else { "Off" },palette.text,- control_width - 26.0,+ control_width - self.ui_px(26.0),)?;Ok(())}@@ -5087,7 +5290,7 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let control_width = if width >= 680.0 {280.0_f32.min(width * 0.36)@@ -5095,7 +5298,7 @@ impl SettingsWindow {220.0_f32.min(width * 0.44)};let control_x = x + width - control_width;- let control_y = y + 4.0;+ let control_y = y + self.ui_px(4.0);let text_width = (control_x - x - 24.0).max(width * 0.45);let control_rect = rect(control_x,@@ -5145,11 +5348,11 @@ impl SettingsWindow {self.draw_text(layers,&ui_font,- control_x + 14.0,+ control_x + self.ui_px(14.0),self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),value,palette.text,- control_width - 26.0,+ control_width - self.ui_px(26.0),)?;Ok(())}@@ -5172,14 +5375,14 @@ impl SettingsWindow {let pressed = enabled && self.ui.interaction.pressed == Some(action);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let row_rect = rect(- x - 14.0,- y - 18.0,- width + 28.0,- self.settings_row_visual_height() + 18.0,+ x - self.ui_px(14.0),+ y - self.ui_px(18.0),+ width + self.ui_px(28.0),+ self.settings_row_visual_height() + self.ui_px(18.0),);if enabled {self.ui_context.push(row_rect, WidgetKind::Button, action);@@ -5200,13 +5403,13 @@ impl SettingsWindow {row_rect.size.width,row_rect.size.height,bg,- 16.0,+ self.ui_px(16.0),)?;}let checkbox_size = 30.0;let checkbox_x = x;- let checkbox_y = y + 6.0;+ let checkbox_y = y + self.ui_px(6.0);let checkbox_fill = if selected {palette.nav_selected_bg} else if hovered {@@ -5228,29 +5431,29 @@ impl SettingsWindow {checkbox_size,checkbox_fill,checkbox_border,- 8.0,+ self.ui_px(8.0),)?;if selected {self.draw_rounded_rect(layers,1,- checkbox_x + 8.0,- checkbox_y + 8.0,- checkbox_size - 16.0,- checkbox_size - 16.0,+ checkbox_x + self.ui_px(8.0),+ checkbox_y + self.ui_px(8.0),+ checkbox_size - self.ui_px(16.0),+ checkbox_size - self.ui_px(16.0),palette.selected_text,- 4.0,+ self.ui_px(4.0),)?;}- let label_x = x + checkbox_size + 18.0;+ let label_x = x + checkbox_size + self.ui_px(18.0);let value_width = if width >= 760.0 {280.0_f32.min(width * 0.30)} else {210.0_f32.min(width * 0.34)};let value_x = x + width - value_width;- let text_width = (value_x - label_x - 28.0).max(width * 0.42);+ let text_width = (value_x - label_x - self.ui_px(28.0)).max(width * 0.42);let title = format!("{} / {}", field.category, field.label);self.draw_text(layers,@@ -5275,7 +5478,7 @@ impl SettingsWindow {text_width,)?;- let preview_y = y + 4.0;+ let preview_y = y + self.ui_px(4.0);self.draw_rounded_frame(layers,0,@@ -5287,15 +5490,15 @@ impl SettingsWindow {palette.control_border,self.ui_px(CONTROL_RADIUS),)?;- let preview = self.text_with_ellipsis(&ui_font, &field.preview, value_width - 28.0);+ let preview = self.text_with_ellipsis(&ui_font, &field.preview, value_width - self.ui_px(28.0));self.draw_text(layers,&ui_font,- value_x + 14.0,+ value_x + self.ui_px(14.0),self.control_text_y(preview_y, self.ui_px(CONTROL_HEIGHT)),&preview,palette.text,- value_width - 28.0,+ value_width - self.ui_px(28.0),)?;Ok(())}@@ -5318,7 +5521,7 @@ impl SettingsWindow {height,palette.card_bg,palette.separator,- 28.0,+ self.ui_px(28.0),)}@@ -5351,7 +5554,7 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let control_width = if width >= 680.0 {@@ -5360,7 +5563,7 @@ impl SettingsWindow {220.0_f32.min(width * 0.44)};let control_x = x + width - control_width;- let control_y = y + 4.0;+ let control_y = y + self.ui_px(4.0);let dynamic_icon_size =(self.metrics.cell_size.height as f32 + 4.0).clamp(self.ui_px(24.0), self.ui_px(34.0));let reset_size = self.ui_px(CONTROL_HEIGHT);@@ -5428,12 +5631,12 @@ impl SettingsWindow {self.draw_rounded_rect(layers,1,- button_rect.origin.x + 4.0,- button_rect.origin.y + 4.0,- button_rect.size.width - 8.0,- button_rect.size.height - 8.0,+ button_rect.origin.x + self.ui_px(4.0),+ button_rect.origin.y + self.ui_px(4.0),+ button_rect.size.width - self.ui_px(8.0),+ button_rect.size.height - self.ui_px(8.0),palette.control_hover_bg,- self.ui_px(CONTROL_RADIUS) - 4.0,+ self.ui_px(CONTROL_RADIUS - 4.0),)?;}self.draw_svg_icon(@@ -5458,11 +5661,11 @@ impl SettingsWindow {self.draw_text(layers,&ui_font,- value_x + 8.0,+ value_x + self.ui_px(8.0),self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),&value_label,palette.text,- value_width - 16.0,+ value_width - self.ui_px(16.0),)?;Ok(())@@ -5484,7 +5687,7 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let control_width = if width >= 680.0 {@@ -5493,7 +5696,7 @@ impl SettingsWindow {220.0_f32.min(width * 0.44)};let control_x = x + width - control_width;- let control_y = y + 4.0;+ let control_y = y + self.ui_px(4.0);let text_width = (control_x - x - 24.0).max(width * 0.45);let focused = self.ui.interaction.focused == Some(action);let hovered = self.ui.interaction.hovered == Some(action);@@ -5565,17 +5768,17 @@ impl SettingsWindow {layers,1,control_x + 12.0,- control_y + 6.0,- selection_width + 8.0,+ control_y + self.ui_px(6.0),+ selection_width + self.ui_px(8.0),self.ui_px(CONTROL_HEIGHT) - 12.0,palette.nav_selected_bg.mul_alpha(0.56),- self.ui_px(CONTROL_RADIUS) - 4.0,+ self.ui_px(CONTROL_RADIUS - 4.0),)?;}self.draw_text(layers,&ui_font,- control_x + 16.0,+ control_x + self.ui_px(16.0),self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),display,text_color,@@ -5584,7 +5787,7 @@ impl SettingsWindow {if focused && !selected_all {let caret_text = if value.trim().is_empty() { "" } else { value };let caret_x = control_x- + 18.0+ + self.ui_px(18.0)+ self.measure_text_width(&ui_font, caret_text).min(control_width - 42.0);@@ -5592,9 +5795,9 @@ impl SettingsWindow {layers,1,caret_x - 1.0,- control_y + 8.0,- 3.0,- self.ui_px(CONTROL_HEIGHT) - 16.0,+ control_y + self.ui_px(8.0),+ self.ui_px(3.0).max(1.0),+ self.ui_px(CONTROL_HEIGHT - 16.0),palette.nav_selected_bg,)?;}@@ -5613,7 +5816,7 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let (control_x, control_y, control_width) = self.theme_mode_control_geometry(x, y, width);@@ -5675,18 +5878,18 @@ impl SettingsWindow {self.draw_text(layers,&ui_font,- control_x + 16.0,+ control_x + self.ui_px(16.0),self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),self.native_settings.appearance.theme_mode.label(),palette.text,- control_width - 60.0,+ control_width - self.ui_px(60.0),)?;self.draw_svg_icon(layers,SvgIcon::ChevronDown,- control_x + control_width - 38.0,+ control_x + control_width - self.ui_px(38.0),control_y + (self.ui_px(CONTROL_HEIGHT) - 22.0) / 2.0,- 22.0,+ self.ui_px(22.0),palette.secondary_text,)?;@@ -5706,7 +5909,7 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let (control_x, control_y, control_width) = self.dropdown_control_geometry(x, y, width);@@ -5750,7 +5953,7 @@ impl SettingsWindow {layers,&ui_font,x,- self.settings_row_description_y(y) + self.metrics.cell_size.height as f32 + 4.0,+ self.settings_row_description_y(y) + self.metrics.cell_size.height as f32 + self.ui_px(4.0),note,palette.muted_text,text_width,@@ -5769,18 +5972,18 @@ impl SettingsWindow {self.draw_text(layers,&ui_font,- control_x + 16.0,+ control_x + self.ui_px(16.0),self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),self.native_settings.appearance.app_icon.label(),palette.text,- control_width - 60.0,+ control_width - self.ui_px(60.0),)?;self.draw_svg_icon(layers,SvgIcon::ChevronDown,- control_x + control_width - 38.0,+ control_x + control_width - self.ui_px(38.0),control_y + (self.ui_px(CONTROL_HEIGHT) - 22.0) / 2.0,- 22.0,+ self.ui_px(22.0),palette.secondary_text,)?;@@ -5798,7 +6001,7 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let (control_x, control_y, control_width) = self.dropdown_control_geometry(x, y, width);@@ -5860,18 +6063,18 @@ impl SettingsWindow {self.draw_text(layers,&ui_font,- control_x + 16.0,+ control_x + self.ui_px(16.0),self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),self.current_main_renderer().label(),palette.text,- control_width - 60.0,+ control_width - self.ui_px(60.0),)?;self.draw_svg_icon(layers,SvgIcon::ChevronDown,- control_x + control_width - 38.0,+ control_x + control_width - self.ui_px(38.0),control_y + (self.ui_px(CONTROL_HEIGHT) - 22.0) / 2.0,- 22.0,+ self.ui_px(22.0),palette.secondary_text,)?;@@ -5889,7 +6092,7 @@ impl SettingsWindow {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);if draw_top_rule {- self.paint_separator(layers, x, y - 28.0, width)?;+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;}let button_label = if self.main_renderer_restart_required() {@@ -5897,7 +6100,7 @@ impl SettingsWindow {} else {"Restart"};- let button_width = self.button_width_for_label(button_label, 0.0).max(220.0);+ let button_width = self.button_width_for_label(button_label, 0.0).max(self.ui_px(220.0));let button_x = x + width - button_width;let text_width = (button_x - x - 24.0).max(width * 0.45);let value = if self.main_renderer_restart_required() {@@ -5918,7 +6121,7 @@ impl SettingsWindow {self.draw_button(layers,button_x,- y + 4.0,+ y + self.ui_px(4.0),button_width,button_label,SettingsAction::RestartApplication,@@ -5937,7 +6140,7 @@ impl SettingsWindow {} else {220.0_f32.min(width * 0.44)};- (x + width - control_width, y + 4.0, control_width)+ (x + width - control_width, y + self.ui_px(4.0), control_width)}fn paint_open_dropdown_overlay(@@ -6109,7 +6312,7 @@ impl SettingsWindow {let mut row_y = y + menu_padding;for (label, action, selected) in options.iter().copied() {- let row_rect = rect(x + 8.0, row_y, width - 16.0, row_height);+ let row_rect = rect(x + self.ui_px(8.0), row_y, width - self.ui_px(16.0), row_height);self.ui_context.push(row_rect, WidgetKind::Button, action);let hovered = self.ui.interaction.hovered == Some(action);let pressed = self.ui.interaction.pressed == Some(action);@@ -6131,13 +6334,13 @@ impl SettingsWindow {row_rect.size.width,row_rect.size.height,row_bg,- 9.0,+ self.ui_px(9.0),)?;}self.draw_text(layers,&ui_font,- row_rect.origin.x + 14.0,+ row_rect.origin.x + self.ui_px(14.0),self.control_text_y(row_rect.origin.y, row_height),label,if selected {@@ -6145,7 +6348,7 @@ impl SettingsWindow {} else {palette.text},- row_rect.size.width - 28.0,+ row_rect.size.width - self.ui_px(28.0),)?;row_y += row_height + row_gap;}@@ -6260,30 +6463,30 @@ impl SettingsWindow {if spec.focused && spec.selected_all && !spec.text.is_empty() {let selection_width = self.measure_text_width(&Rc::clone(&self.ui_font), spec.text)- .min((spec.rect.size.width - 116.0).max(0.0));+ .min((spec.rect.size.width - self.ui_px(116.0)).max(0.0));self.draw_rounded_rect(layers,1,- spec.rect.origin.x + 54.0,- spec.rect.origin.y + 6.0,- selection_width + 8.0,+ spec.rect.origin.x + self.ui_px(54.0),+ spec.rect.origin.y + self.ui_px(6.0),+ selection_width + self.ui_px(8.0),spec.rect.size.height - 12.0,palette.nav_selected_bg.mul_alpha(0.56),- self.ui.tokens.control_radius - 4.0,+ self.ui.tokens.control_radius - self.ui_px(4.0),)?;}self.draw_text(layers,&Rc::clone(&self.ui_font),- spec.rect.origin.x + 58.0,+ spec.rect.origin.x + self.ui_px(58.0),self.control_text_y(spec.rect.origin.y, spec.rect.size.height),text,color,- spec.rect.size.width - 116.0,+ spec.rect.size.width - self.ui_px(116.0),)?;if spec.focused && !spec.selected_all {let caret_x = spec.rect.origin.x- + 60.0+ + self.ui_px(60.0)+ self.measure_text_width(&Rc::clone(&self.ui_font), spec.text).min((spec.rect.size.width - 124.0).max(0.0));@@ -6291,9 +6494,9 @@ impl SettingsWindow {layers,1,caret_x - 1.0,- spec.rect.origin.y + 8.0,- 3.0,- spec.rect.size.height - 16.0,+ spec.rect.origin.y + self.ui_px(8.0),+ self.ui_px(3.0).max(1.0),+ spec.rect.size.height - self.ui_px(16.0),palette.nav_selected_bg,)?;}@@ -6370,11 +6573,11 @@ impl SettingsWindow {self.draw_text(layers,&Rc::clone(&self.ui_font),- x + 14.0,+ x + self.ui_px(14.0),self.control_text_y(y, self.ui_px(CONTROL_HEIGHT)),button.label,palette.text,- width - 36.0,+ width - self.ui_px(36.0),)?;Ok(())}@@ -6420,7 +6623,9 @@ impl SettingsWindow {}fn button_width_for_label(&self, label: &str, min_width: f32) -> f32 {- (self.measure_text_width(&Rc::clone(&self.ui_font), label) + 44.0).max(min_width)+ // min_width is in design pixels, like the layout constants+ (self.measure_text_width(&Rc::clone(&self.ui_font), label) + self.ui_px(44.0))+ .max(self.ui_px(min_width))}fn control_text_y(&self, y: f32, height: f32) -> f32 {diff --git a/wezterm-gui/src/shader.wgsl b/wezterm-gui/src/shader.wgslindex 931fc202..524b04da 100644--- a/wezterm-gui/src/shader.wgsl+++ b/wezterm-gui/src/shader.wgsl@@ -38,6 +38,8 @@ const IS_GRAY_SCALE: f32 = 4.0;struct ShaderUniform {foreground_text_hsb: vec3<f32>,milliseconds: u32,+ viewport_and_corner: vec4<f32>,+ window_border: vec4<f32>,projection: mat4x4<f32>,};@group(0) @binding(0) var<uniform> uniforms: ShaderUniform;@@ -72,6 +74,51 @@ fn apply_hsv(c: vec4<f32>, transform: vec3<f32>) -> vec4<f32>return vec4<f32>(hsv2rgb(hsv).rgb, c.a);}+fn rounded_window_coverage(position: vec2<f32>) -> f32 {+ let viewport = uniforms.viewport_and_corner.xy;+ let radius = uniforms.viewport_and_corner.z;+ if radius <= 0.0 {+ return 1.0;+ }++ let in_corner_x = position.x < radius || position.x > viewport.x - radius;+ let in_corner_y = position.y < radius || position.y > viewport.y - radius;+ if !in_corner_x || !in_corner_y {+ return 1.0;+ }++ let center = vec2<f32>(+ select(radius, viewport.x - radius, position.x > viewport.x * 0.5),+ select(radius, viewport.y - radius, position.y > viewport.y * 0.5),+ );+ let feather = 1.0;+ return 1.0 - smoothstep(radius - feather, radius, distance(position, center));+}++fn rounded_window_signed_distance(position: vec2<f32>) -> f32 {+ let viewport = uniforms.viewport_and_corner.xy;+ let half_size = viewport * 0.5;+ let radius = min(+ max(uniforms.viewport_and_corner.z, 0.0),+ min(half_size.x, half_size.y),+ );+ let q = abs(position - half_size) - (half_size - vec2<f32>(radius));+ return length(max(q, vec2<f32>(0.0))) + min(max(q.x, q.y), 0.0) - radius;+}++fn rounded_window_border_coverage(position: vec2<f32>) -> f32 {+ let width = uniforms.window_border.w;+ if width <= 0.0 {+ return 0.0;+ }+ let signed_distance = rounded_window_signed_distance(position);+ return smoothstep(+ -width - 0.5,+ -width + 0.5,+ signed_distance,+ );+}+@vertexfn vs_main(model: VertexInput,@@ -119,6 +166,17 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {}color = apply_hsv(color, hsv);+ let border_coverage = rounded_window_border_coverage(in.clip_position.xy);+ color = mix(+ color,+ vec4<f32>(uniforms.window_border.rgb, 1.0),+ border_coverage,+ );+ let coverage = rounded_window_coverage(in.clip_position.xy);+ if coverage <= 0.0 {+ discard;+ }+ color.a *= coverage;return color;}diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rsindex 4c7e22fd..30a41544 100644--- a/wezterm-gui/src/tabbar.rs+++ b/wezterm-gui/src/tabbar.rs@@ -433,6 +433,7 @@ impl TabBarState {pane_info: &[PaneInformation],colors: Option<&TabBarColors>,config: &ConfigHandle,+ use_integrated_title_buttons: bool,tab_scroll_offset: f32,left_status: &str,right_status: &str,@@ -462,10 +463,6 @@ impl TabBarState {},);- let use_integrated_title_buttons = config- .window_decorations- .contains(window::WindowDecorations::INTEGRATED_BUTTONS);-// We ultimately want to produce a line looking like this:// ` | tab1-title x | tab2-title x | + . - X `// Where the `+` sign will spawn a new tab (or show a contextdiff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex 775af122..f7a02133 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -4257,6 +4257,10 @@ impl TermWindow {&panes,tab_bar_colors,&self.config,+ crate::termwindow::ui::platform_chrome::uses_integrated_window_buttons(+ self.config.window_decorations,+ self.window_state,+ ),self.tab_bar_scroll_offset,&self.left_status,&self.right_status,diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex 7d98fedc..8c5238e2 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -14,7 +14,7 @@ use crate::termwindow::{};use ::window::{ContextMenuIcon, ContextMenuItem, IntegratedTitleButtonStyle, MouseButtons as WMB, MouseCursor,- MouseEvent, MouseEventKind as WMEK, MousePress, WindowDecorations, WindowOps, WindowState,+ MouseEvent, MouseEventKind as WMEK, MousePress, WindowOps, WindowState,};use config::keyassignment::{ClipboardCopyDestination, ClipboardPasteSource, KeyAssignment, MouseEventTrigger,@@ -279,9 +279,8 @@ impl super::TermWindow {};let window_button_count = if self.right_sidebar_width() == 0&& self- .config- .window_decorations- .contains(WindowDecorations::INTEGRATED_BUTTONS)+ .window_tab_chrome_params()+ .uses_integrated_window_buttons()&& self.config.integrated_title_button_style != IntegratedTitleButtonStyle::MacOsNative{self.config.integrated_title_buttons.len()@@ -3058,7 +3057,13 @@ impl super::TermWindow {context.request_drag_move();}#[cfg(not(target_os = "macos"))]- self.window_drag_position.replace(event);+ {+ // X11's _NET_WM_MOVERESIZE request needs the root coordinates+ // from this press. The last hover/move position can be stale+ // and causes the WM to start the drag from the wrong anchor.+ context.set_window_drag_position(event.screen_coords);+ self.window_drag_position.replace(event);+ }#[cfg(not(target_os = "macos"))]context.request_drag_move();}diff --git a/wezterm-gui/src/termwindow/onboarding.rs b/wezterm-gui/src/termwindow/onboarding.rsindex df12d04e..f2b0edc6 100644--- a/wezterm-gui/src/termwindow/onboarding.rs+++ b/wezterm-gui/src/termwindow/onboarding.rs@@ -506,33 +506,36 @@ impl OnboardingView {}fn line_h(ctx: &DrawContext) -> f32 {- (ctx.metrics.cell_size.height as f32 + 14.0).max(34.0)+ (ctx.metrics.cell_size.height as f32 + ctx.px(14.0)).max(ctx.px(34.0))}fn compact_line_h(ctx: &DrawContext) -> f32 {- (ctx.metrics.cell_size.height as f32 + 8.0).max(28.0)+ (ctx.metrics.cell_size.height as f32 + ctx.px(8.0)).max(ctx.px(28.0))}fn control_h(ctx: &DrawContext) -> f32 {- (ctx.metrics.cell_size.height as f32 + 30.0).max(60.0)+ (ctx.metrics.cell_size.height as f32 + ctx.px(30.0)).max(ctx.px(60.0))}fn preference_choice_h(ctx: &DrawContext) -> f32 {- (Self::control_h(ctx) + 10.0).clamp(68.0, 80.0)+ (Self::control_h(ctx) + ctx.px(10.0)).clamp(ctx.px(68.0), ctx.px(80.0))}fn preference_group_height(ctx: &DrawContext, choice_count: usize) -> f32 {let rows = choice_count.div_ceil(2).max(1) as f32;- Self::line_h(ctx) + 26.0 + rows * Self::preference_choice_h(ctx) + (rows - 1.0) * 18.0+ Self::line_h(ctx)+ + ctx.px(26.0)+ + rows * Self::preference_choice_h(ctx)+ + (rows - 1.0) * ctx.px(18.0)}fn action_h(ctx: &DrawContext) -> f32 {- Self::control_h(ctx).min(68.0).max(ACTION_H)+ Self::control_h(ctx).min(ctx.px(68.0)).max(ctx.px(ACTION_H))}fn centered_text_y(ctx: &DrawContext, area: RectF) -> f32 {let text_h = ctx.metrics.cell_size.height as f32;- area.origin.y + ((area.size.height - text_h) / 2.0).max(4.0)+ area.origin.y + ((area.size.height - text_h) / 2.0).max(ctx.px(4.0))}fn transition_duration() -> Duration {@@ -623,17 +626,17 @@ impl OnboardingView {palette.window_bg,)?;- let shell = inset_rect(area, OUTER_PAD);- let content_w = shell.size.width.min(CONTENT_MAX_W).max(0.0);+ let shell = inset_rect(area, ctx.px(OUTER_PAD));+ let content_w = shell.size.width.min(ctx.px(CONTENT_MAX_W)).max(0.0);let content_x = shell.origin.x + ((shell.size.width - content_w) / 2.0).max(0.0);let content = rect(content_x, shell.origin.y, content_w, shell.size.height);self.paint_header(ctx, layers, content, palette, font, title_font)?;let body = rect(content.origin.x,- content.origin.y + HEADER_H,+ content.origin.y + ctx.px(HEADER_H),content.size.width,- (content.size.height - HEADER_H - FOOTER_H).max(0.0),+ (content.size.height - ctx.px(HEADER_H + FOOTER_H)).max(0.0),);self.paint_body(ctx, layers, body, palette, font, tokens, section_font)?;self.paint_status(ctx, layers, content, palette, font)?;@@ -654,7 +657,7 @@ impl OnboardingView {layers,title_font,content.origin.x,- content.origin.y + 6.0,+ content.origin.y + ctx.px(6.0),self.step.title(),palette.text,content.size.width,@@ -664,8 +667,8 @@ impl OnboardingView {layers,font,content.origin.x,- content.origin.y + 64.0,- content.size.width.min(900.0),+ content.origin.y + ctx.px(64.0),+ content.size.width.min(ctx.px(900.0)),self.step.eyebrow(),palette.muted_text,2,@@ -674,7 +677,7 @@ impl OnboardingView {layers,0,content.origin.x,- content.origin.y + HEADER_H - 24.0,+ content.origin.y + ctx.px(HEADER_H - 24.0),content.size.width,1.0,palette.separator,@@ -695,13 +698,13 @@ impl OnboardingView {font,area.origin.x,area.origin.y,- area.size.width.min(960.0),+ area.size.width.min(ctx.px(960.0)),"Open folders, review imports, and keep terminal sessions tied to the work they belong to.",palette.secondary_text,2,)?;let line_h = Self::line_h(ctx);- let card_h = (line_h * 3.2 + 58.0).max(156.0);+ let card_h = (line_h * 3.2 + ctx.px(58.0)).max(ctx.px(156.0));let cards = [(SvgIcon::Layers,@@ -719,10 +722,10 @@ impl OnboardingView {"Return to long-running terminal work quickly.",),];- let card_gap = 22.0;- let card_w = ((area.size.width - card_gap * 2.0) / 3.0).max(240.0);+ let card_gap = ctx.px(22.0);+ let card_w = ((area.size.width - card_gap * 2.0) / 3.0).max(ctx.px(240.0));let mut x = area.origin.x;- let y = area.origin.y + line_h * 2.0 + 46.0;+ let y = area.origin.y + line_h * 2.0 + ctx.px(46.0);for (icon, title, description) in cards {self.paint_info_card(ctx,@@ -741,9 +744,9 @@ impl OnboardingView {layers,rect(area.origin.x,- y + card_h + 24.0,+ y + card_h + ctx.px(24.0),area.size.width,- (line_h * 2.6 + 54.0).max(136.0),+ (line_h * 2.6 + ctx.px(54.0)).max(ctx.px(136.0)),),palette,font,@@ -768,7 +771,7 @@ impl OnboardingView {font,area.origin.x,area.origin.y,- area.size.width.min(960.0),+ area.size.width.min(ctx.px(960.0)),"Choose a source to scan. v1 imports manual folders only, and nothing is created until review.",palette.secondary_text,2,@@ -776,9 +779,9 @@ impl OnboardingView {let line_h = Self::line_h(ctx);let grid_w = area.size.width;let gap = 20.0;- let card_w = ((grid_w - gap) / 2.0).max(280.0);- let card_h = (line_h * 3.0 + 64.0).max(164.0);- let start_y = area.origin.y + line_h * 2.0 + 42.0;+ let card_w = ((grid_w - gap) / 2.0).max(ctx.px(280.0));+ let card_h = (line_h * 3.0 + ctx.px(64.0)).max(ctx.px(164.0));+ let start_y = area.origin.y + line_h * 2.0 + ctx.px(42.0);for (idx, provider) in ImportProvider::all().iter().enumerate() {let is_manual = *provider == ImportProvider::Manual;let row = idx / 2;@@ -827,24 +830,24 @@ impl OnboardingView {let list = rect(area.origin.x,area.origin.y + line_h + 20.0,- area.size.width.min(820.0),+ area.size.width.min(ctx.px(820.0)),(area.size.height - line_h - 28.0).max(0.0),);if self.pending_projects.is_empty() {self.paint_empty_state(ctx, layers, list, palette, font)?;return Ok(());}- let content_h = self.pending_projects.len() as f32 * PROJECT_ROW_H- + self.pending_projects.len().saturating_sub(1) as f32 * PROJECT_ROW_GAP;+ let content_h = self.pending_projects.len() as f32 * ctx.px(PROJECT_ROW_H)+ + self.pending_projects.len().saturating_sub(1) as f32 * ctx.px(PROJECT_ROW_GAP);self.review_scroll.set_extents(list.size.height, content_h);let mut y = list.origin.y - self.review_scroll.offset;let projects = self.pending_projects.clone();for (idx, project) in projects.iter().enumerate() {- if y + PROJECT_ROW_H >= list.origin.y && y <= list.origin.y + list.size.height {+ if y + ctx.px(PROJECT_ROW_H) >= list.origin.y && y <= list.origin.y + list.size.height {self.paint_project_row(ctx,layers,- rect(list.origin.x, y, list.size.width, PROJECT_ROW_H),+ rect(list.origin.x, y, list.size.width, ctx.px(PROJECT_ROW_H)),list,palette,font,@@ -852,7 +855,7 @@ impl OnboardingView {project,)?;}- y += PROJECT_ROW_H + PROJECT_ROW_GAP;+ y += ctx.px(PROJECT_ROW_H + PROJECT_ROW_GAP);}if self.review_scroll.has_overflow() {draw_scrollbar(ctx, layers, palette, tokens, list, self.review_scroll)?;@@ -869,7 +872,7 @@ impl OnboardingView {font: &Rc<LoadedFont>,section_font: &Rc<LoadedFont>,) -> anyhow::Result<()> {- let group_w = area.size.width.min(1120.0);+ let group_w = area.size.width.min(ctx.px(1120.0));let language_h = Self::preference_group_height(ctx, 4);self.paint_preference_group(ctx,@@ -902,7 +905,7 @@ impl OnboardingView {),],)?;- let appearance_y = area.origin.y + language_h + 54.0;+ let appearance_y = area.origin.y + language_h + ctx.px(54.0);let appearance_h = Self::preference_group_height(ctx, 3);self.paint_preference_group(ctx,@@ -930,8 +933,8 @@ impl OnboardingView {),],)?;- let toggle_y = appearance_y + appearance_h + 58.0;- let toggle_row = rect(area.origin.x, toggle_y, group_w, 124.0);+ let toggle_y = appearance_y + appearance_h + ctx.px(58.0);+ let toggle_row = rect(area.origin.x, toggle_y, group_w, ctx.px(124.0));self.widgets.push(toggle_row,WidgetKind::Button,@@ -955,13 +958,13 @@ impl OnboardingView {toggle_row.size.height,toggle_bg,palette.control_border,- CARD_RADIUS,+ ctx.px(CARD_RADIUS),)?;let toggle_rect = rect(- toggle_row.origin.x + 24.0,- toggle_row.origin.y + 47.0,- 54.0,- 30.0,+ toggle_row.origin.x + ctx.px(24.0),+ toggle_row.origin.y + ctx.px(47.0),+ ctx.px(54.0),+ ctx.px(30.0),);draw_toggle(ctx,@@ -976,19 +979,19 @@ impl OnboardingView {layers,section_font,toggle_row.origin.x + 100.0,- toggle_row.origin.y + 26.0,+ toggle_row.origin.y + ctx.px(26.0),"Show left sidebar by default",palette.text,- toggle_row.size.width - 124.0,+ toggle_row.size.width - ctx.px(124.0),)?;ctx.draw_text(layers,font,toggle_row.origin.x + 100.0,- toggle_row.origin.y + 72.0,+ toggle_row.origin.y + ctx.px(72.0),"Applies to newly opened main windows and this setup finish.",palette.muted_text,- toggle_row.size.width - 124.0,+ toggle_row.size.width - ctx.px(124.0),)?;Ok(())}@@ -1016,18 +1019,18 @@ impl OnboardingView {("Appearance", self.selected_appearance.label().to_string()),];let mut y = area.origin.y;- let row_h = (Self::line_h(ctx) + 34.0).max(64.0);+ let row_h = (Self::line_h(ctx) + ctx.px(34.0)).max(ctx.px(64.0));for (label, value) in rows {self.paint_summary_row(ctx,layers,- rect(area.origin.x, y, area.size.width.min(760.0), row_h),+ rect(area.origin.x, y, area.size.width.min(ctx.px(760.0)), row_h),palette,font,label,&value,)?;- y += row_h + 12.0;+ y += row_h + ctx.px(12.0);}Ok(())}@@ -1040,7 +1043,7 @@ impl OnboardingView {palette: UiPalette,font: &Rc<LoadedFont>,) -> anyhow::Result<()> {- let footer_y = content.origin.y + content.size.height - FOOTER_H;+ let footer_y = content.origin.y + content.size.height - ctx.px(FOOTER_H);ctx.draw_rect(layers,0,@@ -1059,13 +1062,13 @@ impl OnboardingView {)?;let action_h = Self::action_h(ctx);- let y = footer_y + 76.0;+ let y = footer_y + ctx.px(76.0);let primary_w = if self.step == Step::ReviewProjects {- 330.0+ ctx.px(330.0)} else if self.step == Step::Ready {- 290.0+ ctx.px(290.0)} else {- 230.0+ ctx.px(230.0)};let primary = rect(content.origin.x + content.size.width - primary_w,@@ -1100,7 +1103,7 @@ impl OnboardingView {self.paint_button(ctx,layers,- rect(content.origin.x, y, 154.0, action_h),+ rect(content.origin.x, y, ctx.px(154.0), action_h),palette,font,"Skip",@@ -1125,7 +1128,10 @@ impl OnboardingView {layers,font,content.origin.x,- content.origin.y + content.size.height - FOOTER_H - Self::compact_line_h(ctx) - 16.0,+ content.origin.y + content.size.height+ - ctx.px(FOOTER_H)+ - Self::compact_line_h(ctx)+ - ctx.px(16.0),status,palette.muted_text,content.size.width,@@ -1165,7 +1171,7 @@ impl OnboardingView {area.size.width * 0.42,)?;- let track_w = (area.size.width * 0.46).min(520.0).max(280.0);+ let track_w = (area.size.width * 0.46).min(ctx.px(520.0)).max(ctx.px(280.0));let track_x = area.origin.x + area.size.width - track_w;let center_y = area.origin.y + area.size.height / 2.0;let segment_w = track_w / steps.len().max(1) as f32;@@ -1174,22 +1180,22 @@ impl OnboardingView {layers,0,track_x,- center_y - 2.0,+ center_y - ctx.px(2.0),track_w,- 4.0,+ ctx.px(4.0),palette.control_border,- 2.0,+ ctx.px(2.0),)?;let fill_w = segment_w * (progress_index + 1.0);ctx.draw_rounded_rect(layers,1,track_x,- center_y - 2.0,+ center_y - ctx.px(2.0),fill_w.min(track_w),- 4.0,+ ctx.px(4.0),active_progress,- 2.0,+ ctx.px(2.0),)?;for (idx, step) in steps.iter().enumerate() {let active = *step == self.step;@@ -1197,7 +1203,7 @@ impl OnboardingView {let complete = idx_f < progress_index.floor();let active_strength = (1.0 - (idx_f - progress_index).abs()).clamp(0.0, 1.0);let cx = track_x + segment_w * idx as f32 + segment_w / 2.0;- let size = 14.0 + 4.0 * active_strength;+ let size = ctx.px(14.0) + ctx.px(4.0) * active_strength;let color = if complete || active || active_strength > 0.01 {active_progress} else {@@ -1238,34 +1244,34 @@ impl OnboardingView {card.size.height,palette.control_bg,palette.control_border,- CARD_RADIUS,+ ctx.px(CARD_RADIUS),)?;let line_h = Self::line_h(ctx);- let icon_y = card.origin.y + 24.0;+ let icon_y = card.origin.y + ctx.px(24.0);ctx.draw_svg_icon(layers,icon,- card.origin.x + 24.0,+ card.origin.x + ctx.px(24.0),icon_y,- 28.0,+ ctx.px(28.0),palette.secondary_text,)?;ctx.draw_text(layers,font,- card.origin.x + 68.0,- card.origin.y + 22.0,+ card.origin.x + ctx.px(68.0),+ card.origin.y + ctx.px(22.0),title,palette.text,- card.size.width - 92.0,+ card.size.width - ctx.px(92.0),)?;self.draw_wrapped_text(ctx,layers,font,- card.origin.x + 24.0,- card.origin.y + 26.0 + line_h,- card.size.width - 48.0,+ card.origin.x + ctx.px(24.0),+ card.origin.y + ctx.px(26.0) + line_h,+ card.size.width - ctx.px(48.0),description,palette.secondary_text,2,@@ -1311,7 +1317,7 @@ impl OnboardingView {card.size.height,bg,border,- CARD_RADIUS,+ ctx.px(CARD_RADIUS),)?;let icon_color = if available {palette.secondary_text@@ -1321,27 +1327,27 @@ impl OnboardingView {ctx.draw_svg_icon(layers,provider.icon(),- card.origin.x + 18.0,- card.origin.y + 22.0,- 28.0,+ card.origin.x + ctx.px(18.0),+ card.origin.y + ctx.px(22.0),+ ctx.px(28.0),icon_color,)?;ctx.draw_text(layers,font,card.origin.x + 60.0,- card.origin.y + 16.0,+ card.origin.y + ctx.px(16.0),provider.label(),palette.text,- card.size.width - 78.0,+ card.size.width - ctx.px(78.0),)?;self.draw_wrapped_text(ctx,layers,font,card.origin.x + 60.0,- card.origin.y + 16.0 + line_h,- card.size.width - 78.0,+ card.origin.y + ctx.px(16.0) + line_h,+ card.size.width - ctx.px(78.0),provider.description(),palette.muted_text,2,@@ -1355,14 +1361,14 @@ impl OnboardingView {layers,font,card.origin.x + 60.0,- card.origin.y + card.size.height - line_h - 12.0,+ card.origin.y + card.size.height - line_h - ctx.px(12.0),badge,if available {palette.secondary_text} else {palette.muted_text},- card.size.width - 78.0,+ card.size.width - ctx.px(78.0),)}@@ -1404,9 +1410,14 @@ impl OnboardingView {row.size.height,bg,palette.control_border,- CARD_RADIUS,+ ctx.px(CARD_RADIUS),)?;- let checkbox = rect(row.origin.x + 16.0, row.origin.y + 24.0, 28.0, 28.0);+ let checkbox = rect(+ row.origin.x + ctx.px(16.0),+ row.origin.y + ctx.px(24.0),+ ctx.px(28.0),+ ctx.px(28.0),+ );ctx.draw_rounded_frame(layers,1,@@ -1424,51 +1435,51 @@ impl OnboardingView {} else {palette.control_border},- 6.0,+ ctx.px(6.0),)?;if project.selected {ctx.draw_svg_icon(layers,SvgIcon::CircleCheck,- checkbox.origin.x + 3.0,- checkbox.origin.y + 3.0,- 22.0,+ checkbox.origin.x + ctx.px(3.0),+ checkbox.origin.y + ctx.px(3.0),+ ctx.px(22.0),palette.selected_text,)?;}ctx.draw_text(layers,font,- row.origin.x + 62.0,- row.origin.y + 16.0,+ row.origin.x + ctx.px(62.0),+ row.origin.y + ctx.px(16.0),&project.name,palette.text,- row.size.width - 154.0,+ row.size.width - ctx.px(154.0),)?;let line_h = Self::line_h(ctx);ctx.draw_text(layers,font,- row.origin.x + 62.0,- row.origin.y + 16.0 + line_h,+ row.origin.x + ctx.px(62.0),+ row.origin.y + ctx.px(16.0) + line_h,&project.path.display().to_string(),palette.secondary_text,- row.size.width - 154.0,+ row.size.width - ctx.px(154.0),)?;ctx.draw_text(layers,font,- row.origin.x + row.size.width - 132.0,- row.origin.y + 16.0,+ row.origin.x + row.size.width - ctx.px(132.0),+ row.origin.y + ctx.px(16.0),project.source.label(),palette.muted_text,- 76.0,+ ctx.px(76.0),)?;let remove = rect(- row.origin.x + row.size.width - 46.0,- row.origin.y + 22.0,- 32.0,- 32.0,+ row.origin.x + row.size.width - ctx.px(46.0),+ row.origin.y + ctx.px(22.0),+ ctx.px(32.0),+ ctx.px(32.0),);self.widgets.push(remove,@@ -1485,15 +1496,15 @@ impl OnboardingView {remove.size.width,remove.size.height,palette.control_hover_bg,- 8.0,+ ctx.px(8.0),)?;}ctx.draw_svg_icon(layers,SvgIcon::X,- remove.origin.x + 8.0,- remove.origin.y + 8.0,- 16.0,+ remove.origin.x + ctx.px(8.0),+ remove.origin.y + ctx.px(8.0),+ ctx.px(16.0),palette.muted_text,)}@@ -1510,7 +1521,7 @@ impl OnboardingView {let card = rect(area.origin.x,area.origin.y,- area.size.width.min(720.0),+ area.size.width.min(ctx.px(720.0)),line_h * 3.4,);ctx.draw_rounded_frame(@@ -1522,32 +1533,32 @@ impl OnboardingView {card.size.height,palette.control_bg,palette.control_border,- CARD_RADIUS,+ ctx.px(CARD_RADIUS),)?;ctx.draw_svg_icon(layers,SvgIcon::FolderOpen,- card.origin.x + 22.0,- card.origin.y + 26.0,- 34.0,+ card.origin.x + ctx.px(22.0),+ card.origin.y + ctx.px(26.0),+ ctx.px(34.0),palette.muted_text,)?;ctx.draw_text(layers,font,- card.origin.x + 76.0,- card.origin.y + 24.0,+ card.origin.x + ctx.px(76.0),+ card.origin.y + ctx.px(24.0),"No projects queued",palette.text,- card.size.width - 98.0,+ card.size.width - ctx.px(98.0),)?;self.draw_wrapped_text(ctx,layers,font,- card.origin.x + 76.0,- card.origin.y + 24.0 + line_h,- card.size.width - 98.0,+ card.origin.x + ctx.px(76.0),+ card.origin.y + ctx.px(24.0) + line_h,+ card.size.width - ctx.px(98.0),"Go back to choose a folder manually, continue with an empty workspace, or Skip setup.",palette.secondary_text,2,@@ -1576,15 +1587,15 @@ impl OnboardingView {area.size.width,)?;let columns = 2usize;- let gap = 18.0;+ let gap = ctx.px(18.0);let control_h = Self::preference_choice_h(ctx);- let width = ((area.size.width - gap) / columns as f32).max(180.0);- let start_y = area.origin.y + line_h + 26.0;+ let width = ((area.size.width - gap) / columns as f32).max(ctx.px(180.0));+ let start_y = area.origin.y + line_h + ctx.px(26.0);for (idx, (label, action, selected)) in choices.iter().enumerate() {let col = idx % columns;let row = idx / columns;let x = area.origin.x + col as f32 * (width + gap);- let y = start_y + row as f32 * (control_h + 18.0);+ let y = start_y + row as f32 * (control_h + ctx.px(18.0));self.paint_choice_pill(ctx,layers,@@ -1636,12 +1647,12 @@ impl OnboardingView {area.size.height,bg,border,- CARD_RADIUS,+ ctx.px(CARD_RADIUS),)?;ctx.draw_text(layers,font,- area.origin.x + 22.0,+ area.origin.x + ctx.px(22.0),Self::centered_text_y(ctx, area),label,if selected {@@ -1649,7 +1660,7 @@ impl OnboardingView {} else {palette.secondary_text},- area.size.width - 44.0,+ area.size.width - ctx.px(44.0),)}@@ -1698,11 +1709,11 @@ impl OnboardingView {area.size.height,bg,border,- CARD_RADIUS,+ ctx.px(CARD_RADIUS),)?;let text_w = ctx.measure_text_width(font, label);let max_text_w = (area.size.width - 24.0).max(0.0);- let x = area.origin.x + ((area.size.width - text_w.min(max_text_w)) / 2.0).max(12.0);+ let x = area.origin.x + ((area.size.width - text_w.min(max_text_w)) / 2.0).max(ctx.px(12.0));ctx.draw_text(layers,font,@@ -1733,12 +1744,12 @@ impl OnboardingView {row.size.height,palette.control_bg,palette.control_border,- CARD_RADIUS,+ ctx.px(CARD_RADIUS),)?;ctx.draw_text(layers,font,- row.origin.x + 18.0,+ row.origin.x + ctx.px(18.0),Self::centered_text_y(ctx, row),label,palette.secondary_text,diff --git a/wezterm-gui/src/termwindow/render/draw.rs b/wezterm-gui/src/termwindow/render/draw.rsindex 309c54bd..3e0929f4 100644--- a/wezterm-gui/src/termwindow/render/draw.rs+++ b/wezterm-gui/src/termwindow/render/draw.rs@@ -8,9 +8,77 @@ use ::window::glium::uniforms::{MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerWrapFunction,};use ::window::glium::{BlendingFunction, LinearBlendingFactor, Surface};-use ::window::Dimensions;+use ::window::color::LinearRgba;+use ::window::{Appearance, Dimensions, WindowDecorations, WindowState};use config::FreeTypeLoadTarget;+const LINUX_WINDOW_CORNER_RADIUS: f32 = 12.0;+const LINUX_WINDOW_BORDER_WIDTH: f32 = 1.0;++#[derive(Clone, Copy, Debug, PartialEq)]+pub(crate) struct WindowBorder {+ pub width: f32,+ pub color: [f32; 3],+}++impl WindowBorder {+ const NONE: Self = Self {+ width: 0.0,+ color: [0.0; 3],+ };+}++pub(crate) fn effective_window_corner_radius(+ decorations: WindowDecorations,+ window_state: WindowState,+ dpi: usize,+) -> f32 {+ if cfg!(target_os = "linux")+ && crate::termwindow::ui::platform_chrome::uses_integrated_window_buttons(+ decorations,+ window_state,+ )+ && window_state.can_resize()+ && !window_state.contains(WindowState::TILED)+ && window_state.contains(WindowState::COMPOSITED)+ {+ LINUX_WINDOW_CORNER_RADIUS * dpi.max(1) as f32 / 96.0+ } else {+ 0.0+ }+}++pub(crate) fn effective_window_border(+ decorations: WindowDecorations,+ window_state: WindowState,+ dpi: usize,+ appearance: Appearance,+) -> WindowBorder {+ if !cfg!(target_os = "linux")+ || !crate::termwindow::ui::platform_chrome::uses_integrated_window_buttons(+ decorations,+ window_state,+ )+ || !window_state.can_resize()+ || window_state.contains(WindowState::TILED)+ {+ return WindowBorder::NONE;+ }++ let color = match appearance {+ Appearance::Light | Appearance::LightHighContrast => {+ LinearRgba::with_srgba(199, 199, 204, 255)+ }+ Appearance::Dark | Appearance::DarkHighContrast => {+ LinearRgba::with_srgba(68, 68, 76, 255)+ }+ };+ WindowBorder {+ width: LINUX_WINDOW_BORDER_WIDTH * dpi.max(1) as f32 / 96.0,+ color: [color.0, color.1, color.2],+ }+}+pub(crate) fn draw_webgpu_layers(webgpu: &WebGpuState,render_state: &RenderState,@@ -18,6 +86,8 @@ pub(crate) fn draw_webgpu_layers(foreground_text_hsb: [f32; 3],milliseconds: u32,clear_color: wgpu::Color,+ corner_radius: f32,+ window_border: WindowBorder,) -> anyhow::Result<()> {let acquire_start = crate::perf::now();let output = webgpu.surface.get_current_texture()?;@@ -109,6 +179,18 @@ pub(crate) fn draw_webgpu_layers(uniforms = webgpu.create_uniform(ShaderUniform {foreground_text_hsb,milliseconds,+ viewport_and_corner: [+ dimensions.pixel_width as f32,+ dimensions.pixel_height as f32,+ corner_radius,+ 0.0,+ ],+ window_border: [+ window_border.color[0],+ window_border.color[1],+ window_border.color[2],+ window_border.width,+ ],projection,});@@ -160,6 +242,17 @@ impl crate::TermWindow {];let milliseconds = self.created.elapsed().as_millis() as u32;+ let corner_radius = effective_window_corner_radius(+ self.config.window_decorations,+ self.window_state,+ self.dimensions.dpi,+ );+ let window_border = effective_window_border(+ self.config.window_decorations,+ self.window_state,+ self.dimensions.dpi,+ crate::native_settings::effective_appearance(),+ );draw_webgpu_layers(webgpu,render_state,@@ -172,6 +265,8 @@ impl crate::TermWindow {b: 0.,a: 0.,},+ corner_radius,+ window_border,)}@@ -261,6 +356,28 @@ impl crate::TermWindow {);let milliseconds = self.created.elapsed().as_millis() as u32;+ let corner_radius = effective_window_corner_radius(+ self.config.window_decorations,+ self.window_state,+ self.dimensions.dpi,+ );+ let window_clip = (+ self.dimensions.pixel_width as f32,+ self.dimensions.pixel_height as f32,+ corner_radius,+ );+ let window_border = effective_window_border(+ self.config.window_decorations,+ self.window_state,+ self.dimensions.dpi,+ crate::native_settings::effective_appearance(),+ );+ let window_border = (+ window_border.color[0],+ window_border.color[1],+ window_border.color[2],+ window_border.width,+ );let cursor_blink: ColorEaseUniform = (*self.cursor_blink_state.borrow()).into();let blink: ColorEaseUniform = (*self.blink_state.borrow()).into();@@ -282,6 +399,8 @@ impl crate::TermWindow {uniforms.add("foreground_text_hsb", &foreground_text_hsb);uniforms.add("subpixel_aa", &subpixel_aa);uniforms.add("milliseconds", &milliseconds);+ uniforms.add("window_clip", &window_clip);+ uniforms.add("window_border", &window_border);uniforms.add_struct("cursor_blink", &cursor_blink);uniforms.add_struct("blink", &blink);uniforms.add_struct("rapid_blink", &rapid_blink);@@ -306,3 +425,100 @@ impl crate::TermWindow {Ok(())}}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn linux_corner_radius_only_applies_to_floating_client_chrome() {+ let decorations = WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE;+ let radius =+ effective_window_corner_radius(decorations, WindowState::COMPOSITED, 96);+ if cfg!(target_os = "linux") {+ assert_eq!(radius, 12.0);+ } else {+ assert_eq!(radius, 0.0);+ }++ for state in [+ WindowState::MAXIMIZED,+ WindowState::FULL_SCREEN,+ WindowState::TILED,+ WindowState::SERVER_DECORATED,+ ] {+ assert_eq!(+ effective_window_corner_radius(+ decorations,+ state | WindowState::COMPOSITED,+ 96,+ ),+ 0.0+ );+ }+ assert_eq!(+ effective_window_corner_radius(+ WindowDecorations::TITLE | WindowDecorations::RESIZE,+ WindowState::COMPOSITED,+ 96,+ ),+ 0.0+ );+ assert_eq!(+ effective_window_corner_radius(decorations, WindowState::default(), 96),+ 0.0+ );+ }++ #[test]+ fn linux_window_border_tracks_appearance_and_floating_state() {+ let decorations = WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE;+ let dark = effective_window_border(+ decorations,+ WindowState::COMPOSITED,+ 96,+ Appearance::Dark,+ );+ let light = effective_window_border(+ decorations,+ WindowState::COMPOSITED,+ 96,+ Appearance::Light,+ );+ if cfg!(target_os = "linux") {+ assert_eq!(dark.width, 1.0);+ assert_eq!(light.width, 1.0);+ assert_ne!(dark.color, light.color);+ assert_eq!(+ effective_window_border(+ decorations,+ WindowState::COMPOSITED,+ 192,+ Appearance::Dark,+ )+ .width,+ 2.0+ );+ } else {+ assert_eq!(dark, WindowBorder::NONE);+ assert_eq!(light, WindowBorder::NONE);+ }++ for state in [+ WindowState::MAXIMIZED,+ WindowState::FULL_SCREEN,+ WindowState::TILED,+ WindowState::SERVER_DECORATED,+ ] {+ assert_eq!(+ effective_window_border(+ decorations,+ state | WindowState::COMPOSITED,+ 96,+ Appearance::Dark,+ ),+ WindowBorder::NONE+ );+ }+ }+}diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rsindex 4e703a26..1fd3bf1f 100644--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs@@ -3,6 +3,7 @@ use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTuse crate::shapecache::{BorrowedShapeCacheKey, ShapedInfo};use crate::tabbar::{TabBarItem, TabEntry};use crate::termwindow::ui::icons::SvgIcon;+use crate::termwindow::ui::platform_chrome::uses_integrated_window_buttons;use crate::termwindow::ui::tokens::{CAPSULE_BORDER_WIDTH, ICON_BUTTON_BORDER_WIDTH, SIDEBAR_INSET, TAB_CLOSE_HOVER_INSET,TAB_CLOSE_HOVER_RADIUS, TAB_CLOSE_RIGHT_GAP, TAB_ROW_START_PADDING, TAB_VERTICAL_PADDING,@@ -21,7 +22,7 @@ use wezterm_font::{ClearShapeCache, LoadedFont};use wezterm_term::Line;use window::color::LinearRgba;use window::WindowOps;-use window::{IntegratedTitleButton, IntegratedTitleButtonStyle, WindowDecorations, WindowState};+use window::{IntegratedTitleButton, IntegratedTitleButtonStyle, WindowState};const WINDOW_TAB_INSET: usize = 8;const WINDOW_TAB_ICON_GAP: usize = 8;@@ -363,9 +364,7 @@ impl crate::TermWindow {}fn fancy_tab_bar_shows_window_buttons(&self) -> bool {- self.config- .window_decorations- .contains(WindowDecorations::INTEGRATED_BUTTONS)+ uses_integrated_window_buttons(self.config.window_decorations, self.window_state)&& self.config.integrated_title_button_style != IntegratedTitleButtonStyle::MacOsNative&& !self.config.integrated_title_buttons.is_empty()}diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rsindex 6f1bc987..e8208662 100644--- a/wezterm-gui/src/termwindow/render/paint.rs+++ b/wezterm-gui/src/termwindow/render/paint.rs@@ -399,10 +399,18 @@ impl crate::TermWindow {let target_rect = state.target.as_ref().map(|target| target.rect);if let Some(rect) = target_rect {- let chrome =- UiPalette::for_appearance(crate::native_settings::effective_appearance());- let fill = chrome.selected_bg.mul_alpha(0.28);- let border = chrome.selected_bg.mul_alpha(0.8);+ // Explicit accent blue: the palette's selected_bg is gray in+ // dark mode, but the drop preview should read as blue in both.+ let accent = match crate::native_settings::effective_appearance() {+ window::Appearance::Light | window::Appearance::LightHighContrast => {+ LinearRgba::with_srgba(0, 122, 255, 255)+ }+ window::Appearance::Dark | window::Appearance::DarkHighContrast => {+ LinearRgba::with_srgba(10, 132, 255, 255)+ }+ };+ let fill = accent.mul_alpha(0.28);+ let border = accent.mul_alpha(0.8);let gl_state = self.render_state.as_ref().unwrap();let layer = gl_statediff --git a/wezterm-gui/src/termwindow/render/tab_bar.rs b/wezterm-gui/src/termwindow/render/tab_bar.rsindex 66c6955e..eab6dda7 100644--- a/wezterm-gui/src/termwindow/render/tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/tab_bar.rs@@ -22,7 +22,7 @@ mod tests {#[test]fn fancy_height_scales_with_monitor_dpi() {- let design_dpi = if cfg!(target_os = "macos") { 144 } else { 96 };+ let design_dpi = if cfg!(target_os = "macos") { 144 } else { 192 };let base = fancy_tab_bar_pixel_height(20, design_dpi);let doubled = fancy_tab_bar_pixel_height(40, design_dpi * 2);assert_eq!(doubled, base * 2);@@ -30,7 +30,7 @@ mod tests {#[test]fn fancy_height_keeps_compact_comfortable_proportion() {- let dpi = if cfg!(target_os = "macos") { 144 } else { 96 };+ let dpi = if cfg!(target_os = "macos") { 144 } else { 192 };assert_eq!(fancy_tab_bar_pixel_height(20, dpi), 44);assert_eq!(fancy_tab_bar_pixel_height(30, dpi) - fancy_tab_bar_pixel_height(20, dpi),diff --git a/wezterm-gui/src/termwindow/ssh_hosts_view.rs b/wezterm-gui/src/termwindow/ssh_hosts_view.rsindex d5e65f15..abfb2881 100644--- a/wezterm-gui/src/termwindow/ssh_hosts_view.rs+++ b/wezterm-gui/src/termwindow/ssh_hosts_view.rs@@ -105,10 +105,14 @@ pub(crate) struct SshHostsView {filtered: Vec<SshHostEntry>,system_host_count: usize,system_hosts_collapsed: bool,+ /// Split position in design pixels; painted via ctx.px.left_width: f32,dragging_left_pane: bool,last_area_x: f32,last_area_w: f32,+ /// ui scale captured at paint time so mouse handlers (no DrawContext)+ /// can convert pointer pixels back into design pixels.+ last_ui_scale: f32,list_area: RectF,/// When true the focused field is "select-all"; the next edit replaces it.select_all: bool,@@ -131,6 +135,7 @@ impl SshHostsView {dragging_left_pane: false,last_area_x: 0.0,last_area_w: 0.0,+ last_ui_scale: 1.0,list_area: rect(0.0, 0.0, 0.0, 0.0),select_all: false,widgets: UiContext::default(),@@ -353,8 +358,12 @@ impl SshHostsView {}WMEK::Move => {if self.dragging_left_pane {+ let scale = self.last_ui_scale.max(0.01);self.left_width =- Self::clamp_left_width(x - self.last_area_x, self.last_area_w);+ Self::clamp_left_width(+ (x - self.last_area_x) / scale,+ self.last_area_w / scale,+ );return ContentViewResponse::Redraw;}if self.interaction.hovered != hit {@@ -670,20 +679,21 @@ impl SshHostsView {let h = area.size.height;self.last_area_x = ox;self.last_area_w = w;- self.left_width = Self::clamp_left_width(self.left_width, w);+ self.last_ui_scale = ctx.px(1.0).max(0.01);+ self.left_width = Self::clamp_left_width(self.left_width, w / self.last_ui_scale);// Background.ctx.draw_rect(layers, 0, ox, oy, w, h, palette.window_bg)?;- let left_w = self.left_width;- let left_x = ox + PAD;- let inner_left_w = left_w - PAD * 2.0;+ let left_w = ctx.px(self.left_width);+ let left_x = ox + ctx.px(PAD);+ let inner_left_w = left_w - ctx.px(PAD * 2.0);- let search_y = oy + PAD + 48.0;+ let search_y = oy + ctx.px(PAD + 48.0);// Host list.- let list_top = search_y + INPUT_H + 14.0;- let list_bottom = oy + h - PAD;+ let list_top = search_y + ctx.px(INPUT_H + 14.0);+ let list_bottom = oy + h - ctx.px(PAD);self.list_area = rect(left_x,list_top,@@ -696,7 +706,7 @@ impl SshHostsView {layers,font,left_x,- list_top + 8.0,+ list_top + ctx.px(8.0),"No hosts yet. Click + to add.",palette.muted_text,inner_left_w,@@ -717,15 +727,15 @@ impl SshHostsView {} else {0};- let mut content_h = Self::rows_height(think_count, row_h);+ let mut content_h = Self::rows_height(think_count, row_h, ctx.px(ROW_GAP));if self.system_host_count > 0 {if content_h > 0.0 {- content_h += ROW_GAP + 4.0;+ content_h += ctx.px(ROW_GAP + 4.0);} else {- content_h += 4.0;+ content_h += ctx.px(4.0);}- content_h += GROUP_ROW_H + 10.0;- content_h += Self::rows_height(visible_system_count, row_h);+ content_h += ctx.px(GROUP_ROW_H + 10.0);+ content_h += Self::rows_height(visible_system_count, row_h, ctx.px(ROW_GAP));}self.scroll.set_extents(self.list_area.size.height, content_h);@@ -754,12 +764,12 @@ impl SshHostsView {list_bottom,)?;}- row_y += row_h + ROW_GAP;+ row_y += row_h + ctx.px(ROW_GAP);}if self.system_host_count > 0 {- row_y += 4.0;- if Self::row_visible(row_y, GROUP_ROW_H, list_top, list_bottom) {+ row_y += ctx.px(4.0);+ if Self::row_visible(row_y, ctx.px(GROUP_ROW_H), list_top, list_bottom) {self.paint_system_group_header(ctx,layers,@@ -771,7 +781,7 @@ impl SshHostsView {list_top,list_bottom,)?;- row_y += GROUP_ROW_H + 10.0;+ row_y += ctx.px(GROUP_ROW_H + 10.0);}if !self.system_hosts_collapsed || !self.search.trim().is_empty() {for (i, entry) in filtered@@ -797,7 +807,7 @@ impl SshHostsView {list_bottom,)?;}- row_y += row_h + ROW_GAP;+ row_y += row_h + ctx.px(ROW_GAP);}}}@@ -830,7 +840,7 @@ impl SshHostsView {layers,font,left_x,- oy + PAD,+ oy + ctx.px(PAD),search_y,inner_left_w,palette,@@ -842,17 +852,17 @@ impl SshHostsView {}// Right pane: form or empty hint.- let right_x = ox + left_w + PAD;- let right_w = (ox + w - PAD) - right_x;+ let right_x = ox + left_w + ctx.px(PAD);+ let right_w = (ox + w - ctx.px(PAD)) - right_x;// Vertical separator.let split_x = ox + left_w;ctx.draw_rect(layers,0,split_x,- oy + PAD,+ oy + ctx.px(PAD),if self.dragging_left_pane { 2.0 } else { 1.0 },- h - PAD * 2.0,+ h - ctx.px(PAD * 2.0),if self.dragging_left_pane {palette.selected_bg} else {@@ -860,7 +870,12 @@ impl SshHostsView {},)?;self.widgets.push(- rect(split_x - SPLIT_HANDLE_W / 2.0, oy, SPLIT_HANDLE_W, h),+ rect(+ split_x - ctx.px(SPLIT_HANDLE_W / 2.0),+ oy,+ ctx.px(SPLIT_HANDLE_W),+ h,+ ),WidgetKind::ResizeHandle,SshViewAction::ResizeLeftPane,);@@ -874,7 +889,7 @@ impl SshHostsView {tokens,cursor_on,right_x,- oy + PAD,+ oy + ctx.px(PAD),right_w,)?;} else {@@ -917,7 +932,12 @@ impl SshHostsView {inner_left_w,)?;- let search_rect = rect(left_x, search_y, inner_left_w - INPUT_H - 8.0, INPUT_H);+ let search_rect = rect(+ left_x,+ search_y,+ inner_left_w - ctx.px(INPUT_H + 8.0),+ ctx.px(INPUT_H),+ );self.widgets.push(search_rect, WidgetKind::TextInput, SshViewAction::Search);let search_focused = matches!(self.focus, Focus::Search);@@ -940,7 +960,7 @@ impl SshHostsView {tokens.control_radius,)?;- let text_pad = 12.0;+ let text_pad = ctx.px(12.0);let (search_text, search_color) = if self.search.is_empty() && !search_focused {("Search hosts...", palette.muted_text)} else {@@ -953,12 +973,12 @@ impl SshHostsView {ctx.draw_rounded_rect(layers,2,- search_rect.origin.x + text_pad - 4.0,- search_rect.origin.y + 5.0,- selection_width + 8.0,+ search_rect.origin.x + text_pad - ctx.px(4.0),+ search_rect.origin.y + ctx.px(5.0),+ selection_width + ctx.px(8.0),search_rect.size.height - 10.0,palette.selected_bg.mul_alpha(0.56),- (tokens.control_radius - 5.0).max(3.0),+ (tokens.control_radius - ctx.px(5.0)).max(ctx.px(3.0)),)?;}ctx.draw_text_on_layer(@@ -981,15 +1001,15 @@ impl SshHostsView {layers,2,caret_x - 1.0,- search_rect.origin.y + 5.0,- 3.0,+ search_rect.origin.y + ctx.px(5.0),+ ctx.px(3.0),search_rect.size.height - 10.0,palette.selected_bg,)?;}- let add_x = left_x + inner_left_w - INPUT_H;- let add_rect = rect(add_x, search_y, INPUT_H, INPUT_H);+ let add_x = left_x + inner_left_w - ctx.px(INPUT_H);+ let add_rect = rect(add_x, search_y, ctx.px(INPUT_H), ctx.px(INPUT_H));self.widgets.push(add_rect, WidgetKind::Button, SshViewAction::New);let add_hovered = self.interaction.hovered == Some(SshViewAction::New);@@ -1002,14 +1022,23 @@ impl SshHostsView {LinearRgba::TRANSPARENT};if add_bg.3 > 0.0 {- ctx.draw_rounded_rect(layers, 2, add_x, search_y, INPUT_H, INPUT_H, add_bg, 8.0)?;+ ctx.draw_rounded_rect(+ layers,+ 2,+ add_x,+ search_y,+ ctx.px(INPUT_H),+ ctx.px(INPUT_H),+ add_bg,+ ctx.px(8.0),+ )?;}let icon_size = (ctx.metrics.cell_size.height as f32 + 4.0).clamp(20.0, 30.0);ctx.draw_svg_icon(layers,SvgIcon::Plus,- add_x + (INPUT_H - icon_size) / 2.0,- search_y + (INPUT_H - icon_size) / 2.0,+ add_x + (ctx.px(INPUT_H) - icon_size) / 2.0,+ search_y + (ctx.px(INPUT_H) - icon_size) / 2.0,icon_size,if add_hovered || add_pressed {palette.text@@ -1037,7 +1066,7 @@ impl SshHostsView {return Ok(());}- let fade_height = LIST_FADE_HEIGHT.min(area.size.height).ceil() as usize;+ let fade_height = ctx.px(LIST_FADE_HEIGHT).min(area.size.height).ceil() as usize;if fade_height == 0 {return Ok(());}@@ -1116,7 +1145,7 @@ impl SshHostsView {list_bottom: f32,) -> anyhow::Result<()> {let hit_y = y.max(list_top);- let hit_h = (y + GROUP_ROW_H).min(list_bottom) - hit_y;+ let hit_h = (y + ctx.px(GROUP_ROW_H)).min(list_bottom) - hit_y;let rect = rect(x, hit_y, width, hit_h.max(0.0));self.widgets.push(rect,@@ -1131,7 +1160,7 @@ impl SshHostsView {x,y,width,- GROUP_ROW_H,+ ctx.px(GROUP_ROW_H),palette.sidebar_row_hover_bg,10.0,)?;@@ -1146,8 +1175,8 @@ impl SshHostsView {ctx.draw_text(layers,font,- x + 42.0,- y + 8.0,+ x + ctx.px(42.0),+ y + ctx.px(8.0),&label,palette.muted_text,(width - 50.0).max(0.0),@@ -1156,14 +1185,14 @@ impl SshHostsView {}fn host_row_height(ctx: &DrawContext) -> f32 {- (ctx.metrics.cell_size.height as f32 * 2.15 + 26.0).max(ROW_MIN_H)+ (ctx.metrics.cell_size.height as f32 * 2.15 + ctx.px(26.0)).max(ctx.px(ROW_MIN_H))}- fn rows_height(count: usize, row_h: f32) -> f32 {+ fn rows_height(count: usize, row_h: f32, row_gap: f32) -> f32 {if count == 0 {0.0} else {- count as f32 * row_h + (count.saturating_sub(1)) as f32 * ROW_GAP+ count as f32 * row_h + (count.saturating_sub(1)) as f32 * row_gap}}@@ -1207,13 +1236,13 @@ impl SshHostsView {LinearRgba::TRANSPARENT};if bg.3 > 0.0 {- ctx.draw_rounded_rect(layers, 0, x, y, width, row_h, bg, HOST_ROW_RADIUS)?;+ ctx.draw_rounded_rect(layers, 0, x, y, width, row_h, bg, ctx.px(HOST_ROW_RADIUS))?;}// OS / brand icon.let line_h = ctx.metrics.cell_size.height as f32;- let icon_size = (line_h * 1.05).clamp(34.0, 48.0);- let icon_x = x + 12.0;+ let icon_size = (line_h * 1.05).clamp(ctx.px(34.0), ctx.px(48.0));+ let icon_x = x + ctx.px(12.0);let icon_y = y + (row_h - icon_size) / 2.0;match spec.detected_distro.as_deref().and_then(distro_to_icon) {Some(brand) => ctx.draw_brand_icon(layers, brand, icon_x, icon_y, icon_size)?,@@ -1227,16 +1256,16 @@ impl SshHostsView {)?,}- let text_x = icon_x + icon_size + 14.0;+ let text_x = icon_x + icon_size + ctx.px(14.0);let action_space = if entry.source == SshHostSource::ThinkTerm {- HOST_ACTION_RIGHT_PAD + HOST_ACTION_BTN * 2.0 + HOST_ACTION_GAP + 10.0+ ctx.px(HOST_ACTION_RIGHT_PAD + HOST_ACTION_BTN * 2.0 + HOST_ACTION_GAP + 10.0)} else {- 16.0+ ctx.px(16.0)};let text_w = width - (text_x - x) - action_space;let stack_h = line_h * 2.02;- let title_y = y + ((row_h - stack_h) / 2.0).max(8.0) - 2.0;- let subtitle_y = (title_y + line_h * 1.02).min(y + row_h - line_h - 8.0);+ let title_y = y + ((row_h - stack_h) / 2.0).max(ctx.px(8.0)) - ctx.px(2.0);+ let subtitle_y = (title_y + line_h * 1.02).min(y + row_h - line_h - ctx.px(8.0));ctx.draw_text(layers,font,@@ -1279,7 +1308,7 @@ impl SshHostsView {if entry.source == SshHostSource::System {return Ok(());}- let btn = HOST_ACTION_BTN;+ let btn = ctx.px(HOST_ACTION_BTN);let btn_y = y + (row_h - btn) / 2.0;draw_icon_button(ctx,@@ -1287,7 +1316,7 @@ impl SshHostsView {&mut self.widgets,&self.interaction,palette,- x + width - HOST_ACTION_RIGHT_PAD - btn * 2.0 - HOST_ACTION_GAP,+ x + width - ctx.px(HOST_ACTION_RIGHT_PAD) - btn * 2.0 - ctx.px(HOST_ACTION_GAP),btn_y,btn,SvgIcon::SlidersHorizontal,@@ -1299,7 +1328,7 @@ impl SshHostsView {&mut self.widgets,&self.interaction,palette,- x + width - HOST_ACTION_RIGHT_PAD - btn,+ x + width - ctx.px(HOST_ACTION_RIGHT_PAD) - btn,btn_y,btn,SvgIcon::Trash2,@@ -1341,8 +1370,8 @@ impl SshHostsView {)?;let line_h = ctx.metrics.cell_size.height as f32;- let field_w = width.min(560.0);- let mut cur_y = y + line_h + 18.0;+ let field_w = width.min(ctx.px(560.0));+ let mut cur_y = y + line_h + ctx.px(18.0);for i in 0..BASE_FIELD_COUNT {ctx.draw_text(layers,@@ -1353,7 +1382,7 @@ impl SshHostsView {palette.muted_text,field_w,)?;- let input_y = cur_y + line_h + 6.0;+ let input_y = cur_y + line_h + ctx.px(6.0);// Mask the password field.let masked = if i == FIELD_PASSWORD {"•".repeat(fields[i].chars().count())@@ -1373,23 +1402,23 @@ impl SshHostsView {&self.interaction,palette,tokens,- 12.0,+ ctx.px(12.0),cursor_on,TextInputSpec {placeholder: "",text: shown,- rect: rect(x, input_y, field_w, INPUT_H),+ rect: rect(x, input_y, field_w, ctx.px(INPUT_H)),focused: focus == Focus::Field(i),selected_all: focus == Focus::Field(i) && self.select_all,action: SshViewAction::FocusField(i),},)?;- cur_y = input_y + INPUT_H + 18.0;+ cur_y = input_y + ctx.px(INPUT_H + 18.0);}// Detect-OS toggle.- let toggle_w = 44.0;- let toggle_h = 24.0;+ let toggle_w = ctx.px(44.0);+ let toggle_h = ctx.px(24.0);ctx.draw_text(layers,font,@@ -1397,7 +1426,7 @@ impl SshHostsView {cur_y + (toggle_h - line_h) / 2.0,"Detect OS on connect",palette.text,- field_w - toggle_w - 12.0,+ field_w - toggle_w - ctx.px(12.0),)?;draw_toggle(ctx,@@ -1408,7 +1437,7 @@ impl SshHostsView {detect_os,SshViewAction::ToggleDetect,)?;- cur_y += toggle_h + 24.0;+ cur_y += toggle_h + ctx.px(24.0);// Use-Mosh toggle: connect by launching the local `mosh` client instead// of the SSH domain.@@ -1419,7 +1448,7 @@ impl SshHostsView {cur_y + (toggle_h - line_h) / 2.0,"Connect with Mosh",palette.text,- field_w - toggle_w - 12.0,+ field_w - toggle_w - ctx.px(12.0),)?;draw_toggle(ctx,@@ -1430,7 +1459,7 @@ impl SshHostsView {use_mosh,SshViewAction::ToggleMosh,)?;- cur_y += toggle_h + 24.0;+ cur_y += toggle_h + ctx.px(24.0);if use_mosh {draw_text_input(@@ -1441,18 +1470,18 @@ impl SshHostsView {&self.interaction,palette,tokens,- 12.0,+ ctx.px(12.0),cursor_on,TextInputSpec {placeholder: ssh_hosts::DEFAULT_MOSH_SERVER_COMMAND,text: &fields[FIELD_MOSH_SERVER],- rect: rect(x, cur_y, field_w, INPUT_H),+ rect: rect(x, cur_y, field_w, ctx.px(INPUT_H)),focused: focus == Focus::Field(FIELD_MOSH_SERVER),selected_all: focus == Focus::Field(FIELD_MOSH_SERVER) && self.select_all,action: SshViewAction::FocusField(FIELD_MOSH_SERVER),},)?;- cur_y += INPUT_H + 24.0;+ cur_y += ctx.px(INPUT_H + 24.0);}// ThinkTerm-Connect toggle: attach the persistent remote mux domain@@ -1465,7 +1494,7 @@ impl SshHostsView {cur_y + (toggle_h - line_h) / 2.0,"ThinkTerm Connect (persistent mux)",palette.text,- field_w - toggle_w - 12.0,+ field_w - toggle_w - ctx.px(12.0),)?;draw_toggle(ctx,@@ -1476,7 +1505,7 @@ impl SshHostsView {multiplexing,SshViewAction::ToggleMux,)?;- cur_y += toggle_h + 24.0;+ cur_y += toggle_h + ctx.px(24.0);if let Some(err) = &error {ctx.draw_text(@@ -1488,12 +1517,12 @@ impl SshHostsView {palette.text,field_w,)?;- cur_y += line_h + 12.0;+ cur_y += line_h + ctx.px(12.0);}// Buttons sized to their (measured) label so nothing is truncated.- let gap = 12.0;- let btn_w = |label: &str| ctx.measure_text_width(font, label) + 36.0;+ let gap = ctx.px(12.0);+ let btn_w = |label: &str| ctx.measure_text_width(font, label) + ctx.px(36.0);let mut bx = x;for (label, action, primary) in [("Save & Open", SshViewAction::SaveAndConnect, true),@@ -1504,7 +1533,7 @@ impl SshHostsView {let spec = ButtonSpec {label,action,- rect: rect(bx, cur_y, w, BTN_H),+ rect: rect(bx, cur_y, w, ctx.px(BTN_H)),state: self.button_state(action, primary),kind: WidgetKind::Button,};diff --git a/wezterm-gui/src/termwindow/ui/context_menu.rs b/wezterm-gui/src/termwindow/ui/context_menu.rsindex 4701c256..1faf9c5e 100644--- a/wezterm-gui/src/termwindow/ui/context_menu.rs+++ b/wezterm-gui/src/termwindow/ui/context_menu.rs@@ -14,23 +14,26 @@ use std::rc::Rc;use std::sync::Arc;use wezterm_font::LoadedFont;-const MENU_MIN_WIDTH: usize = 220;-const MENU_MAX_WIDTH: usize = 500;-const MENU_WINDOW_MARGIN: usize = 12;-const MENU_PADDING_X: usize = 14;-const MENU_PADDING_Y: usize = 10;-const MENU_LABEL_GAP: usize = 12;-const MENU_ICON_SIZE: usize = 21;-const MENU_ICON_SLOT: usize = 32;-const MENU_CHECK_SLOT: usize = 28;-const MENU_ARROW_SLOT: usize = 28;-const MENU_ROW_EXTRA_HEIGHT: usize = 22;-const MENU_SEPARATOR_HEIGHT: usize = 9;-const MENU_BORDER_WIDTH: f32 = 1.0;-const MENU_RADIUS: f32 = 22.0;-const MENU_ROW_RADIUS: f32 = 15.0;-const MENU_ROW_HOVER_INSET_X: usize = 8;-const MENU_ROW_HOVER_INSET_Y: usize = 2;+// Design pixels (2x macOS backing), scaled via ui_px/ui_f32 like the rest+// of the chrome. The fallback menu only shows on non-mac (and behind a+// debug flag on mac).+const MENU_MIN_WIDTH: usize = 440;+const MENU_MAX_WIDTH: usize = 1000;+const MENU_WINDOW_MARGIN: usize = 24;+const MENU_PADDING_X: usize = 28;+const MENU_PADDING_Y: usize = 20;+const MENU_LABEL_GAP: usize = 24;+const MENU_ICON_SIZE: usize = 42;+const MENU_ICON_SLOT: usize = 64;+const MENU_CHECK_SLOT: usize = 56;+const MENU_ARROW_SLOT: usize = 56;+const MENU_ROW_EXTRA_HEIGHT: usize = 44;+const MENU_SEPARATOR_HEIGHT: usize = 18;+const MENU_BORDER_WIDTH: f32 = 2.0;+const MENU_RADIUS: f32 = 44.0;+const MENU_ROW_RADIUS: f32 = 30.0;+const MENU_ROW_HOVER_INSET_X: usize = 16;+const MENU_ROW_HOVER_INSET_Y: usize = 4;pub(crate) fn reveal_in_folder_label() -> &'static str {if cfg!(target_os = "macos") {@@ -359,7 +362,9 @@ impl crate::TermWindow {.title_font_with_size(menu_font_size).context("context menu ui font")?;let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());- let row_height = (ui_metrics.cell_size.height as usize + MENU_ROW_EXTRA_HEIGHT).max(28);+ let row_height = (ui_metrics.cell_size.height as usize+ + self.ui_px(MENU_ROW_EXTRA_HEIGHT))+ .max(self.ui_px(56));let palette = context_menu_palette(crate::native_settings::effective_appearance());let gl_state = self.render_state.as_ref().unwrap();@@ -522,7 +527,7 @@ fn compute_menu_metrics(window_width: usize,) -> anyhow::Result<MenuMetrics> {let mut label_width = 0usize;- let mut height = MENU_PADDING_Y * 2;+ let mut height = term.ui_px(MENU_PADDING_Y) * 2;for row in rows {match row {@@ -534,21 +539,22 @@ fn compute_menu_metrics(height = height.saturating_add(row_height);}MenuRow::Separator => {- height = height.saturating_add(MENU_SEPARATOR_HEIGHT);+ height = height.saturating_add(term.ui_px(MENU_SEPARATOR_HEIGHT));}}}- let ideal_width = MENU_PADDING_X * 2- + MENU_CHECK_SLOT- + MENU_ICON_SLOT- + MENU_LABEL_GAP+ let ideal_width = term.ui_px(MENU_PADDING_X) * 2+ + term.ui_px(MENU_CHECK_SLOT)+ + term.ui_px(MENU_ICON_SLOT)+ + term.ui_px(MENU_LABEL_GAP)+ label_width- + MENU_ARROW_SLOT;- let max_width = MENU_MAX_WIDTH- .min(window_width.saturating_sub(MENU_WINDOW_MARGIN * 2))+ + term.ui_px(MENU_ARROW_SLOT);+ let max_width = term+ .ui_px(MENU_MAX_WIDTH)+ .min(window_width.saturating_sub(term.ui_px(MENU_WINDOW_MARGIN) * 2)).max(1);- let min_width = MENU_MIN_WIDTH.min(max_width);+ let min_width = term.ui_px(MENU_MIN_WIDTH).min(max_width);let width = ideal_width.clamp(min_width, max_width);Ok(MenuMetrics {@@ -616,7 +622,7 @@ fn paint_menu_panel(metrics.height as f32,),LinearRgba::with_components(0.0, 0.0, 0.0, 0.18),- MENU_RADIUS,+ term.ui_f32(MENU_RADIUS),)?;term.fill_rounded_rectangle_with_border(layers,@@ -624,8 +630,8 @@ fn paint_menu_panel(rect,palette.control_bg,palette.control_border,- MENU_RADIUS,- MENU_BORDER_WIDTH,+ term.ui_f32(MENU_RADIUS),+ term.ui_f32(MENU_BORDER_WIDTH).max(1.0),)}@@ -644,34 +650,34 @@ fn paint_menu_rows(layout: &mut Vec<ContextMenuLayoutItem>,) -> anyhow::Result<()> {let (x, y) = origin;- let mut cursor_y = y + MENU_PADDING_Y;+ let mut cursor_y = y + term.ui_px(MENU_PADDING_Y);for row in rows {match row {MenuRow::Separator => {- let sep_y = cursor_y + MENU_SEPARATOR_HEIGHT / 2;+ let sep_y = cursor_y + term.ui_px(MENU_SEPARATOR_HEIGHT) / 2;term.filled_rectangle(layers,2,euclid::rect(- (x + MENU_PADDING_X) as f32,+ (x + term.ui_px(MENU_PADDING_X)) as f32,sep_y as f32,- metrics.width.saturating_sub(MENU_PADDING_X * 2) as f32,+ metrics.width.saturating_sub(term.ui_px(MENU_PADDING_X) * 2) as f32,1.0,),palette.separator,)?;- cursor_y += MENU_SEPARATOR_HEIGHT;+ cursor_y += term.ui_px(MENU_SEPARATOR_HEIGHT);}MenuRow::Item { index, item } => {let mut path = menu_path.to_vec();path.push(*index);let item_rect = MenuRect {- x: x + MENU_BORDER_WIDTH as usize,+ x: x + term.ui_f32(MENU_BORDER_WIDTH) as usize,y: cursor_y,width: metrics.width- .saturating_sub((MENU_BORDER_WIDTH as usize) * 2),+ .saturating_sub((term.ui_f32(MENU_BORDER_WIDTH) as usize) * 2),height: metrics.row_height,};let has_submenu = match item {@@ -689,13 +695,15 @@ fn paint_menu_rows(layers,2,euclid::rect(- item_rect.x.saturating_add(MENU_ROW_HOVER_INSET_X) as f32,- item_rect.y.saturating_add(MENU_ROW_HOVER_INSET_Y) as f32,- item_rect.width.saturating_sub(MENU_ROW_HOVER_INSET_X * 2) as f32,- item_rect.height.saturating_sub(MENU_ROW_HOVER_INSET_Y * 2) as f32,+ item_rect.x.saturating_add(term.ui_px(MENU_ROW_HOVER_INSET_X)) as f32,+ item_rect.y.saturating_add(term.ui_px(MENU_ROW_HOVER_INSET_Y)) as f32,+ item_rect.width.saturating_sub(term.ui_px(MENU_ROW_HOVER_INSET_X) * 2)+ as f32,+ item_rect.height.saturating_sub(term.ui_px(MENU_ROW_HOVER_INSET_Y) * 2)+ as f32,),palette.control_hover_bg,- MENU_ROW_RADIUS,+ term.ui_f32(MENU_ROW_RADIUS),)?;}@@ -716,16 +724,16 @@ fn paint_menu_rows(palette.secondary_text};let icon_y =- item_rect.y + (item_rect.height.saturating_sub(MENU_ICON_SIZE)) / 2;- let check_x = item_rect.x + MENU_PADDING_X;- let icon_x = check_x + MENU_CHECK_SLOT;+ item_rect.y + (item_rect.height.saturating_sub(term.ui_px(MENU_ICON_SIZE))) / 2;+ let check_x = item_rect.x + term.ui_px(MENU_PADDING_X);+ let icon_x = check_x + term.ui_px(MENU_CHECK_SLOT);if *checked {term.paint_sidebar_icon(layers,SvgIcon::Check,check_x,icon_y,- MENU_ICON_SIZE,+ term.ui_px(MENU_ICON_SIZE),foreground,)?;}@@ -735,18 +743,18 @@ fn paint_menu_rows(icon,icon_x,icon_y,- MENU_ICON_SIZE,+ term.ui_px(MENU_ICON_SIZE),foreground,)?;}let label_x = item_rect.x- + MENU_PADDING_X- + MENU_CHECK_SLOT- + MENU_ICON_SLOT- + MENU_LABEL_GAP;+ + term.ui_px(MENU_PADDING_X)+ + term.ui_px(MENU_CHECK_SLOT)+ + term.ui_px(MENU_ICON_SLOT)+ + term.ui_px(MENU_LABEL_GAP);let arrow_width = if ContextMenuState::has_renderable_items(submenu) {- MENU_ARROW_SLOT+ term.ui_px(MENU_ARROW_SLOT)} else {0};@@ -754,7 +762,7 @@ fn paint_menu_rows(.width.saturating_sub(label_x.saturating_sub(item_rect.x)).saturating_sub(arrow_width)- .saturating_sub(MENU_PADDING_X);+ .saturating_sub(term.ui_px(MENU_PADDING_X));let text_y = item_rect.y+ (item_rect.height@@ -775,14 +783,14 @@ fn paint_menu_rows(let arrow_x = item_rect.x.saturating_add(item_rect.width)- .saturating_sub(MENU_PADDING_X)- .saturating_sub(MENU_ICON_SIZE);+ .saturating_sub(term.ui_px(MENU_PADDING_X))+ .saturating_sub(term.ui_px(MENU_ICON_SIZE));term.paint_sidebar_icon(layers,SvgIcon::ChevronRight,arrow_x,icon_y,- MENU_ICON_SIZE,+ term.ui_px(MENU_ICON_SIZE),foreground,)?;}diff --git a/wezterm-gui/src/termwindow/ui/platform_chrome.rs b/wezterm-gui/src/termwindow/ui/platform_chrome.rsindex 55d80d8b..f43714af 100644--- a/wezterm-gui/src/termwindow/ui/platform_chrome.rs+++ b/wezterm-gui/src/termwindow/ui/platform_chrome.rs@@ -22,6 +22,14 @@ pub struct WindowTabChromeParams {pub dpi: usize,}+pub fn uses_integrated_window_buttons(+ decorations: WindowDecorations,+ window_state: WindowState,+) -> bool {+ decorations.contains(WindowDecorations::INTEGRATED_BUTTONS)+ && !window_state.contains(WindowState::SERVER_DECORATED)+}+impl WindowTabChromeParams {fn px(self, value: usize) -> usize {scale_ui_usize(value, self.dpi)@@ -47,6 +55,10 @@ impl WindowTabChromeParams {0}+ pub fn uses_integrated_window_buttons(self) -> bool {+ uses_integrated_window_buttons(self.window_decorations, self.window_state)+ }+pub fn shows_sidebar_toggle_action(self) -> bool {self.use_fancy_tab_bar&& self.workspace_sidebar_width == 0@@ -106,9 +118,7 @@ impl WindowTabChromeParams {return leading_action_padding.max(self.px(MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH) as f32);}- if self- .window_decorations- .contains(WindowDecorations::INTEGRATED_BUTTONS)+ if self.uses_integrated_window_buttons()&& (self.integrated_title_button_alignment == IntegratedTitleButtonAlignment::Left|| self.integrated_title_button_style == IntegratedTitleButtonStyle::MacOsNative){@@ -149,11 +159,10 @@ pub fn workspace_sidebar_toolbar_uses_fullscreen_style(window_state: WindowStatewindow_state.contains(WindowState::FULL_SCREEN)}+/// Sizes are design pixels (2x macOS backing); callers scale via ui_px.pub fn workspace_sidebar_toolbar_button_size(window_state: WindowState) -> usize {if workspace_sidebar_toolbar_uses_fullscreen_style(window_state) {WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE- } else if !cfg!(target_os = "macos") {- WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE + 8} else {WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE}@@ -162,9 +171,48 @@ pub fn workspace_sidebar_toolbar_button_size(window_state: WindowState) -> usizepub fn workspace_sidebar_toolbar_icon_size(window_state: WindowState) -> usize {if workspace_sidebar_toolbar_uses_fullscreen_style(window_state) {WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE- } else if !cfg!(target_os = "macos") {- WINDOW_TAB_LEADING_ACTION_ICON_SIZE + 6} else {WINDOW_TAB_LEADING_ACTION_ICON_SIZE}}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn server_decorations_suppress_integrated_window_buttons() {+ let decorations = WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE;+ assert!(uses_integrated_window_buttons(+ decorations,+ WindowState::default()+ ));+ assert!(!uses_integrated_window_buttons(+ decorations,+ WindowState::SERVER_DECORATED+ ));+ }++ #[test]+ fn toolbar_sizes_are_shared_design_pixels() {+ // Same design-pixel values on every platform; ui_px maps them to+ // the local scale (halving at 96dpi), so per-OS values would+ // double-apply the reduction.+ assert_eq!(+ workspace_sidebar_toolbar_button_size(WindowState::default()),+ WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE+ );+ assert_eq!(+ workspace_sidebar_toolbar_icon_size(WindowState::default()),+ WINDOW_TAB_LEADING_ACTION_ICON_SIZE+ );+ assert_eq!(+ workspace_sidebar_toolbar_button_size(WindowState::FULL_SCREEN),+ WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE+ );+ assert_eq!(+ workspace_sidebar_toolbar_icon_size(WindowState::FULL_SCREEN),+ WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE+ );+ }+}diff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rsindex f5c67118..f1290642 100644--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs@@ -10,6 +10,7 @@ use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTuse crate::termwindow::ui::icons::{MaterialIcon, SvgIcon, material_file_icon_for_name, material_folder_icon_for_name,};+use crate::termwindow::ui::platform_chrome::uses_integrated_window_buttons;use crate::termwindow::ui::tokens::{CAPSULE_BORDER_WIDTH, ICON_BUTTON_BORDER_WIDTH, SIDEBAR_ICON_GAP, SIDEBAR_INSET,SIDEBAR_RESIZE_HANDLE_WIDTH, SIDEBAR_ROW_RADIUS, WINDOW_TAB_ADD_BUTTON_RADIUS,@@ -52,7 +53,7 @@ use wezterm_font::LoadedFont;use window::color::LinearRgba;use window::{Clipboard, ContextMenuIcon, ContextMenuItem, DeadKeyStatus, FolderPickerOptions,- IntegratedTitleButtonStyle, Point, Rect, WindowDecorations, WindowOps,+ IntegratedTitleButtonStyle, Point, Rect, WindowOps,};const RIGHT_SIDEBAR_SECTION_GAP: usize = 12;@@ -106,7 +107,10 @@ const NOTE_IMAGE_CACHE_MAX_ENCODED_BYTES: usize = 64 * 1024 * 1024;const NOTE_VAULT_SPLIT_MIN_WIDTH: usize = 620;const NOTE_VAULT_TREE_WIDTH: usize = 230;const NOTE_VAULT_RESCAN_SECS: u64 = 10;-const FILE_FONT_MIN_SIZE: f64 = 14.0;+// Points render 4/3 larger at 96dpi than on macOS, so the floor follows+// the same 0.75x rule as the default font sizes; otherwise it pins the+// Files panel above any reasonable Home Font Size setting on Linux.+const FILE_FONT_MIN_SIZE: f64 = if cfg!(target_os = "macos") { 14.0 } else { 10.5 };const FILE_FILTER_HEIGHT: usize = 66;const FILE_TREE_TOP_GAP: usize = 14;const FILE_SCROLL_FADE_HEIGHT: usize = 32;@@ -1050,10 +1054,7 @@ impl crate::TermWindow {fn right_sidebar_window_button_reserved_width(&self) -> usize {if cfg!(target_os = "macos")- || !self- .config- .window_decorations- .contains(WindowDecorations::INTEGRATED_BUTTONS)+ || !uses_integrated_window_buttons(self.config.window_decorations, self.window_state)|| self.config.integrated_title_button_style == IntegratedTitleButtonStyle::MacOsNative{return 0;@@ -1513,7 +1514,7 @@ impl crate::TermWindow {let old = self.right_sidebar_snippet_scroll_offset;let max = self.right_sidebar_snippet_scroll_max();let steps = amount.unsigned_abs().max(1) as f32;- let delta = (steps * 6.0).min(42.0);+ let delta = (steps * self.ui_f32(6.0)).min(self.ui_f32(42.0));if amount < 0 {self.right_sidebar_snippet_scroll_offset =(self.right_sidebar_snippet_scroll_offset + delta).clamp(0.0, max);@@ -5027,7 +5028,7 @@ impl crate::TermWindow {let track_height = visible_height.max(1);let thumb_height = ((visible_height as f32 / metrics.total_height as f32)* track_height as f32)- .clamp(28.0, track_height as f32);+ .clamp(self.ui_f32(28.0), track_height as f32);let travel = (track_height as f32 - thumb_height).max(1.0);let scroll_offset = self.right_sidebar_file_preview_scroll_offset@@ -5073,7 +5074,7 @@ impl crate::TermWindow {let track_width = text_width.max(1);let track_height = self.ui_px(FILE_PREVIEW_SCROLLBAR_THICKNESS);let thumb_width = ((visible_columns as f32 / max_columns as f32) * track_width as f32)- .clamp(28.0, track_width as f32);+ .clamp(self.ui_f32(28.0), track_width as f32);let travel = (track_width as f32 - thumb_width).max(1.0);let scroll_offset = self.right_sidebar_file_preview_horizontal_offset@@ -5166,7 +5167,7 @@ impl crate::TermWindow {let track_width = 4usize;let track_height = visible_height.max(1);let thumb_height = ((visible_height as f32 / total_height as f32) * track_height as f32)- .clamp(28.0, track_height as f32);+ .clamp(self.ui_f32(28.0), track_height as f32);let travel = (track_height as f32 - thumb_height).max(1.0);let scroll_offset = self.right_sidebar_snippet_scroll_offset@@ -10725,7 +10726,7 @@ impl crate::TermWindow {text_x as f32 + start_w,baseline_y as f32 - 2.0,sel_w,- ui_metrics.cell_size.height as f32 + 4.0,+ ui_metrics.cell_size.height as f32 + self.ui_f32(4.0),),chrome.selected_bg.mul_alpha(0.55),)diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rsindex 0b0d54e2..8a62e905 100644--- a/wezterm-gui/src/termwindow/ui/sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs@@ -1017,7 +1017,7 @@ impl crate::TermWindow {space_menu_height as f32,),chrome.sidebar_button_hover_bg,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),).context("sidebar space menu button")?;}@@ -1156,7 +1156,7 @@ impl crate::TermWindow {} else {chrome.sidebar_button_bg},- self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),).context("sidebar add thread button")?;self.fill_rounded_rectangle(@@ -1173,7 +1173,7 @@ impl crate::TermWindow {} else {chrome.sidebar_button_bg},- self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),).context("sidebar notifications button")?;if let Some(project_id) = active_project_id.clone() {@@ -1934,7 +1934,7 @@ impl crate::TermWindow {space_menu_height as f32,),chrome.sidebar_button_hover_bg,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),).context("sidebar space menu button repaint")?;}@@ -2003,7 +2003,7 @@ impl crate::TermWindow {} else {chrome.sidebar_button_bg},- self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),).context("sidebar add thread button repaint")?;let notification_action_hovered = self.is_pointer_over_ui_rect(@@ -2026,7 +2026,7 @@ impl crate::TermWindow {} else {chrome.sidebar_button_bg},- self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),).context("sidebar notifications button repaint")?;let top_action_fg = if active_project_id.is_some() {@@ -2196,7 +2196,7 @@ impl crate::TermWindow {settings_row_height as f32,),chrome.sidebar_row_hover_bg,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),).context("sidebar settings button hover")?;}@@ -2218,7 +2218,7 @@ impl crate::TermWindow {settings_action_size as f32,),chrome.sidebar_button_hover_bg,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),).context("sidebar settings view options hover")?;}@@ -2240,7 +2240,7 @@ impl crate::TermWindow {settings_action_size as f32,),chrome.sidebar_button_hover_bg,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),).context("sidebar ssh hosts hover")?;}diff --git a/wezterm-gui/src/termwindow/webgpu.rs b/wezterm-gui/src/termwindow/webgpu.rsindex 5f7bbff6..b0acba67 100644--- a/wezterm-gui/src/termwindow/webgpu.rs+++ b/wezterm-gui/src/termwindow/webgpu.rs@@ -26,6 +26,8 @@ fn gpu_debug(message: impl AsRef<str>) {pub struct ShaderUniform {pub foreground_text_hsb: [f32; 3],pub milliseconds: u32,+ pub viewport_and_corner: [f32; 4],+ pub window_border: [f32; 4],pub projection: [[f32; 4]; 4],// sampler2D atlas_nearest_sampler;// sampler2D atlas_linear_sampler;@@ -52,6 +54,21 @@ pub struct RawHandlePair {display: RawDisplayHandle,}+#[cfg(test)]+mod shader_tests {+ #[test]+ fn main_wgsl_shader_parses_and_validates() {+ let module = wgpu::naga::front::wgsl::parse_str(include_str!("../shader.wgsl"))+ .expect("main WGSL shader should parse");+ wgpu::naga::valid::Validator::new(+ wgpu::naga::valid::ValidationFlags::all(),+ wgpu::naga::valid::Capabilities::all(),+ )+ .validate(&module)+ .expect("main WGSL shader should validate");+ }+}+impl RawHandlePair {fn new(window: &Window) -> Self {Self {diff --git a/wezterm-gui/src/ui/draw.rs b/wezterm-gui/src/ui/draw.rsindex e1949cae..58321cfb 100644--- a/wezterm-gui/src/ui/draw.rs+++ b/wezterm-gui/src/ui/draw.rs@@ -43,6 +43,11 @@ impl<'a> DrawContext<'a> {}}+ /// Design pixels (2x macOS backing) → this window's backing pixels.+ pub(crate) fn px(&self, value: f32) -> f32 {+ crate::ui::scale_ui_f32(value, self.dimensions.dpi)+ }+pub(crate) fn draw_rect(&self,layers: &mut TripleLayerQuadAllocator<'_>,diff --git a/wezterm-gui/src/ui/tokens.rs b/wezterm-gui/src/ui/tokens.rsindex ff043827..bf1cac05 100644--- a/wezterm-gui/src/ui/tokens.rs+++ b/wezterm-gui/src/ui/tokens.rs@@ -139,17 +139,19 @@ impl UiTokens {}}-/// ThinkTerm's custom chrome is expressed in design pixels: Retina pixels on-/// macOS and logical pixels elsewhere. Convert those values to the current-/// monitor's backing-pixel grid.+/// ThinkTerm's custom chrome is authored in 2x macOS backing pixels on every+/// platform. Convert those values to the current monitor's backing-pixel+/// grid: on macOS a 2x surface reports dpi 144, so that is the design dpi;+/// elsewhere windows report logical dpi, so the design maps to 192 — a+/// 96dpi/100% display renders at 0.5, Windows 150% (144dpi) at 0.75 and+/// 200% (192dpi) at 1.0, all matching the macOS logical proportions.pub(crate) fn ui_scale_for_dpi(dpi: usize) -> f32 {let design_dpi = if cfg!(target_os = "macos") {- // The custom chrome was authored on a 2x macOS backing surface.144.0} else {- 96.0+ 192.0};- (dpi.max(1) as f32 / design_dpi).clamp(0.5, 4.0)+ (dpi.max(1) as f32 / design_dpi).clamp(0.25, 4.0)}pub(crate) fn scale_ui_usize(value: usize, dpi: usize) -> usize {@@ -199,7 +201,7 @@ mod tests {if cfg!(target_os = "macos") {144} else {- 96+ 192}}diff --git a/window/src/lib.rs b/window/src/lib.rsindex 002fd9d3..91c5897b 100644--- a/window/src/lib.rs+++ b/window/src/lib.rs@@ -390,6 +390,8 @@ pub enum MouseCursor {Text,SizeUpDown,SizeLeftRight,+ SizeNorthWestSouthEast,+ SizeNorthEastSouthWest,}/// Represents the preferred appearance of the windowing@@ -422,7 +424,7 @@ impl std::string::ToString for Appearance {bitflags! {#[derive(Default)]- pub struct WindowState: u8 {+ pub struct WindowState: u16 {/// Occupies the whole screen; cannot be resized while in this state.const FULL_SCREEN = 1<<1;/// Maximized along either or both of horizontal or vertical dimensions;@@ -435,6 +437,12 @@ bitflags! {const ALWAYS_ON_TOP = 1<<4;/// Always on bottom (docked) windowconst ALWAYS_ON_BOTTOM = 1<<5;+ /// The compositor/window manager is drawing the title bar.+ const SERVER_DECORATED = 1<<6;+ /// The compositor has tiled the window against one or more edges.+ const TILED = 1<<7;+ /// The window system can preserve transparent pixels in the surface.+ const COMPOSITED = 1<<8;}}diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rsindex 0bf56d77..b576ea8d 100644--- a/window/src/os/macos/window.rs+++ b/window/src/os/macos/window.rs@@ -2590,6 +2590,10 @@ unsafe fn ns_cursor_instance(cursor: MouseCursor) -> id {MouseCursor::Hand => msg_send![cls, pointingHandCursor],MouseCursor::SizeUpDown => msg_send![cls, resizeUpDownCursor],MouseCursor::SizeLeftRight => msg_send![cls, resizeLeftRightCursor],+ // AppKit doesn't expose public diagonal resize cursor selectors.+ MouseCursor::SizeNorthWestSouthEast | MouseCursor::SizeNorthEastSouthWest => {+ msg_send![cls, arrowCursor]+ }}}@@ -2603,6 +2607,8 @@ fn cursor_to_code(cursor: Option<MouseCursor>) -> i64 {Some(MouseCursor::Hand) => 3,Some(MouseCursor::SizeUpDown) => 4,Some(MouseCursor::SizeLeftRight) => 5,+ Some(MouseCursor::SizeNorthWestSouthEast) => 6,+ Some(MouseCursor::SizeNorthEastSouthWest) => 7,}}@@ -2614,6 +2620,8 @@ fn code_to_cursor(code: i64) -> Option<MouseCursor> {3 => Some(MouseCursor::Hand),4 => Some(MouseCursor::SizeUpDown),5 => Some(MouseCursor::SizeLeftRight),+ 6 => Some(MouseCursor::SizeNorthWestSouthEast),+ 7 => Some(MouseCursor::SizeNorthEastSouthWest),_ => None,}}diff --git a/window/src/os/wayland/pointer.rs b/window/src/os/wayland/pointer.rsindex 3436d17f..74122d4f 100644--- a/window/src/os/wayland/pointer.rs+++ b/window/src/os/wayland/pointer.rs@@ -94,7 +94,7 @@ pub struct PendingMouse {window_id: usize,pub(super) copy_and_paste: Arc<Mutex<CopyAndPaste>>,surface_coords: Option<(f64, f64)>,- button: Vec<(MousePress, ButtonState)>,+ button: Vec<(MousePress, ButtonState, u32)>,scroll: Option<(f64, f64)>,in_window: bool,}@@ -131,7 +131,8 @@ impl PendingMouse {self.surface_coords.replace(evt.position);changed}- PointerEventKind::Press { button, .. } | PointerEventKind::Release { button, .. } => {+ PointerEventKind::Press { button, serial, .. }+ | PointerEventKind::Release { button, serial, .. } => {fn linux_button(b: u32) -> Option<MousePress> {// See BTN_LEFT and friends in <linux/input-event-codes.h>match b {@@ -151,7 +152,7 @@ impl PendingMouse {PointerEventKind::Release { .. } => ButtonState::Released,_ => unreachable!(),};- self.button.push((button, button_state));+ self.button.push((button, button_state, serial));changed}PointerEventKind::Axis {@@ -168,7 +169,9 @@ impl PendingMouse {}}- pub(super) fn next_button(pending: &Arc<Mutex<Self>>) -> Option<(MousePress, ButtonState)> {+ pub(super) fn next_button(+ pending: &Arc<Mutex<Self>>,+ ) -> Option<(MousePress, ButtonState, u32)> {let mut pending = pending.lock().unwrap();if pending.button.is_empty() {Nonediff --git a/window/src/os/wayland/seat.rs b/window/src/os/wayland/seat.rsindex 38bd2594..e433e53e 100644--- a/window/src/os/wayland/seat.rs+++ b/window/src/os/wayland/seat.rs@@ -50,6 +50,7 @@ impl SeatHandler for WaylandState {).expect("Failed to create pointer");self.pointer = Some(pointer);+ self.pointer_seat = Some(seat.clone());}Capability::Touch /* if self.touch.is_none() */ => {log::trace!("Setting touch capability");@@ -85,6 +86,7 @@ impl SeatHandler for WaylandState {Capability::Pointer => {log::trace!("Lost pointer capability");self.pointer.take(); // ThemedPointer's drop implementation calls wl_pointer.release() already.+ self.pointer_seat.take();}Capability::Touch => {log::trace!("Lost touch capability");diff --git a/window/src/os/wayland/state.rs b/window/src/os/wayland/state.rsindex d8067d70..fcbda535 100644--- a/window/src/os/wayland/state.rs+++ b/window/src/os/wayland/state.rs@@ -62,6 +62,7 @@ pub(super) struct WaylandState {pub(super) keyboard_window_id: Option<usize>,pub(super) pointer: Option<ThemedPointer<PointerUserData>>,+ pub(super) pointer_seat: Option<wayland_client::protocol::wl_seat::WlSeat>,pub(super) surface_to_pending: HashMap<ObjectId, Arc<Mutex<PendingMouse>>>,pub(super) data_device_manager_state: DataDeviceManagerState,@@ -107,6 +108,7 @@ impl WaylandState {key_repeat_delay: 400,keyboard_window_id: None,pointer: None,+ pointer_seat: None,surface_to_pending: HashMap::new(),data_device_manager_state: DataDeviceManagerState::bind(globals, qh)?,data_device: None,diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rsindex 72f742fd..6e520198 100644--- a/window/src/os/wayland/window.rs+++ b/window/src/os/wayland/window.rs@@ -81,6 +81,99 @@ impl WaylandDimensions for Dimensions {}}+const WAYLAND_RESIZE_EDGE_LOGICAL_PIXELS: f64 = 6.0;++fn requested_wayland_decoration_mode(+ decorations: WindowDecorations,+) -> Option<DecorationMode> {+ if decorations == WindowDecorations::NONE {+ None+ } else if decorations.contains(WindowDecorations::INTEGRATED_BUTTONS) {+ Some(DecorationMode::Client)+ } else if decorations == WindowDecorations::default() {+ Some(DecorationMode::Server)+ } else {+ Some(DecorationMode::Client)+ }+}++fn wayland_fallback_frame_visible(+ decorations: WindowDecorations,+ effective_mode: DecorationMode,+) -> bool {+ effective_mode == DecorationMode::Client && decorations.shows_separate_title_bar()+}++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+enum WaylandSurfaceResizeEdge {+ TopLeft,+ Top,+ TopRight,+ Right,+ BottomRight,+ Bottom,+ BottomLeft,+ Left,+}++impl WaylandSurfaceResizeEdge {+ fn cursor(self) -> MouseCursor {+ match self {+ Self::Top | Self::Bottom => MouseCursor::SizeUpDown,+ Self::Left | Self::Right => MouseCursor::SizeLeftRight,+ Self::TopLeft | Self::BottomRight => MouseCursor::SizeNorthWestSouthEast,+ Self::TopRight | Self::BottomLeft => MouseCursor::SizeNorthEastSouthWest,+ }+ }++ fn xdg_edge(self) -> XdgResizeEdge {+ match self {+ Self::TopLeft => XdgResizeEdge::TopLeft,+ Self::Top => XdgResizeEdge::Top,+ Self::TopRight => XdgResizeEdge::TopRight,+ Self::Right => XdgResizeEdge::Right,+ Self::BottomRight => XdgResizeEdge::BottomRight,+ Self::Bottom => XdgResizeEdge::Bottom,+ Self::BottomLeft => XdgResizeEdge::BottomLeft,+ Self::Left => XdgResizeEdge::Left,+ }+ }+}++fn wayland_surface_resize_edge_at(+ x: isize,+ y: isize,+ width: usize,+ height: usize,+ edge_pixels: usize,+) -> Option<WaylandSurfaceResizeEdge> {+ if x < 0 || y < 0 || x as usize >= width || y as usize >= height || width == 0 || height == 0+ {+ return None;+ }++ let x = x as usize;+ let y = y as usize;+ let edge_x = edge_pixels.max(1).min((width / 2).max(1));+ let edge_y = edge_pixels.max(1).min((height / 2).max(1));+ let left = x < edge_x;+ let right = x >= width - edge_x;+ let top = y < edge_y;+ let bottom = y >= height - edge_y;++ match (left, right, top, bottom) {+ (true, _, true, _) => Some(WaylandSurfaceResizeEdge::TopLeft),+ (_, true, true, _) => Some(WaylandSurfaceResizeEdge::TopRight),+ (true, _, _, true) => Some(WaylandSurfaceResizeEdge::BottomLeft),+ (_, true, _, true) => Some(WaylandSurfaceResizeEdge::BottomRight),+ (_, _, true, _) => Some(WaylandSurfaceResizeEdge::Top),+ (_, _, _, true) => Some(WaylandSurfaceResizeEdge::Bottom),+ (true, _, _, _) => Some(WaylandSurfaceResizeEdge::Left),+ (_, true, _, _) => Some(WaylandSurfaceResizeEdge::Right),+ _ => None,+ }+}+use super::copy_and_paste::CopyAndPaste;use super::pointer::{PendingMouse, PointerUserData};use super::state::WaylandState;@@ -246,16 +339,7 @@ impl WaylandWindow {window.set_app_id(class_name.to_string());window.set_title(name.to_string());let decorations = config.window_decorations;-- let decor_mode = if decorations == WindowDecorations::NONE {- None- } else if decorations.contains(WindowDecorations::INTEGRATED_BUTTONS) {- Some(DecorationMode::Client)- } else if decorations == WindowDecorations::default() {- Some(DecorationMode::Server)- } else {- Some(DecorationMode::Client)- };+ let decor_mode = requested_wayland_decoration_mode(decorations);window.request_decoration_mode(decor_mode);let mut window_frame = {@@ -265,10 +349,9 @@ impl WaylandWindow {FallbackFrame::new(&window, shm, subcompositor, qh.clone()).expect("failed to create csd frame")};- let hidden = match decor_mode {- Some(DecorationMode::Client) => false,- _ => true,- };+ let hidden = !decor_mode+ .map(|mode| wayland_fallback_frame_visible(decorations, mode))+ .unwrap_or(false);window_frame.set_hidden(hidden);if !hidden {window_frame.resize(@@ -310,6 +393,9 @@ impl WaylandWindow {window_state: WindowState::default(),last_mouse_coords: Point::new(0, 0),mouse_buttons: MouseButtons::NONE,+ surface_resize_cursor_active: false,+ surface_resize_in_progress: false,+ last_pointer_press_serial: None,hscroll_remainder: 0.0,vscroll_remainder: 0.0,@@ -409,6 +495,13 @@ impl WindowOps for WaylandWindow {});}+ fn request_drag_move(&self) {+ WaylandConnection::with_window_inner(self.0, |inner| {+ inner.begin_surface_move();+ Ok(())+ });+ }+fn invalidate(&self) {WaylandConnection::with_window_inner(self.0, |inner| {inner.invalidate();@@ -576,6 +669,9 @@ pub struct WaylandWindowInner {window_state: WindowState,last_mouse_coords: Point,mouse_buttons: MouseButtons,+ surface_resize_cursor_active: bool,+ surface_resize_in_progress: bool,+ last_pointer_press_serial: Option<u32>,hscroll_remainder: f64,vscroll_remainder: f64,modifiers: Modifiers,@@ -625,6 +721,85 @@ impl WaylandWindowInner {self.do_paint().unwrap();}+ fn apply_fallback_frame_visibility(&mut self, effective_mode: DecorationMode) {+ let visible =+ wayland_fallback_frame_visible(self.config.window_decorations, effective_mode);+ self.window_frame.set_hidden(!visible);+ if visible {+ let width = NonZeroU32::new(+ self.pixels_to_surface(self.dimensions.pixel_width as i32)+ .max(1) as u32,+ )+ .unwrap();+ let height = NonZeroU32::new(+ self.pixels_to_surface(self.dimensions.pixel_height as i32)+ .max(1) as u32,+ )+ .unwrap();+ self.window_frame.resize(width, height);+ }+ if self.window.is_some() {+ let (x, y) = self.window_frame.location();+ let surface_width = self.pixels_to_surface(self.dimensions.pixel_width as i32);+ let surface_height = self.pixels_to_surface(self.dimensions.pixel_height as i32);+ self.window+ .as_mut()+ .unwrap()+ .xdg_surface()+ .set_window_geometry(x, y, surface_width, surface_height);+ }+ }++ fn surface_resize_edge_at(&self, coords: Point) -> Option<WaylandSurfaceResizeEdge> {+ if !self+ .config+ .window_decorations+ .contains(WindowDecorations::RESIZE)+ || !self.window_state.can_resize()+ || self.window_state.contains(WindowState::SERVER_DECORATED)+ || !self.window_frame.is_hidden()+ {+ return None;+ }++ let edge_pixels =+ (WAYLAND_RESIZE_EDGE_LOGICAL_PIXELS * self.dimensions.dpi as f64 / crate::DEFAULT_DPI)+ .round() as usize;+ wayland_surface_resize_edge_at(+ coords.x,+ coords.y,+ self.dimensions.pixel_width,+ self.dimensions.pixel_height,+ edge_pixels,+ )+ }++ fn begin_surface_resize(&mut self, serial: u32, edge: WaylandSurfaceResizeEdge) {+ let conn = Connection::get().unwrap().wayland();+ let state = conn.wayland_state.borrow();+ let Some(seat) = state.pointer_seat.as_ref() else {+ return;+ };+ if let Some(window) = self.window.as_ref() {+ window.resize(seat, serial, edge.xdg_edge());+ self.surface_resize_in_progress = true;+ }+ }++ fn begin_surface_move(&mut self) {+ let Some(serial) = self.last_pointer_press_serial.take() else {+ return;+ };+ let conn = Connection::get().unwrap().wayland();+ let state = conn.wayland_state.borrow();+ let Some(seat) = state.pointer_seat.as_ref() else {+ return;+ };+ if let Some(window) = self.window.as_ref() {+ window.move_(seat, serial);+ }+ }+fn refresh_frame(&mut self) {if self.window_frame.is_dirty() && !self.window_frame.is_hidden() {self.window_frame.draw();@@ -712,24 +887,52 @@ impl WaylandWindowInner {self.surface_to_pixels(y as i32) as isize,);self.last_mouse_coords = coords;- let event = MouseEvent {- kind: MouseEventKind::Move,- coords,- screen_coords: ScreenPoint::new(- coords.x + self.dimensions.pixel_width as isize,- coords.y + self.dimensions.pixel_height as isize,- ),- mouse_buttons: self.mouse_buttons,- modifiers: self.modifiers,- precise_scroll_delta: None,- scroll_phase: None,- momentum_phase: None,- };- self.events.dispatch(WindowEvent::MouseEvent(event));+ if let Some(edge) = self.surface_resize_edge_at(coords) {+ self.set_cursor(Some(edge.cursor()));+ self.surface_resize_cursor_active = true;+ } else {+ if self.surface_resize_cursor_active {+ // None hides the pointer entirely; restore the arrow and+ // let the application pick a more specific cursor on the+ // next dispatched motion.+ self.set_cursor(Some(MouseCursor::Arrow));+ self.surface_resize_cursor_active = false;+ }+ let event = MouseEvent {+ kind: MouseEventKind::Move,+ coords,+ screen_coords: ScreenPoint::new(+ coords.x + self.dimensions.pixel_width as isize,+ coords.y + self.dimensions.pixel_height as isize,+ ),+ mouse_buttons: self.mouse_buttons,+ modifiers: self.modifiers,+ precise_scroll_delta: None,+ scroll_phase: None,+ momentum_phase: None,+ };+ self.events.dispatch(WindowEvent::MouseEvent(event));+ }self.refresh_frame();}- while let Some((button, state)) = PendingMouse::next_button(&pending_mouse) {+ while let Some((button, state, serial)) = PendingMouse::next_button(&pending_mouse) {+ if button == MousePress::Left && self.surface_resize_in_progress {+ if state == ButtonState::Released {+ self.surface_resize_in_progress = false;+ }+ continue;+ }+ if button == MousePress::Left && state == ButtonState::Pressed {+ if let Some(edge) = self.surface_resize_edge_at(self.last_mouse_coords) {+ self.begin_surface_resize(serial, edge);+ continue;+ }+ self.last_pointer_press_serial = Some(serial);+ } else if button == MousePress::Left && state == ButtonState::Released {+ self.last_pointer_press_serial = None;+ }+let button_mask = match button {MousePress::Left => MouseButtons::LEFT,MousePress::Right => MouseButtons::RIGHT,@@ -837,12 +1040,14 @@ impl WaylandWindowInner {self.events.dispatch(WindowEvent::CloseRequested);}+ let mut window_state_changed = false;if let Some(window_state) = pending.window_state.take() {log::debug!("dispatch_pending_event self.window_state={:?}, pending:{:?}",self.window_state,window_state);+ window_state_changed = self.window_state != window_state;self.window_state = window_state;}@@ -858,6 +1063,7 @@ impl WaylandWindowInner {}if let Some(ref window_config) = pending.window_configure {+ self.apply_fallback_frame_visibility(window_config.decoration_mode);self.window_frame.update_state(window_config.state);self.window_frame.update_wm_capabilities(window_config.capabilities);@@ -919,10 +1125,10 @@ impl WaylandWindowInner {dpi,};- // Only trigger a resize if the new dimensions are different;- // this makes things more efficient and a little more smooth- if new_dimensions != old_dimensions {+ let dimensions_changed = new_dimensions != old_dimensions;+ if dimensions_changed || window_state_changed {self.dimensions = new_dimensions;+ window_state_changed = false;self.events.dispatch(WindowEvent::Resized {dimensions: self.dimensions,@@ -931,6 +1137,8 @@ impl WaylandWindowInner {// assume no.live_resizing: false,});+ }+ if dimensions_changed {// Avoid blurring by matching the scaling factor of the// compositor; if it is going to double the size then// we render at double the size anyway and tell it that@@ -969,6 +1177,13 @@ impl WaylandWindowInner {self.do_paint().unwrap();}}+ if window_state_changed && self.window.is_some() {+ self.events.dispatch(WindowEvent::Resized {+ dimensions: self.dimensions,+ window_state: self.window_state,+ live_resizing: false,+ });+ }if pending.refresh_decorations && self.window.is_some() {self.refresh_frame();}@@ -1002,6 +1217,8 @@ impl WaylandWindowInner {MouseCursor::Hand => CursorIcon::Pointer,MouseCursor::SizeUpDown => CursorIcon::NsResize,MouseCursor::SizeLeftRight => CursorIcon::EwResize,+ MouseCursor::SizeNorthWestSouthEast => CursorIcon::NwseResize,+ MouseCursor::SizeNorthEastSouthWest => CursorIcon::NeswResize,MouseCursor::Text => CursorIcon::Text,},) {@@ -1285,6 +1502,12 @@ impl WaylandWindowInner {fn config_did_change(&mut self, config: ConfigHandle) {self.config = config;+ let decor_mode = requested_wayland_decoration_mode(self.config.window_decorations);+ if let Some(window) = self.window.as_ref() {+ window.request_decoration_mode(decor_mode);+ }+ self.apply_fallback_frame_visibility(decor_mode.unwrap_or(DecorationMode::Client));+ self.refresh_frame();self.update_window_background_blur();}@@ -1345,13 +1568,24 @@ impl WaylandState {changed = true;}- let mut state = WindowState::default();+ let mut state = WindowState::COMPOSITED;if configure.state.contains(SCTKWindowState::FULLSCREEN) {state |= WindowState::FULL_SCREEN;}if configure.state.contains(SCTKWindowState::MAXIMIZED) {state |= WindowState::MAXIMIZED;}+ if configure.state.intersects(+ SCTKWindowState::TILED_LEFT+ | SCTKWindowState::TILED_RIGHT+ | SCTKWindowState::TILED_TOP+ | SCTKWindowState::TILED_BOTTOM,+ ) {+ state |= WindowState::TILED;+ }+ if configure.decoration_mode == DecorationMode::Server {+ state |= WindowState::SERVER_DECORATED;+ }log::debug!("Config: self.window_state={:?}, states: {:?} {:?}",@@ -1360,7 +1594,7 @@ impl WaylandState {configure.state);- if pending_event.window_state.is_none() && state != WindowState::default() {+ if pending_event.window_state != Some(state) {changed = true;}@@ -1555,3 +1789,64 @@ impl HasWindowHandle for WaylandWindow {unsafe { Ok(WindowHandle::borrow_raw(handle.as_raw())) }}}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn integrated_buttons_use_client_mode_without_fallback_header() {+ let decorations = WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE;+ assert_eq!(+ requested_wayland_decoration_mode(decorations),+ Some(DecorationMode::Client)+ );+ assert!(!wayland_fallback_frame_visible(+ decorations,+ DecorationMode::Client+ ));+ }++ #[test]+ fn fallback_header_requires_title_and_client_mode() {+ let decorations = WindowDecorations::TITLE | WindowDecorations::RESIZE;+ assert!(wayland_fallback_frame_visible(+ decorations,+ DecorationMode::Client+ ));+ assert!(!wayland_fallback_frame_visible(+ decorations,+ DecorationMode::Server+ ));+ assert!(!wayland_fallback_frame_visible(+ WindowDecorations::RESIZE,+ DecorationMode::Client+ ));+ }++ #[test]+ fn surface_resize_hit_testing_covers_all_directions() {+ let width = 100;+ let height = 80;+ let edge = 6;+ for (x, y, expected) in [+ (0, 0, WaylandSurfaceResizeEdge::TopLeft),+ (50, 0, WaylandSurfaceResizeEdge::Top),+ (99, 0, WaylandSurfaceResizeEdge::TopRight),+ (99, 40, WaylandSurfaceResizeEdge::Right),+ (99, 79, WaylandSurfaceResizeEdge::BottomRight),+ (50, 79, WaylandSurfaceResizeEdge::Bottom),+ (0, 79, WaylandSurfaceResizeEdge::BottomLeft),+ (0, 40, WaylandSurfaceResizeEdge::Left),+ ] {+ assert_eq!(+ wayland_surface_resize_edge_at(x, y, width, height, edge),+ Some(expected)+ );+ }+ assert_eq!(+ wayland_surface_resize_edge_at(50, 40, width, height, edge),+ None+ );+ }+}diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rsindex 031e562d..6f0540ac 100644--- a/window/src/os/windows/window.rs+++ b/window/src/os/windows/window.rs@@ -1989,6 +1989,8 @@ fn apply_mouse_cursor(cursor: Option<MouseCursor>) {MouseCursor::Text => IDC_IBEAM,MouseCursor::SizeUpDown => IDC_SIZENS,MouseCursor::SizeLeftRight => IDC_SIZEWE,+ MouseCursor::SizeNorthWestSouthEast => IDC_SIZENWSE,+ MouseCursor::SizeNorthEastSouthWest => IDC_SIZENESW,},));},diff --git a/window/src/os/x11/connection.rs b/window/src/os/x11/connection.rsindex dc78677c..22c3f53b 100644--- a/window/src/os/x11/connection.rs+++ b/window/src/os/x11/connection.rs@@ -93,6 +93,8 @@ pub struct XConnection {pub atom_net_wm_icon: Atom,pub atom_net_move_resize_window: Atom,pub atom_net_wm_moveresize: Atom,+ pub atom_wm_change_state: Atom,+ pub atom_net_wm_cm: Atom,pub atom_net_supported: Atom,pub atom_net_supporting_wm_check: Atom,pub atom_net_active_window: Atom,@@ -711,6 +713,8 @@ impl XConnection {let atom_net_wm_icon = Self::intern_atom(&conn, "_NET_WM_ICON")?;let atom_net_move_resize_window = Self::intern_atom(&conn, "_NET_MOVERESIZE_WINDOW")?;let atom_net_wm_moveresize = Self::intern_atom(&conn, "_NET_WM_MOVERESIZE")?;+ let atom_wm_change_state = Self::intern_atom(&conn, "WM_CHANGE_STATE")?;+ let atom_net_wm_cm = Self::intern_atom(&conn, &format!("_NET_WM_CM_S{}", screen_num))?;let atom_net_supported = Self::intern_atom(&conn, "_NET_SUPPORTED")?;let atom_net_supporting_wm_check = Self::intern_atom(&conn, "_NET_SUPPORTING_WM_CHECK")?;let atom_net_active_window = Self::intern_atom(&conn, "_NET_ACTIVE_WINDOW")?;@@ -847,6 +851,8 @@ impl XConnection {atom_net_wm_name,atom_net_move_resize_window,atom_net_wm_moveresize,+ atom_wm_change_state,+ atom_net_wm_cm,atom_net_supported,atom_net_supporting_wm_check,atom_net_active_window,diff --git a/window/src/os/x11/cursor.rs b/window/src/os/x11/cursor.rsindex 26c13726..48601379 100644--- a/window/src/os/x11/cursor.rs+++ b/window/src/os/x11/cursor.rs@@ -19,6 +19,7 @@ pub const SB_H_DOUBLE_ARROW: u16 = 108;pub const SB_V_DOUBLE_ARROW: u16 = 116;pub const TOP_LEFT_ARROW: u16 = 132;pub const TOP_LEFT_CORNER: u16 = 134;+pub const TOP_RIGHT_CORNER: u16 = 136;pub const XTERM: u16 = 152;pub struct XcbCursor {@@ -317,6 +318,12 @@ impl CursorInfo {MouseCursor::Text => &["xterm"],MouseCursor::SizeUpDown => &["sb_v_double_arrow"],MouseCursor::SizeLeftRight => &["sb_h_double_arrow"],+ MouseCursor::SizeNorthWestSouthEast => {+ &["nwse-resize", "size_fdiag", "top_left_corner"]+ }+ MouseCursor::SizeNorthEastSouthWest => {+ &["nesw-resize", "size_bdiag", "top_right_corner"]+ }};let mut theme_list = vec![theme.to_string()];@@ -376,6 +383,8 @@ impl CursorInfo {MouseCursor::Text => XTERM,MouseCursor::SizeUpDown => SB_V_DOUBLE_ARROW,MouseCursor::SizeLeftRight => SB_H_DOUBLE_ARROW,+ MouseCursor::SizeNorthWestSouthEast => TOP_LEFT_CORNER,+ MouseCursor::SizeNorthEastSouthWest => TOP_RIGHT_CORNER,};log::trace!("loading X11 basic cursor {} for {:?}", id_no, cursor);diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rsindex cbf34604..c7203448 100644--- a/window/src/os/x11/window.rs+++ b/window/src/os/x11/window.rs@@ -108,6 +108,8 @@ pub(crate) struct XWindowInner {current_mouse_event: Option<MouseEvent>,window_drag_position: Option<ScreenPoint>,dragging: bool,+ edge_resizing: bool,+ resize_cursor_active: bool,outstanding_configure_requests: usize,pending_finished_resizes: usize,}@@ -115,6 +117,71 @@ pub(crate) struct XWindowInner {/// <https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm46409506331616>const _NET_WM_MOVERESIZE_MOVE: u32 = 8;const _NET_WM_MOVERESIZE_CANCEL: u32 = 11;+const X11_RESIZE_EDGE_LOGICAL_PIXELS: f64 = 6.0;+const ICCCM_ICONIC_STATE: u32 = 3;++fn wm_change_state_iconic_data() -> [u32; 5] {+ [ICCCM_ICONIC_STATE, 0, 0, 0, 0]+}++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+#[repr(u32)]+enum X11ResizeEdge {+ TopLeft = 0,+ Top = 1,+ TopRight = 2,+ Right = 3,+ BottomRight = 4,+ Bottom = 5,+ BottomLeft = 6,+ Left = 7,+}++impl X11ResizeEdge {+ fn cursor(self) -> MouseCursor {+ match self {+ Self::Top | Self::Bottom => MouseCursor::SizeUpDown,+ Self::Left | Self::Right => MouseCursor::SizeLeftRight,+ Self::TopLeft | Self::BottomRight => MouseCursor::SizeNorthWestSouthEast,+ Self::TopRight | Self::BottomLeft => MouseCursor::SizeNorthEastSouthWest,+ }+ }+}++fn x11_resize_edge_at(+ x: i16,+ y: i16,+ width: u16,+ height: u16,+ edge_pixels: u16,+) -> Option<X11ResizeEdge> {+ let x = i32::from(x);+ let y = i32::from(y);+ let width = i32::from(width);+ let height = i32::from(height);+ if x < 0 || y < 0 || x >= width || y >= height || width == 0 || height == 0 {+ return None;+ }++ let edge_x = i32::from(edge_pixels.max(1)).min((width / 2).max(1));+ let edge_y = i32::from(edge_pixels.max(1)).min((height / 2).max(1));+ let left = x < edge_x;+ let right = x >= width - edge_x;+ let top = y < edge_y;+ let bottom = y >= height - edge_y;++ match (left, right, top, bottom) {+ (true, _, true, _) => Some(X11ResizeEdge::TopLeft),+ (_, true, true, _) => Some(X11ResizeEdge::TopRight),+ (true, _, _, true) => Some(X11ResizeEdge::BottomLeft),+ (_, true, _, true) => Some(X11ResizeEdge::BottomRight),+ (_, _, true, _) => Some(X11ResizeEdge::Top),+ (_, _, _, true) => Some(X11ResizeEdge::Bottom),+ (true, _, _, _) => Some(X11ResizeEdge::Left),+ (_, true, _, _) => Some(X11ResizeEdge::Right),+ _ => None,+ }+}// `_MOTIF_WM_HINTS` uses a different bit layout for decorations than it does// for window functions. Keep the decoration values explicit so that asking@@ -152,6 +219,12 @@ fn motif_decorations_for(decorations: WindowDecorations) -> u32 {}}+fn uses_client_resize_edges(decorations: WindowDecorations) -> bool {+ decorations.contains(WindowDecorations::INTEGRATED_BUTTONS)+ && decorations.contains(WindowDecorations::RESIZE)+ && motif_decorations_for(decorations) == 0+}+impl Drop for XWindowInner {fn drop(&mut self) {if self.window_id != xcb::x::Window::none() {@@ -275,6 +348,45 @@ impl XWindowInner {self.cursors.set_cursor(self.window_id, cursor)}+ fn wm_supports_moveresize(&self) -> bool {+ let conn = self.conn();+ let supported = conn+ .supported+ .borrow()+ .contains(&conn.atom_net_wm_moveresize);+ supported+ }++ fn resize_edge_at(&self, x: i16, y: i16) -> Option<X11ResizeEdge> {+ if !uses_client_resize_edges(self.config.window_decorations)+ || !self.last_wm_state.can_resize()+ || !self.wm_supports_moveresize()+ {+ return None;+ }++ let edge_pixels =+ (X11_RESIZE_EDGE_LOGICAL_PIXELS * self.dpi / crate::DEFAULT_DPI).round() as u16;+ x11_resize_edge_at(x, y, self.width, self.height, edge_pixels)+ }++ fn update_resize_cursor(&mut self, x: i16, y: i16) -> anyhow::Result<bool> {+ if let Some(edge) = self.resize_edge_at(x, y) {+ self.set_cursor(Some(edge.cursor()))?;+ self.resize_cursor_active = true;+ Ok(true)+ } else {+ if self.resize_cursor_active {+ // None selects the blank (invisible) cursor on X11; restore+ // the default arrow instead. The next dispatched motion lets+ // the application pick a more specific cursor.+ self.set_cursor(Some(MouseCursor::Arrow))?;+ self.resize_cursor_active = false;+ }+ Ok(false)+ }+ }+fn check_dpi_and_synthesize_resize(&mut self) {let conn = self.conn();let dpi = conn.default_dpi();@@ -463,11 +575,35 @@ impl XWindowInner {) -> anyhow::Result<()> {self.copy_and_paste.time = time;+ if self.edge_resizing {+ if !pressed && detail == 1 {+ self.edge_resizing = false;+ return Ok(());+ }+ if pressed {+ // A new press means that the WM already completed the resize+ // without forwarding its release to us. Do not swallow the+ // new application click.+ self.edge_resizing = false;+ }+ }+if self.cancel_drag() {log::debug!("cancel drag due to button {detail} {state:?}");return Ok(());}+ if pressed && detail == 1 {+ if let Some(edge) = self.resize_edge_at(event_x, event_y) {+ self.set_cursor(Some(edge.cursor()))?;+ self.resize_cursor_active = true;+ if self.net_wm_moveresize(root_x as u32, root_y as u32, edge as u32, 1) {+ self.edge_resizing = true;+ return Ok(());+ }+ }+ }+let kind = match detail {b @ 1..=3 => {let button = match b {@@ -762,6 +898,9 @@ impl XWindowInner {.process_key_release_event(key_release, &mut self.events);}Event::X(xcb::x::Event::MotionNotify(motion)) => {+ if self.update_resize_cursor(motion.event_x(), motion.event_y())? {+ return Ok(());+ }let event = MouseEvent {kind: MouseEventKind::Move,coords: Point::new(@@ -1259,6 +1398,13 @@ impl XWindowInner {window_state |= WindowState::HIDDEN;}}+ if let Ok(owner) = conn.send_and_wait_request(&xcb::x::GetSelectionOwner {+ selection: conn.atom_net_wm_cm,+ }) {+ if owner.owner() != xcb::x::Window::none() {+ window_state |= WindowState::COMPOSITED;+ }+ }Ok(window_state)}@@ -1518,6 +1664,8 @@ impl XWindow {current_mouse_event: None,window_drag_position: None,dragging: false,+ edge_resizing: false,+ resize_cursor_active: false,outstanding_configure_requests: 0,pending_finished_resizes: 0,}))@@ -1652,7 +1800,23 @@ impl XWindowInner {log::trace!("clear out self.window_id");self.window_id = xcb::x::Window::none();}- fn hide(&mut self) {}+ fn hide(&mut self) {+ let conn = self.conn();+ conn.send_request_no_reply_log(&xcb::x::SendEvent {+ propagate: false,+ destination: xcb::x::SendEventDest::Window(conn.root),+ event_mask: xcb::x::EventMask::SUBSTRUCTURE_REDIRECT+ | xcb::x::EventMask::SUBSTRUCTURE_NOTIFY,+ event: &xcb::x::ClientMessageEvent::new(+ self.window_id,+ conn.atom_wm_change_state,+ xcb::x::ClientMessageData::Data32(wm_change_state_iconic_data()),+ ),+ });+ if let Err(err) = conn.flush() {+ log::error!("Error flushing WM_CHANGE_STATE minimize request: {err:#}");+ }+ }fn show(&mut self) {self.conn().send_request_no_reply_log(&xcb::x::MapWindow {window: self.window_id,@@ -1726,7 +1890,13 @@ impl XWindowInner {}}- fn net_wm_moveresize(&mut self, x_root: u32, y_root: u32, direction: u32, button: u32) {+ fn net_wm_moveresize(+ &mut self,+ x_root: u32,+ y_root: u32,+ direction: u32,+ button: u32,+ ) -> bool {let source_indication = 1;let conn = self.conn();@@ -1736,7 +1906,7 @@ impl XWindowInner {.contains(&conn.atom_net_wm_moveresize){log::debug!("WM doesn't support _NET_WM_MOVERESIZE");- return;+ return false;}log::debug!("net_wm_moveresize {x_root},{y_root} direction={direction} button={button}");@@ -1749,11 +1919,6 @@ impl XWindowInner {conn.send_request_no_reply_log(&xcb::x::UngrabPointer {time: self.copy_and_paste.time,});- // Flag to ourselves that we are dragging.- // This is also used to gate the fallback of calling- // set_window_position in case the WM doesn't support- // _NET_WM_MOVERESIZE and we returned early above.- self.dragging = true;}conn.send_request_no_reply_log(&xcb::x::SendEvent {@@ -1774,6 +1939,7 @@ impl XWindowInner {),});conn.flush().context("flush moveresize").ok();+ true}fn request_drag_move(&mut self) -> anyhow::Result<()> {@@ -1783,7 +1949,12 @@ impl XWindowInner {let y_root = pos.y as u32;let button = 1; // Left- self.net_wm_moveresize(x_root, y_root, _NET_WM_MOVERESIZE_MOVE, button);+ if self.net_wm_moveresize(x_root, y_root, _NET_WM_MOVERESIZE_MOVE, button) {+ // This gates the manual set_window_position fallback. Edge+ // resizing deliberately uses a separate state because it never+ // dispatched an application mouse press.+ self.dragging = true;+ }Ok(())}@@ -2302,4 +2473,54 @@ mod tests {0);}++ #[test]+ fn client_resize_edges_are_only_used_for_frameless_integrated_windows() {+ assert!(uses_client_resize_edges(+ WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE+ ));+ for decorations in [+ WindowDecorations::TITLE | WindowDecorations::RESIZE,+ WindowDecorations::RESIZE,+ WindowDecorations::INTEGRATED_BUTTONS,+ WindowDecorations::NONE,+ ] {+ assert!(!uses_client_resize_edges(decorations));+ }+ }++ #[test]+ fn resize_edge_hit_testing_covers_all_directions() {+ let width = 100;+ let height = 80;+ let edge = 6;+ for (x, y, expected) in [+ (0, 0, X11ResizeEdge::TopLeft),+ (50, 0, X11ResizeEdge::Top),+ (99, 0, X11ResizeEdge::TopRight),+ (99, 40, X11ResizeEdge::Right),+ (99, 79, X11ResizeEdge::BottomRight),+ (50, 79, X11ResizeEdge::Bottom),+ (0, 79, X11ResizeEdge::BottomLeft),+ (0, 40, X11ResizeEdge::Left),+ ] {+ assert_eq!(+ x11_resize_edge_at(x, y, width, height, edge),+ Some(expected)+ );+ }+ assert_eq!(x11_resize_edge_at(50, 40, width, height, edge), None);+ }++ #[test]+ fn resize_edge_hit_testing_rejects_outside_coordinates() {+ assert_eq!(x11_resize_edge_at(-1, 0, 100, 80, 6), None);+ assert_eq!(x11_resize_edge_at(100, 0, 100, 80, 6), None);+ assert_eq!(x11_resize_edge_at(0, 80, 100, 80, 6), None);+ }++ #[test]+ fn minimize_uses_icccm_iconic_state_payload() {+ assert_eq!(wm_change_state_iconic_data(), [3, 0, 0, 0, 0]);+ }}