Commit d3410fdc authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz

Keyboard shows up on a single ShowKeyboard

parent 8087c3e5
......@@ -31,8 +31,8 @@
#include "eekboard/key-emitter.h"
#include "eekboard/eekboard-context-service.h"
#include "eekboard/eekboard-xklutil.h"
#include "eek/eek-xkl.h"
//#include "eekboard/eekboard-xklutil.h"
//#include "eek/eek-xkl.h"
#define CSW 640
#define CSH 480
......@@ -350,28 +350,42 @@ eekboard_context_service_finalize (GObject *object)
finalize (object);
}
// declaration for eekboard_context_service_constructed
static void
emit_group_changed_signal (EekboardContextService *context,
gint group);
static void
eekboard_context_service_constructed (GObject *object)
{
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE (object);
if (context->priv->connection && context->priv->object_path) {
GError *error = NULL;
context->priv->registration_id = g_dbus_connection_register_object
(context->priv->connection,
context->priv->object_path,
context->priv->introspection_data->interfaces[0],
&interface_vtable,
context,
NULL,
&error);
if (context->priv->registration_id == 0) {
g_warning ("failed to register context object: %s",
error->message);
g_error_free (error);
}
}
EekboardContextServiceClass *klass = EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context);
static guint keyboard_id = 0;
const gchar *keyboard_type = "us"; // TODO: fetch from gsettings
EekKeyboard *keyboard;
// create a keyboard
keyboard = klass->create_keyboard (context, keyboard_type);
eek_keyboard_set_modifier_behavior (keyboard,
EEK_MODIFIER_BEHAVIOR_LATCH);
keyboard_id++;
g_hash_table_insert (context->priv->keyboard_hash,
GUINT_TO_POINTER(keyboard_id),
keyboard);
g_object_set_data (G_OBJECT(keyboard),
"keyboard-id",
GUINT_TO_POINTER(keyboard_id));
// set as current
if (context->priv->keyboard)
disconnect_keyboard_signals (context);
context->priv->keyboard = keyboard;
connect_keyboard_signals (context);
gint group;
group = eek_element_get_group (EEK_ELEMENT(context->priv->keyboard));
emit_group_changed_signal (context, group);
g_object_notify (G_OBJECT(context), "keyboard");
}
static void
......@@ -570,6 +584,7 @@ static void
emit_visibility_changed_signal (EekboardContextService *context,
gboolean visible)
{
return; // FIXME: update Visible property
if (context->priv->connection && context->priv->enabled) {
GError *error = NULL;
gboolean retval;
......@@ -772,38 +787,6 @@ handle_method_call (GDBusConnection *connection,
context->priv->repeat_timeout_id = 0;
}
if (g_strcmp0 (method_name, "AddKeyboard") == 0) {
const gchar *keyboard_type;
static guint keyboard_id = 0;
EekKeyboard *keyboard;
g_variant_get (parameters, "(&s)", &keyboard_type);
keyboard = klass->create_keyboard (context, keyboard_type);
if (keyboard == NULL) {
g_dbus_method_invocation_return_error (invocation,
G_IO_ERROR,
G_IO_ERROR_FAILED_HANDLED,
"can't create a keyboard");
return;
}
eek_keyboard_set_modifier_behavior (keyboard,
EEK_MODIFIER_BEHAVIOR_LATCH);
keyboard_id++;
g_hash_table_insert (context->priv->keyboard_hash,
GUINT_TO_POINTER(keyboard_id),
keyboard);
g_object_set_data (G_OBJECT(keyboard),
"keyboard-id",
GUINT_TO_POINTER(keyboard_id));
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(u)",
keyboard_id));
return;
}
if (g_strcmp0 (method_name, "RemoveKeyboard") == 0) {
guint keyboard_id, current_keyboard_id;
......@@ -826,43 +809,6 @@ handle_method_call (GDBusConnection *connection,
return;
}
if (g_strcmp0 (method_name, "SetKeyboard") == 0) {
EekKeyboard *keyboard;
guint keyboard_id;
gint group;
g_variant_get (parameters, "(u)", &keyboard_id);
keyboard = g_hash_table_lookup (context->priv->keyboard_hash,
GUINT_TO_POINTER(keyboard_id));
if (!keyboard) {
g_dbus_method_invocation_return_error (invocation,
G_IO_ERROR,
G_IO_ERROR_FAILED_HANDLED,
"no such keyboard");
return;
}
if (keyboard == context->priv->keyboard) {
g_dbus_method_invocation_return_value (invocation, NULL);
return;
}
if (context->priv->keyboard)
disconnect_keyboard_signals (context);
context->priv->keyboard = keyboard;
connect_keyboard_signals (context);
g_dbus_method_invocation_return_value (invocation, NULL);
group = eek_element_get_group (EEK_ELEMENT(context->priv->keyboard));
emit_group_changed_signal (context, group);
g_object_notify (G_OBJECT(context), "keyboard");
return;
}
if (g_strcmp0 (method_name, "SetFullscreen") == 0) {
gboolean fullscreen;
......@@ -979,24 +925,7 @@ eekboard_context_service_enable (EekboardContextService *context)
g_return_if_fail (context->priv->connection);
if (!context->priv->enabled) {
gboolean retval;
context->priv->enabled = TRUE;
error = NULL;
retval = g_dbus_connection_emit_signal (context->priv->connection,
NULL,
context->priv->object_path,
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
"Enabled",
NULL,
&error);
if (!retval) {
g_warning ("failed to emit Enabled signal: %s",
error->message);
g_error_free (error);
g_assert_not_reached ();
}
g_signal_emit (context, signals[ENABLED], 0);
}
}
......
......@@ -30,6 +30,8 @@
#include "eekboard/eekboard-service.h"
#include <stdio.h>
enum {
PROP_0,
PROP_OBJECT_PATH,
......@@ -210,6 +212,25 @@ eekboard_service_constructed (GObject *object)
g_error_free (error);
}
}
// CreateContext
EekboardServiceClass *klass = EEKBOARD_SERVICE_GET_CLASS(service);
EekboardContextService *context;
g_assert (klass->create_context);
context = klass->create_context (service, "client_name", "object_path");
g_object_set_data_full (G_OBJECT(context),
"owner", g_strdup ("sender"),
(GDestroyNotify)g_free);
g_hash_table_insert (service->priv->context_hash,
"object_path",
context);
// PushContext
service->priv->context_stack = g_slist_prepend (service->priv->context_stack,
g_object_ref (context));
eekboard_context_service_enable (context);
}
static void
......@@ -383,37 +404,10 @@ handle_method_call (GDBusConnection *connection,
EekboardServiceClass *klass = EEKBOARD_SERVICE_GET_CLASS(service);
if (g_strcmp0 (method_name, "CreateContext") == 0) {
const gchar *client_name;
gchar *object_path;
static gint context_id = 0;
EekboardContextService *context;
g_variant_get (parameters, "(&s)", &client_name);
object_path = g_strdup_printf (EEKBOARD_CONTEXT_SERVICE_PATH, context_id++);
g_assert (klass->create_context);
context = klass->create_context (service, client_name, object_path);
g_object_set_data_full (G_OBJECT(context),
"owner", g_strdup (sender),
(GDestroyNotify)g_free);
g_hash_table_insert (service->priv->context_hash,
object_path,
context);
/* the vanished callback is called when clients are disconnected */
g_bus_watch_name_on_connection (service->priv->connection,
sender,
G_BUS_NAME_WATCHER_FLAGS_NONE,
NULL,
service_name_vanished_callback,
service,
NULL);
g_signal_connect (G_OBJECT(context), "destroyed",
G_CALLBACK(context_destroyed_cb), service);
printf("Ignoring CreateContext call\n");
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(s)",
object_path));
"object_path"));
return;
}
......@@ -482,6 +476,7 @@ handle_method_call (GDBusConnection *connection,
} else {
service->priv->visible = TRUE;
}
g_dbus_method_invocation_return_value (invocation, NULL);
return;
}
......@@ -491,6 +486,7 @@ handle_method_call (GDBusConnection *connection,
} else {
service->priv->visible = FALSE;
}
g_dbus_method_invocation_return_value (invocation, NULL);
return;
}
......
......@@ -122,6 +122,7 @@ int WaylandFakeKeyEvent(
unsigned long delay
) {
printf("Sending fake event %d press %d delay %d\n", keycode, is_press, delay);
return 0;
}
static void
......
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