mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 05:00:16 +00:00
linux: Fix some small issues (#11458)
Fixed various small issues on Linux, mainly on Wayland.
Apart from the first commit (which should be self-describing), the other
commits have a description explaining the issue and what they do.
caadc58bea
should fix
https://github.com/zed-industries/zed/issues/11037
Release Notes:
- N/A
This commit is contained in:
parent
fd3831861b
commit
11bc28080f
3 changed files with 23 additions and 21 deletions
|
@ -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);
|
||||
|
|
|
@ -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!(),
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue