1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00

window: implement window movement by dragging on Wayland

This commit is contained in:
Greg V 2021-09-08 23:18:07 +03:00 committed by Wez Furlong
parent bd9b964106
commit 94ede1e8f1
6 changed files with 30 additions and 4 deletions

View File

@ -321,6 +321,7 @@ impl super::TermWindow {
TabBarItem::None => {
// Potentially starting a drag by the tab bar
self.window_drag_position.replace(event.clone());
context.request_drag_move();
}
},
WMEK::Press(MousePress::Middle) => match self.tab_bar.hit_test(x) {

View File

@ -220,9 +220,18 @@ pub trait WindowOps {
/// Resize the inner or client area of the window
fn set_inner_size(&self, width: usize, height: usize);
/// Requests the windowing system to start a window drag.
///
/// This is only implemented on backends that handle
/// window movement on the server side (Wayland).
fn request_drag_move(&self) {}
/// Changes the location of the window on the screen.
/// The coordinates are of the top left pixel of the
/// client area.
///
/// This is only implemented on backends that allow
/// windows to move themselves (not Wayland).
fn set_window_position(&self, _coords: ScreenPoint) {}
/// inform the windowing system of the current textual

View File

@ -10,7 +10,7 @@ use wayland_client::Attached;
#[derive(Default)]
pub struct CopyAndPaste {
data_offer: Option<WlDataOffer>,
last_serial: u32,
pub(crate) last_serial: u32,
}
impl std::fmt::Debug for CopyAndPaste {

View File

@ -94,6 +94,7 @@ pub struct PointerDispatcher {
auto_pointer: ThemedPointer,
#[allow(dead_code)]
themer: ThemeManager,
pub(crate) seat: WlSeat,
}
#[derive(Clone, Debug)]
@ -237,6 +238,7 @@ impl PointerDispatcher {
data_device,
themer,
auto_pointer,
seat: seat.clone(),
})
}

View File

@ -793,9 +793,9 @@ impl WindowOps for WaylandWindow {
});
}
fn set_window_position(&self, coords: ScreenPoint) {
fn request_drag_move(&self) {
WaylandConnection::with_window_inner(self.0, move |inner| {
inner.set_window_position(coords);
inner.request_drag_move();
Ok(())
});
}
@ -1000,7 +1000,13 @@ impl WaylandWindowInner {
}
}
fn set_window_position(&self, _coords: ScreenPoint) {}
fn request_drag_move(&self) {
if let Some(window) = self.window.as_ref() {
let serial = self.copy_and_paste.lock().unwrap().last_serial;
let conn = Connection::get().unwrap().wayland();
window.start_interactive_move(&conn.pointer.seat, serial);
}
}
/// Change the title for the window manager
fn set_title(&mut self, title: &str) {

View File

@ -285,6 +285,14 @@ impl WindowOps for Window {
}
}
fn request_drag_move(&self) {
match self {
Self::X11(x) => x.request_drag_move(),
#[cfg(feature = "wayland")]
Self::Wayland(w) => w.request_drag_move(),
}
}
fn set_window_position(&self, coords: ScreenPoint) {
match self {
Self::X11(x) => x.set_window_position(coords),