Commit a3d745ed authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz

Moved key pressing from context to keyboard

parent 40a92fe7
......@@ -211,7 +211,7 @@ eek_gtk_keyboard_real_button_press_event (GtkWidget *self,
(gdouble)event->y);
if (key) {
g_log("squeek", G_LOG_LEVEL_DEBUG, "emit EekKey pressed");
g_signal_emit_by_name (key, "pressed");
g_signal_emit_by_name (key, "pressed"); // TODO: set the pressed property on the key instead
eek_keyboard_press_key(priv->keyboard, key);
}
// TODO: send time
......
......@@ -36,6 +36,7 @@
#include "eek-key.h"
#include "eek-symbol.h"
#include "eek-enumtypes.h"
#include "eekboard/key-emitter.h"
enum {
PROP_0,
......@@ -96,15 +97,6 @@ void eek_keyboard_press_key(EekKeyboard *keyboard, EekKey *key) {
g_signal_emit (keyboard, signals[KEY_PRESSED], 0, key);
}
static void
on_key_pressed (EekSection *section,
EekKey *key,
EekKeyboard *keyboard)
{
g_log("squeek", G_LOG_LEVEL_DEBUG, "DO NOT emit EekKeyboard key-pressed");
//g_signal_emit (keyboard, signals[KEY_PRESSED], 0, key);
}
static void
on_key_released (EekSection *section,
EekKey *key,
......@@ -304,6 +296,16 @@ eek_keyboard_real_key_pressed (EekKeyboard *self,
set_modifiers_with_key (self, key, priv->modifiers | modifier);
set_level_from_modifiers (self);
}
// "Borrowed" from eek-context-service; doesn't influence the state but forwards the event
guint keycode = eek_key_get_keycode (key);
guint modifiers = eek_keyboard_get_modifiers (self);
// Insert
EekboardContext ec = {0};
Client c = {&ec, 0, {0}};
emit_key_activated(&ec, keycode, symbol, modifiers, &c, TRUE);
}
static void
......@@ -396,8 +398,6 @@ static void
eek_keyboard_real_child_added (EekContainer *self,
EekElement *element)
{
g_signal_connect (element, "key-pressed",
G_CALLBACK(on_key_pressed), self);
g_signal_connect (element, "key-released",
G_CALLBACK(on_key_released), self);
g_signal_connect (element, "key-locked",
......@@ -414,7 +414,6 @@ static void
eek_keyboard_real_child_removed (EekContainer *self,
EekElement *element)
{
g_signal_handlers_disconnect_by_func (element, on_key_pressed, self);
g_signal_handlers_disconnect_by_func (element, on_key_released, self);
g_signal_handlers_disconnect_by_func (element, on_key_locked, self);
g_signal_handlers_disconnect_by_func (element, on_key_unlocked, self);
......
......@@ -45,6 +45,8 @@ typedef struct _EekKeyboardPrivate EekKeyboardPrivate;
/**
* EekKeyboard:
*
* Contains the state of the physical keyboard.
*
* The #EekKeyboard structure contains only private data and should
* only be accessed using the provided API.
*/
......
......@@ -114,14 +114,6 @@ eek_section_real_get_row (EekSection *self,
*orientation = row->orientation;
}
static void
on_pressed (EekKey *key,
EekSection *section)
{
g_log("squeek", G_LOG_LEVEL_DEBUG, "emit EekSection key-pressed");
g_signal_emit (section, signals[KEY_PRESSED], 0, key);
}
static void
on_released (EekKey *key,
EekSection *section)
......@@ -298,7 +290,6 @@ static void
eek_section_real_child_added (EekContainer *self,
EekElement *element)
{
g_signal_connect (element, "pressed", G_CALLBACK(on_pressed), self);
g_signal_connect (element, "released", G_CALLBACK(on_released), self);
g_signal_connect (element, "locked", G_CALLBACK(on_locked), self);
g_signal_connect (element, "unlocked", G_CALLBACK(on_unlocked), self);
......@@ -309,7 +300,6 @@ static void
eek_section_real_child_removed (EekContainer *self,
EekElement *element)
{
g_signal_handlers_disconnect_by_func (element, on_pressed, self);
g_signal_handlers_disconnect_by_func (element, on_released, self);
g_signal_handlers_disconnect_by_func (element, on_locked, self);
g_signal_handlers_disconnect_by_func (element, on_unlocked, self);
......@@ -355,28 +345,6 @@ eek_section_class_init (EekSectionClass *klass)
PROP_ANGLE,
pspec);
/**
* EekSection::key-pressed:
* @section: an #EekSection
* @key: an #EekKey
*
* The ::key-pressed signal is emitted each time a key in @section
* is shifted to the pressed state.
*/
signals[KEY_PRESSED] =
g_signal_new (I_("key-pressed"),
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_LAST,
// FIXME: this handler seems to be unnecessary complexity. Either remove or justify
// G_STRUCT_OFFSET(EekSectionClass, key_pressed),
0,
NULL,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
EEK_TYPE_KEY);
/**
* EekSection::key-released:
* @section: an #EekSection
......
......@@ -718,30 +718,6 @@ on_key_activated(EekKeyboard *keyboard,
emit_key_activated(&ec, keycode, symbol, modifiers, &c, pressed);
}
static void
on_key_pressed (EekKeyboard *keyboard,
EekKey *key,
gpointer user_data)
{
EekboardContextService *context = user_data;
guint delay = 500;
// org.gnome.desktop.input-sources doesn't have delay info
//g_settings_get (context->priv->settings, "repeat-delay", "u", &delay);
if (context->priv->repeat_timeout_id) {
g_source_remove (context->priv->repeat_timeout_id);
context->priv->repeat_timeout_id = 0;
}
context->priv->repeat_key = key;
context->priv->repeat_timeout_id =
g_timeout_add (delay,
(GSourceFunc)on_repeat_timeout_init,
context);
on_key_activated(keyboard, key, context, TRUE);
}
static void
on_key_released (EekKeyboard *keyboard,
EekKey *key,
......@@ -768,10 +744,6 @@ on_key_cancelled (EekKeyboard *keyboard,
static void
connect_keyboard_signals (EekboardContextService *context)
{
context->priv->key_pressed_handler =
g_signal_connect (context->priv->keyboard, "key-pressed",
G_CALLBACK(on_key_pressed),
context);
context->priv->key_released_handler =
g_signal_connect (context->priv->keyboard, "key-released",
G_CALLBACK(on_key_released),
......
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