Commit 260ab42b authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz

Forward press timestamps

parent a3d745ed
......@@ -72,7 +72,7 @@ struct _EekGtkKeyboardPrivate
static EekColor * color_from_gdk_color (GdkColor *gdk_color);
static void on_key_pressed (EekKeyboard *keyboard,
EekKey *key,
EekKey *key, guint32 timestamp,
gpointer user_data);
static void on_key_released (EekKeyboard *keyboard,
EekKey *key,
......@@ -212,7 +212,7 @@ eek_gtk_keyboard_real_button_press_event (GtkWidget *self,
if (key) {
g_log("squeek", G_LOG_LEVEL_DEBUG, "emit EekKey pressed");
g_signal_emit_by_name (key, "pressed"); // TODO: set the pressed property on the key instead
eek_keyboard_press_key(priv->keyboard, key);
eek_keyboard_press_key(priv->keyboard, key, event->time);
}
// TODO: send time
return TRUE;
......@@ -584,8 +584,11 @@ render_released_key (GtkWidget *widget,
static void
on_key_pressed (EekKeyboard *keyboard,
EekKey *key,
guint32 timestamp,
gpointer user_data)
{
(void)keyboard;
(void)timestamp;
GtkWidget *widget = user_data;
EekGtkKeyboardPrivate *priv = EEK_GTK_KEYBOARD_GET_PRIVATE(widget);
......
......@@ -30,10 +30,6 @@
#endif /* HAVE_CONFIG_H */
#include <string.h>
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#include "eek-key.h"
#include "eek-section.h"
......
......@@ -32,6 +32,7 @@
#endif /* HAVE_CONFIG_H */
#include "eek-keyboard.h"
#include "eek-marshalers.h"
#include "eek-section.h"
#include "eek-key.h"
#include "eek-symbol.h"
......@@ -92,9 +93,9 @@ eek_modifier_key_free (EekModifierKey *modkey)
g_slice_free (EekModifierKey, modkey);
}
void eek_keyboard_press_key(EekKeyboard *keyboard, EekKey *key) {
void eek_keyboard_press_key(EekKeyboard *keyboard, EekKey *key, guint32 timestamp) {
g_log("squeek", G_LOG_LEVEL_DEBUG, "emit EekKeyboard key-pressed");
g_signal_emit (keyboard, signals[KEY_PRESSED], 0, key);
g_signal_emit (keyboard, signals[KEY_PRESSED], 0, key, timestamp);
}
static void
......@@ -279,7 +280,8 @@ set_modifiers_with_key (EekKeyboard *self,
static void
eek_keyboard_real_key_pressed (EekKeyboard *self,
EekKey *key)
EekKey *key,
guint32 timestamp)
{
EekKeyboardPrivate *priv = EEK_KEYBOARD_GET_PRIVATE(self);
EekSymbol *symbol;
......@@ -305,7 +307,7 @@ eek_keyboard_real_key_pressed (EekKeyboard *self,
EekboardContext ec = {0};
Client c = {&ec, 0, {0}};
emit_key_activated(&ec, keycode, symbol, modifiers, &c, TRUE);
emit_key_activated(&ec, keycode, symbol, modifiers, &c, TRUE, timestamp);
}
static void
......@@ -489,10 +491,11 @@ eek_keyboard_class_init (EekKeyboardClass *klass)
G_STRUCT_OFFSET(EekKeyboardClass, key_pressed),
NULL,
NULL,
g_cclosure_marshal_VOID__OBJECT,
_eek_marshal_VOID__OBJECT_UINT,
G_TYPE_NONE,
1,
EEK_TYPE_KEY);
2,
EEK_TYPE_KEY,
G_TYPE_UINT);
/**
* EekKeyboard::key-released:
......
......@@ -86,7 +86,8 @@ struct _EekKeyboardClass
/* signals */
void (* key_pressed) (EekKeyboard *self,
EekKey *key);
EekKey *key,
guint32 timestamp);
void (* key_released) (EekKeyboard *self,
EekKey *key);
......@@ -190,7 +191,7 @@ EekModifierKey *eek_modifier_key_copy
void eek_modifier_key_free
(EekModifierKey *modkey);
void eek_keyboard_press_key(EekKeyboard *keyboard, EekKey *key);
void eek_keyboard_press_key(EekKeyboard *keyboard, EekKey *key, guint32 timestamp);
G_END_DECLS
#endif /* EEK_KEYBOARD_H */
......@@ -715,7 +715,7 @@ on_key_activated(EekKeyboard *keyboard,
EekboardContext ec = {0};
Client c = {&ec, 0, {0}};
emit_key_activated(&ec, keycode, symbol, modifiers, &c, pressed);
emit_key_activated(&ec, keycode, symbol, modifiers, &c, pressed, 0);
}
static void
......
......@@ -119,16 +119,17 @@ int WaylandFakeKeyEvent(
Display* dpy,
unsigned int keycode,
Bool is_press,
unsigned long delay
uint32_t timestamp
) {
printf("Sending fake event %d press %d delay %ld\n", keycode, is_press, delay);
printf("%d: Sending fake event %d press %d\n", timestamp, keycode, is_press);
return 0;
}
static void
send_fake_modifier_key_event (Client *client,
EekModifierType modifiers,
gboolean is_pressed)
gboolean is_pressed,
uint32_t timestamp)
{
GdkDisplay *display = gdk_display_get_default ();
Display *xdisplay = NULL; //GDK_DISPLAY_XDISPLAY (display);
......@@ -141,9 +142,9 @@ send_fake_modifier_key_event (Client *client,
g_return_if_fail (keycode > 0);
WaylandFakeKeyEvent (xdisplay,
keycode,
is_pressed,
CurrentTime);
keycode,
is_pressed,
timestamp);
}
}
}
......@@ -152,7 +153,8 @@ static void
send_fake_key_event (Client *client,
guint xkeysym,
guint keyboard_modifiers,
gboolean pressed)
gboolean pressed,
uint32_t timestamp)
{
GdkDisplay *display = gdk_display_get_default ();
Display *xdisplay = NULL; // GDK_DISPLAY_XDISPLAY (display);
......@@ -188,9 +190,9 @@ send_fake_key_event (Client *client,
modifiers |= keyboard_modifiers;
send_fake_modifier_key_event (client, modifiers, TRUE);
WaylandFakeKeyEvent (xdisplay, keycode, pressed, 0);
send_fake_modifier_key_event (client, modifiers, FALSE);
send_fake_modifier_key_event (client, modifiers, TRUE, timestamp);
WaylandFakeKeyEvent (xdisplay, keycode, pressed, timestamp);
send_fake_modifier_key_event (client, modifiers, FALSE, timestamp);
if (old_keysym != xkeysym)
replace_keycode (client, keycode, &old_keysym);
......@@ -200,7 +202,8 @@ static void
send_fake_key_events (Client *client,
EekSymbol *symbol,
guint keyboard_modifiers,
gboolean pressed)
gboolean pressed,
uint32_t timestamp)
{
/* Ignore modifier keys */
if (eek_symbol_is_modifier (symbol))
......@@ -236,7 +239,7 @@ 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);
send_fake_key_event (client, xkeysym, keyboard_modifiers, pressed, timestamp);
}
}
......@@ -245,8 +248,9 @@ emit_key_activated (EekboardContext *context,
guint keycode,
EekSymbol *symbol,
guint modifiers,
Client *client,
gboolean pressed)
Client *client,
gboolean pressed,
uint32_t timestamp)
{
/* FIXME: figure out how to deal with Client after key presses go through
if (g_strcmp0 (eek_symbol_get_name (symbol), "cycle-keyboard") == 0) {
......@@ -275,7 +279,7 @@ emit_key_activated (EekboardContext *context,
return;
}
*/
send_fake_key_events (client, symbol, modifiers, pressed);
send_fake_key_events (client, symbol, modifiers, pressed, timestamp);
}
/* Finds the first key code for each modifier and saves it in modifier_keycodes */
......
#ifndef KEYEMITTER_H
#define KEYEMITTER_H
#include <inttypes.h>
#include <glib.h>
#include <X11/XKBlib.h>
......@@ -18,10 +19,10 @@ typedef struct {
void
emit_key_activated (EekboardContext *context,
guint keycode,
EekSymbol *symbol,
guint modifiers,
Client *client, gboolean pressed);
guint keycode,
EekSymbol *symbol,
guint modifiers,
Client *client, gboolean pressed, uint32_t timestamp);
gboolean
client_enable_xtest (Client *client);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment