mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
wayland-keyboard: Add support for the repeat_info event in Wayland v4
This commit is contained in:
parent
c30ef668de
commit
4f55e16fe9
@ -290,6 +290,62 @@ meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard)
|
|||||||
xkb_state_serialize_layout (xkb_info->state, XKB_STATE_LAYOUT_EFFECTIVE));
|
xkb_state_serialize_layout (xkb_info->state, XKB_STATE_LAYOUT_EFFECTIVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
notify_key_repeat_for_resource (MetaWaylandKeyboard *keyboard,
|
||||||
|
struct wl_resource *keyboard_resource)
|
||||||
|
{
|
||||||
|
if (wl_resource_get_version (keyboard_resource) >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION)
|
||||||
|
{
|
||||||
|
gboolean repeat;
|
||||||
|
unsigned int delay, rate;
|
||||||
|
|
||||||
|
repeat = g_settings_get_boolean (keyboard->settings, "repeat");
|
||||||
|
|
||||||
|
if (repeat)
|
||||||
|
{
|
||||||
|
unsigned int interval;
|
||||||
|
interval = g_settings_get_uint (keyboard->settings, "repeat-interval");
|
||||||
|
/* Our setting is in the milliseconds between keys. "rate" is the number
|
||||||
|
* of keys per second. */
|
||||||
|
rate = (1000 / interval);
|
||||||
|
delay = g_settings_get_uint (keyboard->settings, "delay");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rate = 0;
|
||||||
|
delay = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_keyboard_send_repeat_info (keyboard_resource, rate, delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
notify_key_repeat (MetaWaylandKeyboard *keyboard)
|
||||||
|
{
|
||||||
|
struct wl_resource *keyboard_resource;
|
||||||
|
|
||||||
|
wl_resource_for_each (keyboard_resource, &keyboard->resource_list)
|
||||||
|
{
|
||||||
|
notify_key_repeat_for_resource (keyboard, keyboard_resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_resource_for_each (keyboard_resource, &keyboard->focus_resource_list)
|
||||||
|
{
|
||||||
|
notify_key_repeat_for_resource (keyboard, keyboard_resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
settings_changed (GSettings *settings,
|
||||||
|
const char *key,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
MetaWaylandKeyboard *keyboard = data;
|
||||||
|
|
||||||
|
notify_key_repeat (keyboard);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
|
meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
|
||||||
struct wl_display *display)
|
struct wl_display *display)
|
||||||
@ -315,6 +371,10 @@ meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
|
|||||||
"evdev",
|
"evdev",
|
||||||
"pc105",
|
"pc105",
|
||||||
"us", "", "", 0);
|
"us", "", "", 0);
|
||||||
|
|
||||||
|
keyboard->settings = g_settings_new ("org.gnome.settings-daemon.peripherals.keyboard");
|
||||||
|
g_signal_connect (keyboard->settings, "changed",
|
||||||
|
G_CALLBACK (settings_changed), keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -338,6 +398,8 @@ meta_wayland_keyboard_release (MetaWaylandKeyboard *keyboard)
|
|||||||
|
|
||||||
/* XXX: What about keyboard->resource_list? */
|
/* XXX: What about keyboard->resource_list? */
|
||||||
wl_array_release (&keyboard->keys);
|
wl_array_release (&keyboard->keys);
|
||||||
|
|
||||||
|
g_object_unref (keyboard->settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -589,6 +651,8 @@ meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
|
|||||||
keyboard->xkb_info.keymap_fd,
|
keyboard->xkb_info.keymap_fd,
|
||||||
keyboard->xkb_info.keymap_size);
|
keyboard->xkb_info.keymap_size);
|
||||||
|
|
||||||
|
notify_key_repeat_for_resource (keyboard, cr);
|
||||||
|
|
||||||
if (keyboard->focus_surface && wl_resource_get_client (keyboard->focus_surface->resource) == client)
|
if (keyboard->focus_surface && wl_resource_get_client (keyboard->focus_surface->resource) == client)
|
||||||
meta_wayland_keyboard_set_focus (keyboard, keyboard->focus_surface);
|
meta_wayland_keyboard_set_focus (keyboard, keyboard->focus_surface);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,8 @@ struct _MetaWaylandKeyboard
|
|||||||
|
|
||||||
struct xkb_context *xkb_context;
|
struct xkb_context *xkb_context;
|
||||||
MetaWaylandXkbInfo xkb_info;
|
MetaWaylandXkbInfo xkb_info;
|
||||||
|
|
||||||
|
GSettings *settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
void meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
|
void meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#define META_WL_DATA_DEVICE_MANAGER_VERSION 1
|
#define META_WL_DATA_DEVICE_MANAGER_VERSION 1
|
||||||
#define META_XDG_SHELL_VERSION 1
|
#define META_XDG_SHELL_VERSION 1
|
||||||
#define META_WL_SHELL_VERSION 1
|
#define META_WL_SHELL_VERSION 1
|
||||||
#define META_WL_SEAT_VERSION 3
|
#define META_WL_SEAT_VERSION 4
|
||||||
#define META_WL_OUTPUT_VERSION 2
|
#define META_WL_OUTPUT_VERSION 2
|
||||||
#define META_XSERVER_VERSION 1
|
#define META_XSERVER_VERSION 1
|
||||||
#define META_GTK_SHELL_VERSION 1
|
#define META_GTK_SHELL_VERSION 1
|
||||||
@ -51,7 +51,7 @@
|
|||||||
#define META_WL_DATA_DEVICE_VERSION 1 /* from wl_data_device_manager */
|
#define META_WL_DATA_DEVICE_VERSION 1 /* from wl_data_device_manager */
|
||||||
#define META_WL_SURFACE_VERSION 3 /* from wl_compositor */
|
#define META_WL_SURFACE_VERSION 3 /* from wl_compositor */
|
||||||
#define META_WL_POINTER_VERSION 3 /* from wl_seat */
|
#define META_WL_POINTER_VERSION 3 /* from wl_seat */
|
||||||
#define META_WL_KEYBOARD_VERSION 3 /* from wl_seat */
|
#define META_WL_KEYBOARD_VERSION 4 /* from wl_seat */
|
||||||
#define META_WL_TOUCH_VERSION 3 /* from wl_seat */
|
#define META_WL_TOUCH_VERSION 3 /* from wl_seat */
|
||||||
#define META_WL_REGION_VERSION 1 /* from wl_compositor */
|
#define META_WL_REGION_VERSION 1 /* from wl_compositor */
|
||||||
#define META_XDG_SURFACE_VERSION 1 /* from xdg_shell */
|
#define META_XDG_SURFACE_VERSION 1 /* from xdg_shell */
|
||||||
|
Loading…
Reference in New Issue
Block a user