Revert "Fix blurry cursor on Wayland at a scale other than 100%" (#18642)
Closes #17771 Reverts zed-industries/zed#17496 This PR turns out to need more work than I thought when I merged it. Release Notes: - Linux: Fix a bug where the cursor would be the wrong size on Wayland
This commit is contained in:
parent
a5f50e5c1e
commit
209ebb0c65
2 changed files with 8 additions and 28 deletions
|
@ -477,8 +477,7 @@ impl WaylandClient {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|primary_selection_manager| primary_selection_manager.get_device(&seat, &qh, ()));
|
.map(|primary_selection_manager| primary_selection_manager.get_device(&seat, &qh, ()));
|
||||||
|
|
||||||
// FIXME: Determine the scaling factor dynamically by the compositor
|
let mut cursor = Cursor::new(&conn, &globals, 24);
|
||||||
let mut cursor = Cursor::new(&conn, &globals, 24, 2);
|
|
||||||
|
|
||||||
handle
|
handle
|
||||||
.insert_source(XDPEventSource::new(&common.background_executor), {
|
.insert_source(XDPEventSource::new(&common.background_executor), {
|
||||||
|
|
|
@ -11,7 +11,6 @@ pub(crate) struct Cursor {
|
||||||
theme_name: Option<String>,
|
theme_name: Option<String>,
|
||||||
surface: WlSurface,
|
surface: WlSurface,
|
||||||
size: u32,
|
size: u32,
|
||||||
scale: u32,
|
|
||||||
shm: WlShm,
|
shm: WlShm,
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
}
|
}
|
||||||
|
@ -24,7 +23,7 @@ impl Drop for Cursor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cursor {
|
impl Cursor {
|
||||||
pub fn new(connection: &Connection, globals: &Globals, size: u32, scale: u32) -> Self {
|
pub fn new(connection: &Connection, globals: &Globals, size: u32) -> Self {
|
||||||
Self {
|
Self {
|
||||||
theme: CursorTheme::load(&connection, globals.shm.clone(), size).log_err(),
|
theme: CursorTheme::load(&connection, globals.shm.clone(), size).log_err(),
|
||||||
theme_name: None,
|
theme_name: None,
|
||||||
|
@ -32,7 +31,6 @@ impl Cursor {
|
||||||
shm: globals.shm.clone(),
|
shm: globals.shm.clone(),
|
||||||
connection: connection.clone(),
|
connection: connection.clone(),
|
||||||
size,
|
size,
|
||||||
scale,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,18 +38,14 @@ impl Cursor {
|
||||||
if let Some(size) = size {
|
if let Some(size) = size {
|
||||||
self.size = size;
|
self.size = size;
|
||||||
}
|
}
|
||||||
if let Some(theme) = CursorTheme::load_from_name(
|
if let Some(theme) =
|
||||||
&self.connection,
|
CursorTheme::load_from_name(&self.connection, self.shm.clone(), theme_name, self.size)
|
||||||
self.shm.clone(),
|
.log_err()
|
||||||
theme_name,
|
|
||||||
self.size * self.scale,
|
|
||||||
)
|
|
||||||
.log_err()
|
|
||||||
{
|
{
|
||||||
self.theme = Some(theme);
|
self.theme = Some(theme);
|
||||||
self.theme_name = Some(theme_name.to_string());
|
self.theme_name = Some(theme_name.to_string());
|
||||||
} else if let Some(theme) =
|
} else if let Some(theme) =
|
||||||
CursorTheme::load(&self.connection, self.shm.clone(), self.size * self.scale).log_err()
|
CursorTheme::load(&self.connection, self.shm.clone(), self.size).log_err()
|
||||||
{
|
{
|
||||||
self.theme = Some(theme);
|
self.theme = Some(theme);
|
||||||
self.theme_name = None;
|
self.theme_name = None;
|
||||||
|
@ -97,22 +91,9 @@ impl Cursor {
|
||||||
let (width, height) = buffer.dimensions();
|
let (width, height) = buffer.dimensions();
|
||||||
let (hot_x, hot_y) = buffer.hotspot();
|
let (hot_x, hot_y) = buffer.hotspot();
|
||||||
|
|
||||||
let scaled_width = width / self.scale;
|
wl_pointer.set_cursor(serial_id, Some(&self.surface), hot_x as i32, hot_y as i32);
|
||||||
let scaled_height = height / self.scale;
|
|
||||||
let scaled_hot_x = hot_x / self.scale;
|
|
||||||
let scaled_hot_y = hot_y / self.scale;
|
|
||||||
|
|
||||||
self.surface.set_buffer_scale(self.scale as i32);
|
|
||||||
|
|
||||||
wl_pointer.set_cursor(
|
|
||||||
serial_id,
|
|
||||||
Some(&self.surface),
|
|
||||||
scaled_hot_x as i32,
|
|
||||||
scaled_hot_y as i32,
|
|
||||||
);
|
|
||||||
self.surface.attach(Some(&buffer), 0, 0);
|
self.surface.attach(Some(&buffer), 0, 0);
|
||||||
self.surface
|
self.surface.damage(0, 0, width as i32, height as i32);
|
||||||
.damage(0, 0, scaled_width as i32, scaled_height as i32);
|
|
||||||
self.surface.commit();
|
self.surface.commit();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue