@@ -19,6 +19,7 @@ wf::cursor_t::cursor_t(wf::seat_t *seat)
1919 wlr_cursor_map_to_output (cursor, NULL );
2020 wlr_cursor_warp (cursor, NULL , cursor->x , cursor->y );
2121 init_xcursor ();
22+ init_cursor_shape_manager ();
2223
2324 config_reloaded = [=] (auto )
2425 {
@@ -128,14 +129,46 @@ void wf::cursor_t::init_xcursor()
128129 set_cursor (" default" );
129130}
130131
131- void wf::cursor_t::set_cursor (std::string name )
132+ bool wf::cursor_t::can_client_set_cursor ( )
132133{
134+ if (this ->touchscreen_mode_active )
135+ {
136+ return false ;
137+ }
138+
133139 if (this ->hide_ref_counter )
134140 {
135- return ;
141+ return false ;
136142 }
137143
138- if (this ->touchscreen_mode_active )
144+ return true ;
145+ }
146+
147+ void wf::cursor_t::init_cursor_shape_manager ()
148+ {
149+ cursor_shape_manager = wlr_cursor_shape_manager_v1_create (seat->seat ->display , 1 );
150+ request_set_cursor_shape.set_callback ([&] (void *data)
151+ {
152+ auto event = (wlr_cursor_shape_manager_v1_request_set_shape_event*)data;
153+ const char *shape_name = wlr_cursor_shape_v1_name (event->shape );
154+ struct wlr_seat_client *focused_client = seat->seat ->pointer_state .focused_client ;
155+
156+ if (focused_client != event->seat_client )
157+ {
158+ return ;
159+ }
160+
161+ if (can_client_set_cursor ())
162+ {
163+ wlr_cursor_set_xcursor (cursor, xcursor, shape_name);
164+ }
165+ });
166+ request_set_cursor_shape.connect (&cursor_shape_manager->events .request_set_shape );
167+ }
168+
169+ void wf::cursor_t::set_cursor (std::string name)
170+ {
171+ if (!can_client_set_cursor ())
139172 {
140173 return ;
141174 }
@@ -189,12 +222,7 @@ wf::pointf_t wf::cursor_t::get_cursor_position()
189222void wf::cursor_t::set_cursor (
190223 wlr_seat_pointer_request_set_cursor_event *ev, bool validate_request)
191224{
192- if (this ->hide_ref_counter )
193- {
194- return ;
195- }
196-
197- if (this ->touchscreen_mode_active )
225+ if (!can_client_set_cursor ())
198226 {
199227 return ;
200228 }
0 commit comments