mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 15:04:36 +03:00
window: fixup build for x11/wayland
This commit is contained in:
parent
4f80fd9bcd
commit
1af1c85818
@ -24,7 +24,6 @@ use std::sync::{Arc, Mutex};
|
|||||||
use toolkit::get_surface_scale_factor;
|
use toolkit::get_surface_scale_factor;
|
||||||
use toolkit::reexports::client::protocol::wl_data_source::Event as DataSourceEvent;
|
use toolkit::reexports::client::protocol::wl_data_source::Event as DataSourceEvent;
|
||||||
use toolkit::reexports::client::protocol::wl_surface::WlSurface;
|
use toolkit::reexports::client::protocol::wl_surface::WlSurface;
|
||||||
use toolkit::shm::MemPool;
|
|
||||||
use toolkit::window::{ButtonColorSpec, ColorSpec, ConceptConfig, ConceptFrame, Event};
|
use toolkit::window::{ButtonColorSpec, ColorSpec, ConceptConfig, ConceptFrame, Event};
|
||||||
use wayland_client::protocol::wl_data_device_manager::WlDataDeviceManager;
|
use wayland_client::protocol::wl_data_device_manager::WlDataDeviceManager;
|
||||||
use wayland_egl::{is_available as egl_is_available, WlEglSurface};
|
use wayland_egl::{is_available as egl_is_available, WlEglSurface};
|
||||||
@ -86,7 +85,6 @@ pub struct WaylandWindowInner {
|
|||||||
surface: WlSurface,
|
surface: WlSurface,
|
||||||
copy_and_paste: Arc<Mutex<CopyAndPaste>>,
|
copy_and_paste: Arc<Mutex<CopyAndPaste>>,
|
||||||
window: Option<toolkit::window::Window<ConceptFrame>>,
|
window: Option<toolkit::window::Window<ConceptFrame>>,
|
||||||
pool: MemPool,
|
|
||||||
dimensions: Dimensions,
|
dimensions: Dimensions,
|
||||||
need_paint: bool,
|
need_paint: bool,
|
||||||
last_mouse_coords: Point,
|
last_mouse_coords: Point,
|
||||||
@ -218,8 +216,6 @@ impl WaylandWindow {
|
|||||||
window.set_title(name.to_string());
|
window.set_title(name.to_string());
|
||||||
window.set_frame_config(frame_config());
|
window.set_frame_config(frame_config());
|
||||||
|
|
||||||
let pool = MemPool::new(conn.environment.borrow().require_global(), |_| {})?;
|
|
||||||
|
|
||||||
// window.new_seat(&conn.seat);
|
// window.new_seat(&conn.seat);
|
||||||
conn.keyboard.add_window(window_id, &surface);
|
conn.keyboard.add_window(window_id, &surface);
|
||||||
|
|
||||||
@ -234,7 +230,6 @@ impl WaylandWindow {
|
|||||||
callbacks,
|
callbacks,
|
||||||
surface: surface.detach(),
|
surface: surface.detach(),
|
||||||
window: Some(window),
|
window: Some(window),
|
||||||
pool,
|
|
||||||
dimensions,
|
dimensions,
|
||||||
need_paint: true,
|
need_paint: true,
|
||||||
last_mouse_coords: Point::new(0, 0),
|
last_mouse_coords: Point::new(0, 0),
|
||||||
@ -420,10 +415,6 @@ impl WaylandWindowInner {
|
|||||||
self.dimensions.dpi as i32 / crate::DEFAULT_DPI as i32
|
self.dimensions.dpi as i32 / crate::DEFAULT_DPI as i32
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_dpi(&self) -> usize {
|
|
||||||
self.dimensions.dpi
|
|
||||||
}
|
|
||||||
|
|
||||||
fn surface_to_pixels(&self, surface: i32) -> i32 {
|
fn surface_to_pixels(&self, surface: i32) -> i32 {
|
||||||
surface * self.get_dpi_factor()
|
surface * self.get_dpi_factor()
|
||||||
}
|
}
|
||||||
@ -579,27 +570,6 @@ impl WaylandWindowInner {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn damage(&mut self) {
|
|
||||||
if self.surface.as_ref().version() >= 4 {
|
|
||||||
self.surface.damage_buffer(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
self.dimensions.pixel_width as i32,
|
|
||||||
self.dimensions.pixel_height as i32,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Older versions use the surface size which is the pre-scaled
|
|
||||||
// dimensions. Since we store the scaled dimensions, we need
|
|
||||||
// to compensate here.
|
|
||||||
self.surface.damage(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
self.pixels_to_surface(self.dimensions.pixel_width as i32),
|
|
||||||
self.pixels_to_surface(self.dimensions.pixel_height as i32),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MmapImage<'a> {
|
struct MmapImage<'a> {
|
||||||
|
@ -41,12 +41,10 @@ pub(crate) struct XWindowInner {
|
|||||||
window_id: xcb::xproto::Window,
|
window_id: xcb::xproto::Window,
|
||||||
conn: Weak<XConnection>,
|
conn: Weak<XConnection>,
|
||||||
callbacks: Box<dyn WindowCallbacks>,
|
callbacks: Box<dyn WindowCallbacks>,
|
||||||
window_context: Context,
|
|
||||||
width: u16,
|
width: u16,
|
||||||
height: u16,
|
height: u16,
|
||||||
expose: VecDeque<Rect>,
|
expose: VecDeque<Rect>,
|
||||||
paint_all: bool,
|
paint_all: bool,
|
||||||
buffer_image: BufferImage,
|
|
||||||
cursor: Option<MouseCursor>,
|
cursor: Option<MouseCursor>,
|
||||||
cursors: HashMap<Option<MouseCursor>, XcbCursor>,
|
cursors: HashMap<Option<MouseCursor>, XcbCursor>,
|
||||||
copy_and_paste: CopyAndPaste,
|
copy_and_paste: CopyAndPaste,
|
||||||
@ -111,7 +109,6 @@ impl<'a> PaintContext for X11GraphicsContext<'a> {
|
|||||||
|
|
||||||
impl XWindowInner {
|
impl XWindowInner {
|
||||||
fn enable_opengl(&mut self) -> anyhow::Result<()> {
|
fn enable_opengl(&mut self) -> anyhow::Result<()> {
|
||||||
let window = XWindow(self.window_id);
|
|
||||||
let conn = self.conn();
|
let conn = self.conn();
|
||||||
|
|
||||||
let gl_state = match conn.gl_connection.borrow().as_ref() {
|
let gl_state = match conn.gl_connection.borrow().as_ref() {
|
||||||
@ -142,13 +139,11 @@ impl XWindowInner {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.gl_state.replace(gl_state.clone());
|
self.gl_state.replace(gl_state.clone());
|
||||||
self.callbacks.created(&window, gl_state)
|
let window_handle = Window::X11(XWindow::from_id(self.window_id));
|
||||||
|
self.callbacks.created(&window_handle, gl_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn paint(&mut self) -> anyhow::Result<()> {
|
pub fn paint(&mut self) -> anyhow::Result<()> {
|
||||||
let window_dimensions =
|
|
||||||
Rect::from_size(Size::new(self.width as isize, self.height as isize));
|
|
||||||
|
|
||||||
if !self.paint_all && self.expose.is_empty() {
|
if !self.paint_all && self.expose.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@ -757,21 +752,15 @@ impl XWindow {
|
|||||||
.request_check()
|
.request_check()
|
||||||
.context("xcb::create_window_checked")?;
|
.context("xcb::create_window_checked")?;
|
||||||
|
|
||||||
let window_context = Context::new(&conn, &window_id);
|
|
||||||
|
|
||||||
let buffer_image = BufferImage::new(&conn, window_id, width, height);
|
|
||||||
|
|
||||||
Arc::new(Mutex::new(XWindowInner {
|
Arc::new(Mutex::new(XWindowInner {
|
||||||
window_id,
|
window_id,
|
||||||
conn: Rc::downgrade(&conn),
|
conn: Rc::downgrade(&conn),
|
||||||
callbacks,
|
callbacks,
|
||||||
window_context,
|
|
||||||
width: width.try_into()?,
|
width: width.try_into()?,
|
||||||
height: height.try_into()?,
|
height: height.try_into()?,
|
||||||
expose: VecDeque::new(),
|
expose: VecDeque::new(),
|
||||||
paint_all: true,
|
paint_all: true,
|
||||||
copy_and_paste: CopyAndPaste::default(),
|
copy_and_paste: CopyAndPaste::default(),
|
||||||
buffer_image,
|
|
||||||
cursor: None,
|
cursor: None,
|
||||||
cursors: HashMap::new(),
|
cursors: HashMap::new(),
|
||||||
gl_state: None,
|
gl_state: None,
|
||||||
|
Loading…
Reference in New Issue
Block a user