forge
Explore
Log in

Don't you dare go Hollow

Change cursor to crosshairs when taking a screenshot

Browse files at this commit

d854c2d699b15c68c4715dc6be803065c01f2fe6Ivan MolodetskikhParent: 25e701d
src/handlers/mod.rsmodified+7 -2
@@ -11,7 +11,7 @@ use std::thread;
11 use smithay::backend::allocator::dmabuf::Dmabuf;11 use smithay::backend::allocator::dmabuf::Dmabuf;
12 use smithay::backend::renderer::ImportDma;12 use smithay::backend::renderer::ImportDma;
13 use smithay::desktop::{PopupKind, PopupManager};13 use smithay::desktop::{PopupKind, PopupManager};
14-use smithay::input::pointer::CursorImageStatus;14+use smithay::input::pointer::{CursorIcon, CursorImageStatus};
15 use smithay::input::{Seat, SeatHandler, SeatState};15 use smithay::input::{Seat, SeatHandler, SeatState};
16 use smithay::output::Output;16 use smithay::output::Output;
17 use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource;17 use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource;
@@ -52,7 +52,12 @@ impl SeatHandler for State {
52 &mut self.niri.seat_state52 &mut self.niri.seat_state
53 }53 }
54 54
55- fn cursor_image(&mut self, _seat: &Seat<Self>, image: CursorImageStatus) {55+ fn cursor_image(&mut self, _seat: &Seat<Self>, mut image: CursorImageStatus) {
56+ // FIXME: this hack should be removable once the screenshot UI is tracked with a
57+ // PointerFocus properly.
58+ if self.niri.screenshot_ui.is_open() {
59+ image = CursorImageStatus::Named(CursorIcon::Crosshair);
60+ }
56 self.niri.cursor_manager.set_cursor_image(image);61 self.niri.cursor_manager.set_cursor_image(image);
57 // FIXME: more granular62 // FIXME: more granular
58 self.niri.queue_redraw_all();63 self.niri.queue_redraw_all();
src/input.rsmodified+9 -3
@@ -10,9 +10,9 @@ use smithay::backend::input::{
10 use smithay::backend::libinput::LibinputInputBackend;10 use smithay::backend::libinput::LibinputInputBackend;
11 use smithay::input::keyboard::{keysyms, FilterResult, Keysym, ModifiersState};11 use smithay::input::keyboard::{keysyms, FilterResult, Keysym, ModifiersState};
12 use smithay::input::pointer::{12 use smithay::input::pointer::{
13- AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,13+ AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent,
14- GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, GestureSwipeEndEvent,14+ GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
15- GestureSwipeUpdateEvent, MotionEvent, RelativeMotionEvent,15+ GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent, RelativeMotionEvent,
16 };16 };
17 use smithay::utils::SERIAL_COUNTER;17 use smithay::utils::SERIAL_COUNTER;
18 use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};18 use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};
@@ -146,10 +146,16 @@ impl State {
146 }146 }
147 147
148 self.niri.screenshot_ui.close();148 self.niri.screenshot_ui.close();
149+ self.niri
150+ .cursor_manager
151+ .set_cursor_image(CursorImageStatus::default_named());
149 self.niri.queue_redraw_all();152 self.niri.queue_redraw_all();
150 }153 }
151 Action::CancelScreenshot => {154 Action::CancelScreenshot => {
152 self.niri.screenshot_ui.close();155 self.niri.screenshot_ui.close();
156+ self.niri
157+ .cursor_manager
158+ .set_cursor_image(CursorImageStatus::default_named());
153 self.niri.queue_redraw_all();159 self.niri.queue_redraw_all();
154 }160 }
155 Action::Screenshot => {161 Action::Screenshot => {
src/niri.rsmodified+9 -1
@@ -30,7 +30,7 @@ use smithay::desktop::utils::{
30 };30 };
31 use smithay::desktop::{layer_map_for_output, PopupManager, Space, Window, WindowSurfaceType};31 use smithay::desktop::{layer_map_for_output, PopupManager, Space, Window, WindowSurfaceType};
32 use smithay::input::keyboard::XkbConfig;32 use smithay::input::keyboard::XkbConfig;
33-use smithay::input::pointer::{CursorImageAttributes, CursorImageStatus, MotionEvent};33+use smithay::input::pointer::{CursorIcon, CursorImageAttributes, CursorImageStatus, MotionEvent};
34 use smithay::input::{Seat, SeatState};34 use smithay::input::{Seat, SeatState};
35 use smithay::output::Output;35 use smithay::output::Output;
36 use smithay::reexports::calloop::generic::Generic;36 use smithay::reexports::calloop::generic::Generic;
@@ -844,6 +844,8 @@ impl Niri {
844 }844 }
845 845
846 if self.screenshot_ui.close() {846 if self.screenshot_ui.close() {
847+ self.cursor_manager
848+ .set_cursor_image(CursorImageStatus::default_named());
847 self.queue_redraw_all();849 self.queue_redraw_all();
848 }850 }
849 }851 }
@@ -873,6 +875,8 @@ impl Niri {
873 let size = output_transform.transform_size(output_mode.size);875 let size = output_transform.transform_size(output_mode.size);
874 if old_size != size {876 if old_size != size {
875 self.screenshot_ui.close();877 self.screenshot_ui.close();
878+ self.cursor_manager
879+ .set_cursor_image(CursorImageStatus::default_named());
876 self.queue_redraw_all();880 self.queue_redraw_all();
877 return;881 return;
878 }882 }
@@ -1958,6 +1962,8 @@ impl Niri {
1958 1962
1959 self.screenshot_ui1963 self.screenshot_ui
1960 .open(renderer, screenshots, default_output);1964 .open(renderer, screenshots, default_output);
1965+ self.cursor_manager
1966+ .set_cursor_image(CursorImageStatus::Named(CursorIcon::Crosshair));
1961 self.queue_redraw_all();1967 self.queue_redraw_all();
1962 }1968 }
1963 1969
@@ -2116,6 +2122,8 @@ impl Niri {
2116 info!("locking session");2122 info!("locking session");
2117 2123
2118 self.screenshot_ui.close();2124 self.screenshot_ui.close();
2125+ self.cursor_manager
2126+ .set_cursor_image(CursorImageStatus::default_named());
2119 2127
2120 self.lock_state = LockState::Locking(confirmation);2128 self.lock_state = LockState::Locking(confirmation);
2121 self.queue_redraw_all();2129 self.queue_redraw_all();