mirror of
https://github.com/labwc/labwc.git
synced 2026-03-10 05:33:47 -04:00
config: support libinput sendEventsMode
This allows to enable / disable libinput devices. Co-Authored-By: @Consolatis
This commit is contained in:
parent
9456b50983
commit
6fb06c54c2
6 changed files with 78 additions and 6 deletions
|
|
@ -684,6 +684,20 @@ extending outward from the snapped edge.
|
||||||
|
|
||||||
The default method depends on the touchpad hardware.
|
The default method depends on the touchpad hardware.
|
||||||
|
|
||||||
|
*<libinput><device><sendEventsMode>* [yes|no|disabledOnExternalMouse]
|
||||||
|
Optionally enable or disable sending any device events.
|
||||||
|
|
||||||
|
The options available are:
|
||||||
|
- *yes* - Events are sent as usual
|
||||||
|
- *no* - No events are sent from this device
|
||||||
|
- *disabledOnExternalMouse* - This device does not send events if an
|
||||||
|
external mouse has been detected.
|
||||||
|
|
||||||
|
It is possible to prevent events from a device in the config and then do
|
||||||
|
a Reconfigure to temporarily enable / disable specific devices.
|
||||||
|
|
||||||
|
By default, this setting is not configured.
|
||||||
|
|
||||||
## WINDOW RULES
|
## WINDOW RULES
|
||||||
|
|
||||||
Two types of window rules are supported, actions and properties. They are
|
Two types of window rules are supported, actions and properties. They are
|
||||||
|
|
|
||||||
|
|
@ -473,6 +473,7 @@
|
||||||
- accelProfile [flat|adaptive]
|
- accelProfile [flat|adaptive]
|
||||||
- tapButtonMap [lrm|lmr]
|
- tapButtonMap [lrm|lmr]
|
||||||
- clickMethod [none|buttonAreas|clickfinger]
|
- clickMethod [none|buttonAreas|clickfinger]
|
||||||
|
- sendEventsMode [yes|no|disabledOnExternalMouse]
|
||||||
-->
|
-->
|
||||||
<libinput>
|
<libinput>
|
||||||
<device category="default">
|
<device category="default">
|
||||||
|
|
@ -487,6 +488,7 @@
|
||||||
<middleEmulation></middleEmulation>
|
<middleEmulation></middleEmulation>
|
||||||
<disableWhileTyping></disableWhileTyping>
|
<disableWhileTyping></disableWhileTyping>
|
||||||
<clickMethod></clickMethod>
|
<clickMethod></clickMethod>
|
||||||
|
<sendEventsMode></sendEventsMode>
|
||||||
</device>
|
</device>
|
||||||
</libinput>
|
</libinput>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,13 @@ struct libinput_category {
|
||||||
int left_handed;
|
int left_handed;
|
||||||
enum libinput_config_tap_state tap;
|
enum libinput_config_tap_state tap;
|
||||||
enum libinput_config_tap_button_map tap_button_map;
|
enum libinput_config_tap_button_map tap_button_map;
|
||||||
int tap_and_drag; /* -1 or libinput_config_drag_state */
|
int tap_and_drag; /* -1 or libinput_config_drag_state */
|
||||||
int drag_lock; /* -1 or libinput_config_drag_lock_state */
|
int drag_lock; /* -1 or libinput_config_drag_lock_state */
|
||||||
int accel_profile; /* -1 or libinput_config_accel_profile */
|
int accel_profile; /* -1 or libinput_config_accel_profile */
|
||||||
int middle_emu; /* -1 or libinput_config_middle_emulation_state */
|
int middle_emu; /* -1 or libinput_config_middle_emulation_state */
|
||||||
int dwt; /* -1 or libinput_config_dwt_state */
|
int dwt; /* -1 or libinput_config_dwt_state */
|
||||||
int click_method; /* -1 or libinput_config_click_method */
|
int click_method; /* -1 or libinput_config_click_method */
|
||||||
|
int send_events_mode; /* -1 or libinput_config_send_events_mode */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum lab_libinput_device_type get_device_type(const char *s);
|
enum lab_libinput_device_type get_device_type(const char *s);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ libinput_category_init(struct libinput_category *l)
|
||||||
l->middle_emu = -1;
|
l->middle_emu = -1;
|
||||||
l->dwt = -1;
|
l->dwt = -1;
|
||||||
l->click_method = -1;
|
l->click_method = -1;
|
||||||
|
l->send_events_mode = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum lab_libinput_device_type
|
enum lab_libinput_device_type
|
||||||
|
|
|
||||||
|
|
@ -461,6 +461,29 @@ get_accel_profile(const char *s)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
get_send_events_mode(const char *s)
|
||||||
|
{
|
||||||
|
if (!s) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = parse_bool(s, -1);
|
||||||
|
if (ret >= 0) {
|
||||||
|
return ret
|
||||||
|
? LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
|
||||||
|
: LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcasecmp(s, "disabledOnExternalMouse")) {
|
||||||
|
return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
err:
|
||||||
|
wlr_log(WLR_INFO, "Not a recognised send events mode");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fill_libinput_category(char *nodename, char *content)
|
fill_libinput_category(char *nodename, char *content)
|
||||||
{
|
{
|
||||||
|
|
@ -576,6 +599,9 @@ fill_libinput_category(char *nodename, char *content)
|
||||||
} else {
|
} else {
|
||||||
wlr_log(WLR_ERROR, "invalid clickMethod");
|
wlr_log(WLR_ERROR, "invalid clickMethod");
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(nodename, "sendEventsMode")) {
|
||||||
|
current_libinput_category->send_events_mode =
|
||||||
|
get_send_events_mode(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
28
src/seat.c
28
src/seat.c
|
|
@ -91,6 +91,24 @@ get_category(struct wlr_input_device *device)
|
||||||
static void
|
static void
|
||||||
configure_libinput(struct wlr_input_device *wlr_input_device)
|
configure_libinput(struct wlr_input_device *wlr_input_device)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* TODO: We do not check any return values for the various
|
||||||
|
* libinput_device_config_*_set_*() calls. It would
|
||||||
|
* be nice if we could inform the users via log file
|
||||||
|
* that some libinput setting could not be applied.
|
||||||
|
*
|
||||||
|
* TODO: We are currently using int32_t with -1 as default
|
||||||
|
* to desribe the not-configured state. This is not
|
||||||
|
* really optimal as we can't properly deal with
|
||||||
|
* enum values that are 0. After some discussion via
|
||||||
|
* IRC the best way forward seem to be to use a
|
||||||
|
* uint32_t instead and UINT32_MAX as indicator for
|
||||||
|
* a not-configured state. This allows to properly
|
||||||
|
* test the enum being a member of a bitset via
|
||||||
|
* mask & value == value. All libinput enums are
|
||||||
|
* way below UINT32_MAX.
|
||||||
|
*/
|
||||||
|
|
||||||
if (!wlr_input_device) {
|
if (!wlr_input_device) {
|
||||||
wlr_log(WLR_ERROR, "no wlr_input_device");
|
wlr_log(WLR_ERROR, "no wlr_input_device");
|
||||||
return;
|
return;
|
||||||
|
|
@ -209,6 +227,16 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
|
||||||
|
|
||||||
libinput_device_config_click_set_method(libinput_dev, dc->click_method);
|
libinput_device_config_click_set_method(libinput_dev, dc->click_method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((dc->send_events_mode != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
|
||||||
|
&& (libinput_device_config_send_events_get_modes(libinput_dev)
|
||||||
|
& dc->send_events_mode) == 0)
|
||||||
|
|| dc->send_events_mode < 0) {
|
||||||
|
wlr_log(WLR_INFO, "send events mode not configured");
|
||||||
|
} else {
|
||||||
|
wlr_log(WLR_INFO, "send events mode configured");
|
||||||
|
libinput_device_config_send_events_set_mode(libinput_dev, dc->send_events_mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wlr_output *
|
static struct wlr_output *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue