Merge branch 'swaywm:master' into disable_titlebar

This commit is contained in:
neuromagus 2024-03-07 18:06:32 +03:00 committed by GitHub
commit b57879f9b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 13 deletions

View File

@ -37,19 +37,26 @@
struct sway_config *config = NULL;
static struct xkb_state *keysym_translation_state_create(
struct xkb_rule_names rules) {
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_SECURE_GETENV);
struct xkb_rule_names rules, uint32_t context_flags) {
struct xkb_context *context = xkb_context_new(context_flags | XKB_CONTEXT_NO_SECURE_GETENV);
struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_names(
context,
&rules,
XKB_KEYMAP_COMPILE_NO_FLAGS);
xkb_context_unref(context);
if (xkb_keymap == NULL) {
sway_log(SWAY_ERROR, "Failed to compile keysym translation XKB keymap");
return NULL;
}
return xkb_state_new(xkb_keymap);
}
static void keysym_translation_state_destroy(
struct xkb_state *state) {
if (state == NULL) {
return;
}
xkb_keymap_unref(xkb_state_get_keymap(state));
xkb_state_unref(state);
}
@ -338,8 +345,14 @@ static void config_defaults(struct sway_config *config) {
// The keysym to keycode translation
struct xkb_rule_names rules = {0};
config->keysym_translation_state =
keysym_translation_state_create(rules);
config->keysym_translation_state = keysym_translation_state_create(rules, 0);
if (config->keysym_translation_state == NULL) {
config->keysym_translation_state = keysym_translation_state_create(rules,
XKB_CONTEXT_NO_ENVIRONMENT_NAMES);
}
if (config->keysym_translation_state == NULL) {
goto cleanup;
}
return;
cleanup:
@ -986,8 +999,12 @@ void translate_keysyms(struct input_config *input_config) {
struct xkb_rule_names rules = {0};
input_config_fill_rule_names(input_config, &rules);
config->keysym_translation_state =
keysym_translation_state_create(rules);
config->keysym_translation_state = keysym_translation_state_create(rules, 0);
if (config->keysym_translation_state == NULL) {
sway_log(SWAY_ERROR, "Failed to create keysym translation XKB state "
"for device '%s'", input_config->identifier);
return;
}
for (int i = 0; i < config->modes->length; ++i) {
struct sway_mode *mode = config->modes->items[i];

View File

@ -65,8 +65,15 @@ struct sway_seat *input_manager_sway_seat_from_wlr_seat(struct wlr_seat *wlr_sea
}
char *input_device_get_identifier(struct wlr_input_device *device) {
int vendor = device->vendor;
int product = device->product;
int vendor = 0, product = 0;
#if WLR_HAS_LIBINPUT_BACKEND
if (wlr_input_device_is_libinput(device)) {
struct libinput_device *libinput_dev = wlr_libinput_get_device_handle(device);
vendor = libinput_device_get_id_vendor(libinput_dev);
product = libinput_device_get_id_product(libinput_dev);
}
#endif
char *name = strdup(device->name ? device->name : "");
strip_whitespace(name);

View File

@ -1097,10 +1097,6 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
json_object_new_string(device->identifier));
json_object_object_add(object, "name",
json_object_new_string(device->wlr_device->name));
json_object_object_add(object, "vendor",
json_object_new_int(device->wlr_device->vendor));
json_object_object_add(object, "product",
json_object_new_int(device->wlr_device->product));
json_object_object_add(object, "type",
json_object_new_string(
input_device_get_type(device)));
@ -1154,6 +1150,10 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
libinput_dev = wlr_libinput_get_device_handle(device->wlr_device);
json_object_object_add(object, "libinput",
describe_libinput_device(libinput_dev));
json_object_object_add(object, "vendor",
json_object_new_int(libinput_device_get_id_vendor(libinput_dev)));
json_object_object_add(object, "product",
json_object_new_int(libinput_device_get_id_product(libinput_dev)));
}
#endif