Skip to content

Commit 133268d

Browse files
committed
merge upstream
2 parents 262a8c6 + 10f2109 commit 133268d

File tree

7 files changed

+22
-8
lines changed

7 files changed

+22
-8
lines changed

winit-wayland/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ default = ["dlopen", "csd-adwaita"]
1414
csd-adwaita = ["sctk-adwaita", "sctk-adwaita/ab_glyph"]
1515
csd-adwaita-crossfont = ["sctk-adwaita", "sctk-adwaita/crossfont"]
1616
csd-adwaita-notitle = ["sctk-adwaita"]
17+
csd-adwaita-notitlebar = ["csd-adwaita-notitle"]
1718
dlopen = ["wayland-backend/dlopen"]
1819
serde = ["dep:serde", "bitflags/serde", "smol_str/serde", "dpi/serde"]
1920

winit-wayland/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//! * `wayland-csd-adwaita` (default).
1414
//! * `wayland-csd-adwaita-crossfont`.
1515
//! * `wayland-csd-adwaita-notitle`.
16+
//! * `wayland-csd-adwaita-notitlebar`.
1617
use std::ffi::c_void;
1718
use std::ptr::NonNull;
1819

winit-wayland/src/seat/pointer/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ impl PointerHandler for WinitState {
195195
// Get the current phase.
196196
let mut pointer_data = pointer.winit_data().inner.lock().unwrap();
197197

198+
let has_value120_scroll = horizontal.value120 != 0 || vertical.value120 != 0;
198199
let has_discrete_scroll = horizontal.discrete != 0 || vertical.discrete != 0;
199200

200201
// Figure out what to do about start/ended phases here.
@@ -206,7 +207,7 @@ impl PointerHandler for WinitState {
206207
} else {
207208
match pointer_data.phase {
208209
// Discrete scroll only results in moved events.
209-
_ if has_discrete_scroll => TouchPhase::Moved,
210+
_ if has_value120_scroll || has_discrete_scroll => TouchPhase::Moved,
210211
TouchPhase::Started | TouchPhase::Moved => TouchPhase::Moved,
211212
_ => TouchPhase::Started,
212213
}
@@ -217,7 +218,13 @@ impl PointerHandler for WinitState {
217218

218219
// Mice events have both pixel and discrete delta's at the same time. So prefer
219220
// the discrete values if they are present.
220-
let delta = if has_discrete_scroll {
221+
let delta = if has_value120_scroll {
222+
// NOTE: Wayland sign convention is the inverse of winit.
223+
MouseScrollDelta::LineDelta(
224+
(-horizontal.value120) as f32 / 120.,
225+
(-vertical.value120) as f32 / 120.,
226+
)
227+
} else if has_discrete_scroll {
221228
// NOTE: Wayland sign convention is the inverse of winit.
222229
MouseScrollDelta::LineDelta(
223230
(-horizontal.discrete) as f32,

winit-wayland/src/window/state.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl WindowState {
302302
subcompositor.clone(),
303303
self.queue_handle.clone(),
304304
#[cfg(feature = "sctk-adwaita")]
305-
into_sctk_adwaita_config(self.theme),
305+
create_sctk_adwaita_config(self.theme),
306306
) {
307307
Ok(mut frame) => {
308308
frame.set_title(&self.title);
@@ -816,7 +816,7 @@ impl WindowState {
816816
self.theme = theme;
817817
#[cfg(feature = "sctk-adwaita")]
818818
if let Some(frame) = self.frame.as_mut() {
819-
frame.set_config(into_sctk_adwaita_config(theme))
819+
frame.set_config(create_sctk_adwaita_config(theme))
820820
}
821821
}
822822

@@ -1228,12 +1228,14 @@ fn resize_direction_to_xdg(direction: ResizeDirection) -> XdgResizeEdge {
12281228
}
12291229
}
12301230

1231-
// NOTE: Rust doesn't allow `From<Option<Theme>>`.
12321231
#[cfg(feature = "sctk-adwaita")]
1233-
fn into_sctk_adwaita_config(theme: Option<Theme>) -> sctk_adwaita::FrameConfig {
1234-
match theme {
1232+
fn create_sctk_adwaita_config(theme: Option<Theme>) -> sctk_adwaita::FrameConfig {
1233+
let config = match theme {
12351234
Some(Theme::Light) => sctk_adwaita::FrameConfig::light(),
12361235
Some(Theme::Dark) => sctk_adwaita::FrameConfig::dark(),
12371236
None => sctk_adwaita::FrameConfig::auto(),
1238-
}
1237+
};
1238+
#[cfg(feature = "csd-adwaita-notitlebar")]
1239+
let config = config.hide_titlebar(true);
1240+
config
12391241
}

winit-x11/src/window.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,7 @@ impl UnownedWindow {
20972097
},
20982098
CoreImeRequest::Update(state) => {
20992099
if let Some(capabilities) = shared_state.ime_capabilities {
2100+
drop(shared_state);
21002101
(capabilities, state)
21012102
} else {
21022103
// The IME was not yet enabled, so discard the update.

winit/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ wayland = ["winit-wayland"]
5757
wayland-csd-adwaita = ["winit-wayland/csd-adwaita"]
5858
wayland-csd-adwaita-crossfont = ["winit-wayland/csd-adwaita-crossfont"]
5959
wayland-csd-adwaita-notitle = ["winit-wayland/csd-adwaita-notitle"]
60+
wayland-csd-adwaita-notitlebar = ["winit-wayland/csd-adwaita-notitlebar"]
6061
wayland-dlopen = ["winit-wayland/dlopen"]
6162
x11 = ["dep:winit-x11"]
6263

winit/src/changelog/unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,4 @@ changelog entry.
268268
- On Windows, `Window::set_theme` will change the title bar color immediately now.
269269
- On Windows 11, prevent incorrect shifting when dragging window onto a monitor with different DPI.
270270
- On Web, device events are emitted regardless of cursor type.
271+
- On Wayland, `axis_value120` scroll events now generate `MouseScrollDelta::LineDelta`

0 commit comments

Comments
 (0)