forge
Explore
Log in

Don't you dare go Hollow

Add support for wl_compositor@v6

Browse files at this commit

0a2052945e62c31585a3c7ec4c0efa84ebc5d312Kirill ChibisovParent: 49a8f15
Cargo.lockmodified+16 -16
@@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
10 10
11 [[package]]11 [[package]]
12 name = "ahash"12 name = "ahash"
13-version = "0.8.5"13+version = "0.8.6"
14 source = "registry+https://github.com/rust-lang/crates.io-index"14 source = "registry+https://github.com/rust-lang/crates.io-index"
15-checksum = "cd7d5a2cecb58716e47d67d5703a249964b14c7be1ec3cad3affc295b2d1c35d"15+checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
16 dependencies = [16 dependencies = [
17 "cfg-if",17 "cfg-if",
18 "getrandom",18 "getrandom",
@@ -535,9 +535,9 @@ dependencies = [
535 535
536 [[package]]536 [[package]]
537 name = "clap"537 name = "clap"
538-version = "4.4.6"538+version = "4.4.7"
539 source = "registry+https://github.com/rust-lang/crates.io-index"539 source = "registry+https://github.com/rust-lang/crates.io-index"
540-checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956"540+checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b"
541 dependencies = [541 dependencies = [
542 "clap_builder",542 "clap_builder",
543 "clap_derive",543 "clap_derive",
@@ -545,9 +545,9 @@ dependencies = [
545 545
546 [[package]]546 [[package]]
547 name = "clap_builder"547 name = "clap_builder"
548-version = "4.4.6"548+version = "4.4.7"
549 source = "registry+https://github.com/rust-lang/crates.io-index"549 source = "registry+https://github.com/rust-lang/crates.io-index"
550-checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45"550+checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663"
551 dependencies = [551 dependencies = [
552 "anstream",552 "anstream",
553 "anstyle",553 "anstyle",
@@ -557,9 +557,9 @@ dependencies = [
557 557
558 [[package]]558 [[package]]
559 name = "clap_derive"559 name = "clap_derive"
560-version = "4.4.2"560+version = "4.4.7"
561 source = "registry+https://github.com/rust-lang/crates.io-index"561 source = "registry+https://github.com/rust-lang/crates.io-index"
562-checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873"562+checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
563 dependencies = [563 dependencies = [
564 "heck",564 "heck",
565 "proc-macro2",565 "proc-macro2",
@@ -569,9 +569,9 @@ dependencies = [
569 569
570 [[package]]570 [[package]]
571 name = "clap_lex"571 name = "clap_lex"
572-version = "0.5.1"572+version = "0.6.0"
573 source = "registry+https://github.com/rust-lang/crates.io-index"573 source = "registry+https://github.com/rust-lang/crates.io-index"
574-checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"574+checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
575 575
576 [[package]]576 [[package]]
577 name = "colorchoice"577 name = "colorchoice"
@@ -2223,7 +2223,7 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
2223 [[package]]2223 [[package]]
2224 name = "smithay"2224 name = "smithay"
2225 version = "0.3.0"2225 version = "0.3.0"
2226-source = "git+https://github.com/Smithay/smithay.git#76c014a569fada77eed361feeb472ab7f9498232"2226+source = "git+https://github.com/Smithay/smithay.git#a82f899bfeeaaf420b9cea390cdab39b12ce702c"
2227 dependencies = [2227 dependencies = [
2228 "appendlist",2228 "appendlist",
2229 "bitflags 2.4.1",2229 "bitflags 2.4.1",
@@ -2295,7 +2295,7 @@ dependencies = [
2295 [[package]]2295 [[package]]
2296 name = "smithay-drm-extras"2296 name = "smithay-drm-extras"
2297 version = "0.1.0"2297 version = "0.1.0"
2298-source = "git+https://github.com/Smithay/smithay.git#76c014a569fada77eed361feeb472ab7f9498232"2298+source = "git+https://github.com/Smithay/smithay.git#a82f899bfeeaaf420b9cea390cdab39b12ce702c"
2299 dependencies = [2299 dependencies = [
2300 "drm",2300 "drm",
2301 "edid-rs",2301 "edid-rs",
@@ -3293,18 +3293,18 @@ dependencies = [
3293 3293
3294 [[package]]3294 [[package]]
3295 name = "zerocopy"3295 name = "zerocopy"
3296-version = "0.7.11"3296+version = "0.7.15"
3297 source = "registry+https://github.com/rust-lang/crates.io-index"3297 source = "registry+https://github.com/rust-lang/crates.io-index"
3298-checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f"3298+checksum = "81ba595b9f2772fbee2312de30eeb80ec773b4cb2f1e8098db024afadda6c06f"
3299 dependencies = [3299 dependencies = [
3300 "zerocopy-derive",3300 "zerocopy-derive",
3301 ]3301 ]
3302 3302
3303 [[package]]3303 [[package]]
3304 name = "zerocopy-derive"3304 name = "zerocopy-derive"
3305-version = "0.7.11"3305+version = "0.7.15"
3306 source = "registry+https://github.com/rust-lang/crates.io-index"3306 source = "registry+https://github.com/rust-lang/crates.io-index"
3307-checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9"3307+checksum = "772666c41fb6dceaf520b564b962d738a8e1a83b41bd48945f50837aed78bb1d"
3308 dependencies = [3308 dependencies = [
3309 "proc-macro2",3309 "proc-macro2",
3310 "quote",3310 "quote",
src/backend/tty.rsmodified+2 -3
@@ -529,9 +529,6 @@ impl Tty {
529 .map(|info| (info.manufacturer, info.model))529 .map(|info| (info.manufacturer, info.model))
530 .unwrap_or_else(|| ("Unknown".into(), "Unknown".into()));530 .unwrap_or_else(|| ("Unknown".into(), "Unknown".into()));
531 531
532- let scale = config.scale.clamp(0.1, 10.);
533- let scale = scale.max(1.).round() as i32;
534-
535 let output = Output::new(532 let output = Output::new(
536 output_name.clone(),533 output_name.clone(),
537 PhysicalProperties {534 PhysicalProperties {
@@ -541,7 +538,9 @@ impl Tty {
541 make,538 make,
542 },539 },
543 );540 );
541+
544 let wl_mode = Mode::from(*mode);542 let wl_mode = Mode::from(*mode);
543+ let scale = config.scale.clamp(1., 10.).ceil() as i32;
545 output.change_current_state(Some(wl_mode), None, Some(Scale::Integer(scale)), None);544 output.change_current_state(Some(wl_mode), None, Some(Scale::Integer(scale)), None);
546 output.set_preferred(wl_mode);545 output.set_preferred(wl_mode);
547 546
src/backend/winit.rsmodified+6 -7
@@ -45,13 +45,6 @@ impl Winit {
45 .find(|o| o.name == "winit")45 .find(|o| o.name == "winit")
46 .cloned()46 .cloned()
47 .unwrap_or_default();47 .unwrap_or_default();
48- let scale = output_config.scale.clamp(0.1, 10.);
49- let scale = scale.max(1.).round() as i32;
50-
51- let mode = Mode {
52- size: backend.window_size(),
53- refresh: 60_000,
54- };
55 48
56 let output = Output::new(49 let output = Output::new(
57 "winit".to_string(),50 "winit".to_string(),
@@ -62,6 +55,12 @@ impl Winit {
62 model: "Winit".into(),55 model: "Winit".into(),
63 },56 },
64 );57 );
58+
59+ let mode = Mode {
60+ size: backend.window_size(),
61+ refresh: 60_000,
62+ };
63+ let scale = output_config.scale.clamp(1., 10.).ceil() as i32;
65 output.change_current_state(64 output.change_current_state(
66 Some(mode),65 Some(mode),
67 Some(Transform::Flipped180),66 Some(Transform::Flipped180),
src/handlers/compositor.rsmodified+13 -2
@@ -9,8 +9,9 @@ use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
9 use smithay::reexports::wayland_server::{Client, Resource};9 use smithay::reexports::wayland_server::{Client, Resource};
10 use smithay::wayland::buffer::BufferHandler;10 use smithay::wayland::buffer::BufferHandler;
11 use smithay::wayland::compositor::{11 use smithay::wayland::compositor::{
12- add_blocker, add_pre_commit_hook, get_parent, is_sync_subsurface, with_states,12+ add_blocker, add_pre_commit_hook, get_parent, is_sync_subsurface, send_surface_state,
13- BufferAssignment, CompositorClientState, CompositorHandler, CompositorState, SurfaceAttributes,13+ with_states, BufferAssignment, CompositorClientState, CompositorHandler, CompositorState,
14+ SurfaceAttributes,
14 };15 };
15 use smithay::wayland::dmabuf::get_dmabuf;16 use smithay::wayland::dmabuf::get_dmabuf;
16 use smithay::wayland::shm::{ShmHandler, ShmState};17 use smithay::wayland::shm::{ShmHandler, ShmState};
@@ -28,6 +29,16 @@ impl CompositorHandler for State {
28 &client.get_data::<ClientState>().unwrap().compositor_state29 &client.get_data::<ClientState>().unwrap().compositor_state
29 }30 }
30 31
32+ fn new_subsurface(&mut self, surface: &WlSurface, parent: &WlSurface) {
33+ if let Some((_, output)) = self.niri.layout.find_window_and_output(parent) {
34+ let scale = output.current_scale().integer_scale();
35+ let transform = output.current_transform();
36+ with_states(surface, |data| {
37+ send_surface_state(surface, data, scale, transform);
38+ });
39+ }
40+ }
41+
31 fn new_surface(&mut self, surface: &WlSurface) {42 fn new_surface(&mut self, surface: &WlSurface) {
32 add_pre_commit_hook::<Self, _>(surface, move |state, _dh, surface| {43 add_pre_commit_hook::<Self, _>(surface, move |state, _dh, surface| {
33 let maybe_dmabuf = with_states(surface, |surface_data| {44 let maybe_dmabuf = with_states(surface, |surface_data| {
src/handlers/layer_shell.rsmodified+7 -1
@@ -3,7 +3,7 @@ use smithay::desktop::{layer_map_for_output, LayerSurface, WindowSurfaceType};
3 use smithay::output::Output;3 use smithay::output::Output;
4 use smithay::reexports::wayland_server::protocol::wl_output::WlOutput;4 use smithay::reexports::wayland_server::protocol::wl_output::WlOutput;
5 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;5 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
6-use smithay::wayland::compositor::with_states;6+use smithay::wayland::compositor::{send_surface_state, with_states};
7 use smithay::wayland::shell::wlr_layer::{7 use smithay::wayland::shell::wlr_layer::{
8 Layer, LayerSurface as WlrLayerSurface, LayerSurfaceData, WlrLayerShellHandler,8 Layer, LayerSurface as WlrLayerSurface, LayerSurfaceData, WlrLayerShellHandler,
9 WlrLayerShellState,9 WlrLayerShellState,
@@ -92,6 +92,12 @@ impl State {
92 .layer_for_surface(surface, WindowSurfaceType::TOPLEVEL)92 .layer_for_surface(surface, WindowSurfaceType::TOPLEVEL)
93 .unwrap();93 .unwrap();
94 94
95+ let scale = output.current_scale().integer_scale();
96+ let transform = output.current_transform();
97+ with_states(surface, |data| {
98+ send_surface_state(surface, data, scale, transform);
99+ });
100+
95 layer.layer_surface().send_configure();101 layer.layer_surface().send_configure();
96 }102 }
97 drop(map);103 drop(map);
src/handlers/mod.rsmodified+18 -0
@@ -19,6 +19,7 @@ use smithay::reexports::wayland_server::protocol::wl_output::WlOutput;
19 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;19 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
20 use smithay::reexports::wayland_server::Resource;20 use smithay::reexports::wayland_server::Resource;
21 use smithay::utils::{Logical, Rectangle, Size};21 use smithay::utils::{Logical, Rectangle, Size};
22+use smithay::wayland::compositor::{send_surface_state, with_states};
22 use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError};23 use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError};
23 use smithay::wayland::input_method::{InputMethodHandler, PopupSurface};24 use smithay::wayland::input_method::{InputMethodHandler, PopupSurface};
24 use smithay::wayland::selection::data_device::{25 use smithay::wayland::selection::data_device::{
@@ -71,6 +72,17 @@ delegate_text_input_manager!(State);
71 72
72 impl InputMethodHandler for State {73 impl InputMethodHandler for State {
73 fn new_popup(&mut self, surface: PopupSurface) {74 fn new_popup(&mut self, surface: PopupSurface) {
75+ if let Some((_, output)) = surface
76+ .get_parent()
77+ .and_then(|parent| self.niri.layout.find_window_and_output(&parent.surface))
78+ {
79+ let scale = output.current_scale().integer_scale();
80+ let transform = output.current_transform();
81+ let wl_surface = surface.wl_surface();
82+ with_states(wl_surface, |data| {
83+ send_surface_state(wl_surface, data, scale, transform);
84+ });
85+ }
74 if let Err(err) = self.niri.popups.track_popup(PopupKind::from(surface)) {86 if let Err(err) = self.niri.popups.track_popup(PopupKind::from(surface)) {
75 warn!("error tracking ime popup {err:?}");87 warn!("error tracking ime popup {err:?}");
76 }88 }
@@ -216,5 +228,11 @@ pub fn configure_lock_surface(surface: &LockSurface, output: &Output) {
216 let size = output_size(output);228 let size = output_size(output);
217 states.size = Some(Size::from((size.w as u32, size.h as u32)));229 states.size = Some(Size::from((size.w as u32, size.h as u32)));
218 });230 });
231+ let scale = output.current_scale().integer_scale();
232+ let transform = output.current_transform();
233+ let wl_surface = surface.wl_surface();
234+ with_states(wl_surface, |data| {
235+ send_surface_state(wl_surface, data, scale, transform);
236+ });
219 surface.send_configure();237 surface.send_configure();
220 }238 }
src/handlers/xdg_shell.rsmodified+13 -3
@@ -6,7 +6,7 @@ use smithay::reexports::wayland_server::protocol::wl_output;
6 use smithay::reexports::wayland_server::protocol::wl_seat::WlSeat;6 use smithay::reexports::wayland_server::protocol::wl_seat::WlSeat;
7 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;7 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
8 use smithay::utils::Serial;8 use smithay::utils::Serial;
9-use smithay::wayland::compositor::with_states;9+use smithay::wayland::compositor::{send_surface_state, with_states};
10 use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState};10 use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState};
11 use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler;11 use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler;
12 use smithay::wayland::shell::xdg::{12 use smithay::wayland::shell::xdg::{
@@ -264,8 +264,18 @@ impl State {
264 .initial_configure_sent264 .initial_configure_sent
265 });265 });
266 if !initial_configure_sent {266 if !initial_configure_sent {
267- // NOTE: This should never fail as the initial configure is always267+ if let Some(output) = popup.get_parent_surface().and_then(|parent| {
268- // allowed.268+ self.niri
269+ .layout
270+ .find_window_and_output(&parent)
271+ .map(|(_, output)| output)
272+ }) {
273+ let scale = output.current_scale().integer_scale();
274+ let transform = output.current_transform();
275+ with_states(surface, |data| {
276+ send_surface_state(surface, data, scale, transform);
277+ });
278+ }
269 popup.send_configure().expect("initial configure failed");279 popup.send_configure().expect("initial configure failed");
270 }280 }
271 }281 }
src/layout.rsmodified+21 -1
@@ -52,7 +52,7 @@ use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
52 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;52 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
53 use smithay::render_elements;53 use smithay::render_elements;
54 use smithay::utils::{Logical, Point, Rectangle, Scale, Size};54 use smithay::utils::{Logical, Point, Rectangle, Scale, Size};
55-use smithay::wayland::compositor::with_states;55+use smithay::wayland::compositor::{send_surface_state, with_states, SurfaceData};
56 use smithay::wayland::shell::xdg::SurfaceCachedState;56 use smithay::wayland::shell::xdg::SurfaceCachedState;
57 57
58 use crate::animation::Animation;58 use crate::animation::Animation;
@@ -77,6 +77,7 @@ pub trait LayoutElement: SpaceElement + PartialEq + Clone {
77 fn max_size(&self) -> Size<i32, Logical>;77 fn max_size(&self) -> Size<i32, Logical>;
78 fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool;78 fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool;
79 fn has_ssd(&self) -> bool;79 fn has_ssd(&self) -> bool;
80+ fn with_surfaces<F: FnMut(&WlSurface, &SurfaceData)>(&self, processor: F);
80 }81 }
81 82
82 #[derive(Debug)]83 #[derive(Debug)]
@@ -333,6 +334,10 @@ impl LayoutElement for Window {
333 self.toplevel().wl_surface() == wl_surface334 self.toplevel().wl_surface() == wl_surface
334 }335 }
335 336
337+ fn with_surfaces<F: FnMut(&WlSurface, &SurfaceData)>(&self, processor: F) {
338+ self.with_surfaces(processor);
339+ }
340+
336 fn has_ssd(&self) -> bool {341 fn has_ssd(&self) -> bool {
337 self.toplevel().current_state().decoration_mode342 self.toplevel().current_state().decoration_mode
338 == Some(zxdg_toplevel_decoration_v1::Mode::ServerSide)343 == Some(zxdg_toplevel_decoration_v1::Mode::ServerSide)
@@ -1903,6 +1908,7 @@ impl<W: LayoutElement> Workspace<W> {
1903 fn enter_output_for_window(&self, window: &W) {1908 fn enter_output_for_window(&self, window: &W) {
1904 if let Some(output) = &self.output {1909 if let Some(output) = &self.output {
1905 // FIXME: proper overlap.1910 // FIXME: proper overlap.
1911+ self.send_surface_state_for_window_tree(window, output);
1906 window.output_enter(1912 window.output_enter(
1907 output,1913 output,
1908 Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX)),1914 Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX)),
@@ -1937,12 +1943,24 @@ impl<W: LayoutElement> Workspace<W> {
1937 1943
1938 let bounds = self.toplevel_bounds();1944 let bounds = self.toplevel_bounds();
1939 1945
1946+ if let Some(output) = self.output.as_ref() {
1947+ self.send_surface_state_for_window_tree(window, output);
1948+ }
1949+
1940 window.toplevel().with_pending_state(|state| {1950 window.toplevel().with_pending_state(|state| {
1941 state.size = Some(size);1951 state.size = Some(size);
1942 state.bounds = Some(bounds);1952 state.bounds = Some(bounds);
1943 });1953 });
1944 }1954 }
1945 1955
1956+ fn send_surface_state_for_window_tree(&self, window: &impl LayoutElement, output: &Output) {
1957+ let scale = output.current_scale().integer_scale();
1958+ let transform = output.current_transform();
1959+ window.with_surfaces(|surface, data| {
1960+ send_surface_state(surface, data, scale, transform);
1961+ });
1962+ }
1963+
1946 fn compute_new_view_offset_for_column(&self, current_x: i32, idx: usize) -> i32 {1964 fn compute_new_view_offset_for_column(&self, current_x: i32, idx: usize) -> i32 {
1947 if self.columns[idx].is_fullscreen {1965 if self.columns[idx].is_fullscreen {
1948 return 0;1966 return 0;
@@ -2890,6 +2908,8 @@ mod tests {
2890 false2908 false
2891 }2909 }
2892 2910
2911+ fn with_surfaces<F: FnMut(&WlSurface, &SurfaceData)>(&self, _processor: F) {}
2912+
2893 fn has_ssd(&self) -> bool {2913 fn has_ssd(&self) -> bool {
2894 false2914 false
2895 }2915 }
src/niri.rsmodified+25 -4
@@ -49,8 +49,8 @@ use smithay::utils::{
49 SERIAL_COUNTER,49 SERIAL_COUNTER,
50 };50 };
51 use smithay::wayland::compositor::{51 use smithay::wayland::compositor::{
52- with_states, with_surface_tree_downward, CompositorClientState, CompositorState, SurfaceData,52+ send_surface_state, with_states, with_surface_tree_downward, CompositorClientState,
53- TraversalAction,53+ CompositorState, SurfaceData, TraversalAction,
54 };54 };
55 use smithay::wayland::dmabuf::DmabufFeedback;55 use smithay::wayland::dmabuf::DmabufFeedback;
56 use smithay::wayland::input_method::InputMethodManagerState;56 use smithay::wayland::input_method::InputMethodManagerState;
@@ -511,7 +511,7 @@ impl Niri {
511 511
512 let layout = Layout::new(&config_);512 let layout = Layout::new(&config_);
513 513
514- let compositor_state = CompositorState::new::<State>(&display_handle);514+ let compositor_state = CompositorState::new_v6::<State>(&display_handle);
515 let xdg_shell_state = XdgShellState::new_with_capabilities::<State>(515 let xdg_shell_state = XdgShellState::new_with_capabilities::<State>(
516 &display_handle,516 &display_handle,
517 [WmCapabilities::Fullscreen],517 [WmCapabilities::Fullscreen],
@@ -542,7 +542,7 @@ impl Niri {
542 |_| true,542 |_| true,
543 );543 );
544 let presentation_state =544 let presentation_state =
545- PresentationState::new::<State>(&display_handle, Monotonic::id() as u32);545+ PresentationState::new::<State>(&display_handle, Monotonic::ID as u32);
546 546
547 let text_input_state = TextInputManagerState::new::<State>(&display_handle);547 let text_input_state = TextInputManagerState::new::<State>(&display_handle);
548 let input_method_state =548 let input_method_state =
@@ -1163,6 +1163,7 @@ impl Niri {
1163 1163
1164 let pointer_pos = self.seat.get_pointer().unwrap().current_location();1164 let pointer_pos = self.seat.get_pointer().unwrap().current_location();
1165 1165
1166+ let mut dnd_scale = 1;
1166 for output in self.global_space.outputs() {1167 for output in self.global_space.outputs() {
1167 let geo = self.global_space.output_geometry(output).unwrap();1168 let geo = self.global_space.output_geometry(output).unwrap();
1168 1169
@@ -1180,10 +1181,15 @@ impl Niri {
1180 1181
1181 if let Some(mut overlap) = geo.intersection(bbox) {1182 if let Some(mut overlap) = geo.intersection(bbox) {
1182 overlap.loc -= surface_pos;1183 overlap.loc -= surface_pos;
1184+ dnd_scale = dnd_scale.max(output.current_scale().integer_scale());
1183 output_update(output, Some(overlap), surface);1185 output_update(output, Some(overlap), surface);
1184 } else {1186 } else {
1185 output_update(output, None, surface);1187 output_update(output, None, surface);
1186 }1188 }
1189+
1190+ with_states(surface, |data| {
1191+ send_surface_state(surface, data, dnd_scale, Transform::Normal);
1192+ });
1187 }1193 }
1188 }1194 }
1189 CursorImageStatus::Surface(surface) => {1195 CursorImageStatus::Surface(surface) => {
@@ -1206,12 +1212,17 @@ impl Niri {
1206 .as_ref()1212 .as_ref()
1207 .map(|surface| (surface, bbox_from_surface_tree(surface, surface_pos)));1213 .map(|surface| (surface, bbox_from_surface_tree(surface, surface_pos)));
1208 1214
1215+ // FIXME we basically need to pick the largest scale factor across the overlapping
1216+ // outputs, this is how it's usually done in clients as well.
1217+ let mut cursor_scale = 1;
1218+ let mut dnd_scale = 1;
1209 for output in self.global_space.outputs() {1219 for output in self.global_space.outputs() {
1210 let geo = self.global_space.output_geometry(output).unwrap();1220 let geo = self.global_space.output_geometry(output).unwrap();
1211 1221
1212 // Compute pointer surface overlap.1222 // Compute pointer surface overlap.
1213 if let Some(mut overlap) = geo.intersection(bbox) {1223 if let Some(mut overlap) = geo.intersection(bbox) {
1214 overlap.loc -= surface_pos;1224 overlap.loc -= surface_pos;
1225+ cursor_scale = cursor_scale.max(output.current_scale().integer_scale());
1215 output_update(output, Some(overlap), surface);1226 output_update(output, Some(overlap), surface);
1216 } else {1227 } else {
1217 output_update(output, None, surface);1228 output_update(output, None, surface);
@@ -1221,12 +1232,22 @@ impl Niri {
1221 if let Some((surface, bbox)) = dnd {1232 if let Some((surface, bbox)) = dnd {
1222 if let Some(mut overlap) = geo.intersection(bbox) {1233 if let Some(mut overlap) = geo.intersection(bbox) {
1223 overlap.loc -= surface_pos;1234 overlap.loc -= surface_pos;
1235+ dnd_scale = dnd_scale.max(output.current_scale().integer_scale());
1224 output_update(output, Some(overlap), surface);1236 output_update(output, Some(overlap), surface);
1225 } else {1237 } else {
1226 output_update(output, None, surface);1238 output_update(output, None, surface);
1227 }1239 }
1228 }1240 }
1229 }1241 }
1242+
1243+ with_states(surface, |data| {
1244+ send_surface_state(surface, data, cursor_scale, Transform::Normal);
1245+ });
1246+ if let Some((surface, _)) = dnd {
1247+ with_states(surface, |data| {
1248+ send_surface_state(surface, data, dnd_scale, Transform::Normal);
1249+ });
1250+ }
1230 }1251 }
1231 }1252 }
1232 }1253 }