mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	backend/x11: correctly destroy input devices
This commit is contained in:
		
							parent
							
								
									79da4c175e
								
							
						
					
					
						commit
						f8e0a03451
					
				
					 9 changed files with 34 additions and 10 deletions
				
			
		| 
						 | 
					@ -317,12 +317,12 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_input_device_init(&x11->keyboard_dev, WLR_INPUT_DEVICE_KEYBOARD,
 | 
						wlr_input_device_init(&x11->keyboard_dev, WLR_INPUT_DEVICE_KEYBOARD,
 | 
				
			||||||
		&input_device_impl, "X11 keyboard", 0, 0);
 | 
							&input_device_impl, "X11 keyboard", 0, 0);
 | 
				
			||||||
	wlr_keyboard_init(&x11->keyboard, NULL);
 | 
						wlr_keyboard_init(&x11->keyboard, &keyboard_impl);
 | 
				
			||||||
	x11->keyboard_dev.keyboard = &x11->keyboard;
 | 
						x11->keyboard_dev.keyboard = &x11->keyboard;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_input_device_init(&x11->pointer_dev, WLR_INPUT_DEVICE_POINTER,
 | 
						wlr_input_device_init(&x11->pointer_dev, WLR_INPUT_DEVICE_POINTER,
 | 
				
			||||||
		&input_device_impl, "X11 pointer", 0, 0);
 | 
							&input_device_impl, "X11 pointer", 0, 0);
 | 
				
			||||||
	wlr_pointer_init(&x11->pointer, NULL);
 | 
						wlr_pointer_init(&x11->pointer, &pointer_impl);
 | 
				
			||||||
	x11->pointer_dev.pointer = &x11->pointer;
 | 
						x11->pointer_dev.pointer = &x11->pointer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	x11->display_destroy.notify = handle_display_destroy;
 | 
						x11->display_destroy.notify = handle_display_destroy;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -136,7 +136,29 @@ void handle_x11_input_event(struct wlr_x11_backend *x11,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct wlr_input_device_impl input_device_impl = { 0 };
 | 
					static void input_device_destroy(struct wlr_input_device *wlr_device) {
 | 
				
			||||||
 | 
						// Don't free the input device, it's on the stack
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const struct wlr_input_device_impl input_device_impl = {
 | 
				
			||||||
 | 
						.destroy = input_device_destroy,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void keyboard_destroy(struct wlr_keyboard *wlr_keyboard) {
 | 
				
			||||||
 | 
						// Don't free the keyboard, it's on the stack
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const struct wlr_keyboard_impl keyboard_impl = {
 | 
				
			||||||
 | 
						.destroy = keyboard_destroy,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void pointer_destroy(struct wlr_pointer *wlr_pointer) {
 | 
				
			||||||
 | 
						// Don't free the pointer, it's on the stack
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const struct wlr_pointer_impl pointer_impl = {
 | 
				
			||||||
 | 
						.destroy = pointer_destroy,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void update_x11_pointer_position(struct wlr_x11_output *output,
 | 
					void update_x11_pointer_position(struct wlr_x11_output *output,
 | 
				
			||||||
		xcb_timestamp_t time) {
 | 
							xcb_timestamp_t time) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,6 +77,8 @@ struct wlr_x11_output *get_x11_output_from_window_id(struct wlr_x11_backend *x11
 | 
				
			||||||
void get_x11_output_layout_box(struct wlr_x11_backend *backend,
 | 
					void get_x11_output_layout_box(struct wlr_x11_backend *backend,
 | 
				
			||||||
	struct wlr_box *box);
 | 
						struct wlr_box *box);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern const struct wlr_keyboard_impl keyboard_impl;
 | 
				
			||||||
 | 
					extern const struct wlr_pointer_impl pointer_impl;
 | 
				
			||||||
extern const struct wlr_input_device_impl input_device_impl;
 | 
					extern const struct wlr_input_device_impl input_device_impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void handle_x11_input_event(struct wlr_x11_backend *x11,
 | 
					void handle_x11_input_event(struct wlr_x11_backend *x11,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,8 @@ struct wlr_keyboard_impl {
 | 
				
			||||||
	void (*led_update)(struct wlr_keyboard *keyboard, uint32_t leds);
 | 
						void (*led_update)(struct wlr_keyboard *keyboard, uint32_t leds);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_keyboard_init(struct wlr_keyboard *keyboard, struct wlr_keyboard_impl *impl);
 | 
					void wlr_keyboard_init(struct wlr_keyboard *keyboard,
 | 
				
			||||||
 | 
							const struct wlr_keyboard_impl *impl);
 | 
				
			||||||
void wlr_keyboard_destroy(struct wlr_keyboard *keyboard);
 | 
					void wlr_keyboard_destroy(struct wlr_keyboard *keyboard);
 | 
				
			||||||
void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard,
 | 
					void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard,
 | 
				
			||||||
		struct wlr_event_keyboard_key *event);
 | 
							struct wlr_event_keyboard_key *event);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@ struct wlr_pointer_impl {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_pointer_init(struct wlr_pointer *pointer,
 | 
					void wlr_pointer_init(struct wlr_pointer *pointer,
 | 
				
			||||||
		struct wlr_pointer_impl *impl);
 | 
							const struct wlr_pointer_impl *impl);
 | 
				
			||||||
void wlr_pointer_destroy(struct wlr_pointer *pointer);
 | 
					void wlr_pointer_destroy(struct wlr_pointer *pointer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,8 +40,7 @@ struct wlr_keyboard_modifiers {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_keyboard {
 | 
					struct wlr_keyboard {
 | 
				
			||||||
	struct wlr_keyboard_impl *impl;
 | 
						const struct wlr_keyboard_impl *impl;
 | 
				
			||||||
	// TODO: Should this store key repeat info too?
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int keymap_fd;
 | 
						int keymap_fd;
 | 
				
			||||||
	size_t keymap_size;
 | 
						size_t keymap_size;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@
 | 
				
			||||||
struct wlr_pointer_impl;
 | 
					struct wlr_pointer_impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_pointer {
 | 
					struct wlr_pointer {
 | 
				
			||||||
	struct wlr_pointer_impl *impl;
 | 
						const struct wlr_pointer_impl *impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct {
 | 
						struct {
 | 
				
			||||||
		struct wl_signal motion;
 | 
							struct wl_signal motion;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -138,7 +138,7 @@ void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_keyboard_init(struct wlr_keyboard *kb,
 | 
					void wlr_keyboard_init(struct wlr_keyboard *kb,
 | 
				
			||||||
		struct wlr_keyboard_impl *impl) {
 | 
							const struct wlr_keyboard_impl *impl) {
 | 
				
			||||||
	kb->impl = impl;
 | 
						kb->impl = impl;
 | 
				
			||||||
	wl_signal_init(&kb->events.key);
 | 
						wl_signal_init(&kb->events.key);
 | 
				
			||||||
	wl_signal_init(&kb->events.modifiers);
 | 
						wl_signal_init(&kb->events.modifiers);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@
 | 
				
			||||||
#include <wlr/types/wlr_pointer.h>
 | 
					#include <wlr/types/wlr_pointer.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wlr_pointer_init(struct wlr_pointer *pointer,
 | 
					void wlr_pointer_init(struct wlr_pointer *pointer,
 | 
				
			||||||
		struct wlr_pointer_impl *impl) {
 | 
							const struct wlr_pointer_impl *impl) {
 | 
				
			||||||
	pointer->impl = impl;
 | 
						pointer->impl = impl;
 | 
				
			||||||
	wl_signal_init(&pointer->events.motion);
 | 
						wl_signal_init(&pointer->events.motion);
 | 
				
			||||||
	wl_signal_init(&pointer->events.motion_absolute);
 | 
						wl_signal_init(&pointer->events.motion_absolute);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue