Ignore motion event when button is pressed.
This commit is contained in:
@ -52,6 +52,7 @@ struct _EekClutterKeyActorPrivate
|
|||||||
EekClutterDrawingContext *context;
|
EekClutterDrawingContext *context;
|
||||||
EekKey *key;
|
EekKey *key;
|
||||||
ClutterActor *texture;
|
ClutterActor *texture;
|
||||||
|
gboolean is_pressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ClutterActor *get_texture (EekClutterKeyActor *actor);
|
static ClutterActor *get_texture (EekClutterKeyActor *actor);
|
||||||
@ -195,8 +196,11 @@ on_button_press_event (ClutterActor *actor,
|
|||||||
EekClutterKeyActorPrivate *priv =
|
EekClutterKeyActorPrivate *priv =
|
||||||
EEK_CLUTTER_KEY_ACTOR_GET_PRIVATE(actor);
|
EEK_CLUTTER_KEY_ACTOR_GET_PRIVATE(actor);
|
||||||
|
|
||||||
|
if (!priv->is_pressed) {
|
||||||
|
priv->is_pressed = TRUE;
|
||||||
/* priv->key will send back PRESSED event of actor. */
|
/* priv->key will send back PRESSED event of actor. */
|
||||||
g_signal_emit_by_name (priv->key, "pressed");
|
g_signal_emit_by_name (priv->key, "pressed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -207,8 +211,27 @@ on_button_release_event (ClutterActor *actor,
|
|||||||
EekClutterKeyActorPrivate *priv =
|
EekClutterKeyActorPrivate *priv =
|
||||||
EEK_CLUTTER_KEY_ACTOR_GET_PRIVATE(actor);
|
EEK_CLUTTER_KEY_ACTOR_GET_PRIVATE(actor);
|
||||||
|
|
||||||
|
if (priv->is_pressed) {
|
||||||
|
priv->is_pressed = FALSE;
|
||||||
/* priv->key will send back RELEASED event of actor. */
|
/* priv->key will send back RELEASED event of actor. */
|
||||||
g_signal_emit_by_name (priv->key, "released");
|
g_signal_emit_by_name (priv->key, "released");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
on_leave_event (ClutterActor *actor,
|
||||||
|
ClutterEvent *event,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
EekClutterKeyActorPrivate *priv =
|
||||||
|
EEK_CLUTTER_KEY_ACTOR_GET_PRIVATE(actor);
|
||||||
|
|
||||||
|
if (priv->is_pressed) {
|
||||||
|
priv->is_pressed = FALSE;
|
||||||
|
/* priv->key will send back RELEASED event of actor. */
|
||||||
|
g_signal_emit_by_name (priv->key, "released");
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -221,10 +244,13 @@ eek_clutter_key_actor_init (EekClutterKeyActor *self)
|
|||||||
priv->texture = NULL;
|
priv->texture = NULL;
|
||||||
|
|
||||||
clutter_actor_set_reactive (CLUTTER_ACTOR(self), TRUE);
|
clutter_actor_set_reactive (CLUTTER_ACTOR(self), TRUE);
|
||||||
|
|
||||||
g_signal_connect (self, "button-press-event",
|
g_signal_connect (self, "button-press-event",
|
||||||
G_CALLBACK (on_button_press_event), NULL);
|
G_CALLBACK (on_button_press_event), NULL);
|
||||||
g_signal_connect (self, "button-release-event",
|
g_signal_connect (self, "button-release-event",
|
||||||
G_CALLBACK (on_button_release_event), NULL);
|
G_CALLBACK (on_button_release_event), NULL);
|
||||||
|
g_signal_connect (self, "leave-event",
|
||||||
|
G_CALLBACK (on_leave_event), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClutterActor *
|
ClutterActor *
|
||||||
|
|||||||
@ -59,6 +59,8 @@ struct _EekGtkKeyboardPrivate
|
|||||||
PangoFontDescription *fonts[EEK_KEYSYM_CATEGORY_LAST];
|
PangoFontDescription *fonts[EEK_KEYSYM_CATEGORY_LAST];
|
||||||
|
|
||||||
gdouble scale;
|
gdouble scale;
|
||||||
|
|
||||||
|
EekKey *key;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void prepare_keyboard_pixmap (EekGtkKeyboard *keyboard);
|
static void prepare_keyboard_pixmap (EekGtkKeyboard *keyboard);
|
||||||
@ -155,6 +157,7 @@ eek_gtk_keyboard_init (EekGtkKeyboard *self)
|
|||||||
g_object_unref);
|
g_object_unref);
|
||||||
memset (priv->fonts, 0, sizeof priv->fonts);
|
memset (priv->fonts, 0, sizeof priv->fonts);
|
||||||
priv->scale = 1.0;
|
priv->scale = 1.0;
|
||||||
|
priv->key = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -434,12 +437,22 @@ on_button_event (GtkWidget *widget,
|
|||||||
if (key)
|
if (key)
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case GDK_BUTTON_PRESS:
|
case GDK_BUTTON_PRESS:
|
||||||
|
if (priv->key == key)
|
||||||
|
return FALSE;
|
||||||
|
if (priv->key) {
|
||||||
|
key_shrink (EEK_GTK_KEYBOARD(keyboard), EEK_KEY(priv->key));
|
||||||
|
g_signal_emit_by_name (keyboard, "key-released", priv->key);
|
||||||
|
}
|
||||||
key_enlarge (EEK_GTK_KEYBOARD(keyboard), EEK_KEY(key));
|
key_enlarge (EEK_GTK_KEYBOARD(keyboard), EEK_KEY(key));
|
||||||
g_signal_emit_by_name (keyboard, "key-pressed", key);
|
g_signal_emit_by_name (keyboard, "key-pressed", key);
|
||||||
|
priv->key = key;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case GDK_BUTTON_RELEASE:
|
case GDK_BUTTON_RELEASE:
|
||||||
key_shrink (EEK_GTK_KEYBOARD(keyboard), EEK_KEY(key));
|
if (!priv->key)
|
||||||
g_signal_emit_by_name (keyboard, "key-released", key);
|
return FALSE;
|
||||||
|
key_shrink (EEK_GTK_KEYBOARD(keyboard), EEK_KEY(priv->key));
|
||||||
|
g_signal_emit_by_name (keyboard, "key-released", priv->key);
|
||||||
|
priv->key = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -447,6 +460,7 @@ on_button_event (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_size_allocate (GtkWidget *widget,
|
on_size_allocate (GtkWidget *widget,
|
||||||
GtkAllocation *allocation,
|
GtkAllocation *allocation,
|
||||||
@ -469,6 +483,7 @@ on_size_allocate (GtkWidget *widget,
|
|||||||
allocation->width / bounds.width :
|
allocation->width / bounds.width :
|
||||||
allocation->height / bounds.height;
|
allocation->height / bounds.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
eek_gtk_keyboard_get_widget (EekGtkKeyboard *keyboard)
|
eek_gtk_keyboard_get_widget (EekGtkKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user