Rename EekboardDevice to EekboardKeyboard.
This commit is contained in:
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
lib_LTLIBRARIES = libeekboard.la
|
lib_LTLIBRARIES = libeekboard.la
|
||||||
|
|
||||||
libeekboard_headers = eekboard.h eekboard-device.h
|
libeekboard_headers = eekboard.h eekboard-keyboard.h
|
||||||
libeekboard_sources = eekboard-device.c
|
libeekboard_sources = eekboard-keyboard.c
|
||||||
|
|
||||||
libeekboard_la_SOURCES = $(libeekboard_sources)
|
libeekboard_la_SOURCES = $(libeekboard_sources)
|
||||||
libeekboard_la_CFLAGS = -I$(top_srcdir) $(GIO2_CFLAGS)
|
libeekboard_la_CFLAGS = -I$(top_srcdir) $(GIO2_CFLAGS)
|
||||||
|
|||||||
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#ifndef EEKBOARD_DEVICE_H
|
|
||||||
#define EEKBOARD_DEVICE_H 1
|
|
||||||
|
|
||||||
#include <gio/gio.h>
|
|
||||||
#include "eek/eek.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define EEKBOARD_TYPE_DEVICE (eekboard_device_get_type())
|
|
||||||
#define EEKBOARD_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_DEVICE, EekboardDevice))
|
|
||||||
#define EEKBOARD_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_DEVICE, EekboardDeviceClass))
|
|
||||||
#define EEKBOARD_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_DEVICE))
|
|
||||||
#define EEKBOARD_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_DEVICE))
|
|
||||||
#define EEKBOARD_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_DEVICE, EekboardDeviceClass))
|
|
||||||
|
|
||||||
typedef struct _EekboardDevice EekboardDevice;
|
|
||||||
typedef struct _EekboardDeviceClass EekboardDeviceClass;
|
|
||||||
|
|
||||||
EekboardDevice *eekboard_device_new (const gchar *path,
|
|
||||||
GDBusConnection *connection,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error);
|
|
||||||
void eekboard_device_set_keyboard (EekboardDevice *device,
|
|
||||||
EekKeyboard *keyboard);
|
|
||||||
void eekboard_device_set_group (EekboardDevice *device,
|
|
||||||
gint group);
|
|
||||||
void eekboard_device_show (EekboardDevice *device);
|
|
||||||
void eekboard_device_hide (EekboardDevice *device);
|
|
||||||
void eekboard_device_press_key (EekboardDevice *device,
|
|
||||||
guint keycode);
|
|
||||||
void eekboard_device_release_key (EekboardDevice *device,
|
|
||||||
guint keycode);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
#endif /* EEKBOARD_DEVICE_H */
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include "eekboard-device.h"
|
#include "eekboard-keyboard.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
KEY_PRESSED,
|
KEY_PRESSED,
|
||||||
@ -29,35 +29,35 @@ enum {
|
|||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0, };
|
static guint signals[LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
struct _EekboardDevice {
|
struct _EekboardKeyboard {
|
||||||
GDBusProxy parent;
|
GDBusProxy parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _EekboardDeviceClass {
|
struct _EekboardKeyboardClass {
|
||||||
GDBusProxyClass parent_class;
|
GDBusProxyClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (EekboardDevice, eekboard_device, G_TYPE_DBUS_PROXY);
|
G_DEFINE_TYPE (EekboardKeyboard, eekboard_keyboard, G_TYPE_DBUS_PROXY);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_device_real_g_signal (GDBusProxy *self,
|
eekboard_keyboard_real_g_signal (GDBusProxy *self,
|
||||||
const gchar *sender_name,
|
const gchar *sender_name,
|
||||||
const gchar *signal_name,
|
const gchar *signal_name,
|
||||||
GVariant *parameters)
|
GVariant *parameters)
|
||||||
{
|
{
|
||||||
EekboardDevice *device = EEKBOARD_DEVICE (self);
|
EekboardKeyboard *keyboard = EEKBOARD_KEYBOARD (self);
|
||||||
guint *keycode;
|
guint *keycode;
|
||||||
|
|
||||||
if (g_strcmp0 (signal_name, "KeyPressed") == 0) {
|
if (g_strcmp0 (signal_name, "KeyPressed") == 0) {
|
||||||
|
|
||||||
g_variant_get (parameters, "(u)", &keycode);
|
g_variant_get (parameters, "(u)", &keycode);
|
||||||
g_signal_emit_by_name (device, "key-pressed", keycode);
|
g_signal_emit_by_name (keyboard, "key-pressed", keycode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_strcmp0 (signal_name, "KeyReleased") == 0) {
|
if (g_strcmp0 (signal_name, "KeyReleased") == 0) {
|
||||||
g_variant_get (parameters, "(u)", &keycode);
|
g_variant_get (parameters, "(u)", &keycode);
|
||||||
g_signal_emit_by_name (device, "key-released", keycode);
|
g_signal_emit_by_name (keyboard, "key-released", keycode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,12 +65,12 @@ eekboard_device_real_g_signal (GDBusProxy *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_device_class_init (EekboardDeviceClass *klass)
|
eekboard_keyboard_class_init (EekboardKeyboardClass *klass)
|
||||||
{
|
{
|
||||||
GDBusProxyClass *proxy_class = G_DBUS_PROXY_CLASS (klass);
|
GDBusProxyClass *proxy_class = G_DBUS_PROXY_CLASS (klass);
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
proxy_class->g_signal = eekboard_device_real_g_signal;
|
proxy_class->g_signal = eekboard_keyboard_real_g_signal;
|
||||||
|
|
||||||
signals[KEY_PRESSED] =
|
signals[KEY_PRESSED] =
|
||||||
g_signal_new ("key-pressed",
|
g_signal_new ("key-pressed",
|
||||||
@ -98,15 +98,15 @@ eekboard_device_class_init (EekboardDeviceClass *klass)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_device_init (EekboardDevice *device)
|
eekboard_keyboard_init (EekboardKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
EekboardDevice *
|
EekboardKeyboard *
|
||||||
eekboard_device_new (const gchar *path,
|
eekboard_keyboard_new (const gchar *path,
|
||||||
GDBusConnection *connection,
|
GDBusConnection *connection,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GInitable *initable;
|
GInitable *initable;
|
||||||
|
|
||||||
@ -114,18 +114,18 @@ eekboard_device_new (const gchar *path,
|
|||||||
g_assert (G_IS_DBUS_CONNECTION(connection));
|
g_assert (G_IS_DBUS_CONNECTION(connection));
|
||||||
|
|
||||||
initable =
|
initable =
|
||||||
g_initable_new (EEKBOARD_TYPE_DEVICE,
|
g_initable_new (EEKBOARD_TYPE_KEYBOARD,
|
||||||
cancellable,
|
cancellable,
|
||||||
error,
|
error,
|
||||||
"g-connection", connection,
|
"g-connection", connection,
|
||||||
"g-name", "com.redhat.eekboard.Device",
|
"g-name", "com.redhat.eekboard.Keyboard",
|
||||||
"g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|
"g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|
||||||
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
|
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
|
||||||
"g-interface-name", "com.redhat.eekboard.Device",
|
"g-interface-name", "com.redhat.eekboard.Keyboard",
|
||||||
"g-object-path", path,
|
"g-object-path", path,
|
||||||
NULL);
|
NULL);
|
||||||
if (initable != NULL)
|
if (initable != NULL)
|
||||||
return EEKBOARD_DEVICE (initable);
|
return EEKBOARD_KEYBOARD (initable);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,13 +146,14 @@ proxy_call_async_ready_cb (GObject *source_object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eekboard_device_set_keyboard (EekboardDevice *device, EekKeyboard *keyboard)
|
eekboard_keyboard_set_description (EekboardKeyboard *keyboard,
|
||||||
|
EekKeyboard *description)
|
||||||
{
|
{
|
||||||
GVariant *variant;
|
GVariant *variant;
|
||||||
|
|
||||||
variant = eek_serializable_serialize (EEK_SERIALIZABLE(keyboard));
|
variant = eek_serializable_serialize (description);
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(device),
|
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
|
||||||
"SetKeyboard",
|
"SetDescription",
|
||||||
g_variant_new ("(v)", variant),
|
g_variant_new ("(v)", variant),
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
@ -163,10 +164,10 @@ eekboard_device_set_keyboard (EekboardDevice *device, EekKeyboard *keyboard)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eekboard_device_set_group (EekboardDevice *device,
|
eekboard_keyboard_set_group (EekboardKeyboard *keyboard,
|
||||||
gint group)
|
gint group)
|
||||||
{
|
{
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(device),
|
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
|
||||||
"SetGroup",
|
"SetGroup",
|
||||||
g_variant_new ("(i)", group),
|
g_variant_new ("(i)", group),
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -177,9 +178,9 @@ eekboard_device_set_group (EekboardDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eekboard_device_show (EekboardDevice *device)
|
eekboard_keyboard_show (EekboardKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(device),
|
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
|
||||||
"Show",
|
"Show",
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -190,9 +191,9 @@ eekboard_device_show (EekboardDevice *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eekboard_device_hide (EekboardDevice *device)
|
eekboard_keyboard_hide (EekboardKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(device),
|
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
|
||||||
"Hide",
|
"Hide",
|
||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -203,10 +204,10 @@ eekboard_device_hide (EekboardDevice *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eekboard_device_press_key (EekboardDevice *device,
|
eekboard_keyboard_press_key (EekboardKeyboard *keyboard,
|
||||||
guint keycode)
|
guint keycode)
|
||||||
{
|
{
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(device),
|
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
|
||||||
"PressKey",
|
"PressKey",
|
||||||
g_variant_new ("(u)", keycode),
|
g_variant_new ("(u)", keycode),
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
@ -217,10 +218,10 @@ eekboard_device_press_key (EekboardDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eekboard_device_release_key (EekboardDevice *device,
|
eekboard_keyboard_release_key (EekboardKeyboard *keyboard,
|
||||||
guint keycode)
|
guint keycode)
|
||||||
{
|
{
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(device),
|
g_dbus_proxy_call (G_DBUS_PROXY(keyboard),
|
||||||
"ReleaseKey",
|
"ReleaseKey",
|
||||||
g_variant_new ("(u)", keycode),
|
g_variant_new ("(u)", keycode),
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
53
eekboard/eekboard-keyboard.h
Normal file
53
eekboard/eekboard-keyboard.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef EEKBOARD_KEYBOARD_H
|
||||||
|
#define EEKBOARD_KEYBOARD_H 1
|
||||||
|
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include "eek/eek.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define EEKBOARD_TYPE_KEYBOARD (eekboard_keyboard_get_type())
|
||||||
|
#define EEKBOARD_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_KEYBOARD, EekboardKeyboard))
|
||||||
|
#define EEKBOARD_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_KEYBOARD, EekboardKeyboardClass))
|
||||||
|
#define EEKBOARD_IS_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_KEYBOARD))
|
||||||
|
#define EEKBOARD_IS_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_KEYBOARD))
|
||||||
|
#define EEKBOARD_KEYBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_KEYBOARD, EekboardKeyboardClass))
|
||||||
|
|
||||||
|
typedef struct _EekboardKeyboard EekboardKeyboard;
|
||||||
|
typedef struct _EekboardKeyboardClass EekboardKeyboardClass;
|
||||||
|
|
||||||
|
EekboardKeyboard *eekboard_keyboard_new (const gchar *path,
|
||||||
|
GDBusConnection *connection,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
void eekboard_keyboard_set_description
|
||||||
|
(EekboardKeyboard *keyboard,
|
||||||
|
EekKeyboard *description);
|
||||||
|
void eekboard_keyboard_set_group (EekboardKeyboard *keyboard,
|
||||||
|
gint group);
|
||||||
|
void eekboard_keyboard_show (EekboardKeyboard *keyboard);
|
||||||
|
void eekboard_keyboard_hide (EekboardKeyboard *keyboard);
|
||||||
|
void eekboard_keyboard_press_key (EekboardKeyboard *keyboard,
|
||||||
|
guint keycode);
|
||||||
|
void eekboard_keyboard_release_key (EekboardKeyboard *keyboard,
|
||||||
|
guint keycode);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
#endif /* EEKBOARD_KEYBOARD_H */
|
||||||
@ -18,6 +18,6 @@
|
|||||||
#ifndef EEKBOARD_H
|
#ifndef EEKBOARD_H
|
||||||
#define EEKBOARD_H 1
|
#define EEKBOARD_H 1
|
||||||
|
|
||||||
#include "eekboard/eekboard-device.h"
|
#include "eekboard/eekboard-keyboard.h"
|
||||||
|
|
||||||
#endif /* EEKBOARD_H */
|
#endif /* EEKBOARD_H */
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "eekboard/eekboard.h"
|
#include "eekboard/eekboard.h"
|
||||||
|
|
||||||
static gchar *opt_set_keyboard = NULL;
|
static gchar *opt_set_description = NULL;
|
||||||
static gint opt_set_group = -1;
|
static gint opt_set_group = -1;
|
||||||
static gboolean opt_show = FALSE;
|
static gboolean opt_show = FALSE;
|
||||||
static gboolean opt_hide = FALSE;
|
static gboolean opt_hide = FALSE;
|
||||||
@ -30,7 +30,7 @@ static gint opt_release_key = -1;
|
|||||||
static gboolean opt_listen = FALSE;
|
static gboolean opt_listen = FALSE;
|
||||||
|
|
||||||
static const GOptionEntry options[] = {
|
static const GOptionEntry options[] = {
|
||||||
{"set-keyboard", '\0', 0, G_OPTION_ARG_STRING, &opt_set_keyboard,
|
{"set-keyboard", '\0', 0, G_OPTION_ARG_STRING, &opt_set_description,
|
||||||
"Set keyboard from an XML file"},
|
"Set keyboard from an XML file"},
|
||||||
{"set-group", '\0', 0, G_OPTION_ARG_INT, &opt_set_group,
|
{"set-group", '\0', 0, G_OPTION_ARG_INT, &opt_set_group,
|
||||||
"Set group of the keyboard"},
|
"Set group of the keyboard"},
|
||||||
@ -62,7 +62,7 @@ on_key_released (guint keycode, gpointer user_data)
|
|||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
EekboardDevice *device = NULL;
|
EekboardKeyboard *keyboard = NULL;
|
||||||
GDBusConnection *connection = NULL;
|
GDBusConnection *connection = NULL;
|
||||||
GError *error;
|
GError *error;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
@ -86,7 +86,7 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
device = eekboard_device_new ("/com/redhat/eekboard/Device",
|
keyboard = eekboard_keyboard_new ("/com/redhat/eekboard/Keyboard",
|
||||||
connection,
|
connection,
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
@ -96,64 +96,64 @@ main (int argc, char **argv)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_set_keyboard) {
|
if (opt_set_description) {
|
||||||
GFile *file;
|
GFile *file;
|
||||||
GFileInputStream *input;
|
GFileInputStream *input;
|
||||||
EekLayout *layout;
|
EekLayout *layout;
|
||||||
EekKeyboard *keyboard;
|
EekKeyboard *description;
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
file = g_file_new_for_path (opt_set_keyboard);
|
file = g_file_new_for_path (opt_set_description);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
input = g_file_read (file, NULL, &error);
|
input = g_file_read (file, NULL, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_printerr ("Can't read file %s: %s\n",
|
g_printerr ("Can't read file %s: %s\n",
|
||||||
opt_set_keyboard, error->message);
|
opt_set_description, error->message);
|
||||||
retval = 1;
|
retval = 1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
layout = eek_xml_layout_new (G_INPUT_STREAM(input));
|
layout = eek_xml_layout_new (G_INPUT_STREAM(input));
|
||||||
g_object_unref (input);
|
g_object_unref (input);
|
||||||
keyboard = eek_keyboard_new (layout, 640, 480);
|
description = eek_keyboard_new (layout, 640, 480);
|
||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
eekboard_device_set_keyboard (device, keyboard);
|
eekboard_keyboard_set_description (keyboard, description);
|
||||||
g_object_unref (keyboard);
|
g_object_unref (description);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_set_group >= 0) {
|
if (opt_set_group >= 0) {
|
||||||
eekboard_device_set_group (device, opt_set_group);
|
eekboard_keyboard_set_group (keyboard, opt_set_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_show) {
|
if (opt_show) {
|
||||||
eekboard_device_show (device);
|
eekboard_keyboard_show (keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_hide) {
|
if (opt_hide) {
|
||||||
eekboard_device_hide (device);
|
eekboard_keyboard_hide (keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_press_key >= 0) {
|
if (opt_press_key >= 0) {
|
||||||
eekboard_device_press_key (device, opt_press_key);
|
eekboard_keyboard_press_key (keyboard, opt_press_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_release_key >= 0) {
|
if (opt_release_key >= 0) {
|
||||||
eekboard_device_release_key (device, opt_release_key);
|
eekboard_keyboard_release_key (keyboard, opt_release_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_listen) {
|
if (opt_listen) {
|
||||||
g_signal_connect (device, "key-pressed",
|
g_signal_connect (keyboard, "key-pressed",
|
||||||
G_CALLBACK(on_key_pressed), NULL);
|
G_CALLBACK(on_key_pressed), NULL);
|
||||||
g_signal_connect (device, "key-released",
|
g_signal_connect (keyboard, "key-released",
|
||||||
G_CALLBACK(on_key_released), NULL);
|
G_CALLBACK(on_key_released), NULL);
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (device)
|
if (keyboard)
|
||||||
g_object_unref (device);
|
g_object_unref (keyboard);
|
||||||
if (connection)
|
if (connection)
|
||||||
g_object_unref (connection);
|
g_object_unref (connection);
|
||||||
if (loop)
|
if (loop)
|
||||||
|
|||||||
24
src/server.c
24
src/server.c
@ -43,9 +43,9 @@ enum {
|
|||||||
|
|
||||||
static const gchar introspection_xml[] =
|
static const gchar introspection_xml[] =
|
||||||
"<node>"
|
"<node>"
|
||||||
" <interface name='com.redhat.eekboard.Device'>"
|
" <interface name='com.redhat.eekboard.Keyboard'>"
|
||||||
" <method name='SetKeyboard'>"
|
" <method name='SetDescription'>"
|
||||||
" <arg type='v' name='keyboard'/>"
|
" <arg type='v' name='description'/>"
|
||||||
" </method>"
|
" </method>"
|
||||||
" <method name='SetGroup'>"
|
" <method name='SetGroup'>"
|
||||||
" <arg type='i' name='group'/>"
|
" <arg type='i' name='group'/>"
|
||||||
@ -253,9 +253,9 @@ on_key_pressed (EekKeyboard *keyboard,
|
|||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
g_dbus_connection_emit_signal (server->connection,
|
g_dbus_connection_emit_signal (server->connection,
|
||||||
"com.redhat.eekboard.Device",
|
"com.redhat.eekboard.Keyboard",
|
||||||
"/com/redhat/eekboard/Device",
|
"/com/redhat/eekboard/Keyboard",
|
||||||
"com.redhat.eekboard.Device",
|
"com.redhat.eekboard.Keyboard",
|
||||||
"KeyPressed",
|
"KeyPressed",
|
||||||
g_variant_new ("(u)",
|
g_variant_new ("(u)",
|
||||||
eek_key_get_keycode (key)),
|
eek_key_get_keycode (key)),
|
||||||
@ -273,9 +273,9 @@ on_key_released (EekKeyboard *keyboard,
|
|||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
g_dbus_connection_emit_signal (server->connection,
|
g_dbus_connection_emit_signal (server->connection,
|
||||||
"com.redhat.eekboard.Device",
|
"com.redhat.eekboard.Keyboard",
|
||||||
"/com/redhat/eekboard/Device",
|
"/com/redhat/eekboard/Keyboard",
|
||||||
"com.redhat.eekboard.Device",
|
"com.redhat.eekboard.Keyboard",
|
||||||
"KeyReleased",
|
"KeyReleased",
|
||||||
g_variant_new ("(u)",
|
g_variant_new ("(u)",
|
||||||
eek_key_get_keycode (key)),
|
eek_key_get_keycode (key)),
|
||||||
@ -309,7 +309,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
EekboardServer *server = user_data;
|
EekboardServer *server = user_data;
|
||||||
|
|
||||||
// g_debug ("%s", method_name);
|
// g_debug ("%s", method_name);
|
||||||
if (g_strcmp0 (method_name, "SetKeyboard") == 0) {
|
if (g_strcmp0 (method_name, "SetDescription") == 0) {
|
||||||
EekSerializable *serializable;
|
EekSerializable *serializable;
|
||||||
GVariant *variant;
|
GVariant *variant;
|
||||||
gchar *data;
|
gchar *data;
|
||||||
@ -481,7 +481,7 @@ eekboard_server_start (EekboardServer *server)
|
|||||||
error = NULL;
|
error = NULL;
|
||||||
registration_id = g_dbus_connection_register_object
|
registration_id = g_dbus_connection_register_object
|
||||||
(server->connection,
|
(server->connection,
|
||||||
"/com/redhat/eekboard/Device",
|
"/com/redhat/eekboard/Keyboard",
|
||||||
server->introspection_data->interfaces[0],
|
server->introspection_data->interfaces[0],
|
||||||
&interface_vtable,
|
&interface_vtable,
|
||||||
server,
|
server,
|
||||||
@ -493,7 +493,7 @@ eekboard_server_start (EekboardServer *server)
|
|||||||
|
|
||||||
server->owner_id =
|
server->owner_id =
|
||||||
g_bus_own_name_on_connection (server->connection,
|
g_bus_own_name_on_connection (server->connection,
|
||||||
"com.redhat.eekboard.Device",
|
"com.redhat.eekboard.Keyboard",
|
||||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||||
on_name_acquired,
|
on_name_acquired,
|
||||||
on_name_lost,
|
on_name_lost,
|
||||||
|
|||||||
@ -50,9 +50,9 @@ typedef struct _EekboardSystemClientClass EekboardSystemClientClass;
|
|||||||
struct _EekboardSystemClient {
|
struct _EekboardSystemClient {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
EekboardDevice *device;
|
EekboardKeyboard *keyboard;
|
||||||
|
|
||||||
EekKeyboard *keyboard;
|
EekKeyboard *description;
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
XklEngine *xkl_engine;
|
XklEngine *xkl_engine;
|
||||||
XklConfigRegistry *xkl_config_registry;
|
XklConfigRegistry *xkl_config_registry;
|
||||||
@ -101,7 +101,7 @@ static SPIBoolean keystroke_listener_cb
|
|||||||
(const AccessibleKeystroke *stroke,
|
(const AccessibleKeystroke *stroke,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
#endif /* HAVE_CSPI */
|
#endif /* HAVE_CSPI */
|
||||||
static void set_keyboard (EekboardSystemClient *client);
|
static void set_description (EekboardSystemClient *client);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_system_client_set_property (GObject *object,
|
eekboard_system_client_set_property (GObject *object,
|
||||||
@ -117,7 +117,7 @@ eekboard_system_client_set_property (GObject *object,
|
|||||||
case PROP_CONNECTION:
|
case PROP_CONNECTION:
|
||||||
connection = g_value_get_object (value);
|
connection = g_value_get_object (value);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
client->device = eekboard_device_new ("/com/redhat/eekboard/Device",
|
client->keyboard = eekboard_keyboard_new ("/com/redhat/eekboard/Keyboard",
|
||||||
connection,
|
connection,
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
@ -146,9 +146,14 @@ eekboard_system_client_dispose (GObject *object)
|
|||||||
eekboard_system_client_disable_fakekey (client);
|
eekboard_system_client_disable_fakekey (client);
|
||||||
#endif /* HAVE_FAKEKEY */
|
#endif /* HAVE_FAKEKEY */
|
||||||
|
|
||||||
if (client->device) {
|
if (client->keyboard) {
|
||||||
g_object_unref (client->device);
|
g_object_unref (client->keyboard);
|
||||||
client->device = NULL;
|
client->keyboard = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client->description) {
|
||||||
|
g_object_unref (client->description);
|
||||||
|
client->description = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_FAKEKEY
|
#ifdef HAVE_FAKEKEY
|
||||||
@ -191,7 +196,7 @@ eekboard_system_client_init (EekboardSystemClient *client)
|
|||||||
client->display = NULL;
|
client->display = NULL;
|
||||||
client->xkl_engine = NULL;
|
client->xkl_engine = NULL;
|
||||||
client->xkl_config_registry = NULL;
|
client->xkl_config_registry = NULL;
|
||||||
client->device = NULL;
|
client->description = NULL;
|
||||||
client->key_pressed_handler = 0;
|
client->key_pressed_handler = 0;
|
||||||
client->key_released_handler = 0;
|
client->key_released_handler = 0;
|
||||||
client->xkl_config_changed_handler = 0;
|
client->xkl_config_changed_handler = 0;
|
||||||
@ -241,7 +246,7 @@ eekboard_system_client_enable_xkl (EekboardSystemClient *client)
|
|||||||
|
|
||||||
xkl_engine_start_listen (client->xkl_engine, XKLL_TRACK_KEYBOARD_STATE);
|
xkl_engine_start_listen (client->xkl_engine, XKLL_TRACK_KEYBOARD_STATE);
|
||||||
|
|
||||||
set_keyboard (client);
|
set_description (client);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -337,12 +342,12 @@ focus_listener_cb (const AccessibleEvent *event,
|
|||||||
case SPI_ROLE_TERMINAL:
|
case SPI_ROLE_TERMINAL:
|
||||||
case SPI_ROLE_ENTRY:
|
case SPI_ROLE_ENTRY:
|
||||||
if (g_strcmp0 (event->type, "focus") == 0 || event->detail1 == 1)
|
if (g_strcmp0 (event->type, "focus") == 0 || event->detail1 == 1)
|
||||||
eekboard_device_show (client->device);
|
eekboard_keyboard_show (client->keyboard);
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
eekboard_device_hide (client->device);
|
eekboard_keyboard_hide (client->keyboard);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -356,7 +361,8 @@ keystroke_listener_cb (const AccessibleKeystroke *stroke,
|
|||||||
|
|
||||||
/* Ignore modifiers since the keystroke listener does not called
|
/* Ignore modifiers since the keystroke listener does not called
|
||||||
when a modifier key is released. */
|
when a modifier key is released. */
|
||||||
key = eek_keyboard_find_key_by_keycode (client->keyboard, stroke->keycode);
|
key = eek_keyboard_find_key_by_keycode (client->description,
|
||||||
|
stroke->keycode);
|
||||||
if (key) {
|
if (key) {
|
||||||
EekSymbol *symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
|
EekSymbol *symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
|
||||||
if (symbol && eek_symbol_is_modifier (symbol))
|
if (symbol && eek_symbol_is_modifier (symbol))
|
||||||
@ -364,9 +370,9 @@ keystroke_listener_cb (const AccessibleKeystroke *stroke,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stroke->type == SPI_KEY_PRESSED)
|
if (stroke->type == SPI_KEY_PRESSED)
|
||||||
eekboard_device_press_key (client->device, stroke->keycode);
|
eekboard_keyboard_press_key (client->keyboard, stroke->keycode);
|
||||||
else
|
else
|
||||||
eekboard_device_release_key (client->device, stroke->keycode);
|
eekboard_keyboard_release_key (client->keyboard, stroke->keycode);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_CSPI */
|
#endif /* HAVE_CSPI */
|
||||||
@ -397,7 +403,7 @@ on_xkl_config_changed (XklEngine *xklengine,
|
|||||||
{
|
{
|
||||||
EekboardSystemClient *client = user_data;
|
EekboardSystemClient *client = user_data;
|
||||||
|
|
||||||
set_keyboard (client);
|
set_description (client);
|
||||||
|
|
||||||
#ifdef HAVE_FAKEKEY
|
#ifdef HAVE_FAKEKEY
|
||||||
if (client->fakekey)
|
if (client->fakekey)
|
||||||
@ -406,23 +412,23 @@ on_xkl_config_changed (XklEngine *xklengine,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_keyboard (EekboardSystemClient *client)
|
set_description (EekboardSystemClient *client)
|
||||||
{
|
{
|
||||||
EekLayout *layout;
|
EekLayout *layout;
|
||||||
gchar *keyboard_name;
|
gchar *keyboard_name;
|
||||||
static gint keyboard_serial = 0;
|
static gint keyboard_serial = 0;
|
||||||
|
|
||||||
if (client->keyboard)
|
if (client->description)
|
||||||
g_object_unref (client->keyboard);
|
g_object_unref (client->description);
|
||||||
layout = eek_xkl_layout_new ();
|
layout = eek_xkl_layout_new ();
|
||||||
client->keyboard = eek_keyboard_new (layout, CSW, CSH);
|
client->description = eek_keyboard_new (layout, CSW, CSH);
|
||||||
eek_keyboard_set_modifier_behavior (client->keyboard,
|
eek_keyboard_set_modifier_behavior (client->description,
|
||||||
EEK_MODIFIER_BEHAVIOR_LATCH);
|
EEK_MODIFIER_BEHAVIOR_LATCH);
|
||||||
|
|
||||||
keyboard_name = g_strdup_printf ("keyboard%d", keyboard_serial++);
|
keyboard_name = g_strdup_printf ("keyboard%d", keyboard_serial++);
|
||||||
eek_element_set_name (EEK_ELEMENT(client->keyboard), keyboard_name);
|
eek_element_set_name (EEK_ELEMENT(client->description), keyboard_name);
|
||||||
|
|
||||||
eekboard_device_set_keyboard (client->device, client->keyboard);
|
eekboard_keyboard_set_description (client->keyboard, client->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -434,11 +440,11 @@ on_xkl_state_changed (XklEngine *xklengine,
|
|||||||
{
|
{
|
||||||
EekboardSystemClient *client = user_data;
|
EekboardSystemClient *client = user_data;
|
||||||
|
|
||||||
if (type == GROUP_CHANGED && client->keyboard) {
|
if (type == GROUP_CHANGED && client->description) {
|
||||||
gint group = eek_keyboard_get_group (client->keyboard);
|
gint group = eek_keyboard_get_group (client->description);
|
||||||
if (group != value) {
|
if (group != value) {
|
||||||
eek_keyboard_set_group (client->keyboard, value);
|
eek_keyboard_set_group (client->description, value);
|
||||||
eekboard_device_set_group (client->device, value);
|
eekboard_keyboard_set_group (client->keyboard, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -462,7 +468,7 @@ get_fakekey_modifiers (EekModifierType modifiers)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_key_pressed (EekboardDevice *device,
|
on_key_pressed (EekboardKeyboard *keyboard,
|
||||||
guint keycode,
|
guint keycode,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
@ -473,8 +479,8 @@ on_key_pressed (EekboardDevice *device,
|
|||||||
|
|
||||||
g_assert (client->fakekey);
|
g_assert (client->fakekey);
|
||||||
|
|
||||||
modifiers = eek_keyboard_get_modifiers (client->keyboard);
|
modifiers = eek_keyboard_get_modifiers (client->description);
|
||||||
key = eek_keyboard_find_key_by_keycode (client->keyboard, keycode);
|
key = eek_keyboard_find_key_by_keycode (client->description, keycode);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
// g_debug ("Can't find key for keycode %u", keycode);
|
// g_debug ("Can't find key for keycode %u", keycode);
|
||||||
return;
|
return;
|
||||||
@ -495,7 +501,7 @@ on_key_pressed (EekboardDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_key_released (EekboardDevice *device,
|
on_key_released (EekboardKeyboard *keyboard,
|
||||||
guint keycode,
|
guint keycode,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
@ -504,7 +510,7 @@ on_key_released (EekboardDevice *device,
|
|||||||
|
|
||||||
g_assert (client->fakekey);
|
g_assert (client->fakekey);
|
||||||
fakekey_release (client->fakekey);
|
fakekey_release (client->fakekey);
|
||||||
key = eek_keyboard_find_key_by_keycode (client->keyboard, keycode);
|
key = eek_keyboard_find_key_by_keycode (client->description, keycode);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
// g_debug ("Can't find key for keycode %u", keycode);
|
// g_debug ("Can't find key for keycode %u", keycode);
|
||||||
return;
|
return;
|
||||||
@ -526,10 +532,10 @@ eekboard_system_client_enable_fakekey (EekboardSystemClient *client)
|
|||||||
g_assert (client->fakekey);
|
g_assert (client->fakekey);
|
||||||
|
|
||||||
client->key_pressed_handler =
|
client->key_pressed_handler =
|
||||||
g_signal_connect (client->device, "key-pressed",
|
g_signal_connect (client->keyboard, "key-pressed",
|
||||||
G_CALLBACK(on_key_pressed), client);
|
G_CALLBACK(on_key_pressed), client);
|
||||||
client->key_released_handler =
|
client->key_released_handler =
|
||||||
g_signal_connect (client->device, "key-pressed",
|
g_signal_connect (client->keyboard, "key-released",
|
||||||
G_CALLBACK(on_key_released), client);
|
G_CALLBACK(on_key_released), client);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -541,13 +547,13 @@ eekboard_system_client_disable_fakekey (EekboardSystemClient *client)
|
|||||||
if (client->fakekey)
|
if (client->fakekey)
|
||||||
fakekey_release (client->fakekey);
|
fakekey_release (client->fakekey);
|
||||||
|
|
||||||
if (g_signal_handler_is_connected (client->device,
|
if (g_signal_handler_is_connected (client->keyboard,
|
||||||
client->key_pressed_handler))
|
client->key_pressed_handler))
|
||||||
g_signal_handler_disconnect (client->device,
|
g_signal_handler_disconnect (client->keyboard,
|
||||||
client->key_pressed_handler);
|
client->key_pressed_handler);
|
||||||
if (g_signal_handler_is_connected (client->device,
|
if (g_signal_handler_is_connected (client->keyboard,
|
||||||
client->key_released_handler))
|
client->key_released_handler))
|
||||||
g_signal_handler_disconnect (client->device,
|
g_signal_handler_disconnect (client->keyboard,
|
||||||
client->key_released_handler);
|
client->key_released_handler);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_FAKEKEY */
|
#endif /* HAVE_FAKEKEY */
|
||||||
|
|||||||
Reference in New Issue
Block a user