mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	seat.c: minor refactoring of seat_reconfigure()
This commit is contained in:
		
							parent
							
								
									8b0d5969a6
								
							
						
					
					
						commit
						d7eecca34d
					
				
					 1 changed files with 22 additions and 16 deletions
				
			
		
							
								
								
									
										38
									
								
								src/seat.c
									
										
									
									
									
								
							
							
						
						
									
										38
									
								
								src/seat.c
									
										
									
									
									
								
							| 
						 | 
					@ -49,6 +49,10 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
 | 
				
			||||||
		wlr_log(WLR_ERROR, "no wlr_input_device");
 | 
							wlr_log(WLR_ERROR, "no wlr_input_device");
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (!wlr_input_device_is_libinput(wlr_input_device)) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct libinput_device *libinput_dev =
 | 
						struct libinput_device *libinput_dev =
 | 
				
			||||||
		wlr_libinput_get_device_handle(wlr_input_device);
 | 
							wlr_libinput_get_device_handle(wlr_input_device);
 | 
				
			||||||
	if (!libinput_dev) {
 | 
						if (!libinput_dev) {
 | 
				
			||||||
| 
						 | 
					@ -157,10 +161,7 @@ new_pointer(struct seat *seat, struct wlr_input_device *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct input *input = znew(*input);
 | 
						struct input *input = znew(*input);
 | 
				
			||||||
	input->wlr_input_device = dev;
 | 
						input->wlr_input_device = dev;
 | 
				
			||||||
 | 
						configure_libinput(dev);
 | 
				
			||||||
	if (wlr_input_device_is_libinput(dev)) {
 | 
					 | 
				
			||||||
		configure_libinput(dev);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	wlr_cursor_attach_input_device(seat->cursor, dev);
 | 
						wlr_cursor_attach_input_device(seat->cursor, dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* In support of running with WLR_WL_OUTPUTS set to >=2 */
 | 
						/* In support of running with WLR_WL_OUTPUTS set to >=2 */
 | 
				
			||||||
| 
						 | 
					@ -208,10 +209,7 @@ new_touch(struct seat *seat, struct wlr_input_device *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct input *input = znew(*input);
 | 
						struct input *input = znew(*input);
 | 
				
			||||||
	input->wlr_input_device = dev;
 | 
						input->wlr_input_device = dev;
 | 
				
			||||||
 | 
						configure_libinput(dev);
 | 
				
			||||||
	if (wlr_input_device_is_libinput(dev)) {
 | 
					 | 
				
			||||||
		configure_libinput(dev);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	wlr_cursor_attach_input_device(seat->cursor, dev);
 | 
						wlr_cursor_attach_input_device(seat->cursor, dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* In support of running with WLR_WL_OUTPUTS set to >=2 */
 | 
						/* In support of running with WLR_WL_OUTPUTS set to >=2 */
 | 
				
			||||||
| 
						 | 
					@ -413,21 +411,29 @@ seat_finish(struct server *server)
 | 
				
			||||||
	cursor_finish(seat);
 | 
						cursor_finish(seat);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					configure_keyboard(struct wlr_input_device *device)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						assert(device->type == WLR_INPUT_DEVICE_KEYBOARD);
 | 
				
			||||||
 | 
						struct wlr_keyboard *kb = wlr_keyboard_from_input_device(device);
 | 
				
			||||||
 | 
						wlr_keyboard_set_repeat_info(kb, rc.repeat_rate, rc.repeat_delay);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
seat_reconfigure(struct server *server)
 | 
					seat_reconfigure(struct server *server)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct seat *seat = &server->seat;
 | 
						struct seat *seat = &server->seat;
 | 
				
			||||||
	struct input *input;
 | 
						struct input *input;
 | 
				
			||||||
	wl_list_for_each(input, &seat->inputs, link) {
 | 
						wl_list_for_each(input, &seat->inputs, link) {
 | 
				
			||||||
		/* We don't configure keyboards by libinput, so skip them */
 | 
							switch (input->wlr_input_device->type) {
 | 
				
			||||||
		if (wlr_input_device_is_libinput(input->wlr_input_device) &&
 | 
							case WLR_INPUT_DEVICE_KEYBOARD:
 | 
				
			||||||
			input->wlr_input_device->type ==
 | 
								configure_keyboard(input->wlr_input_device);
 | 
				
			||||||
			WLR_INPUT_DEVICE_POINTER) {
 | 
								break;
 | 
				
			||||||
 | 
							case WLR_INPUT_DEVICE_POINTER:
 | 
				
			||||||
			configure_libinput(input->wlr_input_device);
 | 
								configure_libinput(input->wlr_input_device);
 | 
				
			||||||
		} else if (input->wlr_input_device->type == WLR_INPUT_DEVICE_KEYBOARD) {
 | 
								break;
 | 
				
			||||||
			struct wlr_keyboard *kb =
 | 
							default:
 | 
				
			||||||
				wlr_keyboard_from_input_device(input->wlr_input_device);
 | 
								break;
 | 
				
			||||||
			wlr_keyboard_set_repeat_info(kb, rc.repeat_rate, rc.repeat_delay);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue