Merge branch 'master' into tap-button-map-man-fix

This commit is contained in:
Ryan Dwyer 2018-07-29 23:01:59 +10:00 committed by GitHub
commit b2f58af46c
Failed to generate hash of commit
2 changed files with 39 additions and 0 deletions

View file

@ -2,6 +2,7 @@
#define _SWAY_INPUT_INPUT_MANAGER_H
#include <libinput.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include "sway/server.h"
#include "sway/config.h"
#include "list.h"
@ -25,10 +26,12 @@ struct sway_input_manager {
struct wl_list seats;
struct wlr_input_inhibit_manager *inhibit;
struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard;
struct wl_listener new_input;
struct wl_listener inhibit_activate;
struct wl_listener inhibit_deactivate;
struct wl_listener virtual_keyboard_new;
};
struct sway_input_manager *input_manager_create(struct sway_server *server);

View file

@ -8,6 +8,7 @@
#include <math.h>
#include <wlr/backend/libinput.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include "sway/config.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
@ -303,6 +304,35 @@ static void handle_inhibit_deactivate(struct wl_listener *listener, void *data)
}
}
void handle_virtual_keyboard(struct wl_listener *listener, void *data) {
struct sway_input_manager *input_manager =
wl_container_of(listener, input_manager, virtual_keyboard_new);
struct wlr_virtual_keyboard_v1 *keyboard = data;
struct wlr_input_device *device = &keyboard->input_device;
struct sway_seat *seat = input_manager_get_default_seat(input_manager);
// TODO: The user might want this on a different seat
struct sway_input_device *input_device =
calloc(1, sizeof(struct sway_input_device));
if (!sway_assert(input_device, "could not allocate input device")) {
return;
}
device->data = input_device;
input_device->wlr_device = device;
input_device->identifier = get_device_identifier(device);
wl_list_insert(&input_manager->devices, &input_device->link);
wlr_log(WLR_DEBUG, "adding virtual keyboard: '%s'",
input_device->identifier);
wl_signal_add(&device->events.destroy, &input_device->device_destroy);
input_device->device_destroy.notify = handle_device_destroy;
seat_add_device(seat, input_device);
}
struct sway_input_manager *input_manager_create(
struct sway_server *server) {
struct sway_input_manager *input =
@ -321,6 +351,12 @@ struct sway_input_manager *input_manager_create(
input->new_input.notify = handle_new_input;
wl_signal_add(&server->backend->events.new_input, &input->new_input);
input->virtual_keyboard = wlr_virtual_keyboard_manager_v1_create(
server->wl_display);
wl_signal_add(&input->virtual_keyboard->events.new_virtual_keyboard,
&input->virtual_keyboard_new);
input->virtual_keyboard_new.notify = handle_virtual_keyboard;
input->inhibit = wlr_input_inhibit_manager_create(server->wl_display);
input->inhibit_activate.notify = handle_inhibit_activate;
wl_signal_add(&input->inhibit->events.activate,