Merge pull request #1377 from tokyovigilante/switch-events
Add support for libinput_switch input devices
This commit is contained in:
commit
6d4bfa3226
|
@ -6,6 +6,7 @@
|
||||||
#include <wlr/interfaces/wlr_tablet_pad.h>
|
#include <wlr/interfaces/wlr_tablet_pad.h>
|
||||||
#include <wlr/interfaces/wlr_tablet_tool.h>
|
#include <wlr/interfaces/wlr_tablet_tool.h>
|
||||||
#include <wlr/interfaces/wlr_touch.h>
|
#include <wlr/interfaces/wlr_touch.h>
|
||||||
|
#include <wlr/interfaces/wlr_switch.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "backend/headless.h"
|
#include "backend/headless.h"
|
||||||
#include "util/signal.h"
|
#include "util/signal.h"
|
||||||
|
@ -76,6 +77,13 @@ struct wlr_input_device *wlr_headless_add_input_device(
|
||||||
}
|
}
|
||||||
wlr_tablet_pad_init(wlr_device->tablet_pad, NULL);
|
wlr_tablet_pad_init(wlr_device->tablet_pad, NULL);
|
||||||
break;
|
break;
|
||||||
|
case WLR_INPUT_DEVICE_SWITCH:
|
||||||
|
wlr_device->lid_switch = calloc(1, sizeof(struct wlr_switch));
|
||||||
|
if (wlr_device->lid_switch == NULL) {
|
||||||
|
wlr_log(WLR_ERROR, "Unable to allocate wlr_switch");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
wlr_switch_init(wlr_device->lid_switch, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_list_insert(&backend->input_devices, &wlr_device->link);
|
wl_list_insert(&backend->input_devices, &wlr_device->link);
|
||||||
|
|
|
@ -169,7 +169,17 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
||||||
}
|
}
|
||||||
if (libinput_device_has_capability(
|
if (libinput_device_has_capability(
|
||||||
libinput_dev, LIBINPUT_DEVICE_CAP_SWITCH)) {
|
libinput_dev, LIBINPUT_DEVICE_CAP_SWITCH)) {
|
||||||
// TODO
|
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||||
|
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_SWITCH);
|
||||||
|
if (!wlr_dev) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
wlr_dev->lid_switch = create_libinput_switch(libinput_dev);
|
||||||
|
if (!wlr_dev->lid_switch) {
|
||||||
|
free(wlr_dev);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wl_list_empty(wlr_devices)) {
|
if (!wl_list_empty(wlr_devices)) {
|
||||||
|
@ -274,6 +284,9 @@ void handle_libinput_event(struct wlr_libinput_backend *backend,
|
||||||
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
|
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
|
||||||
handle_tablet_pad_strip(event, libinput_dev);
|
handle_tablet_pad_strip(event, libinput_dev);
|
||||||
break;
|
break;
|
||||||
|
case LIBINPUT_EVENT_SWITCH_TOGGLE:
|
||||||
|
handle_switch_toggle(event, libinput_dev);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
wlr_log(WLR_DEBUG, "Unknown libinput event %d", event_type);
|
wlr_log(WLR_DEBUG, "Unknown libinput event %d", event_type);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
#include <assert.h>
|
||||||
|
#include <libinput.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <wlr/backend/session.h>
|
||||||
|
#include <wlr/interfaces/wlr_switch.h>
|
||||||
|
#include <wlr/types/wlr_input_device.h>
|
||||||
|
#include <wlr/util/log.h>
|
||||||
|
#include "backend/libinput.h"
|
||||||
|
#include "util/signal.h"
|
||||||
|
|
||||||
|
struct wlr_switch *create_libinput_switch(
|
||||||
|
struct libinput_device *libinput_dev) {
|
||||||
|
assert(libinput_dev);
|
||||||
|
struct wlr_switch *wlr_switch = calloc(1, sizeof(struct wlr_switch));
|
||||||
|
if (!wlr_switch) {
|
||||||
|
wlr_log(WLR_ERROR, "Unable to allocate wlr_switch");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
wlr_switch_init(wlr_switch, NULL);
|
||||||
|
wlr_log(WLR_DEBUG, "Created switch for device %s", libinput_device_get_name(libinput_dev));
|
||||||
|
return wlr_switch;
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_switch_toggle(struct libinput_event *event,
|
||||||
|
struct libinput_device *libinput_dev) {
|
||||||
|
struct wlr_input_device *wlr_dev =
|
||||||
|
get_appropriate_device(WLR_INPUT_DEVICE_SWITCH, libinput_dev);
|
||||||
|
if (!wlr_dev) {
|
||||||
|
wlr_log(WLR_DEBUG, "Got a switch event for a device with no switch?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct libinput_event_switch *sevent =
|
||||||
|
libinput_event_get_switch_event (event);
|
||||||
|
struct wlr_event_switch_toggle wlr_event = { 0 };
|
||||||
|
wlr_event.device = wlr_dev;
|
||||||
|
switch (libinput_event_switch_get_switch(sevent)) {
|
||||||
|
case LIBINPUT_SWITCH_LID:
|
||||||
|
wlr_event.switch_type = WLR_SWITCH_TYPE_LID;
|
||||||
|
break;
|
||||||
|
case LIBINPUT_SWITCH_TABLET_MODE:
|
||||||
|
wlr_event.switch_type = WLR_SWITCH_TYPE_TABLET_MODE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (libinput_event_switch_get_switch_state(sevent)) {
|
||||||
|
case LIBINPUT_SWITCH_STATE_OFF:
|
||||||
|
wlr_event.switch_state = WLR_SWITCH_STATE_OFF;
|
||||||
|
break;
|
||||||
|
case LIBINPUT_SWITCH_STATE_ON:
|
||||||
|
wlr_event.switch_state = WLR_SWITCH_STATE_ON;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
wlr_event.time_msec =
|
||||||
|
usec_to_msec(libinput_event_switch_get_time_usec(sevent));
|
||||||
|
wlr_signal_emit_safe(&wlr_dev->lid_switch->events.toggle, &wlr_event);
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ backend_files = files(
|
||||||
'libinput/events.c',
|
'libinput/events.c',
|
||||||
'libinput/keyboard.c',
|
'libinput/keyboard.c',
|
||||||
'libinput/pointer.c',
|
'libinput/pointer.c',
|
||||||
|
'libinput/switch.c',
|
||||||
'libinput/tablet_pad.c',
|
'libinput/tablet_pad.c',
|
||||||
'libinput/tablet_tool.c',
|
'libinput/tablet_tool.c',
|
||||||
'libinput/touch.c',
|
'libinput/touch.c',
|
||||||
|
|
|
@ -55,6 +55,11 @@ void handle_pointer_button(struct libinput_event *event,
|
||||||
void handle_pointer_axis(struct libinput_event *event,
|
void handle_pointer_axis(struct libinput_event *event,
|
||||||
struct libinput_device *device);
|
struct libinput_device *device);
|
||||||
|
|
||||||
|
struct wlr_switch *create_libinput_switch(
|
||||||
|
struct libinput_device *device);
|
||||||
|
void handle_switch_toggle(struct libinput_event *event,
|
||||||
|
struct libinput_device *device);
|
||||||
|
|
||||||
struct wlr_touch *create_libinput_touch(
|
struct wlr_touch *create_libinput_touch(
|
||||||
struct libinput_device *device);
|
struct libinput_device *device);
|
||||||
void handle_touch_down(struct libinput_event *event,
|
void handle_touch_down(struct libinput_event *event,
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef ROOTSTON_BINDINGS_H
|
||||||
|
#define ROOTSTON_BINDINGS_H
|
||||||
|
|
||||||
|
#include "rootston/seat.h"
|
||||||
|
#include "rootston/input.h"
|
||||||
|
|
||||||
|
void execute_binding_command(struct roots_seat *seat, struct roots_input *input, const char *command);
|
||||||
|
|
||||||
|
#endif //ROOTSTON_BINDINGS_H
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
#include <wlr/types/wlr_input_device.h>
|
#include <wlr/types/wlr_input_device.h>
|
||||||
|
#include <wlr/types/wlr_switch.h>
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
|
|
||||||
#define ROOTS_CONFIG_DEFAULT_SEAT_NAME "seat0"
|
#define ROOTS_CONFIG_DEFAULT_SEAT_NAME "seat0"
|
||||||
|
@ -65,6 +66,14 @@ struct roots_cursor_config {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct roots_switch_config {
|
||||||
|
char *name;
|
||||||
|
enum wlr_switch_type switch_type;
|
||||||
|
enum wlr_switch_state switch_state;
|
||||||
|
char *command;
|
||||||
|
struct wl_list link;
|
||||||
|
};
|
||||||
|
|
||||||
struct roots_config {
|
struct roots_config {
|
||||||
bool xwayland;
|
bool xwayland;
|
||||||
bool xwayland_lazy;
|
bool xwayland_lazy;
|
||||||
|
@ -74,6 +83,7 @@ struct roots_config {
|
||||||
struct wl_list bindings;
|
struct wl_list bindings;
|
||||||
struct wl_list keyboards;
|
struct wl_list keyboards;
|
||||||
struct wl_list cursors;
|
struct wl_list cursors;
|
||||||
|
struct wl_list switches;
|
||||||
|
|
||||||
char *config_path;
|
char *config_path;
|
||||||
char *startup_cmd;
|
char *startup_cmd;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "rootston/input.h"
|
#include "rootston/input.h"
|
||||||
#include "rootston/keyboard.h"
|
#include "rootston/keyboard.h"
|
||||||
#include "rootston/layers.h"
|
#include "rootston/layers.h"
|
||||||
|
#include "rootston/switch.h"
|
||||||
#include "rootston/text_input.h"
|
#include "rootston/text_input.h"
|
||||||
|
|
||||||
struct roots_seat {
|
struct roots_seat {
|
||||||
|
@ -32,6 +33,7 @@ struct roots_seat {
|
||||||
|
|
||||||
struct wl_list keyboards;
|
struct wl_list keyboards;
|
||||||
struct wl_list pointers;
|
struct wl_list pointers;
|
||||||
|
struct wl_list switches;
|
||||||
struct wl_list touch;
|
struct wl_list touch;
|
||||||
struct wl_list tablets;
|
struct wl_list tablets;
|
||||||
struct wl_list tablet_pads;
|
struct wl_list tablet_pads;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef ROOTSTON_SWITCH_H
|
||||||
|
#define ROOTSTON_SWITCH_H
|
||||||
|
|
||||||
|
#include "rootston/input.h"
|
||||||
|
|
||||||
|
struct roots_switch {
|
||||||
|
struct roots_seat *seat;
|
||||||
|
struct wlr_input_device *device;
|
||||||
|
struct wl_listener device_destroy;
|
||||||
|
|
||||||
|
struct wl_listener toggle;
|
||||||
|
struct wl_list link;
|
||||||
|
};
|
||||||
|
|
||||||
|
void roots_switch_handle_toggle(struct roots_switch *lid_switch,
|
||||||
|
struct wlr_event_switch_toggle *event);
|
||||||
|
|
||||||
|
#endif // ROOTSTON_SWITCH_H
|
|
@ -3,6 +3,7 @@ install_headers(
|
||||||
'wlr_keyboard.h',
|
'wlr_keyboard.h',
|
||||||
'wlr_output.h',
|
'wlr_output.h',
|
||||||
'wlr_pointer.h',
|
'wlr_pointer.h',
|
||||||
|
'wlr_switch.h',
|
||||||
'wlr_tablet_pad.h',
|
'wlr_tablet_pad.h',
|
||||||
'wlr_tablet_tool.h',
|
'wlr_tablet_tool.h',
|
||||||
'wlr_touch.h',
|
'wlr_touch.h',
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
||||||
|
* future consistency of this API.
|
||||||
|
*/
|
||||||
|
#ifndef WLR_USE_UNSTABLE
|
||||||
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WLR_INTERFACES_WLR_SWITCH_H
|
||||||
|
#define WLR_INTERFACES_WLR_SWITCH_H
|
||||||
|
|
||||||
|
#include <wlr/types/wlr_switch.h>
|
||||||
|
|
||||||
|
struct wlr_switch_impl {
|
||||||
|
void (*destroy)(struct wlr_switch *lid_switch);
|
||||||
|
};
|
||||||
|
|
||||||
|
void wlr_switch_init(struct wlr_switch *lid_switch,
|
||||||
|
struct wlr_switch_impl *impl);
|
||||||
|
void wlr_switch_destroy(struct wlr_switch *lid_switch);
|
||||||
|
|
||||||
|
#endif
|
|
@ -32,6 +32,7 @@ install_headers(
|
||||||
'wlr_seat.h',
|
'wlr_seat.h',
|
||||||
'wlr_server_decoration.h',
|
'wlr_server_decoration.h',
|
||||||
'wlr_surface.h',
|
'wlr_surface.h',
|
||||||
|
'wlr_switch.h',
|
||||||
'wlr_tablet_pad.h',
|
'wlr_tablet_pad.h',
|
||||||
'wlr_tablet_tool.h',
|
'wlr_tablet_tool.h',
|
||||||
'wlr_tablet_v2.h',
|
'wlr_tablet_v2.h',
|
||||||
|
|
|
@ -20,6 +20,7 @@ enum wlr_input_device_type {
|
||||||
WLR_INPUT_DEVICE_TOUCH,
|
WLR_INPUT_DEVICE_TOUCH,
|
||||||
WLR_INPUT_DEVICE_TABLET_TOOL,
|
WLR_INPUT_DEVICE_TABLET_TOOL,
|
||||||
WLR_INPUT_DEVICE_TABLET_PAD,
|
WLR_INPUT_DEVICE_TABLET_PAD,
|
||||||
|
WLR_INPUT_DEVICE_SWITCH,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Note: these are circular dependencies */
|
/* Note: these are circular dependencies */
|
||||||
|
@ -28,6 +29,7 @@ enum wlr_input_device_type {
|
||||||
#include <wlr/types/wlr_touch.h>
|
#include <wlr/types/wlr_touch.h>
|
||||||
#include <wlr/types/wlr_tablet_tool.h>
|
#include <wlr/types/wlr_tablet_tool.h>
|
||||||
#include <wlr/types/wlr_tablet_pad.h>
|
#include <wlr/types/wlr_tablet_pad.h>
|
||||||
|
#include <wlr/types/wlr_switch.h>
|
||||||
|
|
||||||
struct wlr_input_device_impl;
|
struct wlr_input_device_impl;
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ struct wlr_input_device {
|
||||||
void *_device;
|
void *_device;
|
||||||
struct wlr_keyboard *keyboard;
|
struct wlr_keyboard *keyboard;
|
||||||
struct wlr_pointer *pointer;
|
struct wlr_pointer *pointer;
|
||||||
|
struct wlr_switch *lid_switch;
|
||||||
struct wlr_touch *touch;
|
struct wlr_touch *touch;
|
||||||
struct wlr_tablet *tablet;
|
struct wlr_tablet *tablet;
|
||||||
struct wlr_tablet_pad *tablet_pad;
|
struct wlr_tablet_pad *tablet_pad;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
||||||
|
* future consistency of this API.
|
||||||
|
*/
|
||||||
|
#ifndef WLR_USE_UNSTABLE
|
||||||
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WLR_TYPES_WLR_SWITCH_H
|
||||||
|
#define WLR_TYPES_WLR_SWITCH_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <wayland-server.h>
|
||||||
|
#include <wlr/types/wlr_input_device.h>
|
||||||
|
#include <wlr/types/wlr_list.h>
|
||||||
|
|
||||||
|
struct wlr_switch_impl;
|
||||||
|
|
||||||
|
struct wlr_switch {
|
||||||
|
struct wlr_switch_impl *impl;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct wl_signal toggle;
|
||||||
|
} events;
|
||||||
|
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum wlr_switch_type {
|
||||||
|
WLR_SWITCH_TYPE_LID = 1,
|
||||||
|
WLR_SWITCH_TYPE_TABLET_MODE,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum wlr_switch_state {
|
||||||
|
WLR_SWITCH_STATE_OFF = 0,
|
||||||
|
WLR_SWITCH_STATE_ON,
|
||||||
|
WLR_SWITCH_STATE_TOGGLE
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wlr_event_switch_toggle {
|
||||||
|
struct wlr_input_device *device;
|
||||||
|
uint32_t time_msec;
|
||||||
|
enum wlr_switch_type switch_type;
|
||||||
|
enum wlr_switch_state switch_state;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,107 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <wlr/util/log.h>
|
||||||
|
#include "rootston/bindings.h"
|
||||||
|
|
||||||
|
static bool outputs_enabled = true;
|
||||||
|
|
||||||
|
static const char *exec_prefix = "exec ";
|
||||||
|
|
||||||
|
static void double_fork_shell_cmd(const char *shell_cmd) {
|
||||||
|
pid_t pid = fork();
|
||||||
|
if (pid < 0) {
|
||||||
|
wlr_log(WLR_ERROR, "cannot execute binding command: fork() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
pid = fork();
|
||||||
|
if (pid == 0) {
|
||||||
|
execl("/bin/sh", "/bin/sh", "-c", shell_cmd, NULL);
|
||||||
|
_exit(EXIT_FAILURE);
|
||||||
|
} else {
|
||||||
|
_exit(pid == -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int status;
|
||||||
|
while (waitpid(pid, &status, 0) < 0) {
|
||||||
|
if (errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
wlr_log_errno(WLR_ERROR, "waitpid() on first child failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_log(WLR_ERROR, "first child failed to fork command");
|
||||||
|
}
|
||||||
|
|
||||||
|
void execute_binding_command(struct roots_seat *seat,
|
||||||
|
struct roots_input *input, const char *command) {
|
||||||
|
if (strcmp(command, "exit") == 0) {
|
||||||
|
wl_display_terminate(input->server->wl_display);
|
||||||
|
} else if (strcmp(command, "close") == 0) {
|
||||||
|
struct roots_view *focus = roots_seat_get_focus(seat);
|
||||||
|
if (focus != NULL) {
|
||||||
|
view_close(focus);
|
||||||
|
}
|
||||||
|
} else if (strcmp(command, "fullscreen") == 0) {
|
||||||
|
struct roots_view *focus = roots_seat_get_focus(seat);
|
||||||
|
if (focus != NULL) {
|
||||||
|
bool is_fullscreen = focus->fullscreen_output != NULL;
|
||||||
|
view_set_fullscreen(focus, !is_fullscreen, NULL);
|
||||||
|
}
|
||||||
|
} else if (strcmp(command, "next_window") == 0) {
|
||||||
|
roots_seat_cycle_focus(seat);
|
||||||
|
} else if (strcmp(command, "alpha") == 0) {
|
||||||
|
struct roots_view *focus = roots_seat_get_focus(seat);
|
||||||
|
if (focus != NULL) {
|
||||||
|
view_cycle_alpha(focus);
|
||||||
|
}
|
||||||
|
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
|
||||||
|
const char *shell_cmd = command + strlen(exec_prefix);
|
||||||
|
double_fork_shell_cmd(shell_cmd);
|
||||||
|
} else if (strcmp(command, "maximize") == 0) {
|
||||||
|
struct roots_view *focus = roots_seat_get_focus(seat);
|
||||||
|
if (focus != NULL) {
|
||||||
|
view_maximize(focus, !focus->maximized);
|
||||||
|
}
|
||||||
|
} else if (strcmp(command, "nop") == 0) {
|
||||||
|
wlr_log(WLR_DEBUG, "nop command");
|
||||||
|
} else if (strcmp(command, "toggle_outputs") == 0) {
|
||||||
|
outputs_enabled = !outputs_enabled;
|
||||||
|
struct roots_output *output;
|
||||||
|
wl_list_for_each(output, &input->server->desktop->outputs, link) {
|
||||||
|
wlr_output_enable(output->wlr_output, outputs_enabled);
|
||||||
|
}
|
||||||
|
} else if (strcmp(command, "toggle_decoration_mode") == 0) {
|
||||||
|
struct roots_view *focus = roots_seat_get_focus(seat);
|
||||||
|
if (focus != NULL && focus->type == ROOTS_XDG_SHELL_VIEW) {
|
||||||
|
struct roots_xdg_toplevel_decoration *decoration =
|
||||||
|
focus->roots_xdg_surface->xdg_toplevel_decoration;
|
||||||
|
if (decoration != NULL) {
|
||||||
|
enum wlr_xdg_toplevel_decoration_v1_mode mode =
|
||||||
|
decoration->wlr_decoration->current_mode;
|
||||||
|
mode = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
|
||||||
|
? WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
|
||||||
|
: WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
|
||||||
|
wlr_xdg_toplevel_decoration_v1_set_mode(
|
||||||
|
decoration->wlr_decoration, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (strcmp(command, "break_pointer_constraint") == 0) {
|
||||||
|
struct wl_list *list = &input->seats;
|
||||||
|
struct roots_seat *seat;
|
||||||
|
wl_list_for_each(seat, list, link) {
|
||||||
|
roots_cursor_constrain(seat->cursor, NULL, NAN, NAN);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wlr_log(WLR_ERROR, "unknown binding command: %s", command);
|
||||||
|
}
|
||||||
|
}
|
|
@ -201,6 +201,33 @@ 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 *action,
|
||||||
|
const char* command) {
|
||||||
|
struct roots_switch_config *sc = calloc(1, sizeof(struct roots_switch_config));
|
||||||
|
|
||||||
|
if (strcmp(switch_name, "tablet") == 0) {
|
||||||
|
sc->switch_type = WLR_SWITCH_TYPE_TABLET_MODE;
|
||||||
|
} else if (strcmp(switch_name, "lid") == 0) {
|
||||||
|
sc->switch_type = WLR_SWITCH_TYPE_LID;
|
||||||
|
} else {
|
||||||
|
sc->switch_type = -1;
|
||||||
|
sc->name = strdup(switch_name);
|
||||||
|
}
|
||||||
|
if (strcmp(action, "on") == 0) {
|
||||||
|
sc->switch_state = WLR_SWITCH_STATE_ON;
|
||||||
|
} else if (strcmp(action, "off") == 0) {
|
||||||
|
sc->switch_state = WLR_SWITCH_STATE_OFF;
|
||||||
|
} else if (strcmp(action, "toggle") == 0) {
|
||||||
|
sc->switch_state = WLR_SWITCH_STATE_TOGGLE;
|
||||||
|
} else {
|
||||||
|
wlr_log(WLR_ERROR, "Invalid switch action %s/n for switch %s:%s",
|
||||||
|
action, switch_name, action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sc->command = strdup(command);
|
||||||
|
wl_list_insert(switches, &sc->link);
|
||||||
|
}
|
||||||
|
|
||||||
static void config_handle_cursor(struct roots_config *config,
|
static void config_handle_cursor(struct roots_config *config,
|
||||||
const char *seat_name, const char *name, const char *value) {
|
const char *seat_name, const char *name, const char *value) {
|
||||||
struct roots_cursor_config *cc;
|
struct roots_cursor_config *cc;
|
||||||
|
@ -280,6 +307,7 @@ static const char *output_prefix = "output:";
|
||||||
static const char *device_prefix = "device:";
|
static const char *device_prefix = "device:";
|
||||||
static const char *keyboard_prefix = "keyboard:";
|
static const char *keyboard_prefix = "keyboard:";
|
||||||
static const char *cursor_prefix = "cursor:";
|
static const char *cursor_prefix = "cursor:";
|
||||||
|
static const char *switch_prefix = "switch:";
|
||||||
|
|
||||||
static int config_ini_handler(void *user, const char *section, const char *name,
|
static int config_ini_handler(void *user, const char *section, const char *name,
|
||||||
const char *value) {
|
const char *value) {
|
||||||
|
@ -436,6 +464,9 @@ static int config_ini_handler(void *user, const char *section, const char *name,
|
||||||
config_handle_keyboard(config, device_name, name, value);
|
config_handle_keyboard(config, device_name, name, value);
|
||||||
} else if (strcmp(section, "bindings") == 0) {
|
} else if (strcmp(section, "bindings") == 0) {
|
||||||
add_binding_config(&config->bindings, name, value);
|
add_binding_config(&config->bindings, name, value);
|
||||||
|
} else if (strncmp(switch_prefix, section, strlen(switch_prefix)) == 0) {
|
||||||
|
const char *switch_name = section + strlen(switch_prefix);
|
||||||
|
add_switch_config(&config->switches, switch_name, name, value);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(WLR_ERROR, "got unknown config section: %s", section);
|
wlr_log(WLR_ERROR, "got unknown config section: %s", section);
|
||||||
}
|
}
|
||||||
|
@ -456,6 +487,7 @@ struct roots_config *roots_config_create_from_args(int argc, char *argv[]) {
|
||||||
wl_list_init(&config->keyboards);
|
wl_list_init(&config->keyboards);
|
||||||
wl_list_init(&config->cursors);
|
wl_list_init(&config->cursors);
|
||||||
wl_list_init(&config->bindings);
|
wl_list_init(&config->bindings);
|
||||||
|
wl_list_init(&config->switches);
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
unsigned int log_verbosity = WLR_DEBUG;
|
unsigned int log_verbosity = WLR_DEBUG;
|
||||||
|
|
|
@ -23,6 +23,8 @@ static const char *device_type(enum wlr_input_device_type type) {
|
||||||
return "keyboard";
|
return "keyboard";
|
||||||
case WLR_INPUT_DEVICE_POINTER:
|
case WLR_INPUT_DEVICE_POINTER:
|
||||||
return "pointer";
|
return "pointer";
|
||||||
|
case WLR_INPUT_DEVICE_SWITCH:
|
||||||
|
return "switch";
|
||||||
case WLR_INPUT_DEVICE_TOUCH:
|
case WLR_INPUT_DEVICE_TOUCH:
|
||||||
return "touch";
|
return "touch";
|
||||||
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
case WLR_INPUT_DEVICE_TABLET_TOOL:
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#include <wlr/backend/session.h>
|
#include <wlr/backend/session.h>
|
||||||
#include <wlr/types/wlr_input_device.h>
|
#include <wlr/types/wlr_input_device.h>
|
||||||
|
@ -11,6 +9,7 @@
|
||||||
#include <wlr/types/wlr_pointer.h>
|
#include <wlr/types/wlr_pointer.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
|
#include "rootston/bindings.h"
|
||||||
#include "rootston/input.h"
|
#include "rootston/input.h"
|
||||||
#include "rootston/keyboard.h"
|
#include "rootston/keyboard.h"
|
||||||
#include "rootston/seat.h"
|
#include "rootston/seat.h"
|
||||||
|
@ -85,107 +84,9 @@ static void pressed_keysyms_update(xkb_keysym_t *pressed_keysyms,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void double_fork_shell_cmd(const char *shell_cmd) {
|
|
||||||
pid_t pid = fork();
|
|
||||||
if (pid < 0) {
|
|
||||||
wlr_log(WLR_ERROR, "cannot execute binding command: fork() failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pid == 0) {
|
|
||||||
pid = fork();
|
|
||||||
if (pid == 0) {
|
|
||||||
execl("/bin/sh", "/bin/sh", "-c", shell_cmd, NULL);
|
|
||||||
_exit(EXIT_FAILURE);
|
|
||||||
} else {
|
|
||||||
_exit(pid == -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int status;
|
|
||||||
while (waitpid(pid, &status, 0) < 0) {
|
|
||||||
if (errno == EINTR) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
wlr_log_errno(WLR_ERROR, "waitpid() on first child failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_log(WLR_ERROR, "first child failed to fork command");
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *exec_prefix = "exec ";
|
|
||||||
|
|
||||||
static bool outputs_enabled = true;
|
|
||||||
|
|
||||||
static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
||||||
const char *command) {
|
const char *command) {
|
||||||
struct roots_seat *seat = keyboard->seat;
|
execute_binding_command(keyboard->seat, keyboard->input, command);
|
||||||
if (strcmp(command, "exit") == 0) {
|
|
||||||
wl_display_terminate(keyboard->input->server->wl_display);
|
|
||||||
} else if (strcmp(command, "close") == 0) {
|
|
||||||
struct roots_view *focus = roots_seat_get_focus(seat);
|
|
||||||
if (focus != NULL) {
|
|
||||||
view_close(focus);
|
|
||||||
}
|
|
||||||
} else if (strcmp(command, "fullscreen") == 0) {
|
|
||||||
struct roots_view *focus = roots_seat_get_focus(seat);
|
|
||||||
if (focus != NULL) {
|
|
||||||
bool is_fullscreen = focus->fullscreen_output != NULL;
|
|
||||||
view_set_fullscreen(focus, !is_fullscreen, NULL);
|
|
||||||
}
|
|
||||||
} else if (strcmp(command, "next_window") == 0) {
|
|
||||||
roots_seat_cycle_focus(seat);
|
|
||||||
} else if (strcmp(command, "alpha") == 0) {
|
|
||||||
struct roots_view *focus = roots_seat_get_focus(seat);
|
|
||||||
if (focus != NULL) {
|
|
||||||
view_cycle_alpha(focus);
|
|
||||||
}
|
|
||||||
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
|
|
||||||
const char *shell_cmd = command + strlen(exec_prefix);
|
|
||||||
double_fork_shell_cmd(shell_cmd);
|
|
||||||
} else if (strcmp(command, "maximize") == 0) {
|
|
||||||
struct roots_view *focus = roots_seat_get_focus(seat);
|
|
||||||
if (focus != NULL) {
|
|
||||||
view_maximize(focus, !focus->maximized);
|
|
||||||
}
|
|
||||||
} else if (strcmp(command, "nop") == 0) {
|
|
||||||
wlr_log(WLR_DEBUG, "nop command");
|
|
||||||
} else if (strcmp(command, "toggle_outputs") == 0) {
|
|
||||||
outputs_enabled = !outputs_enabled;
|
|
||||||
struct roots_output *output;
|
|
||||||
wl_list_for_each(output, &keyboard->input->server->desktop->outputs, link) {
|
|
||||||
wlr_output_enable(output->wlr_output, outputs_enabled);
|
|
||||||
}
|
|
||||||
} else if (strcmp(command, "toggle_decoration_mode") == 0) {
|
|
||||||
struct roots_view *focus = roots_seat_get_focus(seat);
|
|
||||||
if (focus != NULL && focus->type == ROOTS_XDG_SHELL_VIEW) {
|
|
||||||
struct roots_xdg_toplevel_decoration *decoration =
|
|
||||||
focus->roots_xdg_surface->xdg_toplevel_decoration;
|
|
||||||
if (decoration != NULL) {
|
|
||||||
enum wlr_xdg_toplevel_decoration_v1_mode mode =
|
|
||||||
decoration->wlr_decoration->current_mode;
|
|
||||||
mode = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
|
|
||||||
? WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
|
|
||||||
: WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
|
|
||||||
wlr_xdg_toplevel_decoration_v1_set_mode(
|
|
||||||
decoration->wlr_decoration, mode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (strcmp(command, "break_pointer_constraint") == 0) {
|
|
||||||
struct wl_list *list =
|
|
||||||
&keyboard->input->seats;
|
|
||||||
struct roots_seat *seat;
|
|
||||||
wl_list_for_each(seat, list, link) {
|
|
||||||
roots_cursor_constrain(seat->cursor, NULL, NAN, NAN);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
wlr_log(WLR_ERROR, "unknown binding command: %s", command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
sources = [
|
sources = [
|
||||||
|
'bindings.c',
|
||||||
'config.c',
|
'config.c',
|
||||||
'cursor.c',
|
'cursor.c',
|
||||||
'desktop.c',
|
'desktop.c',
|
||||||
|
@ -9,6 +10,7 @@ sources = [
|
||||||
'main.c',
|
'main.c',
|
||||||
'output.c',
|
'output.c',
|
||||||
'seat.c',
|
'seat.c',
|
||||||
|
'switch.c',
|
||||||
'text_input.c',
|
'text_input.c',
|
||||||
'virtual_keyboard.c',
|
'virtual_keyboard.c',
|
||||||
'wl_shell.c',
|
'wl_shell.c',
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <wlr/config.h>
|
#include <wlr/config.h>
|
||||||
#include <wlr/types/wlr_idle.h>
|
#include <wlr/types/wlr_idle.h>
|
||||||
#include <wlr/types/wlr_layer_shell_v1.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_tablet_v2.h>
|
||||||
#include <wlr/types/wlr_xcursor_manager.h>
|
#include <wlr/types/wlr_xcursor_manager.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
@ -75,6 +76,15 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
|
||||||
roots_cursor_handle_axis(cursor, event);
|
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;
|
||||||
|
roots_switch_handle_toggle(lid_switch, event);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_touch_down(struct wl_listener *listener, void *data) {
|
static void handle_touch_down(struct wl_listener *listener, void *data) {
|
||||||
struct roots_cursor *cursor =
|
struct roots_cursor *cursor =
|
||||||
wl_container_of(listener, cursor, touch_down);
|
wl_container_of(listener, cursor, touch_down);
|
||||||
|
@ -587,6 +597,7 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
|
||||||
wl_list_init(&seat->touch);
|
wl_list_init(&seat->touch);
|
||||||
wl_list_init(&seat->tablets);
|
wl_list_init(&seat->tablets);
|
||||||
wl_list_init(&seat->tablet_pads);
|
wl_list_init(&seat->tablet_pads);
|
||||||
|
wl_list_init(&seat->switches);
|
||||||
wl_list_init(&seat->views);
|
wl_list_init(&seat->views);
|
||||||
wl_list_init(&seat->drag_icons);
|
wl_list_init(&seat->drag_icons);
|
||||||
|
|
||||||
|
@ -710,6 +721,36 @@ static void seat_add_pointer(struct roots_seat *seat,
|
||||||
roots_seat_configure_cursor(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);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_touch_destroy(struct wl_listener *listener, void *data) {
|
static void handle_touch_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct roots_pointer *touch =
|
struct roots_pointer *touch =
|
||||||
wl_container_of(listener, touch, device_destroy);
|
wl_container_of(listener, touch, device_destroy);
|
||||||
|
@ -953,6 +994,9 @@ void roots_seat_add_device(struct roots_seat *seat,
|
||||||
case WLR_INPUT_DEVICE_POINTER:
|
case WLR_INPUT_DEVICE_POINTER:
|
||||||
seat_add_pointer(seat, device);
|
seat_add_pointer(seat, device);
|
||||||
break;
|
break;
|
||||||
|
case WLR_INPUT_DEVICE_SWITCH:
|
||||||
|
seat_add_switch(seat, device);
|
||||||
|
break;
|
||||||
case WLR_INPUT_DEVICE_TOUCH:
|
case WLR_INPUT_DEVICE_TOUCH:
|
||||||
seat_add_touch(seat, device);
|
seat_add_touch(seat, device);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
|
#include "rootston/bindings.h"
|
||||||
|
#include "rootston/config.h"
|
||||||
|
#include "rootston/input.h"
|
||||||
|
#include "rootston/seat.h"
|
||||||
|
#include "rootston/switch.h"
|
||||||
|
|
||||||
|
void roots_switch_handle_toggle(struct roots_switch *lid_switch,
|
||||||
|
struct wlr_event_switch_toggle *event) {
|
||||||
|
struct wl_list *bound_switches = &lid_switch->seat->input->server->config->switches;
|
||||||
|
struct roots_switch_config *sc;
|
||||||
|
wl_list_for_each(sc, bound_switches, link) {
|
||||||
|
if ((sc->name != NULL && strcmp(event->device->name, sc->name) != 0) &&
|
||||||
|
(sc->name == NULL && event->switch_type != sc->switch_type)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (sc->switch_state != WLR_SWITCH_STATE_TOGGLE &&
|
||||||
|
event->switch_state != sc->switch_state) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
execute_binding_command(lid_switch->seat, lid_switch->seat->input, sc->command);
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,6 +54,7 @@ lib_wlr_types = static_library(
|
||||||
'wlr_screenshooter.c',
|
'wlr_screenshooter.c',
|
||||||
'wlr_server_decoration.c',
|
'wlr_server_decoration.c',
|
||||||
'wlr_surface.c',
|
'wlr_surface.c',
|
||||||
|
'wlr_switch.c',
|
||||||
'wlr_tablet_pad.c',
|
'wlr_tablet_pad.c',
|
||||||
'wlr_tablet_tool.c',
|
'wlr_tablet_tool.c',
|
||||||
'wlr_text_input_v3.c',
|
'wlr_text_input_v3.c',
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <wlr/interfaces/wlr_input_device.h>
|
#include <wlr/interfaces/wlr_input_device.h>
|
||||||
#include <wlr/interfaces/wlr_keyboard.h>
|
#include <wlr/interfaces/wlr_keyboard.h>
|
||||||
#include <wlr/interfaces/wlr_pointer.h>
|
#include <wlr/interfaces/wlr_pointer.h>
|
||||||
|
#include <wlr/interfaces/wlr_switch.h>
|
||||||
#include <wlr/interfaces/wlr_tablet_pad.h>
|
#include <wlr/interfaces/wlr_tablet_pad.h>
|
||||||
#include <wlr/interfaces/wlr_tablet_tool.h>
|
#include <wlr/interfaces/wlr_tablet_tool.h>
|
||||||
#include <wlr/interfaces/wlr_touch.h>
|
#include <wlr/interfaces/wlr_touch.h>
|
||||||
|
@ -40,6 +41,9 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
|
||||||
case WLR_INPUT_DEVICE_POINTER:
|
case WLR_INPUT_DEVICE_POINTER:
|
||||||
wlr_pointer_destroy(dev->pointer);
|
wlr_pointer_destroy(dev->pointer);
|
||||||
break;
|
break;
|
||||||
|
case WLR_INPUT_DEVICE_SWITCH:
|
||||||
|
wlr_switch_destroy(dev->lid_switch);
|
||||||
|
break;
|
||||||
case WLR_INPUT_DEVICE_TOUCH:
|
case WLR_INPUT_DEVICE_TOUCH:
|
||||||
wlr_touch_destroy(dev->touch);
|
wlr_touch_destroy(dev->touch);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <wayland-server.h>
|
||||||
|
#include <wlr/interfaces/wlr_switch.h>
|
||||||
|
#include <wlr/types/wlr_switch.h>
|
||||||
|
|
||||||
|
void wlr_switch_init(struct wlr_switch *lid_switch,
|
||||||
|
struct wlr_switch_impl *impl) {
|
||||||
|
lid_switch->impl = impl;
|
||||||
|
wl_signal_init(&lid_switch->events.toggle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_switch_destroy(struct wlr_switch *lid_switch) {
|
||||||
|
if (!lid_switch) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lid_switch->impl && lid_switch->impl->destroy) {
|
||||||
|
lid_switch->impl->destroy(lid_switch);
|
||||||
|
} else {
|
||||||
|
free(lid_switch);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue