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
Add drag-and-drop for level-2 pane tabs with move and split drop zones
RoversX61d697d58910
diff --git a/mux/src/domain.rs b/mux/src/domain.rsindex 40f66a2d..1cdf543e 100644--- a/mux/src/domain.rs+++ b/mux/src/domain.rs@@ -94,6 +94,7 @@ pub trait Domain: Downcast + Send + Sync {None => anyhow::bail!("invalid pane index {}", pane_index),};+ let moved_existing_pane = matches!(&source, SplitSource::MovePane(_));let pane = match source {SplitSource::Spawn {command,@@ -126,10 +127,23 @@ pub trait Domain: Downcast + Send + Sync {// pane_index may have changed if src_pane was also in the same tablet final_pane_index = match tab.pane_index_for_pane(pane_id) {Some(index) => index,- None => anyhow::bail!("invalid pane id {}", pane_id),+ None => {+ if moved_existing_pane {+ tab.rehome_orphan_pane(&pane);+ }+ anyhow::bail!("invalid pane id {}", pane_id);+ }};- tab.split_and_insert(final_pane_index, split_request, Arc::clone(&pane))?;+ if let Err(err) = tab.split_and_insert(final_pane_index, split_request, Arc::clone(&pane))+ {+ // A moved pane was already detached from its tab; never let a+ // failed insertion leave it orphaned.+ if moved_existing_pane {+ tab.rehome_orphan_pane(&pane);+ }+ return Err(err);+ }Ok(pane)}diff --git a/mux/src/tab.rs b/mux/src/tab.rsindex 54a61b19..a996ac8b 100644--- a/mux/src/tab.rs+++ b/mux/src/tab.rs@@ -111,6 +111,13 @@ impl PaneStack {self.panes.iter().any(|pane| pane.pane_id() == pane_id)}+ fn pane_by_id(&self, pane_id: PaneId) -> Option<Arc<dyn Pane>> {+ self.panes+ .iter()+ .find(|pane| pane.pane_id() == pane_id)+ .map(Arc::clone)+ }+fn pane_index(&self, pane_id: PaneId) -> Option<usize> {self.panes.iter().position(|pane| pane.pane_id() == pane_id)}@@ -1071,6 +1078,27 @@ impl Tab {self.inner.lock().add_pane_to_stack(base_pane_id, pane)}+ /// Move an existing pane out of its current stack and into the stack+ /// that contains `target_pane_id`, activating it there. The fallible+ /// resize happens before the tree is mutated so a failure cannot leave+ /// the pane detached from the tab.+ pub fn move_pane_to_stack(+ &self,+ src_pane_id: PaneId,+ target_pane_id: PaneId,+ ) -> anyhow::Result<()> {+ self.inner+ .lock()+ .move_pane_to_stack(src_pane_id, target_pane_id)+ }++ /// Re-attach a live pane that was detached mid-operation (e.g. a+ /// MovePane split that failed after removal): push it into the first+ /// leaf stack so it never ends up outside every tab.+ pub fn rehome_orphan_pane(&self, pane: &Arc<dyn Pane>) {+ self.inner.lock().push_pane_into_first_stack(pane)+ }+pub fn activate_pane_in_stack(&self, pane_id: PaneId) -> anyhow::Result<usize> {self.inner.lock().activate_pane_in_stack(pane_id)}@@ -2835,6 +2863,185 @@ impl TabInner {Ok(pane_index)}+ fn move_pane_to_stack(+ &mut self,+ src_pane_id: PaneId,+ target_pane_id: PaneId,+ ) -> anyhow::Result<()> {+ if src_pane_id == target_pane_id {+ anyhow::bail!("cannot move pane {src_pane_id} onto itself");+ }++ // Validation pass: locate both panes without mutating the tree.+ let mut src_pane: Option<Arc<dyn Pane>> = None;+ let mut target_dims: Option<TerminalSize> = None;+ let mut target_found = false;+ let mut same_stack = false;+ {+ let mut cursor = self.pane.take().unwrap().cursor();+ loop {+ if cursor.is_leaf() {+ let stack = cursor.leaf_mut().unwrap();+ let has_src = stack.contains_pane(src_pane_id);+ let has_target = stack.contains_pane(target_pane_id);+ if has_src {+ src_pane = stack.pane_by_id(src_pane_id);+ }+ if has_target {+ target_found = true;+ if let Some(active) = stack.active_pane() {+ let dims = active.get_dimensions();+ target_dims = Some(TerminalSize {+ rows: dims.viewport_rows,+ cols: dims.cols,+ pixel_height: dims.pixel_height,+ pixel_width: dims.pixel_width,+ dpi: dims.dpi,+ });+ }+ }+ if has_src && has_target {+ same_stack = true;+ }+ }+ match cursor.preorder_next() {+ Ok(c) => cursor = c,+ Err(c) => {+ self.pane.replace(c.tree());+ break;+ }+ }+ }+ }++ let src_pane = src_pane+ .ok_or_else(|| anyhow::anyhow!("pane {src_pane_id} not found in tab"))?;+ if !target_found {+ anyhow::bail!("pane {target_pane_id} not found in tab");+ }+ if same_stack {+ anyhow::bail!(+ "panes {src_pane_id} and {target_pane_id} are already in the same stack"+ );+ }++ // The only fallible step happens before the tree is touched: if the+ // pane refuses to resize we bail with the layout intact.+ if let Some(dims) = target_dims {+ src_pane.resize(dims)?;+ }++ // Detach: remove_pane handles emptied-stack pruning and geometry.+ let removed = self.remove_pane(src_pane_id).ok_or_else(|| {+ anyhow::anyhow!("pane {src_pane_id} vanished while moving between stacks")+ })?;++ // Attach: walk the (possibly restructured) tree and push into the+ // target stack. No fallible steps; resize after the removal's+ // rebalance is best-effort.+ let prior = self.get_active_pane();+ let mut pane_index = 0;+ let mut found = false;+ {+ let mut cursor = self.pane.take().unwrap().cursor();+ loop {+ if cursor.is_leaf() {+ let stack = cursor.leaf_mut().unwrap();+ if stack.contains_pane(target_pane_id) {+ if let Some(base) = stack.active_pane() {+ let dims = base.get_dimensions();+ if let Err(err) = removed.resize(TerminalSize {+ rows: dims.viewport_rows,+ cols: dims.cols,+ pixel_height: dims.pixel_height,+ pixel_width: dims.pixel_width,+ dpi: dims.dpi,+ }) {+ log::error!(+ "move_pane_to_stack: resize after rebalance failed: {err:#}"+ );+ }+ }+ stack.push_and_activate(Arc::clone(&removed));+ found = true;+ }+ if !found {+ pane_index += 1;+ }+ }+ match cursor.preorder_next() {+ Ok(c) if !found => cursor = c,+ Ok(c) | Err(c) => {+ self.pane.replace(c.tree());+ break;+ }+ }+ }+ }++ if !found {+ // Should be unreachable: the target lives in a different stack+ // which survives the removal above. Whatever happened, never+ // leave a live pane detached from the tab.+ log::error!(+ "move_pane_to_stack: target pane {target_pane_id} vanished; re-homing pane {src_pane_id}"+ );+ self.push_pane_into_first_stack(&removed);+ anyhow::bail!("pane {target_pane_id} vanished while moving between stacks");+ }++ self.active = pane_index;+ self.recency.tag(pane_index);++ // Mirror add_pane_to_stack: a zoomed stack hands the zoom to the+ // newly arrived pane.+ if let Some(prior_zoomed) = self.zoomed.take() {+ prior_zoomed.set_zoomed(false);+ removed.set_zoomed(true);+ if let Err(err) = removed.resize(self.size) {+ log::error!("failed to resize zoomed pane: {err:#}");+ }+ self.zoomed.replace(removed);+ }++ self.advise_focus_change(prior);+ Mux::try_get().map(|mux| mux.notify(MuxNotification::TabResized(self.id)));++ Ok(())+ }++ /// Last-resort re-homing used when the attach phase of a pane move+ /// cannot find its target: push the pane into the first leaf stack so+ /// it never ends up detached from every tab.+ fn push_pane_into_first_stack(&mut self, pane: &Arc<dyn Pane>) {+ let Some(tree) = self.pane.take() else {+ // The tree was left poisoned by an earlier failure; start over+ // with this pane as the root rather than losing it.+ self.assign_pane(pane);+ return;+ };+ let mut done = false;+ {+ let mut cursor = tree.cursor();+ loop {+ if cursor.is_leaf() {+ cursor.leaf_mut().unwrap().push_and_activate(Arc::clone(pane));+ done = true;+ }+ match cursor.preorder_next() {+ Ok(c) if !done => cursor = c,+ Ok(c) | Err(c) => {+ self.pane.replace(c.tree());+ break;+ }+ }+ }+ }+ if !done {+ self.assign_pane(pane);+ }+ }+fn assign_pane(&mut self, pane: &Arc<dyn Pane>) {match Tree::new().cursor()@@ -3608,7 +3815,10 @@ mod test {impl Drop for MuxTestGuard {fn drop(&mut self) {- Mux::shutdown();+ // Deliberately keep the global Mux installed: tests run in+ // parallel and share it, so shutting it down here makes+ // Mux::get() panic in whichever test is still mid-flight.+ // Each install_mux() swaps in a fresh instance anyway.}}@@ -3681,6 +3891,168 @@ mod test {assert!(panes[0].is_zoomed);}+ #[test]+ fn move_pane_to_stack_between_stacks() {+ let _mux = install_mux();+ let size = test_size();+ let tab = Tab::new(&size);+ tab.assign_pane(&FakePane::new(1, size));+ let horz_size = tab+ .compute_split_size(0, SplitRequest::default())+ .unwrap();+ tab.split_and_insert(0, SplitRequest::default(), FakePane::new(2, horz_size.second))+ .unwrap();+ tab.add_pane_to_stack(1, FakePane::new(3, size)).unwrap();+ assert_eq!(tab.count_panes(), Some(3));++ tab.move_pane_to_stack(3, 2).unwrap();++ assert_eq!(tab.count_panes(), Some(3));+ assert_eq!(tab.pane_index_for_pane(1), Some(0));+ assert_eq!(tab.pane_index_for_pane(2), Some(1));+ assert_eq!(tab.pane_index_for_pane(3), Some(1));+ assert_eq!(tab.get_active_pane().unwrap().pane_id(), 3);++ let tabs = tab.pane_stack_tabs(2);+ assert_eq!(tabs.len(), 2);+ assert_eq!(tabs[0].pane_id, 2);+ assert!(!tabs[0].is_active);+ assert_eq!(tabs[1].pane_id, 3);+ assert!(tabs[1].is_active);++ // Source stack survives with its remaining pane+ assert_eq!(tab.pane_stack_tabs(1).len(), 1);+ assert_eq!(tab.iter_panes().len(), 2);+ }++ #[test]+ fn move_pane_to_stack_prunes_empty_source() {+ let _mux = install_mux();+ let size = test_size();+ let tab = Tab::new(&size);+ tab.assign_pane(&FakePane::new(1, size));+ let horz_size = tab+ .compute_split_size(0, SplitRequest::default())+ .unwrap();+ tab.split_and_insert(0, SplitRequest::default(), FakePane::new(2, horz_size.second))+ .unwrap();++ tab.move_pane_to_stack(1, 2).unwrap();++ assert_eq!(tab.count_panes(), Some(2));+ let panes = tab.iter_panes();+ assert_eq!(panes.len(), 1);+ assert_eq!(panes[0].pane.pane_id(), 1);+ assert!(panes[0].is_active);+ // The surviving stack regains the full tab width+ assert_eq!(panes[0].width, 80);++ let tabs = tab.pane_stack_tabs(2);+ assert_eq!(tabs.len(), 2);+ assert_eq!(tabs[0].pane_id, 2);+ assert_eq!(tabs[1].pane_id, 1);+ assert!(tabs[1].is_active);+ }++ #[test]+ fn move_pane_to_stack_same_stack_bails() {+ let _mux = install_mux();+ let size = test_size();+ let tab = Tab::new(&size);+ tab.assign_pane(&FakePane::new(1, size));+ tab.add_pane_to_stack(1, FakePane::new(3, size)).unwrap();++ assert!(tab.move_pane_to_stack(3, 1).is_err());+ assert!(tab.move_pane_to_stack(1, 1).is_err());+ assert!(tab.move_pane_to_stack(99, 1).is_err());+ assert!(tab.move_pane_to_stack(1, 99).is_err());++ // Tree unchanged in every failure case+ assert_eq!(tab.count_panes(), Some(2));+ let tabs = tab.pane_stack_tabs(1);+ assert_eq!(tabs.len(), 2);+ assert_eq!(tabs[0].pane_id, 1);+ assert_eq!(tabs[1].pane_id, 3);+ assert!(tabs[1].is_active);+ assert_eq!(tab.get_active_pane().unwrap().pane_id(), 3);+ }++ /// A split that fails after the source pane was detached (MovePane+ /// style) must be able to re-home the pane instead of orphaning it.+ #[test]+ fn rehome_orphan_pane_after_failed_split() {+ let _mux = install_mux();+ let size = test_size();+ let tab = Tab::new(&size);+ tab.assign_pane(&FakePane::new(1, size));+ tab.add_pane_to_stack(1, FakePane::new(2, size)).unwrap();++ let removed = tab.remove_pane(2).unwrap();+ // Absurd split size: compute_split_size yields a zero-sized half,+ // which split_and_insert rejects with "No space for split".+ let request = SplitRequest {+ direction: SplitDirection::Horizontal,+ target_is_second: true,+ top_level: false,+ size: SplitSize::Cells(1000),+ };+ let target_index = tab.pane_index_for_pane(1).unwrap();+ assert!(tab+ .split_and_insert(target_index, request, Arc::clone(&removed))+ .is_err());++ tab.rehome_orphan_pane(&removed);+ assert_eq!(tab.count_panes(), Some(2));+ assert!(tab.pane_index_for_pane(2).is_some());+ assert_eq!(tab.get_active_pane().unwrap().pane_id(), 2);+ }++ /// Regression for the same-stack edge drop: dragging the active pane B+ /// out of a stack [A, B] to a split edge must target A (not B itself),+ /// and both panes must remain reachable as two splits afterwards.+ #[test]+ fn split_background_pane_out_of_own_stack() {+ for (direction, target_is_second) in [+ (SplitDirection::Horizontal, true),+ (SplitDirection::Horizontal, false),+ (SplitDirection::Vertical, true),+ (SplitDirection::Vertical, false),+ ] {+ let _mux = install_mux();+ let size = test_size();+ let tab = Tab::new(&size);+ tab.assign_pane(&FakePane::new(1, size));+ tab.add_pane_to_stack(1, FakePane::new(2, size)).unwrap();+ assert_eq!(tab.get_active_pane().unwrap().pane_id(), 2);++ // Emulate the drop: effective target is A (pane 1), the only+ // non-source pane in the stack.+ let removed = tab.remove_pane(2).unwrap();+ let request = SplitRequest {+ direction,+ target_is_second,+ top_level: false,+ size: Default::default(),+ };+ let target_index = tab.pane_index_for_pane(1).unwrap();+ tab.split_and_insert(target_index, request, removed).unwrap();++ assert_eq!(tab.count_panes(), Some(2));+ assert!(tab.pane_index_for_pane(1).is_some());+ assert!(tab.pane_index_for_pane(2).is_some());+ let panes = tab.iter_panes();+ assert_eq!(panes.len(), 2, "{direction:?} second={target_is_second}");++ let moved = tab+ .iter_panes()+ .into_iter()+ .find(|p| p.pane.pane_id() == 2)+ .unwrap();+ tab.set_active_pane(&moved.pane);+ assert_eq!(tab.get_active_pane().unwrap().pane_id(), 2);+ }+ }+fn pane_entry(pane_id: PaneId, size: TerminalSize, is_active_pane: bool) -> PaneEntry {PaneEntry {window_id: 1,diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex acb684ba..775af122 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -584,6 +584,182 @@ struct FileDragState {active: bool,}+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) enum PaneDropZone {+ Center,+ Left,+ Right,+ Top,+ Bottom,+}++#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) enum PaneDropKind {+ MoveIntoStack,+ Split,+}++#[derive(Clone, Debug)]+pub(crate) struct PaneTabDropTarget {+ pub target_pane_id: PaneId,+ pub zone: PaneDropZone,+ pub kind: PaneDropKind,+ /// Preview rectangle in window pixels; painted as the drop overlay.+ pub rect: RectF,+}++/// A level-2 pane tab being dragged toward another pane to move or split.+#[derive(Clone, Debug)]+pub(crate) struct PaneTabDragState {+ pub pane_id: PaneId,+ pub title: String,+ pub start: ::window::Point,+ pub current: ::window::Point,+ pub active: bool,+ pub target: Option<PaneTabDropTarget>,+}++/// Split the target pane into a hit grid: an inner box maps to "move into+/// this pane's stack", the border bands map to the nearest edge.+pub(crate) fn pane_drop_zone(fx: f32, fy: f32) -> PaneDropZone {+ if fx > 0.28 && fx < 0.72 && fy > 0.28 && fy < 0.72 {+ return PaneDropZone::Center;+ }+ let mut best = (fx, PaneDropZone::Left);+ for cand in [+ (1.0 - fx, PaneDropZone::Right),+ (fy, PaneDropZone::Top),+ (1.0 - fy, PaneDropZone::Bottom),+ ] {+ if cand.0 < best.0 {+ best = cand;+ }+ }+ best.1+}++pub(crate) fn zone_split_request(zone: PaneDropZone) -> SplitRequest {+ SplitRequest {+ direction: match zone {+ PaneDropZone::Left | PaneDropZone::Right => SplitDirection::Horizontal,+ PaneDropZone::Top | PaneDropZone::Bottom => SplitDirection::Vertical,+ PaneDropZone::Center => unreachable!("center zone does not split"),+ },+ target_is_second: matches!(zone, PaneDropZone::Right | PaneDropZone::Bottom),+ top_level: false,+ size: MuxSplitSize::Percent(50),+ }+}++/// Decide what dropping onto `zone` would do, or None when the drop is a+/// no-op (moving a pane onto the stack it is already in, or splitting a+/// single-pane stack against itself).+pub(crate) fn pane_drop_action(+ zone: PaneDropZone,+ src_in_target_stack: bool,+ target_stack_len: usize,+) -> Option<PaneDropKind> {+ match zone {+ PaneDropZone::Center => {+ if src_in_target_stack {+ None+ } else {+ Some(PaneDropKind::MoveIntoStack)+ }+ }+ _ => {+ if src_in_target_stack && target_stack_len <= 1 {+ None+ } else {+ Some(PaneDropKind::Split)+ }+ }+ }+}++#[cfg(test)]+mod pane_drop_tests {+ use super::*;++ #[test]+ fn drop_zone_center_box_and_edges() {+ assert_eq!(pane_drop_zone(0.5, 0.5), PaneDropZone::Center);+ assert_eq!(pane_drop_zone(0.29, 0.29), PaneDropZone::Center);+ assert_eq!(pane_drop_zone(0.71, 0.71), PaneDropZone::Center);+ // On/outside the inner box: nearest edge wins+ assert_eq!(pane_drop_zone(0.1, 0.5), PaneDropZone::Left);+ assert_eq!(pane_drop_zone(0.9, 0.5), PaneDropZone::Right);+ assert_eq!(pane_drop_zone(0.5, 0.1), PaneDropZone::Top);+ assert_eq!(pane_drop_zone(0.5, 0.9), PaneDropZone::Bottom);+ // Corners resolve to whichever edge is closest+ assert_eq!(pane_drop_zone(0.05, 0.2), PaneDropZone::Left);+ assert_eq!(pane_drop_zone(0.2, 0.05), PaneDropZone::Top);+ assert_eq!(pane_drop_zone(0.98, 0.9), PaneDropZone::Right);+ assert_eq!(pane_drop_zone(0.9, 0.98), PaneDropZone::Bottom);+ // Extremes+ assert_eq!(pane_drop_zone(0.0, 0.5), PaneDropZone::Left);+ assert_eq!(pane_drop_zone(1.0, 0.5), PaneDropZone::Right);+ }++ #[test]+ fn zone_to_split_request_mapping() {+ let left = zone_split_request(PaneDropZone::Left);+ assert_eq!(left.direction, SplitDirection::Horizontal);+ assert!(!left.target_is_second);++ let right = zone_split_request(PaneDropZone::Right);+ assert_eq!(right.direction, SplitDirection::Horizontal);+ assert!(right.target_is_second);++ let top = zone_split_request(PaneDropZone::Top);+ assert_eq!(top.direction, SplitDirection::Vertical);+ assert!(!top.target_is_second);++ let bottom = zone_split_request(PaneDropZone::Bottom);+ assert_eq!(bottom.direction, SplitDirection::Vertical);+ assert!(bottom.target_is_second);++ for zone in [+ PaneDropZone::Left,+ PaneDropZone::Right,+ PaneDropZone::Top,+ PaneDropZone::Bottom,+ ] {+ let request = zone_split_request(zone);+ assert!(!request.top_level);+ assert_eq!(request.size, MuxSplitSize::Percent(50));+ }+ }++ #[test]+ fn drop_action_table() {+ // Moving into a stack the pane already lives in is a no-op+ assert_eq!(pane_drop_action(PaneDropZone::Center, true, 2), None);+ assert_eq!(+ pane_drop_action(PaneDropZone::Center, false, 1),+ Some(PaneDropKind::MoveIntoStack)+ );+ // Splitting a single-pane stack against itself is a no-op+ assert_eq!(pane_drop_action(PaneDropZone::Left, true, 1), None);+ // ...but a background tab can split out of its own stack+ assert_eq!(+ pane_drop_action(PaneDropZone::Bottom, true, 2),+ Some(PaneDropKind::Split)+ );+ for zone in [+ PaneDropZone::Left,+ PaneDropZone::Right,+ PaneDropZone::Top,+ PaneDropZone::Bottom,+ ] {+ assert_eq!(+ pane_drop_action(zone, false, 1),+ Some(PaneDropKind::Split)+ );+ }+ }+}+#[derive(Clone, Debug)]enum InlineTabRenameTarget {WindowTab(TabId),@@ -1068,6 +1244,8 @@ pub struct TermWindow {// active once the pointer moves past a small threshold so plain clicks// still open the file.right_sidebar_file_drag: Option<FileDragState>,+ /// In-flight drag of a level-2 pane tab toward a move/split drop.+ pane_tab_drag: Option<PaneTabDragState>,/// Content views (e.g. SSH hosts) shown as synthetic tabs.content_views: Vec<ContentViewTab>,active_content_view_id: Option<ContentViewId>,@@ -1403,6 +1581,7 @@ impl TermWindow {// clicking away) and abandons any in-flight file drag.self.finish_inline_tab_rename(true);self.right_sidebar_file_drag = None;+ self.pane_tab_drag = None;self.dragging = None;}@@ -1735,6 +1914,7 @@ impl TermWindow {context_menu_suppressed_release: None,dragging: None,right_sidebar_file_drag: None,+ pane_tab_drag: None,content_views: vec![],active_content_view_id: None,content_view_response_tab_id: None,diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex b0764d42..7d98fedc 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -8,8 +8,9 @@ use crate::termwindow::ui::tokens::{WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE, WINDOW_TAB_LEADING_ACTION_GAP, WINDOW_TAB_TOP_SPACER,};use crate::termwindow::{- GuiWin, MouseCapture, PaneNavAction, PositionedSplit, ScrollHit, TabWheelSurface,- TermWindowNotif, UIItem, UIItemType, TMB,+ pane_drop_action, pane_drop_zone, zone_split_request, GuiWin, MouseCapture, PaneDropKind,+ PaneDropZone, PaneNavAction, PaneTabDragState, PaneTabDropTarget, PositionedSplit, ScrollHit,+ TabWheelSurface, TermWindowNotif, UIItem, UIItemType, TMB,};use ::window::{ContextMenuIcon, ContextMenuItem, IntegratedTitleButtonStyle, MouseButtons as WMB, MouseCursor,@@ -20,11 +21,12 @@ use config::keyassignment::{PaneDirection, SpawnCommand, SpawnTabDomain, SplitPane, SplitSize,};use config::{MouseEventAltScreen, TermConfig};+use mux::domain::SplitSource;use mux::pane::{Pane, WithPaneLines};use mux::ssh::{RemoteSshDomain, SshConnectionStatus};use mux::tab::{PositionedPane, SplitDirection};use mux::window::WindowId as MuxWindowId;-use mux::Mux;+use mux::{Mux, MuxNotification};use mux_lua::MuxPane;use std::convert::TryInto;use std::ops::Sub;@@ -1257,6 +1259,26 @@ impl super::TermWindow {}return;}+ if completed_drag+ .as_ref()+ .is_some_and(|(item, _)| matches!(item.item_type, UIItemType::PaneNav { .. }))+ {+ // Release coordinates can differ from the last move+ // event (coalesced/fast motion); recompute the drop+ // target from where the button actually went up.+ if self.pane_tab_drag.as_ref().is_some_and(|state| state.active) {+ self.update_pane_tab_drag_target(&event);+ }+ if let Some(state) = self.pane_tab_drag.take() {+ if state.active {+ self.drop_pane_tab_drag(state);+ }+ // A plain click (never crossed the threshold)+ // was already handled on press.+ context.invalidate();+ }+ return;+ }if completed_drag.is_some() {// Completed a dragreturn;@@ -1824,7 +1846,9 @@ impl super::TermWindow {self.drag_workspace_sidebar_scroll_thumb(item, start_event, event, context);}UIItemType::ContextMenuBackdrop | UIItemType::ContextMenuItem(_) => {}- UIItemType::PaneNav { .. } => {}+ UIItemType::PaneNav { .. } => {+ self.drag_pane_nav_tab(item, start_event, event, context);+ }UIItemType::RightSidebarFileRow(_) => {self.drag_right_sidebar_file_row(item, start_event, event, context);}@@ -1907,6 +1931,303 @@ impl super::TermWindow {}}+ /// Whether a pane can participate in a drag move/split. Remote mux+ /// panes are excluded because the client's SplitPane move path does+ /// not translate pane ids yet; tmux panes because the tmux domain+ /// ignores SplitSource::MovePane and would spawn instead.+ fn pane_tab_is_movable(pane: &Arc<dyn Pane>) -> bool {+ if pane+ .downcast_ref::<wezterm_client::pane::ClientPane>()+ .is_some()+ {+ return false;+ }+ if let Some(domain) = Mux::get().get_domain(pane.domain_id()) {+ if domain.downcast_ref::<mux::tmux::TmuxDomain>().is_some() {+ return false;+ }+ }+ true+ }++ /// Prime a level-2 pane tab for a potential move/split drag. It only+ /// becomes a real drag once the pointer travels past the threshold, so+ /// plain clicks keep their press-time activation behavior.+ fn arm_pane_tab_drag(&mut self, item: UIItem, pane_id: mux::pane::PaneId, event: MouseEvent) {+ let mux = Mux::get();+ let Some(tab) = mux.get_active_tab_for_window(self.mux_window_id) else {+ return;+ };+ // A zoomed tab shows a single pane: there is nowhere to drop.+ if tab.get_zoomed_pane().is_some() {+ return;+ }+ if tab+ .pane_stack_id(pane_id)+ .is_some_and(|stack_id| self.collapsed_pane_layouts.contains_key(&stack_id))+ {+ return;+ }+ let Some(pane) = mux.get_pane(pane_id) else {+ return;+ };+ if !Self::pane_tab_is_movable(&pane) {+ return;+ }+ let title = self.pane_nav_tab_title(pane_id, &pane.get_title());+ self.pane_tab_drag = Some(PaneTabDragState {+ pane_id,+ title,+ start: event.coords,+ current: event.coords,+ active: false,+ target: None,+ });+ self.dragging.replace((item, event));+ }++ fn drag_pane_nav_tab(+ &mut self,+ item: UIItem,+ start_event: MouseEvent,+ event: MouseEvent,+ context: &dyn WindowOps,+ ) {+ let mut dragging_active = false;+ if let Some(state) = self.pane_tab_drag.as_mut() {+ if !state.active {+ let dx = event.coords.x - state.start.x;+ let dy = event.coords.y - state.start.y;+ // ~5px of travel turns the pending click into a drag+ if dx * dx + dy * dy >= 25 {+ state.active = true;+ }+ }+ state.current = event.coords;+ dragging_active = state.active;+ }+ if dragging_active {+ self.update_pane_tab_drag_target(&event);+ context.set_cursor(Some(MouseCursor::Hand));+ context.invalidate();+ }+ // drag_ui_item takes `dragging` on every move; keep the drag armed+ self.dragging.replace((item, start_event));+ }++ /// Hit-test the pointer against the rendered panes and record which+ /// drop (move-into-stack or directional split) releasing here would+ /// perform, along with the preview rectangle to paint.+ fn update_pane_tab_drag_target(&mut self, event: &MouseEvent) {+ let Some(src_pane_id) = self.pane_tab_drag.as_ref().map(|state| state.pane_id) else {+ return;+ };+ let mut target = None;+ let mux = Mux::get();+ if let Some(tab) = mux.get_active_tab_for_window(self.mux_window_id) {+ let x = event.coords.x as f32;+ let y = event.coords.y as f32;+ for pos in self.get_panes_to_render() {+ if self.collapsed_pane_layouts.contains_key(&pos.pane_stack_id) {+ continue;+ }+ let Ok(rect) = self.pane_frame_rect(&pos) else {+ continue;+ };+ if x < rect.min_x() || x >= rect.max_x() || y < rect.min_y() || y >= rect.max_y()+ {+ continue;+ }+ // Remote mux / tmux panes cannot be split/moved into (v1)+ if !Self::pane_tab_is_movable(&pos.pane) {+ break;+ }+ let stack_tabs = tab.pane_stack_tabs(pos.pane.pane_id());+ let src_in_target_stack =+ stack_tabs.iter().any(|entry| entry.pane_id == src_pane_id);+ let fx = (x - rect.min_x()) / rect.size.width.max(1.0);+ let fy = (y - rect.min_y()) / rect.size.height.max(1.0);+ // Hovering the target pane's own level-2 tab bar reads as+ // "join this stack", like dropping a browser tab onto+ // another window's tab strip.+ let nav_bar_h = self.pane_nav_bar_height_for_pane(&pos) as f32;+ let zone = if y < rect.min_y() + nav_bar_h {+ PaneDropZone::Center+ } else {+ pane_drop_zone(fx, fy)+ };+ let Some(kind) = pane_drop_action(zone, src_in_target_stack, stack_tabs.len())+ else {+ break;+ };+ let preview = match zone {+ // Joining the stack highlights the target's level-2 tab+ // bar, like dropping a browser tab onto a tab strip.+ PaneDropZone::Center => euclid::rect(+ rect.origin.x,+ rect.origin.y,+ rect.size.width,+ nav_bar_h.max(1.0),+ ),+ PaneDropZone::Left => euclid::rect(+ rect.origin.x,+ rect.origin.y,+ rect.size.width / 2.0,+ rect.size.height,+ ),+ PaneDropZone::Right => euclid::rect(+ rect.origin.x + rect.size.width / 2.0,+ rect.origin.y,+ rect.size.width / 2.0,+ rect.size.height,+ ),+ PaneDropZone::Top => euclid::rect(+ rect.origin.x,+ rect.origin.y,+ rect.size.width,+ rect.size.height / 2.0,+ ),+ PaneDropZone::Bottom => euclid::rect(+ rect.origin.x,+ rect.origin.y + rect.size.height / 2.0,+ rect.size.width,+ rect.size.height / 2.0,+ ),+ };+ target = Some(PaneTabDropTarget {+ target_pane_id: pos.pane.pane_id(),+ zone,+ kind,+ rect: preview,+ });+ break;+ }+ }+ if let Some(state) = self.pane_tab_drag.as_mut() {+ state.target = target;+ }+ }++ fn drop_pane_tab_drag(&mut self, state: PaneTabDragState) {+ let Some(target) = state.target else {+ return;+ };+ let src_pane_id = state.pane_id;+ let mux = Mux::get();+ let Some(tab) = mux.get_active_tab_for_window(self.mux_window_id) else {+ return;+ };+ // Re-validate against the live tree: the target was computed on a+ // prior frame and panes may have closed or collapsed since.+ if tab.get_zoomed_pane().is_some() {+ return;+ }+ if tab.pane_index_for_pane(src_pane_id).is_none()+ || tab.pane_index_for_pane(target.target_pane_id).is_none()+ {+ return;+ }+ if tab+ .pane_stack_id(target.target_pane_id)+ .is_some_and(|stack_id| self.collapsed_pane_layouts.contains_key(&stack_id))+ {+ return;+ }++ match target.kind {+ PaneDropKind::MoveIntoStack => {+ if let Err(err) = tab.move_pane_to_stack(src_pane_id, target.target_pane_id) {+ log::error!("pane tab drop move failed: {err:#}");+ return;+ }+ self.persist_workspace_layout_after_mutation("pane tab drop move");+ }+ PaneDropKind::Split => {+ let stack_tabs = tab.pane_stack_tabs(target.target_pane_id);+ let src_in_target_stack =+ stack_tabs.iter().any(|entry| entry.pane_id == src_pane_id);+ // Splitting relative to the source's own stack must target+ // another pane in that stack: MovePane removes the source+ // first and would then fail to find it, orphaning the pane.+ let effective_target = if src_in_target_stack {+ match stack_tabs.iter().find(|entry| entry.pane_id != src_pane_id) {+ Some(other) => other.pane_id,+ None => return,+ }+ } else {+ target.target_pane_id+ };+ let request = zone_split_request(target.zone);+ // Preflight the geometry: compute_split_size hands back+ // zero-sized halves for tiny panes without complaining, and+ // split_and_insert would then reject the split only after+ // MovePane has already detached the source.+ let Some(target_index) = tab.pane_index_for_pane(effective_target) else {+ return;+ };+ match tab.compute_split_size(target_index, request) {+ Some(split)+ if split.first.rows > 0+ && split.first.cols > 0+ && split.second.rows > 0+ && split.second.cols > 0 => {}+ _ => {+ log::debug!(+ "pane tab drop split: no room to split pane {effective_target}"+ );+ return;+ }+ }+ let dest_tab_id = tab.tab_id();+ let workspace = self.current_mux_workspace();+ let window = GuiWin::new(self);+ promise::spawn::spawn(async move {+ match Mux::get()+ .split_pane(+ effective_target,+ request,+ SplitSource::MovePane(src_pane_id),+ SpawnTabDomain::CurrentPaneDomain,+ )+ .await+ {+ Ok((moved, _size)) => {+ // MovePane reuses an already-registered pane, so+ // observers get no PaneAdded; tell them the tab's+ // structure changed.+ Mux::get().notify(MuxNotification::TabResized(dest_tab_id));+ window+ .window+ .notify(TermWindowNotif::Apply(Box::new(move |term_window| {+ // Look up the destination tab by id: the+ // window's active tab may have changed+ // while the split was in flight.+ if let Some(tab) = Mux::get().get_tab(dest_tab_id) {+ // split_and_insert only activates+ // right/bottom targets; make all four+ // directions end focused on the moved+ // pane.+ tab.set_active_pane(&moved);+ }+ if term_window.current_mux_workspace() == workspace {+ term_window.persist_workspace_layout_after_mutation(+ "pane tab drop split",+ );+ }+ term_window.update_title();+ if let Some(window) = term_window.window.as_ref() {+ window.invalidate();+ }+ })));+ }+ Err(err) => log::error!("pane tab drop split failed: {err:#}"),+ }+ })+ .detach();+ }+ }+ }+fn drag_workspace_sidebar_resize(&mut self,item: UIItem,@@ -2019,7 +2340,7 @@ impl super::TermWindow {pane_index,action,} => {- self.mouse_event_pane_nav(pane_id, pane_index, action, event, context);+ self.mouse_event_pane_nav(item, pane_id, pane_index, action, event, context);}UIItemType::ProjectNew => {self.mouse_event_project_new(event, context);@@ -4798,6 +5119,7 @@ impl super::TermWindow {pub fn mouse_event_pane_nav(&mut self,+ item: UIItem,pane_id: mux::pane::PaneId,pane_index: usize,action: PaneNavAction,@@ -4878,6 +5200,7 @@ impl super::TermWindow {client_pane.activate_in_stack_on_server();}}+ self.arm_pane_tab_drag(item, target_pane_id, event);}PaneNavAction::Close(target_pane_id) => {if let Some(tab) = mux.get_active_tab_for_window(self.mux_window_id) {diff --git a/wezterm-gui/src/termwindow/render/corners.rs b/wezterm-gui/src/termwindow/render/corners.rsindex 480ff617..a1a93b9f 100644--- a/wezterm-gui/src/termwindow/render/corners.rs+++ b/wezterm-gui/src/termwindow/render/corners.rs@@ -35,3 +35,81 @@ pub const BOTTOM_RIGHT_ROUNDED_CORNER: &[Poly] = &[Poly {intensity: BlockAlpha::Full,style: PolyStyle::Fill,}];++// Quarter-annulus ring corners: the border stroke of a rounded corner,+// filled as outer arc + inner arc with a ring thickness of 1/5 of the+// corner cell. Together with edge strips of the same thickness they form+// a rounded-rectangle outline that works with translucent colors (which+// the occlusion-based fill_rounded_rectangle_with_border cannot do).++pub const TOP_LEFT_ROUNDED_CORNER_RING: &[Poly] = &[Poly {+ path: &[+ PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::One),+ PolyCommand::QuadTo {+ control: (BlockCoord::Zero, BlockCoord::Zero),+ to: (BlockCoord::One, BlockCoord::Zero),+ },+ PolyCommand::LineTo(BlockCoord::One, BlockCoord::Frac(1, 5)),+ PolyCommand::QuadTo {+ control: (BlockCoord::Frac(1, 5), BlockCoord::Frac(1, 5)),+ to: (BlockCoord::Frac(1, 5), BlockCoord::One),+ },+ PolyCommand::Close,+ ],+ intensity: BlockAlpha::Full,+ style: PolyStyle::Fill,+}];++pub const TOP_RIGHT_ROUNDED_CORNER_RING: &[Poly] = &[Poly {+ path: &[+ PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),+ PolyCommand::QuadTo {+ control: (BlockCoord::One, BlockCoord::Zero),+ to: (BlockCoord::One, BlockCoord::One),+ },+ PolyCommand::LineTo(BlockCoord::Frac(4, 5), BlockCoord::One),+ PolyCommand::QuadTo {+ control: (BlockCoord::Frac(4, 5), BlockCoord::Frac(1, 5)),+ to: (BlockCoord::Zero, BlockCoord::Frac(1, 5)),+ },+ PolyCommand::Close,+ ],+ intensity: BlockAlpha::Full,+ style: PolyStyle::Fill,+}];++pub const BOTTOM_LEFT_ROUNDED_CORNER_RING: &[Poly] = &[Poly {+ path: &[+ PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),+ PolyCommand::QuadTo {+ control: (BlockCoord::Zero, BlockCoord::One),+ to: (BlockCoord::One, BlockCoord::One),+ },+ PolyCommand::LineTo(BlockCoord::One, BlockCoord::Frac(4, 5)),+ PolyCommand::QuadTo {+ control: (BlockCoord::Frac(1, 5), BlockCoord::Frac(4, 5)),+ to: (BlockCoord::Frac(1, 5), BlockCoord::Zero),+ },+ PolyCommand::Close,+ ],+ intensity: BlockAlpha::Full,+ style: PolyStyle::Fill,+}];++pub const BOTTOM_RIGHT_ROUNDED_CORNER_RING: &[Poly] = &[Poly {+ path: &[+ PolyCommand::MoveTo(BlockCoord::One, BlockCoord::Zero),+ PolyCommand::QuadTo {+ control: (BlockCoord::One, BlockCoord::One),+ to: (BlockCoord::Zero, BlockCoord::One),+ },+ PolyCommand::LineTo(BlockCoord::Zero, BlockCoord::Frac(4, 5)),+ PolyCommand::QuadTo {+ control: (BlockCoord::Frac(4, 5), BlockCoord::Frac(4, 5)),+ to: (BlockCoord::Frac(4, 5), BlockCoord::Zero),+ },+ PolyCommand::Close,+ ],+ intensity: BlockAlpha::Full,+ style: PolyStyle::Fill,+}];diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rsindex 9c76a34c..6f1bc987 100644--- a/wezterm-gui/src/termwindow/render/paint.rs+++ b/wezterm-gui/src/termwindow/render/paint.rs@@ -1,4 +1,4 @@-use crate::quad::TripleLayerQuadAllocator;+use crate::quad::{QuadTrait, TripleLayerQuadAllocator};use crate::termwindow::{RenderFrame, TermWindowNotif};use crate::ui::{DrawContext, UiPalette};use ::window::bitmaps::atlas::OutOfTextureSpace;@@ -380,35 +380,136 @@ impl crate::TermWindow {.file_name().map(|name| name.to_string_lossy().into_owned()).unwrap_or_else(|| state.path.to_string_lossy().into_owned());- if label.is_empty() {+ let anchor = state.current;+ self.paint_drag_ghost_pill(&label, anchor)+ }++ /// Translucent preview of where a dragged level-2 pane tab would land+ /// (full pane = move into its stack, half pane = split), plus the+ /// floating tab-title pill. Registers no UIItem (hit-transparent).+ fn paint_pane_tab_drag_overlay(&mut self) -> anyhow::Result<()> {+ let Some(state) = self.pane_tab_drag.as_ref() else {+ return Ok(());+ };+ if !state.active {return Ok(());}+ let label = state.title.clone();let anchor = state.current;+ 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);++ let gl_state = self.render_state.as_ref().unwrap();+ let layer = gl_state+ .layer_for_zindex(0)+ .context("pane drag overlay layer")?;+ let mut layers = layer.quad_allocator();++ // Keep the radius on the same integral grid the corner sprites+ // snap to (and clamped the same way), so the ring corners meet+ // the fill's corners exactly even on short strips.+ let radius = self+ .ui_f32(crate::termwindow::ui::tokens::PANE_DROP_PREVIEW_RADIUS)+ .min(rect.size.width / 2.0)+ .min(rect.size.height / 2.0)+ .floor()+ .max(1.0);+ self.fill_rounded_rectangle(&mut layers, 0, rect, fill, radius)+ .context("pane drag overlay fill")?;+ // The translucent fill can't occlude an underlying border rect,+ // so build the outline from edge strips plus quarter-ring+ // corner sprites of the same thickness (radius / 5).+ let b = (radius / 5.0).max(1.0);+ let (x, y) = (rect.origin.x, rect.origin.y);+ let (w, h) = (rect.size.width, rect.size.height);+ let span_w = (w - radius * 2.0).max(0.0);+ let span_h = (h - radius * 2.0).max(0.0);+ for edge in [+ euclid::rect(x + radius, y, span_w, b),+ euclid::rect(x + radius, y + h - b, span_w, b),+ euclid::rect(x, y + radius, b, span_h),+ euclid::rect(x + w - b, y + radius, b, span_h),+ ] {+ self.filled_rectangle(&mut layers, 0, edge, border)+ .context("pane drag overlay border")?;+ }+ let corner_size = euclid::size2(radius, radius);+ for (cx, cy, poly) in [+ (x, y, super::corners::TOP_LEFT_ROUNDED_CORNER_RING),+ (+ x + w - radius,+ y,+ super::corners::TOP_RIGHT_ROUNDED_CORNER_RING,+ ),+ (+ x,+ y + h - radius,+ super::corners::BOTTOM_LEFT_ROUNDED_CORNER_RING,+ ),+ (+ x + w - radius,+ y + h - radius,+ super::corners::BOTTOM_RIGHT_ROUNDED_CORNER_RING,+ ),+ ] {+ self.poly_quad(+ &mut layers,+ 0,+ euclid::point2(cx, cy),+ poly,+ 0,+ corner_size,+ border,+ )+ .context("pane drag overlay corner")?+ .set_grayscale();+ }+ }++ self.paint_drag_ghost_pill(&label, anchor)+ }++ /// Floating label that follows the cursor during a drag. Painted after+ /// everything else so it stays on top; registers no UIItem.+ fn paint_drag_ghost_pill(+ &mut self,+ label: &str,+ anchor: ::window::Point,+ ) -> anyhow::Result<()> {+ if label.is_empty() {+ return Ok(());+ }let settings = crate::native_settings::load();let font_size = crate::native_settings::home_font_size(&settings);let ui_font = self.fonts.title_font_with_size(font_size)- .context("file drag ghost font")?;+ .context("drag ghost font")?;let metrics = crate::utilsprites::RenderMetrics::with_font_metrics(&ui_font.metrics());let line_height = metrics.cell_size.height as f32;- let (bg, fg) = match crate::native_settings::effective_appearance() {+ let (bg, fg, pill_border) = match crate::native_settings::effective_appearance() {window::Appearance::Light | window::Appearance::LightHighContrast => (LinearRgba::with_srgba(245, 245, 248, 235),LinearRgba::with_srgba(40, 40, 48, 255),+ LinearRgba::with_srgba(60, 60, 67, 70),),window::Appearance::Dark | window::Appearance::DarkHighContrast => (LinearRgba::with_srgba(58, 58, 66, 235),LinearRgba::with_srgba(235, 235, 240, 255),+ LinearRgba::with_srgba(255, 255, 255, 60),),};let gl_state = self.render_state.as_ref().unwrap();let layer = gl_state.layer_for_zindex(0)- .context("file drag ghost layer")?;+ .context("drag ghost layer")?;let mut layers = layer.quad_allocator();let ctx = DrawContext::new(gl_state, self.dimensions, &metrics);@@ -429,8 +530,16 @@ impl crate::TermWindow {.min(self.dimensions.pixel_height as f32 - pill_h).max(0.0);- self.filled_rectangle(&mut layers, 0, euclid::rect(x, y, pill_w, pill_h), bg)- .context("file drag ghost background")?;+ self.fill_rounded_rectangle_with_border(+ &mut layers,+ 0,+ euclid::rect(x, y, pill_w, pill_h),+ bg,+ pill_border,+ pill_h / 2.0,+ 1.0,+ )+ .context("drag ghost background")?;ctx.draw_text_on_layer(&mut layers,2,@@ -441,7 +550,7 @@ impl crate::TermWindow {fg,max_width,)- .context("file drag ghost label")?;+ .context("drag ghost label")?;Ok(())}@@ -610,6 +719,8 @@ impl crate::TermWindow {drop(layers);self.paint_modal().context("paint_modal")?;self.paint_context_menu().context("paint_context_menu")?;+ self.paint_pane_tab_drag_overlay()+ .context("paint_pane_tab_drag_overlay")?;self.paint_file_drag_ghost().context("paint_file_drag_ghost")?;diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rsindex d69bcab6..545e6bb3 100644--- a/wezterm-gui/src/termwindow/render/pane.rs+++ b/wezterm-gui/src/termwindow/render/pane.rs@@ -56,7 +56,7 @@ pub(crate) fn client_pane_lag_ms(pane: &dyn mux::pane::Pane) -> Option<u64> {impl crate::TermWindow {/// Height of the nav bar for this pane: the metric height, clamped so/// that at least one terminal row of the pane's cell remains visible.- fn pane_nav_bar_height_for_pane(&self, pos: &PositionedPane) -> usize {+ pub(crate) fn pane_nav_bar_height_for_pane(&self, pos: &PositionedPane) -> usize {self.pane_nav_bar_height().min(pos.pixel_height.saturating_sub(self.render_metrics.cell_size.height.max(1) as usize),@@ -87,7 +87,7 @@ impl crate::TermWindow {))}- fn pane_frame_rect(&self, pos: &PositionedPane) -> anyhow::Result<RectF> {+ pub(crate) fn pane_frame_rect(&self, pos: &PositionedPane) -> anyhow::Result<RectF> {let (content_pane_x, pane_y) = self.pane_content_origin(pos)?;let content_pane_width = pos.width as f32 * self.render_metrics.cell_size.width as f32;let content_pane_right = content_pane_x + content_pane_width;diff --git a/wezterm-gui/src/termwindow/ui/tokens.rs b/wezterm-gui/src/termwindow/ui/tokens.rsindex ef62fa72..5f067e8f 100644--- a/wezterm-gui/src/termwindow/ui/tokens.rs+++ b/wezterm-gui/src/termwindow/ui/tokens.rs@@ -37,6 +37,7 @@ pub const PANE_NAV_TAB_GAP: usize = 18;pub const PANE_NAV_TAB_TOP_OFFSET: usize = 4;pub const PANE_NAV_TAB_RADIUS: f32 = 12.0;pub const PANE_NAV_ACTION_BUTTON_RADIUS: f32 = 999.0;+pub const PANE_DROP_PREVIEW_RADIUS: f32 = 10.0;pub const CAPSULE_BORDER_WIDTH: f32 = 1.0;pub const ICON_BUTTON_BORDER_WIDTH: f32 = 1.0;diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rsindex 80e07535..cbf34604 100644--- a/window/src/os/x11/window.rs+++ b/window/src/os/x11/window.rs@@ -116,6 +116,42 @@ pub(crate) struct XWindowInner {const _NET_WM_MOVERESIZE_MOVE: u32 = 8;const _NET_WM_MOVERESIZE_CANCEL: u32 = 11;+// `_MOTIF_WM_HINTS` uses a different bit layout for decorations than it does+// for window functions. Keep the decoration values explicit so that asking+// for resize handles cannot accidentally ask the window manager for a title.+const MWM_HINTS_DECORATIONS: u32 = 1 << 1;+const MWM_DECOR_ALL: u32 = 1 << 0;+const MWM_DECOR_BORDER: u32 = 1 << 1;+const MWM_DECOR_RESIZEH: u32 = 1 << 2;+const MWM_DECOR_TITLE: u32 = 1 << 3;+const MWM_DECOR_MENU: u32 = 1 << 4;+const MWM_DECOR_MINIMIZE: u32 = 1 << 5;+const MWM_DECOR_MAXIMIZE: u32 = 1 << 6;++fn motif_decorations_for(decorations: WindowDecorations) -> u32 {+ if decorations.contains(WindowDecorations::INTEGRATED_BUTTONS) {+ // ThinkTerm draws the complete window header. Some X11 window+ // managers, including xfwm4, promote a partial resize-only Motif+ // request back to a complete frame, so integrated mode must request+ // no window-manager decorations at all.+ 0+ } else if decorations == WindowDecorations::TITLE | WindowDecorations::RESIZE {+ MWM_DECOR_ALL+ } else if decorations == WindowDecorations::RESIZE {+ MWM_DECOR_BORDER | MWM_DECOR_RESIZEH+ } else if decorations == WindowDecorations::TITLE {+ MWM_DECOR_BORDER+ | MWM_DECOR_TITLE+ | MWM_DECOR_MENU+ | MWM_DECOR_MINIMIZE+ | MWM_DECOR_MAXIMIZE+ } else if decorations == WindowDecorations::NONE {+ 0+ } else {+ MWM_DECOR_ALL+ }+}+impl Drop for XWindowInner {fn drop(&mut self) {if self.window_id != xcb::x::Window::none() {@@ -1276,7 +1312,6 @@ impl XWindowInner {)}- #[allow(clippy::identity_op)]fn adjust_decorations(&mut self, decorations: WindowDecorations) -> anyhow::Result<()> {// Set the motif hints to disable decorations.// See https://stackoverflow.com/a/1909708@@ -1289,36 +1324,10 @@ impl XWindowInner {status: u32,}- const HINTS_DECORATIONS: u32 = 1 << 1;- const FUNC_ALL: u32 = 1 << 0;- const FUNC_RESIZE: u32 = 1 << 1;- // const HINTS_FUNCTIONS: u32 = 1 << 0;- const FUNC_MOVE: u32 = 1 << 2;- const FUNC_MINIMIZE: u32 = 1 << 3;- const FUNC_MAXIMIZE: u32 = 1 << 4;- const FUNC_CLOSE: u32 = 1 << 5;-- let decorations = if decorations.contains(WindowDecorations::INTEGRATED_BUTTONS) {- // Integrated title buttons live in ThinkTerm's own header. Never- // ask the window manager for another title bar, even if a legacy- // configuration also contains TITLE.- FUNC_RESIZE- } else if decorations == WindowDecorations::TITLE | WindowDecorations::RESIZE {- FUNC_ALL- } else if decorations == WindowDecorations::RESIZE {- FUNC_RESIZE- } else if decorations == WindowDecorations::TITLE {- FUNC_MOVE | FUNC_MINIMIZE | FUNC_MAXIMIZE | FUNC_CLOSE- } else if decorations == WindowDecorations::NONE {- 0- } else {- FUNC_ALL- };-let hints = MwmHints {- flags: HINTS_DECORATIONS,+ flags: MWM_HINTS_DECORATIONS,functions: 0,- decorations,+ decorations: motif_decorations_for(decorations),input_mode: 0,status: 0,};@@ -2261,3 +2270,36 @@ impl NetWmStateAction {}}}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn integrated_buttons_never_request_a_native_title_bar() {+ for decorations in [+ WindowDecorations::INTEGRATED_BUTTONS,+ WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE,+ WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::TITLE,+ WindowDecorations::INTEGRATED_BUTTONS+ | WindowDecorations::TITLE+ | WindowDecorations::RESIZE,+ ] {+ assert_eq!(motif_decorations_for(decorations) & MWM_DECOR_TITLE, 0);+ }+ }++ #[test]+ fn integrated_buttons_disable_the_native_frame() {+ assert_eq!(+ motif_decorations_for(+ WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE+ ),+ 0+ );+ assert_eq!(+ motif_decorations_for(WindowDecorations::INTEGRATED_BUTTONS),+ 0+ );+ }+}