Commit 9e5629d1 authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz

Enable Wayland's virtual-keyboard protocol

This commit includes a little restructuring necessary for keeping wayland objects properly.
It doesn't fix broken modifier functionality yet.
parent c0fdffac
......@@ -5,7 +5,7 @@ stages:
before_script:
- apt-get -y update
- apt-get -y install gnome-common gtk-doc-tools libglib2.0-dev-bin gobject-introspection libglib2.0-dev libpango1.0-dev libgtk-3-dev libcroco3-dev meson
- apt-get -y install gnome-common gtk-doc-tools libglib2.0-dev-bin gobject-introspection libglib2.0-dev libpango1.0-dev libgtk-3-dev libcroco3-dev libxkbcommon-dev meson
build_meson:
stage: build
......
......@@ -21,9 +21,6 @@ Features
- Use Wayland virtual keyboard protocol
- Use Wayland text input protocol
- Use Wayland input method protocol
- Become a Wayland layer shell
- Remove eekboard-client
- Use sm.puri.OSK0 DBus interface
- Pick up DBus interface files from /usr/share
Building
......
......@@ -425,15 +425,6 @@ eek_gtk_keyboard_new (EekKeyboard *keyboard)
return g_object_new (EEK_TYPE_GTK_KEYBOARD, "keyboard", keyboard, NULL);
}
static EekColor *
color_from_gdk_color (GdkColor *gdk_color)
{
return eek_color_new (gdk_color->red / (gdouble)0xFFFF,
gdk_color->green / (gdouble)0xFFFF,
gdk_color->blue / (gdouble)0xFFFF,
1.0);
}
static void
magnify_bounds (GtkWidget *self,
EekBounds *bounds,
......@@ -585,7 +576,7 @@ on_key_cancelled (EekKey *key,
if (!priv->renderer)
return;
render_released_key (self, key);
render_released_key (GTK_WIDGET(self), key);
}
static void
......
......@@ -256,18 +256,15 @@ set_modifiers_with_key (EekKeyboard *self,
void eek_keyboard_press_key(EekKeyboard *keyboard, EekKey *key, guint32 timestamp) {
EekKeyboardPrivate *priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
EekSymbol *symbol;
EekModifierType modifier;
eek_key_set_pressed(key, TRUE);
key = EEK_KEY(key);
priv->pressed_keys = g_list_prepend (priv->pressed_keys, key);
symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
EekSymbol *symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
if (!symbol)
return;
modifier = eek_symbol_get_modifier_mask (symbol);
EekModifierType modifier = eek_symbol_get_modifier_mask (symbol);
if (priv->modifier_behavior == EEK_MODIFIER_BEHAVIOR_NONE) {
set_modifiers_with_key (keyboard, key, priv->modifiers | modifier);
set_level_from_modifiers (keyboard);
......@@ -277,11 +274,8 @@ void eek_keyboard_press_key(EekKeyboard *keyboard, EekKey *key, guint32 timestam
guint keycode = eek_key_get_keycode (key);
guint modifiers = eek_keyboard_get_modifiers (keyboard);
// Insert
EekboardContext ec = {0};
Client c = {&ec, 0, {0}};
emit_key_activated(&ec, keycode, symbol, modifiers, &c, TRUE, timestamp);
emit_key_activated(keyboard->manager, keyboard, keycode, symbol, modifiers, TRUE, timestamp);
}
void eek_keyboard_release_key( EekKeyboard *keyboard,
......@@ -328,11 +322,8 @@ void eek_keyboard_release_key( EekKeyboard *keyboard,
guint keycode = eek_key_get_keycode (key);
guint modifiers = eek_keyboard_get_modifiers (keyboard);
// Insert
EekboardContext ec = {0};
Client c = {&ec, 0, {0}};
emit_key_activated(&ec, keycode, symbol, modifiers, &c, FALSE, timestamp);
emit_key_activated(keyboard->manager, keyboard, keycode, symbol, modifiers, FALSE, timestamp);
}
static void
......
......@@ -26,6 +26,7 @@
#define EEK_KEYBOARD_H 1
#include <glib-object.h>
#include <xkbcommon/xkbcommon.h>
#include "eek-container.h"
#include "eek-types.h"
#include "eek-layout.h"
......@@ -56,6 +57,11 @@ struct _EekKeyboard
EekContainer parent;
EekKeyboardPrivate *priv;
struct xkb_keymap *keymap;
int keymap_fd; // keymap formatted as XKB string
size_t keymap_len; // length of the data inside keymap_fd
EekboardContextService *manager; // unowned reference
};
/**
......@@ -115,12 +121,13 @@ struct _EekModifierKey {
};
typedef struct _EekModifierKey EekModifierKey;
GType eek_keyboard_get_type
(void) G_GNUC_CONST;
EekKeyboard *eek_keyboard_new (EekLayout *layout,
EekKeyboard *eek_keyboard_new (EekboardContextService *manager,
EekLayout *layout,
gdouble initial_width,
gdouble initial_height);
GType eek_keyboard_get_type
(void) G_GNUC_CONST;
EekLayout *eek_keyboard_get_layout
(EekKeyboard *keyboard);
void eek_keyboard_get_size
......
......@@ -32,6 +32,7 @@
#include "eek-layout.h"
#include "eek-keyboard.h"
#include "eekboard/eekboard-context-service.h"
G_DEFINE_ABSTRACT_TYPE (EekLayout, eek_layout, G_TYPE_OBJECT);
......@@ -55,14 +56,16 @@ eek_layout_init (EekLayout *self)
* Create a new #EekKeyboard based on @layout.
*/
EekKeyboard *
eek_keyboard_new (EekLayout *layout,
eek_keyboard_new (EekboardContextService *manager,
EekLayout *layout,
gdouble initial_width,
gdouble initial_height)
{
g_assert (EEK_IS_LAYOUT(layout));
g_assert (EEK_LAYOUT_GET_CLASS(layout)->create_keyboard);
return EEK_LAYOUT_GET_CLASS(layout)->create_keyboard (layout,
return EEK_LAYOUT_GET_CLASS(layout)->create_keyboard (manager,
layout,
initial_width,
initial_height);
}
......@@ -56,7 +56,8 @@ struct _EekLayoutClass
GObjectClass parent_class;
/*< public >*/
EekKeyboard* (* create_keyboard) (EekLayout *self,
EekKeyboard* (* create_keyboard) (EekboardContextService *manager,
EekLayout *self,
gdouble initial_width,
gdouble initial_height);
......
......@@ -150,6 +150,8 @@ typedef struct _EekBounds EekBounds;
typedef struct _EekOutline EekOutline;
typedef struct _EekColor EekColor;
typedef struct _EekboardContextService EekboardContextService;
/**
* EekPoint:
* @x: X coordinate of the point
......
......@@ -320,21 +320,24 @@ create_keyboard (EekXkbLayout *layout, EekKeyboard *keyboard)
}
static EekKeyboard *
eek_xkb_layout_real_create_keyboard (EekLayout *self,
eek_xkb_layout_real_create_keyboard (EekboardContextService *manager,
EekLayout *self,
gdouble initial_width,
gdouble initial_height)
{
EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (self);
EekBounds bounds;
EekKeyboard *keyboard;
keyboard = g_object_new (EEK_TYPE_KEYBOARD, "layout", self, NULL);
bounds.x = bounds.y = 0.0;
bounds.width = initial_width;
bounds.height = initial_height;
EekKeyboard *keyboard = g_object_new (EEK_TYPE_KEYBOARD, "layout", self, NULL);
keyboard->manager = manager;
EekBounds bounds = {
.x = 0.0,
.y = 0.0,
.width = initial_width,
.height = initial_height
};
eek_element_set_bounds (EEK_ELEMENT(keyboard), &bounds);
/* resolve modifiers dynamically assigned at run time */
EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (self);
eek_keyboard_set_num_lock_mask (keyboard,
XkbKeysymToModifiers (priv->display,
XK_Num_Lock));
......
......@@ -896,27 +896,25 @@ static const GMarkupParser prerequisites_parser = {
};
static EekKeyboard *
eek_xml_layout_real_create_keyboard (EekLayout *self,
eek_xml_layout_real_create_keyboard (EekboardContextService *manager,
EekLayout *self,
gdouble initial_width,
gdouble initial_height)
{
EekXmlLayout *layout = EEK_XML_LAYOUT (self);
EekKeyboard *keyboard;
gchar *filename, *path;
GList *loaded;
GError *error;
gboolean retval;
/* Create an empty keyboard to which geometry and symbols
information are applied. */
keyboard = g_object_new (EEK_TYPE_KEYBOARD, "layout", layout, NULL);
EekKeyboard *keyboard = g_object_new (EEK_TYPE_KEYBOARD, "layout", layout, NULL);
keyboard->manager = manager;
/* Read geometry information. */
filename = g_strdup_printf ("%s.xml", layout->priv->desc->geometry);
path = g_build_filename (layout->priv->keyboards_dir, "geometry", filename, NULL);
gchar *filename = g_strdup_printf ("%s.xml", layout->priv->desc->geometry);
gchar *path = g_build_filename (layout->priv->keyboards_dir, "geometry", filename, NULL);
g_free (filename);
error = NULL;
GError *error = NULL;
retval = parse_geometry (path, keyboard, &error);
g_free (path);
if (!retval) {
......@@ -929,7 +927,7 @@ eek_xml_layout_real_create_keyboard (EekLayout *self,
}
/* Read symbols information. */
loaded = NULL;
GList *loaded = NULL;
retval = parse_symbols_with_prerequisites (layout->priv->keyboards_dir,
layout->priv->desc->symbols,
keyboard,
......
......@@ -29,8 +29,17 @@
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eekboard/key-emitter.h"
#include "eekboard/eekboard-context-service.h"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/random.h> // TODO: this is Linux-specific
#include <xkbcommon/xkbcommon.h>
#include "eekboard/key-emitter.h"
#include "wayland.h"
//#include "eekboard/eekboard-xklutil.h"
//#include "eek/eek-xkl.h"
......@@ -116,8 +125,9 @@ eekboard_context_service_real_create_keyboard (EekboardContextService *self,
g_warning ("can't create keyboard %s: %s",
keyboard_type, error->message);
g_error_free (error);
keyboard_type = "us";
error = NULL;
layout = eek_xml_layout_new ("us", &error);
layout = eek_xml_layout_new (keyboard_type, &error);
if (layout == NULL) {
g_error ("failed to create fallback layout: %s", error->message);
g_error_free (error);
......@@ -125,9 +135,54 @@ eekboard_context_service_real_create_keyboard (EekboardContextService *self,
}
}
}
keyboard = eek_keyboard_new (layout, CSW, CSH);
keyboard = eek_keyboard_new (self, layout, CSW, CSH);
g_object_unref (layout);
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!context) {
g_error("No context created");
}
struct xkb_rule_names rules = { 0 };
rules.layout = strdup(keyboard_type);
struct xkb_keymap *keymap = xkb_keymap_new_from_names(context, &rules,
XKB_KEYMAP_COMPILE_NO_FLAGS);
if (!keymap) {
g_error("Bad keymap");
}
keyboard->keymap = keymap;
char *keymap_str = xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1);
int f = open("km", O_CREAT|O_WRONLY);
write(f, keymap_str, strlen(keymap_str) + 1);
if (!keymap_str) {
g_error("Keymap was not serialized");
}
keyboard->keymap_len = strlen(keymap_str) + 1;
char *path = strdup("/eek_keymap-XXXXXX");
char *r = &path[strlen(path) - 6];
getrandom(r, 6, GRND_NONBLOCK);
for (uint i = 0; i < 6; i++) {
r[i] = (r[i] & 0b1111111) | 0b1000000; // A-z
r[i] = r[i] > 'z' ? '?' : r[i]; // The randomizer doesn't need to be good...
}
int keymap_fd = shm_open(path, O_RDWR | O_CREAT | O_EXCL, 0600);
if (keymap_fd < 0) {
g_error("Failed to set up keymap fd");
}
keyboard->keymap_fd = keymap_fd;
shm_unlink(path);
if (ftruncate(keymap_fd, (off_t)keyboard->keymap_len)) {
g_error("Failed to increase keymap fd size");
}
char *ptr = mmap(NULL, keyboard->keymap_len, PROT_WRITE, MAP_SHARED,
keymap_fd, 0);
if ((void*)ptr == (void*)-1) {
g_error("Failed to set up mmap");
}
strcpy(ptr, keymap_str);
munmap(ptr, keyboard->keymap_len);
free(keymap_str);
return keyboard;
}
......@@ -233,14 +288,10 @@ settings_get_layout(GSettings *settings, char **type, char **layout)
g_variant_iter_free(iter);
}
static void
settings_update_layout(EekboardContextService *context) {
EekboardContextServiceClass *klass = EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context);
static guint keyboard_id = 0;
g_autofree gchar *keyboard_type = NULL;
g_autofree gchar *keyboard_layout = NULL;
settings_get_layout(context->priv->settings, &keyboard_type, &keyboard_layout);
if (!keyboard_type) {
......@@ -250,10 +301,13 @@ settings_update_layout(EekboardContextService *context) {
keyboard_layout = g_strdup("undefined");
}
// generic part follows
static guint keyboard_id = 0;
EekKeyboard *keyboard = g_hash_table_lookup(context->priv->keyboard_hash,
GUINT_TO_POINTER(keyboard_id));
// create a keyboard
if (!keyboard) {
EekboardContextServiceClass *klass = EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context);
keyboard = klass->create_keyboard (context, keyboard_layout);
eek_keyboard_set_modifier_behavior (keyboard,
EEK_MODIFIER_BEHAVIOR_LATCH);
......@@ -270,7 +324,6 @@ settings_update_layout(EekboardContextService *context) {
context->priv->keyboard = keyboard;
// TODO: this used to save the group, why?
//group = eek_element_get_group (EEK_ELEMENT(context->priv->keyboard));
g_object_notify (G_OBJECT(context), "keyboard");
}
......@@ -278,16 +331,24 @@ static gboolean
settings_handle_layout_changed(GSettings *s,
gpointer keys, gint n_keys,
gpointer user_data) {
(void)s;
(void)keys;
(void)n_keys;
EekboardContextService *context = user_data;
settings_update_layout(context);
return TRUE;
}
static void
eekboard_context_service_constructed (GObject *object)
{
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE (object);
context->virtual_keyboard = zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(
squeek_wayland->virtual_keyboard_manager,
squeek_wayland->seat);
if (!context->virtual_keyboard) {
g_error("Programmer error: Failed to receive a virtual keyboard instance");
}
settings_update_layout(context);
}
......@@ -563,3 +624,11 @@ eekboard_context_service_get_fullscreen (EekboardContextService *context)
{
return context->priv->fullscreen;
}
void eekboard_context_service_set_keymap(EekboardContextService *context,
const EekKeyboard *keyboard)
{
zwp_virtual_keyboard_v1_keymap(context->virtual_keyboard,
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
keyboard->keymap_fd, keyboard->keymap_len);
}
......@@ -36,14 +36,15 @@ G_BEGIN_DECLS
#define EEKBOARD_IS_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_CONTEXT_SERVICE))
#define EEKBOARD_CONTEXT_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServiceClass))
typedef struct _EekboardContextService EekboardContextService;
typedef struct _EekboardContextServiceClass EekboardContextServiceClass;
typedef struct _EekboardContextServicePrivate EekboardContextServicePrivate;
/**
* EekboardContextService:
*
* TODO: Restrict to managing keyboard layouts, and maybe button rerpeats.
* TODO: Restrict to managing keyboard layouts, and maybe button repeats,
* and the virtual keyboard protocol.
*
* The #EekboardContextService structure contains only private data
* and should only be accessed using the provided API.
......@@ -52,6 +53,8 @@ struct _EekboardContextService {
GObject parent;
EekboardContextServicePrivate *priv;
struct zwp_virtual_keyboard_v1 *virtual_keyboard;
};
/**
......@@ -96,5 +99,8 @@ EekKeyboard *eekboard_context_service_get_keyboard
gboolean eekboard_context_service_get_fullscreen
(EekboardContextService *context);
void eekboard_context_service_set_keymap(EekboardContextService *context,
const EekKeyboard *keyboard);
G_END_DECLS
#endif /* EEKBOARD_CONTEXT_SERVICE_H */
......@@ -41,6 +41,8 @@ typedef struct _EekboardServicePrivate EekboardServicePrivate;
/**
* EekboardService:
*
* Manages DBus interaction.
*
* The #EekboardService structure contains only private data and
* should only be accessed using the provided API.
*/
......
......@@ -20,9 +20,24 @@
/* This file is responsible for managing keycode data and emitting keycodes. */
#include "eekboard/key-emitter.h"
#include "eekboard/keymap.h"
#include <gdk/gdk.h>
#include "eekboard/eekboard-context-service.h"
// TODO: decide whether it's this struct that carries the keyboard around in key-emitter or if the whole manager should be dragged around
// if this is the carrier, then it should be made part of the manager
// hint: check which fields need to be persisted between keypresses; which between keyboards
typedef struct {
struct zwp_virtual_keyboard_v1 *virtual_keyboard; // unowned copy
struct xkb_keymap *keymap; // unowned copy
XkbDescRec *xkb;
guint modifier_keycodes[8];
gint group;
} SeatEmitter;
/* The following functions for keyboard mapping change are direct
translation of the code in Caribou (in libcaribou/xadapter.vala):
......@@ -33,7 +48,7 @@
/* Find an unused keycode where a keysym can be assigned. Restricted to Level 1 */
static guint
get_replaced_keycode (Client *client)
get_replaced_keycode (SeatEmitter *client)
{
guint keycode;
return 0; // FIXME: no xkb allocated yet
......@@ -58,7 +73,7 @@ return 0; // FIXME: no xkb allocated yet
non-zero keycode), it simply changes the current map with the
specified KEYCODE and KEYSYM. */
static gboolean
replace_keycode (Client *client,
replace_keycode (SeatEmitter *emitter,
guint keycode,
guint *keysym)
{
......@@ -68,8 +83,8 @@ replace_keycode (Client *client,
int keysyms_per_keycode;
KeySym *syms;
return TRUE; // FIXME: no xkb allocated at the moment, pretending all is fine
g_return_val_if_fail (client->xkb->min_key_code <= keycode &&
keycode <= client->xkb->max_key_code,
g_return_val_if_fail (emitter->xkb->min_key_code <= keycode &&
keycode <= emitter->xkb->max_key_code,
FALSE);
g_return_val_if_fail (keysym != NULL, FALSE);
/*
......@@ -87,20 +102,19 @@ return TRUE; // FIXME: no xkb allocated at the moment, pretending all is fine
}
static gboolean
get_keycode_from_gdk_keymap (Client *client,
get_keycode_from_gdk_keymap (SeatEmitter *emitter,
guint keysym,
guint *keycode,
guint *modifiers)
{
GdkKeymap *keymap = gdk_keymap_get_default ();
GdkKeymapKey *keys, *best_match = NULL;
gint n_keys, i;
guint n_keys, i;
if (!gdk_keymap_get_entries_for_keyval (keymap, keysym, &keys, &n_keys))
if (!squeek_keymap_get_entries_for_keyval (emitter->keymap, keysym, &keys, &n_keys))
return FALSE;
for (i = 0; i < n_keys; i++)
if (keys[i].group == client->context->group)
if (keys[i].group == emitter->group)
best_match = &keys[i];
if (!best_match) {
......@@ -115,69 +129,63 @@ get_keycode_from_gdk_keymap (Client *client,
return TRUE;
}
int WaylandFakeKeyEvent(
Display* dpy,
int send_virtual_keyboard_key(
struct zwp_virtual_keyboard_v1 *keyboard,
unsigned int keycode,
Bool is_press,
unsigned is_press,
uint32_t timestamp
) {
printf("%d: Sending fake event %d press %d\n", timestamp, keycode, is_press);
zwp_virtual_keyboard_v1_key(keyboard, timestamp, keycode, (unsigned)is_press);
return 0;
}
static void
send_fake_modifier_key_event (Client *client,
send_fake_modifier_key_event (SeatEmitter *emitter,
EekModifierType modifiers,
gboolean is_pressed,
uint32_t timestamp)
{
GdkDisplay *display = gdk_display_get_default ();
Display *xdisplay = NULL; //GDK_DISPLAY_XDISPLAY (display);
unsigned long i;
for (i = 0; i < G_N_ELEMENTS(client->modifier_keycodes); i++) {
for (i = 0; i < G_N_ELEMENTS(emitter->modifier_keycodes); i++) {
if (modifiers & (1 << i)) {
guint keycode = client->modifier_keycodes[i];
guint keycode = emitter->modifier_keycodes[i];
printf("Trying to send a modifier %ld press %d\n", i, is_pressed);
g_return_if_fail (keycode > 0);
WaylandFakeKeyEvent (xdisplay,
keycode,
is_pressed,
timestamp);
send_virtual_keyboard_key (emitter->virtual_keyboard,
keycode,
is_pressed,
timestamp);
}
}
}
static void
send_fake_key_event (Client *client,
send_fake_key_event (SeatEmitter *emitter,
guint xkeysym,
guint keyboard_modifiers,
gboolean pressed,
uint32_t timestamp)
{
GdkDisplay *display = gdk_display_get_default ();
Display *xdisplay = NULL; // GDK_DISPLAY_XDISPLAY (display);
EekModifierType modifiers;
guint keycode;
guint old_keysym = xkeysym;
g_return_if_fail (xkeysym > 0);
modifiers = 0;
if (!get_keycode_from_gdk_keymap (client, xkeysym, &keycode, &modifiers)) {
keycode = get_replaced_keycode (client);
guint keycode;
if (!get_keycode_from_gdk_keymap (emitter, xkeysym, &keycode, &modifiers)) {
keycode = get_replaced_keycode (emitter);
if (keycode == 0) {
g_warning ("no available keycode to replace");
return;
}
if (!replace_keycode (client, keycode, &old_keysym)) {
if (!replace_keycode (emitter, keycode, &old_keysym)) {
g_warning ("failed to lookup X keysym %X", xkeysym);
return;
}
}
/* Clear level shift modifiers */
keyboard_modifiers &= (unsigned)~EEK_SHIFT_MASK;
keyboard_modifiers &= (unsigned)~EEK_LOCK_MASK;
......@@ -190,16 +198,18 @@ send_fake_key_event (Client *client,
modifiers |= keyboard_modifiers;
send_fake_modifier_key_event (client, modifiers, TRUE, timestamp);
WaylandFakeKeyEvent (xdisplay, keycode, pressed, timestamp);
send_fake_modifier_key_event (client, modifiers, FALSE, timestamp);
send_fake_modifier_key_event (emitter, modifiers, TRUE, timestamp);
// There's something magical about subtracting/adding 8 to keycodes for some reason
send_virtual_keyboard_key (emitter->virtual_keyboard, keycode - 8, (unsigned)pressed, timestamp);
send_fake_modifier_key_event (emitter, modifiers, FALSE, timestamp);
if (old_keysym != xkeysym)
replace_keycode (client, keycode, &old_keysym);
replace_keycode (emitter, keycode, &old_keysym);
}
static void
send_fake_key_events (Client *client,
send_fake_key_events (SeatEmitter *emitter,
EekSymbol *symbol,
guint keyboard_modifiers,
gboolean pressed,
......@@ -239,16 +249,16 @@ send_fake_key_events (Client *client,
if (EEK_IS_KEYSYM(symbol)) {
guint xkeysym = eek_keysym_get_xkeysym (EEK_KEYSYM(symbol));
send_fake_key_event (client, xkeysym, keyboard_modifiers, pressed, timestamp);
send_fake_key_event (emitter, xkeysym, keyboard_modifiers, pressed, timestamp);
}
}
void
emit_key_activated (EekboardContext *context,
emit_key_activated (EekboardContextService *manager,
EekKeyboard *keyboard,
guint keycode,
EekSymbol *symbol,
guint modifiers,
Client *client,
gboolean pressed,
uint32_t timestamp)
{
......@@ -279,12 +289,15 @@ emit_key_activated (EekboardContext *context,
return;
}
*/
send_fake_key_events (client, symbol, modifiers, pressed, timestamp);
SeatEmitter emitter = {0};
emitter.virtual_keyboard = manager->virtual_keyboard;
emitter.keymap = keyboard->keymap;
send_fake_key_events (&emitter, symbol, modifiers, pressed, timestamp);
}
/* Finds the first key code for each modifier and saves it in modifier_keycodes */
static void
update_modifier_keycodes (Client *client)
update_modifier_keycodes (SeatEmitter *client)
{
GdkDisplay *display = gdk_display_get_default ();
Display *xdisplay = NULL; // GDK_DISPLAY_XDISPLAY (display);
......@@ -307,7 +320,7 @@ update_modifier_keycodes (Client *client)
}
gboolean
client_enable_xtest (Client *client)
client_enable_xtest (SeatEmitter *client)
{
//GdkDisplay *display = gdk_display_get_default ();
//Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
......@@ -340,7 +353,7 @@ client_enable_xtest (Client *client)
}
void
client_disable_xtest (Client *client)
client_disable_xtest (SeatEmitter *client)
{
//if (client->xkb) {
// XkbFreeKeyboard (client->xkb, 0, TRUE); /* free_all = TRUE */
......
......@@ -7,26 +7,12 @@
#include "eek/eek.h"
typedef struct {
gint group;
} EekboardContext;
typedef struct {
EekboardContext *context;
XkbDescRec *xkb;
guint modifier_keycodes[8];
} Client;
#include "virtual-keyboard-unstable-v1-client-protocol.h"
void
emit_key_activated (EekboardContext *context,
emit_key_activated (EekboardContextService *manager, EekKeyboard *keyboard,
guint keycode,
EekSymbol *symbol,
guint modifiers,
Client *client, gboolean pressed, uint32_t timestamp);
gboolean
client_enable_xtest (Client *client);
void
client_disable_xtest (Client *client);
gboolean pressed, uint32_t timestamp);
#endif // KEYEMITTER_H
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2000 Red Hat, Inc.