Skip to content

Commit

Permalink
Enable emoji keybinding in Wayland
Browse files Browse the repository at this point in the history
XI2 keybinding does not work for the root window in Wayland because
of a security issue maybe. Now I think to move the keybinding in
ibus-extension-gtk3 to each IBusEngine.

FIXME: Unfortunatelly gtk_get_current_event_time() cannot get time
for the delayed DBus events and gtk_window_move() does not work for
GtkDialog without a parent window in Wayland.

R=Shawn.P.Huang@gmail.com

Review URL: https://codereview.appspot.com/333700043
  • Loading branch information
fujiwarat committed Feb 27, 2018
1 parent 7ccbd21 commit c57b7c3
Show file tree
Hide file tree
Showing 11 changed files with 863 additions and 65 deletions.
19 changes: 18 additions & 1 deletion bus/engineproxy.c
Expand Up @@ -2,7 +2,7 @@
/* vim:set et sts=4: */
/* ibus - The Input Bus
* Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (C) 2015-2016 Takao Fujiwara <takao.fujiwara1@gmail.com>
* Copyright (C) 2015-2018 Takao Fujiwara <takao.fujiwara1@gmail.com>
* Copyright (C) 2008-2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -90,6 +90,7 @@ enum {
CURSOR_DOWN_LOOKUP_TABLE,
REGISTER_PROPERTIES,
UPDATE_PROPERTY,
PANEL_EXTENSION,
LAST_SIGNAL,
};

Expand Down Expand Up @@ -370,6 +371,17 @@ bus_engine_proxy_class_init (BusEngineProxyClass *class)
1,
IBUS_TYPE_PROPERTY);

engine_signals[PANEL_EXTENSION] =
g_signal_new (I_("panel-extension"),
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
bus_marshal_VOID__VARIANT,
G_TYPE_NONE,
1,
G_TYPE_VARIANT);

text_empty = ibus_text_new_from_static_string ("");
g_object_ref_sink (text_empty);

Expand Down Expand Up @@ -631,6 +643,11 @@ bus_engine_proxy_g_signal (GDBusProxy *proxy,
return;
}

if (g_strcmp0 (signal_name, "PanelExtension") == 0) {
g_signal_emit (engine, engine_signals[PANEL_EXTENSION], 0, parameters);
return;
}

g_return_if_reached ();
}

Expand Down
47 changes: 40 additions & 7 deletions bus/ibusimpl.c
Expand Up @@ -302,9 +302,8 @@ _panel_destroy_cb (BusPanelProxy *panel,
}

static void
_panel_panel_extension_cb (BusPanelProxy *panel,
GVariant *parameters,
BusIBusImpl *ibus)
bus_ibus_impl_panel_extension_received (BusIBusImpl *ibus,
GVariant *parameters)
{
if (!ibus->extension) {
g_warning ("Panel extension is not running.");
Expand All @@ -323,6 +322,14 @@ _panel_panel_extension_cb (BusPanelProxy *panel,
-1, NULL, NULL, NULL);
}

static void
_panel_panel_extension_cb (BusPanelProxy *panel,
GVariant *parameters,
BusIBusImpl *ibus)
{
bus_ibus_impl_panel_extension_received (ibus, parameters);
}

static void
_registry_changed_cb (IBusRegistry *registry,
BusIBusImpl *ibus)
Expand Down Expand Up @@ -642,6 +649,21 @@ bus_ibus_impl_set_context_engine_from_desc (BusIBusImpl *ibus,
NULL);
}

static void
_context_panel_extension_cb (BusInputContext *context,
GVariant *parameters,
BusIBusImpl *ibus)
{
bus_ibus_impl_panel_extension_received (ibus, parameters);
}

const static struct {
const gchar *name;
GCallback callback;
} context_signals [] = {
{ "panel-extension", G_CALLBACK (_context_panel_extension_cb) }
};

/**
* bus_ibus_impl_set_focused_context:
*
Expand All @@ -651,6 +673,11 @@ static void
bus_ibus_impl_set_focused_context (BusIBusImpl *ibus,
BusInputContext *context)
{
gint i;
BusEngineProxy *engine = NULL;
guint purpose = 0;
guint hints = 0;

g_assert (BUS_IS_IBUS_IMPL (ibus));
g_assert (context == NULL || BUS_IS_INPUT_CONTEXT (context));
g_assert (context == NULL || bus_input_context_get_capabilities (context) & IBUS_CAP_FOCUS);
Expand All @@ -660,10 +687,6 @@ bus_ibus_impl_set_focused_context (BusIBusImpl *ibus,
return;
}

BusEngineProxy *engine = NULL;
guint purpose = 0;
guint hints = 0;

if (ibus->focused_context) {
if (ibus->use_global_engine) {
/* dettach engine from the focused context */
Expand All @@ -681,6 +704,10 @@ bus_ibus_impl_set_focused_context (BusIBusImpl *ibus,

bus_input_context_get_content_type (ibus->focused_context,
&purpose, &hints);
for (i = 0; i < G_N_ELEMENTS(context_signals); i++) {
g_signal_handlers_disconnect_by_func (ibus->focused_context,
context_signals[i].callback, ibus);
}
g_object_unref (ibus->focused_context);
ibus->focused_context = NULL;
}
Expand All @@ -698,6 +725,12 @@ bus_ibus_impl_set_focused_context (BusIBusImpl *ibus,
bus_input_context_set_engine (context, engine);
bus_input_context_enable (context);
}
for (i = 0; i < G_N_ELEMENTS(context_signals); i++) {
g_signal_connect (ibus->focused_context,
context_signals[i].name,
context_signals[i].callback,
ibus);
}

