Commit c0fdffac authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz

Separate keyboards from the dbus handler

parent e94e64d2
/*
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 Red Hat, Inc.
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
......@@ -60,7 +60,7 @@ struct _EekboardServicePrivate {
guint registration_id;
char *object_path;
EekboardContextService *context;
EekboardContextService *context; // unowned reference
};
G_DEFINE_TYPE (EekboardService, eekboard_service, G_TYPE_OBJECT);
......@@ -150,10 +150,12 @@ static gboolean
handle_set_visible(SmPuriOSK0 *object, GDBusMethodInvocation *invocation,
gboolean arg_visible, gpointer user_data) {
EekboardService *service = user_data;
if (arg_visible) {
eekboard_context_service_show_keyboard (service->priv->context);
} else {
eekboard_context_service_hide_keyboard (service->priv->context);
if (service->priv->context) {
if (arg_visible) {
eekboard_context_service_show_keyboard (service->priv->context);
} else {
eekboard_context_service_hide_keyboard (service->priv->context);
}
}
sm_puri_osk0_complete_set_visible(object, invocation);
return TRUE;
......@@ -180,14 +182,6 @@ eekboard_service_constructed (GObject *object)
g_clear_error(&error);
}
}
// CreateContext
EekboardContextService *context = server_context_service_new ();
g_object_set_data_full (G_OBJECT(context),
"owner", g_strdup ("sender"),
(GDestroyNotify)g_free);
service->priv->context = context;
eekboard_context_service_enable (context);
}
static void
......@@ -257,6 +251,7 @@ static void
eekboard_service_init (EekboardService *self)
{
self->priv = EEKBOARD_SERVICE_GET_PRIVATE(self);
self->priv->context = NULL;
}
/**
......@@ -273,3 +268,10 @@ eekboard_service_new (GDBusConnection *connection,
"connection", connection,
NULL);
}
void
eekboard_service_set_context(EekboardService *service,
EekboardContextService *context) {
service->priv->context = context;
}
......@@ -70,6 +70,7 @@ struct _EekboardServiceClass {
GType eekboard_service_get_type (void) G_GNUC_CONST;
EekboardService * eekboard_service_new (GDBusConnection *connection,
const gchar *object_path);
void eekboard_service_set_context(EekboardService *service,
EekboardContextService *context);
G_END_DECLS
#endif /* EEKBOARD_SERVICE_H */
......@@ -33,6 +33,7 @@
#include "eekboard/eekboard-service.h"
#include "eek/eek.h"
#include "server-context-service.h"
#include "wayland.h"
#include <gdk/gdkwayland.h>
......@@ -47,6 +48,9 @@ on_name_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
(void)connection;
(void)name;
(void)user_data;
}
static void
......@@ -54,7 +58,11 @@ on_name_lost (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
exit (1);
// TODO: could conceivable continue working
(void)connection;
(void)name;
(void)user_data;
exit (1);
}
static void
......@@ -67,6 +75,15 @@ on_destroyed (EekboardService *service,
g_main_loop_quit (loop);
}
static EekboardContextService *create_context() {
EekboardContextService *context = server_context_service_new ();
g_object_set_data_full (G_OBJECT(context),
"owner", g_strdup ("sender"),
(GDestroyNotify)g_free);
eekboard_context_service_enable (context);
return context;
}
// Wayland
static void
......@@ -130,6 +147,7 @@ main (int argc, char **argv)
wl_registry_add_listener (registry, &registry_listener, &wayland);
squeek_wayland_set_global(&wayland);
EekboardContextService *context = create_context();
// set up dbus
GBusType bus_type;
......@@ -181,6 +199,8 @@ main (int argc, char **argv)
if (service == NULL) {
g_printerr ("Can't create server\n");
exit (1);
} else {
eekboard_service_set_context(service, context);
}
guint owner_id = g_bus_own_name_on_connection (connection,
......
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