Separate keyboards from the dbus handler
This commit is contained in:
@ -60,7 +60,7 @@ struct _EekboardServicePrivate {
|
|||||||
guint registration_id;
|
guint registration_id;
|
||||||
char *object_path;
|
char *object_path;
|
||||||
|
|
||||||
EekboardContextService *context;
|
EekboardContextService *context; // unowned reference
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (EekboardService, eekboard_service, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (EekboardService, eekboard_service, G_TYPE_OBJECT);
|
||||||
@ -150,10 +150,12 @@ static gboolean
|
|||||||
handle_set_visible(SmPuriOSK0 *object, GDBusMethodInvocation *invocation,
|
handle_set_visible(SmPuriOSK0 *object, GDBusMethodInvocation *invocation,
|
||||||
gboolean arg_visible, gpointer user_data) {
|
gboolean arg_visible, gpointer user_data) {
|
||||||
EekboardService *service = user_data;
|
EekboardService *service = user_data;
|
||||||
if (arg_visible) {
|
if (service->priv->context) {
|
||||||
eekboard_context_service_show_keyboard (service->priv->context);
|
if (arg_visible) {
|
||||||
} else {
|
eekboard_context_service_show_keyboard (service->priv->context);
|
||||||
eekboard_context_service_hide_keyboard (service->priv->context);
|
} else {
|
||||||
|
eekboard_context_service_hide_keyboard (service->priv->context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sm_puri_osk0_complete_set_visible(object, invocation);
|
sm_puri_osk0_complete_set_visible(object, invocation);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -180,14 +182,6 @@ eekboard_service_constructed (GObject *object)
|
|||||||
g_clear_error(&error);
|
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
|
static void
|
||||||
@ -257,6 +251,7 @@ static void
|
|||||||
eekboard_service_init (EekboardService *self)
|
eekboard_service_init (EekboardService *self)
|
||||||
{
|
{
|
||||||
self->priv = EEKBOARD_SERVICE_GET_PRIVATE(self);
|
self->priv = EEKBOARD_SERVICE_GET_PRIVATE(self);
|
||||||
|
self->priv->context = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -273,3 +268,10 @@ eekboard_service_new (GDBusConnection *connection,
|
|||||||
"connection", connection,
|
"connection", connection,
|
||||||
NULL);
|
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;
|
GType eekboard_service_get_type (void) G_GNUC_CONST;
|
||||||
EekboardService * eekboard_service_new (GDBusConnection *connection,
|
EekboardService * eekboard_service_new (GDBusConnection *connection,
|
||||||
const gchar *object_path);
|
const gchar *object_path);
|
||||||
|
void eekboard_service_set_context(EekboardService *service,
|
||||||
|
EekboardContextService *context);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* EEKBOARD_SERVICE_H */
|
#endif /* EEKBOARD_SERVICE_H */
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include "eekboard/eekboard-service.h"
|
#include "eekboard/eekboard-service.h"
|
||||||
#include "eek/eek.h"
|
#include "eek/eek.h"
|
||||||
|
#include "server-context-service.h"
|
||||||
#include "wayland.h"
|
#include "wayland.h"
|
||||||
|
|
||||||
#include <gdk/gdkwayland.h>
|
#include <gdk/gdkwayland.h>
|
||||||
@ -47,6 +48,9 @@ on_name_acquired (GDBusConnection *connection,
|
|||||||
const gchar *name,
|
const gchar *name,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
(void)connection;
|
||||||
|
(void)name;
|
||||||
|
(void)user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -54,7 +58,11 @@ on_name_lost (GDBusConnection *connection,
|
|||||||
const gchar *name,
|
const gchar *name,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
exit (1);
|
// TODO: could conceivable continue working
|
||||||
|
(void)connection;
|
||||||
|
(void)name;
|
||||||
|
(void)user_data;
|
||||||
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -67,6 +75,15 @@ on_destroyed (EekboardService *service,
|
|||||||
g_main_loop_quit (loop);
|
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
|
// Wayland
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -130,6 +147,7 @@ main (int argc, char **argv)
|
|||||||
wl_registry_add_listener (registry, ®istry_listener, &wayland);
|
wl_registry_add_listener (registry, ®istry_listener, &wayland);
|
||||||
squeek_wayland_set_global(&wayland);
|
squeek_wayland_set_global(&wayland);
|
||||||
|
|
||||||
|
EekboardContextService *context = create_context();
|
||||||
// set up dbus
|
// set up dbus
|
||||||
|
|
||||||
GBusType bus_type;
|
GBusType bus_type;
|
||||||
@ -181,6 +199,8 @@ main (int argc, char **argv)
|
|||||||
if (service == NULL) {
|
if (service == NULL) {
|
||||||
g_printerr ("Can't create server\n");
|
g_printerr ("Can't create server\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
|
} else {
|
||||||
|
eekboard_service_set_context(service, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
guint owner_id = g_bus_own_name_on_connection (connection,
|
guint owner_id = g_bus_own_name_on_connection (connection,
|
||||||
|
|||||||
Reference in New Issue
Block a user