mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	rootston: damage tracking for drag icons
This commit is contained in:
		
							parent
							
								
									415a2b7c56
								
							
						
					
					
						commit
						4d282c8590
					
				
					 6 changed files with 57 additions and 11 deletions
				
			
		| 
						 | 
					@ -17,12 +17,15 @@ struct roots_seat {
 | 
				
			||||||
	struct wl_list views; // roots_seat_view::link
 | 
						struct wl_list views; // roots_seat_view::link
 | 
				
			||||||
	bool has_focus;
 | 
						bool has_focus;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct wl_list drag_icons; // roots_drag_icon::link
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_list keyboards;
 | 
						struct wl_list keyboards;
 | 
				
			||||||
	struct wl_list pointers;
 | 
						struct wl_list pointers;
 | 
				
			||||||
	struct wl_list touch;
 | 
						struct wl_list touch;
 | 
				
			||||||
	struct wl_list tablet_tools;
 | 
						struct wl_list tablet_tools;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_listener seat_destroy;
 | 
						struct wl_listener new_drag_icon;
 | 
				
			||||||
 | 
						struct wl_listener destroy;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct roots_seat_view {
 | 
					struct roots_seat_view {
 | 
				
			||||||
| 
						 | 
					@ -33,6 +36,16 @@ struct roots_seat_view {
 | 
				
			||||||
	struct wl_listener view_destroy;
 | 
						struct wl_listener view_destroy;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct roots_drag_icon {
 | 
				
			||||||
 | 
						struct roots_seat *seat;
 | 
				
			||||||
 | 
						struct wlr_drag_icon *wlr_drag_icon;
 | 
				
			||||||
 | 
						struct wl_list link;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct wl_listener surface_commit;
 | 
				
			||||||
 | 
						struct wl_listener map;
 | 
				
			||||||
 | 
						struct wl_listener destroy;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct roots_pointer {
 | 
					struct roots_pointer {
 | 
				
			||||||
	struct roots_seat *seat;
 | 
						struct roots_seat *seat;
 | 
				
			||||||
	struct wlr_input_device *device;
 | 
						struct wlr_input_device *device;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,10 +71,10 @@ struct wlr_drag_icon {
 | 
				
			||||||
	bool is_pointer;
 | 
						bool is_pointer;
 | 
				
			||||||
	int32_t touch_id;
 | 
						int32_t touch_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int32_t sx;
 | 
						int32_t sx, sy;
 | 
				
			||||||
	int32_t sy;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct {
 | 
						struct {
 | 
				
			||||||
 | 
							struct wl_signal map; // emitted when mapped or unmapped
 | 
				
			||||||
		struct wl_signal destroy;
 | 
							struct wl_signal destroy;
 | 
				
			||||||
	} events;
 | 
						} events;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -209,6 +209,8 @@ struct wlr_seat {
 | 
				
			||||||
		struct wl_signal selection;
 | 
							struct wl_signal selection;
 | 
				
			||||||
		struct wl_signal primary_selection;
 | 
							struct wl_signal primary_selection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							struct wl_signal new_drag_icon;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		struct wl_signal destroy;
 | 
							struct wl_signal destroy;
 | 
				
			||||||
	} events;
 | 
						} events;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -241,16 +241,37 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
 | 
				
			||||||
	seat->cursor->tool_tip.notify = handle_tool_tip;
 | 
						seat->cursor->tool_tip.notify = handle_tool_tip;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_signal_add(&seat->seat->events.request_set_cursor,
 | 
						wl_signal_add(&seat->seat->events.request_set_cursor,
 | 
				
			||||||
			&seat->cursor->request_set_cursor);
 | 
							&seat->cursor->request_set_cursor);
 | 
				
			||||||
	seat->cursor->request_set_cursor.notify = handle_request_set_cursor;
 | 
						seat->cursor->request_set_cursor.notify = handle_request_set_cursor;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void roots_seat_handle_new_drag_icon(struct wl_listener *listener,
 | 
				
			||||||
 | 
							void *data) {
 | 
				
			||||||
 | 
						struct roots_seat *seat = wl_container_of(listener, seat, new_drag_icon);
 | 
				
			||||||
 | 
						struct wlr_drag_icon *wlr_drag_icon = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct roots_drag_icon *icon = calloc(1, sizeof(struct roots_drag_icon));
 | 
				
			||||||
 | 
						if (icon == NULL) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						icon->seat = seat;
 | 
				
			||||||
 | 
						icon->wlr_drag_icon = wlr_drag_icon;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						icon->surface_commit.notify = roots_drag_icon_handle_surface_commit;
 | 
				
			||||||
 | 
						wl_signal_add(&wlr_drag_icon->events.surface_commit, &icon->surface_commit);
 | 
				
			||||||
 | 
						icon->map.notify = roots_drag_icon_handle_map;
 | 
				
			||||||
 | 
						wl_signal_add(&wlr_drag_icon->events.map, &icon->map);
 | 
				
			||||||
 | 
						icon->destroy.notify = roots_drag_icon_handle_destroy;
 | 
				
			||||||
 | 
						wl_signal_add(&wlr_drag_icon->events.destroy, &icon->destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wl_list_insert(&seat->drag_icons, &icon->link);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void seat_view_destroy(struct roots_seat_view *seat_view);
 | 
					static void seat_view_destroy(struct roots_seat_view *seat_view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void roots_seat_handle_seat_destroy(struct wl_listener *listener,
 | 
					static void roots_seat_handle_destroy(struct wl_listener *listener,
 | 
				
			||||||
		void *data) {
 | 
							void *data) {
 | 
				
			||||||
	struct roots_seat *seat =
 | 
						struct roots_seat *seat = wl_container_of(listener, seat, destroy);
 | 
				
			||||||
		wl_container_of(listener, seat, seat_destroy);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO: probably more to be freed here
 | 
						// TODO: probably more to be freed here
 | 
				
			||||||
	wl_list_remove(&seat->seat_destroy.link);
 | 
						wl_list_remove(&seat->seat_destroy.link);
 | 
				
			||||||
| 
						 | 
					@ -262,7 +283,7 @@ static void roots_seat_handle_seat_destroy(struct wl_listener *listener,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void roots_seat_destroy(struct roots_seat *seat) {
 | 
					void roots_seat_destroy(struct roots_seat *seat) {
 | 
				
			||||||
	roots_seat_handle_seat_destroy(&seat->seat_destroy, seat->seat);
 | 
						roots_seat_handle_destroy(&seat->destroy, seat->seat);
 | 
				
			||||||
	wlr_seat_destroy(seat->seat);
 | 
						wlr_seat_destroy(seat->seat);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -277,6 +298,7 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
 | 
				
			||||||
	wl_list_init(&seat->touch);
 | 
						wl_list_init(&seat->touch);
 | 
				
			||||||
	wl_list_init(&seat->tablet_tools);
 | 
						wl_list_init(&seat->tablet_tools);
 | 
				
			||||||
	wl_list_init(&seat->views);
 | 
						wl_list_init(&seat->views);
 | 
				
			||||||
 | 
						wl_list_init(&seat->drag_icons);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	seat->input = input;
 | 
						seat->input = input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -295,8 +317,10 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_insert(&input->seats, &seat->link);
 | 
						wl_list_insert(&input->seats, &seat->link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	seat->seat_destroy.notify = roots_seat_handle_seat_destroy;
 | 
						seat->new_drag_icon.notify = roots_seat_handle_new_drag_icon;
 | 
				
			||||||
	wl_signal_add(&seat->seat->events.destroy, &seat->seat_destroy);
 | 
						wl_signal_add(&seat->seat->events.new_drag_icon, &seat->new_drag_icon);
 | 
				
			||||||
 | 
						seat->destroy.notify = roots_seat_handle_seat_destroy;
 | 
				
			||||||
 | 
						wl_signal_add(&seat->seat->events.destroy, &seat->destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return seat;
 | 
						return seat;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -454,6 +454,7 @@ static void wlr_drag_end(struct wlr_drag *drag) {
 | 
				
			||||||
		if (drag->icon) {
 | 
							if (drag->icon) {
 | 
				
			||||||
			drag->icon->mapped = false;
 | 
								drag->icon->mapped = false;
 | 
				
			||||||
			wl_list_remove(&drag->icon_destroy.link);
 | 
								wl_list_remove(&drag->icon_destroy.link);
 | 
				
			||||||
 | 
								wl_signal_emit(&drag->icon->events.map, drag->icon);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		free(drag);
 | 
							free(drag);
 | 
				
			||||||
| 
						 | 
					@ -673,8 +674,8 @@ static struct wlr_drag_icon *wlr_drag_icon_create(
 | 
				
			||||||
	icon->is_pointer = is_pointer;
 | 
						icon->is_pointer = is_pointer;
 | 
				
			||||||
	icon->touch_id = touch_id;
 | 
						icon->touch_id = touch_id;
 | 
				
			||||||
	icon->mapped = true;
 | 
						icon->mapped = true;
 | 
				
			||||||
	wl_list_insert(&client->seat->drag_icons, &icon->link);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wl_signal_init(&icon->events.map);
 | 
				
			||||||
	wl_signal_init(&icon->events.destroy);
 | 
						wl_signal_init(&icon->events.destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy);
 | 
						wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy);
 | 
				
			||||||
| 
						 | 
					@ -686,6 +687,9 @@ static struct wlr_drag_icon *wlr_drag_icon_create(
 | 
				
			||||||
	wl_signal_add(&client->events.destroy, &icon->seat_client_destroy);
 | 
						wl_signal_add(&client->events.destroy, &icon->seat_client_destroy);
 | 
				
			||||||
	icon->seat_client_destroy.notify = handle_drag_icon_seat_client_destroy;
 | 
						icon->seat_client_destroy.notify = handle_drag_icon_seat_client_destroy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wl_list_insert(&client->seat->drag_icons, &icon->link);
 | 
				
			||||||
 | 
						wl_signal_emit(&client->seat->events.new_drag_icon, icon);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return icon;
 | 
						return icon;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -454,7 +454,10 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
 | 
				
			||||||
	wl_list_init(&wlr_seat->clients);
 | 
						wl_list_init(&wlr_seat->clients);
 | 
				
			||||||
	wl_list_init(&wlr_seat->drag_icons);
 | 
						wl_list_init(&wlr_seat->drag_icons);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wl_signal_init(&wlr_seat->events.new_drag_icon);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_signal_init(&wlr_seat->events.request_set_cursor);
 | 
						wl_signal_init(&wlr_seat->events.request_set_cursor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_signal_init(&wlr_seat->events.selection);
 | 
						wl_signal_init(&wlr_seat->events.selection);
 | 
				
			||||||
	wl_signal_init(&wlr_seat->events.primary_selection);
 | 
						wl_signal_init(&wlr_seat->events.primary_selection);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue