mirror of
https://github.com/swaywm/sway.git
synced 2025-11-21 06:59:48 -05:00
Support WLR_INPUT_DEVICE_SWITCH in sway
This commit adds support for laptop lid and tablet mode switches as provided by evdev/libinput and handled by wlroots. Adds a new bindswitch command with syntax: bindswitch <switch>:<state> <command> Where <switch> is one of: tablet for WLR_SWITCH_TYPE_TABLET_MODE lid for WLR_SWITCH_TYPE_LID <state> is one of: on for WLR_SWITCH_STATE_ON off for WLR_SWITCH_STATE_OFF toggle for WLR_SWITCH_STATE_TOGGLE (Note that WLR_SWITCH_STATE_TOGGLE doesn't map to libinput and will trigger at both on and off events)
This commit is contained in:
parent
bfa20e65d8
commit
bdb402404c
14 changed files with 339 additions and 9 deletions
|
|
@ -101,6 +101,7 @@ struct sway_container *container_find_resize_parent(struct sway_container *con,
|
|||
sway_cmd cmd_assign;
|
||||
sway_cmd cmd_bar;
|
||||
sway_cmd cmd_bindcode;
|
||||
sway_cmd cmd_bindswitch;
|
||||
sway_cmd cmd_bindsym;
|
||||
sway_cmd cmd_border;
|
||||
sway_cmd cmd_client_noop;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <wlr/interfaces/wlr_switch.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include "../include/config.h"
|
||||
|
|
@ -29,6 +30,7 @@ enum binding_input_type {
|
|||
BINDING_KEYSYM,
|
||||
BINDING_MOUSECODE,
|
||||
BINDING_MOUSESYM,
|
||||
BINDING_SWITCH
|
||||
};
|
||||
|
||||
enum binding_flags {
|
||||
|
|
@ -60,6 +62,16 @@ struct sway_mouse_binding {
|
|||
char *command;
|
||||
};
|
||||
|
||||
/**
|
||||
* A laptop switch binding and an associated command.
|
||||
*/
|
||||
struct sway_switch_binding {
|
||||
enum wlr_switch_type type;
|
||||
enum wlr_switch_state state;
|
||||
uint32_t flags;
|
||||
char *command;
|
||||
};
|
||||
|
||||
/**
|
||||
* Focus on window activation.
|
||||
*/
|
||||
|
|
@ -78,6 +90,7 @@ struct sway_mode {
|
|||
list_t *keysym_bindings;
|
||||
list_t *keycode_bindings;
|
||||
list_t *mouse_bindings;
|
||||
list_t *switch_bindings;
|
||||
bool pango;
|
||||
};
|
||||
|
||||
|
|
@ -603,6 +616,8 @@ int sway_binding_cmp_keys(const void *a, const void *b);
|
|||
|
||||
void free_sway_binding(struct sway_binding *sb);
|
||||
|
||||
void free_switch_binding(struct sway_switch_binding *binding);
|
||||
|
||||
void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding);
|
||||
|
||||
void load_swaybar(struct bar_config *bar);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ struct sway_seat_device {
|
|||
struct sway_seat *sway_seat;
|
||||
struct sway_input_device *input_device;
|
||||
struct sway_keyboard *keyboard;
|
||||
struct sway_switch *switch_device;
|
||||
struct wl_list link; // sway_seat::devices
|
||||
};
|
||||
|
||||
|
|
|
|||
19
include/sway/input/switch.h
Normal file
19
include/sway/input/switch.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef _SWAY_INPUT_SWITCH_H
|
||||
#define _SWAY_INPUT_SWITCH_H
|
||||
|
||||
#include "sway/input/seat.h"
|
||||
|
||||
struct sway_switch {
|
||||
struct sway_seat_device *seat_device;
|
||||
|
||||
struct wl_listener switch_toggle;
|
||||
};
|
||||
|
||||
struct sway_switch *sway_switch_create(struct sway_seat *seat,
|
||||
struct sway_seat_device *device);
|
||||
|
||||
void sway_switch_configure(struct sway_switch *sway_switch);
|
||||
|
||||
void sway_switch_destroy(struct sway_switch *sway_switch);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue