Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
linux: Fix some small issues (#11458)
apricotbucket2811bc28080ff4
diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rsindex bd519a098d1..c1f6df1593b 100644--- a/crates/gpui/src/platform/linux/platform.rs+++ b/crates/gpui/src/platform/linux/platform.rs@@ -613,11 +613,9 @@ impl Keystroke {}};- // Ignore control characters (and DEL) for the purposes of ime_key,- // but if key_utf32 is 0 then assume it isn't one- let ime_key = ((key_utf32 == 0 || (key_utf32 >= 32 && key_utf32 != 127))- && !key_utf8.is_empty())- .then_some(key_utf8);+ // Ignore control characters (and DEL) for the purposes of ime_key+ let ime_key =+ (key_utf32 >= 32 && key_utf32 != 127 && !key_utf8.is_empty()).then_some(key_utf8);if handle_consumed_modifiers {let mod_shift_index = state.get_keymap().mod_get_index(xkb::MOD_NAME_SHIFT);diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rsindex 7dfde299214..b5aed4e941a 100644--- a/crates/gpui/src/platform/linux/wayland/client.rs+++ b/crates/gpui/src/platform/linux/wayland/client.rs@@ -59,7 +59,7 @@ use crate::platform::linux::wayland::serial::{SerialKind, SerialTracker};use crate::platform::linux::wayland::window::WaylandWindow;use crate::platform::linux::LinuxClient;use crate::platform::PlatformWindow;-use crate::{point, px, FileDropEvent, ForegroundExecutor, MouseExitEvent};+use crate::{point, px, FileDropEvent, ForegroundExecutor, MouseExitEvent, SCROLL_LINES};use crate::{AnyWindowHandle, CursorStyle, DisplayId, KeyDownEvent, KeyUpEvent, Keystroke, Modifiers,ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent,@@ -204,7 +204,7 @@ impl WaylandClientStatePtr {}if let Some(window) = state.keyboard_focused_window.take() {if !window.ptr_eq(&closed_window) {- state.mouse_focused_window = Some(window);+ state.keyboard_focused_window = Some(window);}}if state.windows.is_empty() {@@ -1098,7 +1098,9 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {value,..} => {- let axis_source = state.axis_source;+ if state.axis_source == AxisSource::Wheel {+ return;+ }let axis_modifier = match axis {wl_pointer::Axis::VerticalScroll => state.vertical_modifier,wl_pointer::Axis::HorizontalScroll => state.horizontal_modifier,@@ -1133,16 +1135,13 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {_ => 1.0,};- // TODO: Make nice feeling kinetic scrolling that integrates with the platform's scroll settings- let modifier = 3.0;-let scroll_delta = state.discrete_scroll_delta.get_or_insert(point(0.0, 0.0));match axis {wl_pointer::Axis::VerticalScroll => {- scroll_delta.y += discrete as f32 * axis_modifier * modifier;+ scroll_delta.y += discrete as f32 * axis_modifier * SCROLL_LINES as f32;}wl_pointer::Axis::HorizontalScroll => {- scroll_delta.x += discrete as f32 * axis_modifier * modifier;+ scroll_delta.x += discrete as f32 * axis_modifier * SCROLL_LINES as f32;}_ => unreachable!(),}@@ -1180,10 +1179,10 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {let wheel_percent = value120 as f32 / 120.0;match axis {wl_pointer::Axis::VerticalScroll => {- scroll_delta.y += wheel_percent * axis_modifier;+ scroll_delta.y += wheel_percent * axis_modifier * SCROLL_LINES as f32;}wl_pointer::Axis::HorizontalScroll => {- scroll_delta.x += wheel_percent * axis_modifier;+ scroll_delta.x += wheel_percent * axis_modifier * SCROLL_LINES as f32;}_ => unreachable!(),}diff --git a/crates/gpui/src/platform/linux/wayland/window.rs b/crates/gpui/src/platform/linux/wayland/window.rsindex 7848a9b284c..8924a322b54 100644--- a/crates/gpui/src/platform/linux/wayland/window.rs+++ b/crates/gpui/src/platform/linux/wayland/window.rs@@ -299,7 +299,7 @@ impl WaylandWindowStatePtr {self.set_decoration_state(WaylandDecorationState::Server)}WEnum::Value(zxdg_toplevel_decoration_v1::Mode::ClientSide) => {- self.set_decoration_state(WaylandDecorationState::Server)+ self.set_decoration_state(WaylandDecorationState::Client)}WEnum::Value(_) => {log::warn!("Unknown decoration mode");@@ -610,11 +610,11 @@ impl PlatformWindow for WaylandWindow {}fn set_title(&mut self, title: &str) {- self.borrow_mut().toplevel.set_title(title.to_string());+ self.borrow().toplevel.set_title(title.to_string());}fn set_app_id(&mut self, app_id: &str) {- self.borrow_mut().toplevel.set_app_id(app_id.to_owned());+ self.borrow().toplevel.set_app_id(app_id.to_owned());}fn set_background_appearance(&mut self, background_appearance: WindowBackgroundAppearance) {@@ -666,15 +666,20 @@ impl PlatformWindow for WaylandWindow {}fn minimize(&self) {- self.borrow_mut().toplevel.set_minimized();+ self.borrow().toplevel.set_minimized();}fn zoom(&self) {- // todo(linux)+ let state = self.borrow();+ if !state.maximized {+ state.toplevel.set_maximized();+ } else {+ state.toplevel.unset_maximized();+ }}fn toggle_fullscreen(&self) {- let state = self.borrow_mut();+ let state = self.borrow();if !state.fullscreen {state.toplevel.set_fullscreen(None);} else {