mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Add keyboard handling shims to registry
This commit is contained in:
		
							parent
							
								
									d2e9c68640
								
							
						
					
					
						commit
						7614cb0373
					
				
					 2 changed files with 39 additions and 0 deletions
				
			
		| 
						 | 
					@ -16,6 +16,7 @@ struct registry {
 | 
				
			||||||
        struct wl_compositor *compositor;
 | 
					        struct wl_compositor *compositor;
 | 
				
			||||||
        struct wl_display *display;
 | 
					        struct wl_display *display;
 | 
				
			||||||
        struct wl_pointer *pointer;
 | 
					        struct wl_pointer *pointer;
 | 
				
			||||||
 | 
					        struct wl_keyboard *keyboard;
 | 
				
			||||||
        struct wl_seat *seat;
 | 
					        struct wl_seat *seat;
 | 
				
			||||||
        struct wl_shell *shell;
 | 
					        struct wl_shell *shell;
 | 
				
			||||||
        struct wl_shm *shm;
 | 
					        struct wl_shm *shm;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,6 +38,40 @@ static const struct wl_output_listener output_listener = {
 | 
				
			||||||
	.scale = display_handle_scale
 | 
						.scale = display_handle_scale
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
 | 
				
			||||||
 | 
							uint32_t format, int fd, uint32_t size) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
 | 
				
			||||||
 | 
							uint32_t serial, struct wl_surface *surface, struct wl_array *keys) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
 | 
				
			||||||
 | 
							uint32_t serial, struct wl_surface *surface) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
 | 
				
			||||||
 | 
							uint32_t serial, uint32_t time, uint32_t key, uint32_t state_w) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
 | 
				
			||||||
 | 
							uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched,
 | 
				
			||||||
 | 
							uint32_t mods_locked, uint32_t group) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void keyboard_handle_repeat_info(void *data, struct wl_keyboard *keyboard,
 | 
				
			||||||
 | 
							int32_t rate, int32_t delay) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const struct wl_keyboard_listener keyboard_listener = {
 | 
				
			||||||
 | 
						.keymap = keyboard_handle_keymap,
 | 
				
			||||||
 | 
						.enter = keyboard_handle_enter,
 | 
				
			||||||
 | 
						.leave = keyboard_handle_leave,
 | 
				
			||||||
 | 
						.key = keyboard_handle_key,
 | 
				
			||||||
 | 
						.modifiers = keyboard_handle_modifiers,
 | 
				
			||||||
 | 
						.repeat_info = keyboard_handle_repeat_info
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void registry_global(void *data, struct wl_registry *registry,
 | 
					static void registry_global(void *data, struct wl_registry *registry,
 | 
				
			||||||
		uint32_t name, const char *interface, uint32_t version) {
 | 
							uint32_t name, const char *interface, uint32_t version) {
 | 
				
			||||||
	struct registry *reg = data;
 | 
						struct registry *reg = data;
 | 
				
			||||||
| 
						 | 
					@ -51,6 +85,10 @@ static void registry_global(void *data, struct wl_registry *registry,
 | 
				
			||||||
	} else if (strcmp(interface, wl_seat_interface.name) == 0) {
 | 
						} else if (strcmp(interface, wl_seat_interface.name) == 0) {
 | 
				
			||||||
		reg->seat = wl_registry_bind(registry, name, &wl_seat_interface, version);
 | 
							reg->seat = wl_registry_bind(registry, name, &wl_seat_interface, version);
 | 
				
			||||||
		reg->pointer = wl_seat_get_pointer(reg->seat);
 | 
							reg->pointer = wl_seat_get_pointer(reg->seat);
 | 
				
			||||||
 | 
							reg->keyboard = wl_seat_get_keyboard(reg->seat);
 | 
				
			||||||
 | 
							if (reg->keyboard) {
 | 
				
			||||||
 | 
								wl_keyboard_add_listener(reg->keyboard, &keyboard_listener, reg);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	} else if (strcmp(interface, wl_output_interface.name) == 0) {
 | 
						} else if (strcmp(interface, wl_output_interface.name) == 0) {
 | 
				
			||||||
		struct wl_output *output = wl_registry_bind(registry, name, &wl_output_interface, version);
 | 
							struct wl_output *output = wl_registry_bind(registry, name, &wl_output_interface, version);
 | 
				
			||||||
		struct output_state *ostate = malloc(sizeof(struct output_state));
 | 
							struct output_state *ostate = malloc(sizeof(struct output_state));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue