mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 13:21:38 +03:00
wayland: make scaling workaround accomodate wlroots
Rather than detaching the buffer, replace it with an appropriately sized little one. refs: #1727
This commit is contained in:
parent
509fd98b03
commit
8f222d9559
@ -18,6 +18,7 @@ use std::sync::atomic::AtomicUsize;
|
||||
use toolkit::environment::Environment;
|
||||
use toolkit::reexports::client::Display;
|
||||
use toolkit::seat::SeatListener;
|
||||
use toolkit::shm::AutoMemPool;
|
||||
use wayland_client::protocol::wl_keyboard::{Event as WlKeyboardEvent, KeymapFormat, WlKeyboard};
|
||||
use wayland_client::{EventQueue, Main};
|
||||
|
||||
@ -45,6 +46,8 @@ pub struct WaylandConnection {
|
||||
/// Repeats per second
|
||||
pub(crate) key_repeat_rate: RefCell<i32>,
|
||||
|
||||
pub(crate) mem_pool: RefCell<AutoMemPool>,
|
||||
|
||||
/// Delay before repeating, in milliseconds
|
||||
pub(crate) key_repeat_delay: RefCell<i32>,
|
||||
pub(crate) last_serial: RefCell<u32>,
|
||||
@ -139,6 +142,8 @@ impl WaylandConnection {
|
||||
});
|
||||
}
|
||||
|
||||
let mem_pool = environment.create_auto_pool()?;
|
||||
|
||||
Ok(Self {
|
||||
display: RefCell::new(display),
|
||||
environment: RefCell::new(environment),
|
||||
@ -148,6 +153,7 @@ impl WaylandConnection {
|
||||
event_q: RefCell::new(event_q),
|
||||
pointer: RefCell::new(pointer.unwrap()),
|
||||
seat_listener,
|
||||
mem_pool: RefCell::new(mem_pool),
|
||||
gl_connection: RefCell::new(None),
|
||||
keyboard_mapper: RefCell::new(None),
|
||||
key_repeat_rate: RefCell::new(25),
|
||||
|
@ -677,9 +677,21 @@ impl WaylandWindowInner {
|
||||
// otherwise interactive window resize will keep removing
|
||||
// the window contents!
|
||||
if self.surface_factor != factor {
|
||||
self.surface.attach(None, 0, 0);
|
||||
self.surface.set_buffer_scale(factor);
|
||||
self.surface_factor = factor;
|
||||
let wayland_conn = Connection::get().unwrap().wayland();
|
||||
let mut pool = wayland_conn.mem_pool.borrow_mut();
|
||||
// Make a "fake" buffer with the right dimensions, as
|
||||
// simply detaching the buffer can cause wlroots-derived
|
||||
// compositors consider the window to be unconfigured.
|
||||
if let Ok((_bytes, buffer)) = pool.buffer(
|
||||
factor,
|
||||
factor,
|
||||
factor * 4,
|
||||
wayland_client::protocol::wl_shm::Format::Argb8888,
|
||||
) {
|
||||
self.surface.attach(Some(&buffer), 0, 0);
|
||||
self.surface.set_buffer_scale(factor);
|
||||
self.surface_factor = factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user