aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
Diffstat (limited to 'rootston')
-rw-r--r--rootston/config.c8
-rw-r--r--rootston/input.c2
-rw-r--r--rootston/seat.c48
3 files changed, 58 insertions, 0 deletions
diff --git a/rootston/config.c b/rootston/config.c
index 119a9e2c..53b3718f 100644
--- a/rootston/config.c
+++ b/rootston/config.c
@@ -201,6 +201,11 @@ void add_binding_config(struct wl_list *bindings, const char* combination,
}
}
+void add_switch_config(struct wl_list *switches, const char *switch_name,
+ const char* command) {
+ wlr_log(WLR_DEBUG, "config switch %s: %s", switch_name, command);
+}
+
static void config_handle_cursor(struct roots_config *config,
const char *seat_name, const char *name, const char *value) {
struct roots_cursor_config *cc;
@@ -436,6 +441,8 @@ static int config_ini_handler(void *user, const char *section, const char *name,
config_handle_keyboard(config, device_name, name, value);
} else if (strcmp(section, "bindings") == 0) {
add_binding_config(&config->bindings, name, value);
+ } else if (strcmp(section, "switches") == 0) {
+ add_switch_config(&config->bindings, name, value);
} else {
wlr_log(WLR_ERROR, "got unknown config section: %s", section);
}
@@ -456,6 +463,7 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
wl_list_init(&config->keyboards);
wl_list_init(&config->cursors);
wl_list_init(&config->bindings);
+ wl_list_init(&config->switches);
int c;
unsigned int log_verbosity = WLR_DEBUG;
diff --git a/rootston/input.c b/rootston/input.c
index 7b4001b3..a863b919 100644
--- a/rootston/input.c
+++ b/rootston/input.c
@@ -23,6 +23,8 @@ static const char *device_type(enum wlr_input_device_type type) {
return "keyboard";
case WLR_INPUT_DEVICE_POINTER:
return "pointer";
+ case WLR_INPUT_DEVICE_SWITCH:
+ return "switch";
case WLR_INPUT_DEVICE_TOUCH:
return "touch";
case WLR_INPUT_DEVICE_TABLET_TOOL:
diff --git a/rootston/seat.c b/rootston/seat.c
index e91278c5..101c4ebe 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -9,6 +9,7 @@
#include <wlr/config.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_layer_shell_v1.h>
+#include "wlr/types/wlr_switch.h"
#include <wlr/types/wlr_tablet_v2.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/log.h>
@@ -75,6 +76,16 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
roots_cursor_handle_axis(cursor, event);
}
+static void handle_switch_toggle(struct wl_listener *listener, void *data) {
+ struct roots_switch *lid_switch =
+ wl_container_of(listener, lid_switch, toggle);
+ struct roots_desktop *desktop = lid_switch->seat->input->server->desktop;
+ wlr_idle_notify_activity(desktop->idle, lid_switch->seat->seat);
+ struct wlr_event_switch_toggle *event = data;
+ wlr_log(WLR_DEBUG, "Switch event %s: type %i state %i", event->device->name, event->switch_type, event->switch_state);
+ //roots_switch_handle_toggle(lid_switch, event);
+}
+
static void handle_touch_down(struct wl_listener *listener, void *data) {
struct roots_cursor *cursor =
wl_container_of(listener, cursor, touch_down);
@@ -587,6 +598,7 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
wl_list_init(&seat->touch);
wl_list_init(&seat->tablets);
wl_list_init(&seat->tablet_pads);
+ wl_list_init(&seat->switches);
wl_list_init(&seat->views);
wl_list_init(&seat->drag_icons);
@@ -710,6 +722,39 @@ static void seat_add_pointer(struct roots_seat *seat,
roots_seat_configure_cursor(seat);
}
+static void handle_switch_destroy(struct wl_listener *listener, void *data) {
+ struct roots_switch *lid_switch =
+ wl_container_of(listener, lid_switch, device_destroy);
+ struct roots_seat *seat = lid_switch->seat;
+
+ wl_list_remove(&lid_switch->link);
+ wl_list_remove(&lid_switch->device_destroy.link);
+ free(lid_switch);
+
+ seat_update_capabilities(seat);
+}
+
+static void seat_add_switch(struct roots_seat *seat,
+ struct wlr_input_device *device) {
+ assert(device->type == WLR_INPUT_DEVICE_SWITCH);
+ struct roots_switch *lid_switch = calloc(1, sizeof(struct roots_switch));
+ if (!lid_switch) {
+ wlr_log(WLR_ERROR, "could not allocate switch for seat");
+ return;
+ }
+
+ device->data = lid_switch;
+ lid_switch->device = device;
+ lid_switch->seat = seat;
+ wl_list_insert(&seat->switches, &lid_switch->link);
+ lid_switch->device_destroy.notify = handle_switch_destroy;
+
+ lid_switch->toggle.notify = handle_switch_toggle;
+ wl_signal_add(&lid_switch->device->lid_switch->events.toggle, &lid_switch->toggle);
+
+ wl_signal_add(&lid_switch->device->events.destroy, &lid_switch->device_destroy);
+}
+
static void handle_touch_destroy(struct wl_listener *listener, void *data) {
struct roots_pointer *touch =
wl_container_of(listener, touch, device_destroy);
@@ -953,6 +998,9 @@ void roots_seat_add_device(struct roots_seat *seat,
case WLR_INPUT_DEVICE_POINTER:
seat_add_pointer(seat, device);
break;
+ case WLR_INPUT_DEVICE_SWITCH:
+ seat_add_switch(seat, device);
+ break;
case WLR_INPUT_DEVICE_TOUCH:
seat_add_touch(seat, device);
break;