if (ibus->panel != NULL)
bus_panel_proxy_focus_in (ibus->panel, context);
Expand Down
29 changes: 28 additions & 1 deletion bus/inputcontext.c
Expand Up @@ -127,6 +127,7 @@ enum {
ENGINE_CHANGED,
REQUEST_ENGINE,
SET_CONTENT_TYPE,
PANEL_EXTENSION,
LAST_SIGNAL,
};

Expand Down Expand Up @@ -598,6 +599,17 @@ bus_input_context_class_init (BusInputContextClass *class)
G_TYPE_UINT,
G_TYPE_UINT);

context_signals[PANEL_EXTENSION] =
g_signal_new (I_("panel-extension"),
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
bus_marshal_VOID__VARIANT,
G_TYPE_NONE,
1,
G_TYPE_VARIANT);

text_empty = ibus_text_new_from_string ("");
g_object_ref_sink (text_empty);
lookup_table_empty = ibus_lookup_table_new (9 /* page size */, 0, FALSE, FALSE);
Expand Down Expand Up @@ -2102,6 +2114,20 @@ _engine_update_property_cb (BusEngineProxy *engine,
bus_input_context_update_property (context, prop);
}

/**
* _engine_panel_extension_cb:
*
* A function to be called when "panel-extension" glib signal is sent
* from the engine object.
*/
static void
_engine_panel_extension_cb (BusEngineProxy *engine,
GVariant *parameters,
BusInputContext *context)
{
g_signal_emit (context, context_signals[PANEL_EXTENSION], 0, parameters);
}

#define DEFINE_FUNCTION(name) \
static void \
_engine_##name##_cb (BusEngineProxy *engine, \
Expand Down Expand Up @@ -2244,7 +2270,8 @@ const static struct {
{ "cursor-down-lookup-table", G_CALLBACK (_engine_cursor_down_lookup_table_cb) },
{ "register-properties", G_CALLBACK (_engine_register_properties_cb) },
{ "update-property", G_CALLBACK (_engine_update_property_cb) },
{ "destroy", G_CALLBACK (_engine_destroy_cb) },
{ "panel-extension", G_CALLBACK (_engine_panel_extension_cb) },
{ "destroy", G_CALLBACK (_engine_destroy_cb) }
};

static void
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Expand Up @@ -72,6 +72,7 @@ libibus_1_0_la_LDFLAGS = \
$(NULL)

ibus_sources = \
ibusaccelgroup.c \
ibusattribute.c \
ibusattrlist.c \
ibusbus.c \
Expand Down Expand Up @@ -122,6 +123,7 @@ ibus_enumtypes_sources = \
$(NULL)
ibus_headers = \
ibus.h \
ibusaccelgroup.h \
ibusattribute.h \
ibusattrlist.h \
ibusbus.h \
Expand Down
1 change: 1 addition & 0 deletions src/ibus.h
Expand Up @@ -60,6 +60,7 @@
#include <ibusemoji.h>
#include <ibusunicode.h>
#include <ibusxevent.h>
#include <ibusaccelgroup.h>

#ifndef IBUS_DISABLE_DEPRECATED
#include <ibuskeysyms-compat.h>
Expand Down

0 comments on commit c57b7c3

Please sign in to comment.