Skip to content

Commit

Permalink
Send panel input purpose.
Browse files Browse the repository at this point in the history
gnome-shell gets input purpose so that disables IME with password mode.

Review URL: https://codereview.appspot.com/81770044
  • Loading branch information
fujiwarat committed Apr 3, 2014
1 parent 18612e1 commit 6ca5ddb
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 68 deletions.
16 changes: 14 additions & 2 deletions bus/inputcontext.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
* Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (C) 2008-2013 Red Hat, Inc.
* Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (C) 2008-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -2459,3 +2459,15 @@ bus_input_context_get_client (BusInputContext *context)
g_assert (BUS_IS_INPUT_CONTEXT (context));
return context->client;
}

void
bus_input_context_get_content_type (BusInputContext *context,
guint *purpose,
guint *hints)
{
g_assert (BUS_IS_INPUT_CONTEXT (context));
g_return_if_fail (purpose != NULL && hints != NULL);

*purpose = context->purpose;
*hints = context->hints;
}
158 changes: 100 additions & 58 deletions bus/inputcontext.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* bus - The Input Bus
* Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (C) 2008-2010 Red Hat, Inc.
/* ibus - The Input Bus
* Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (C) 2008-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -32,181 +32,223 @@
*/

/* define GOBJECT macros */
#define BUS_TYPE_INPUT_CONTEXT \
#define BUS_TYPE_INPUT_CONTEXT \
(bus_input_context_get_type ())
#define BUS_INPUT_CONTEXT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), BUS_TYPE_INPUT_CONTEXT, BusInputContext))
#define BUS_INPUT_CONTEXT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), BUS_TYPE_INPUT_CONTEXT, BusInputContextClass))
#define BUS_IS_INPUT_CONTEXT(obj) \
#define BUS_INPUT_CONTEXT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
BUS_TYPE_INPUT_CONTEXT, \
BusInputContext))
#define BUS_INPUT_CONTEXT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
BUS_TYPE_INPUT_CONTEXT, \
BusInputContextClass))
#define BUS_IS_INPUT_CONTEXT(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), BUS_TYPE_INPUT_CONTEXT))
#define BUS_IS_INPUT_CONTEXT_CLASS(klass) \
#define BUS_IS_INPUT_CONTEXT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), BUS_TYPE_INPUT_CONTEXT))
#define BUS_INPUT_CONTEXT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), BUS_TYPE_INPUT_CONTEXT, BusInputContextClass))
#define BUS_INPUT_CONTEXT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
BUS_TYPE_INPUT_CONTEXT, \
BusInputContextClass))

G_BEGIN_DECLS

typedef struct _BusInputContext BusInputContext;
typedef struct _BusInputContextClass BusInputContextClass;

GType bus_input_context_get_type (void);
BusInputContext *bus_input_context_new (BusConnection *connection,
const gchar *client);
GType bus_input_context_get_type (void);
BusInputContext *bus_input_context_new (BusConnection *connection,
const gchar *client);

/**
* bus_input_context_focus_in:
*
* Give a focus to the context. Call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods of the engine for the context,
* and then emit glib signals to the context object. This function does nothing if the context already has a focus.
* Give a focus to the context. Call FocusIn, Enable, SetCapabilities,
* and SetCursorLocation methods of the engine for the context,
* and then emit glib signals to the context object. This function does
* nothing if the context already has a focus.
*/
void bus_input_context_focus_in (BusInputContext *context);
void bus_input_context_focus_in (BusInputContext *context);

/**
* bus_input_context_focus_out:
*
* Remove a focus from the context. Call FocusOut method of the engine for the context.
* Remove a focus from the context. Call FocusOut method of the engine for
* the context.
* This function does nothing if the context does not have a focus.
*/
void bus_input_context_focus_out (BusInputContext *context);
void bus_input_context_focus_out
(BusInputContext *context);

/**
* bus_input_context_has_focus:
* @returns: context->has_focus.
*/
gboolean bus_input_context_has_focus (BusInputContext *context);
gboolean bus_input_context_has_focus
(BusInputContext *context);

/**
* bus_input_context_enable:
*
* Enable the current engine for the context. Request an engine (if needed), call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods
* of the engine for the context, and then emit glib and D-Bus "enabled" signals.
* Enable the current engine for the context. Request an engine (if needed),
* call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods
* of the engine for the context, and then emit glib and D-Bus "enabled"
* signals.
*/
void bus_input_context_enable (BusInputContext *context);
void bus_input_context_enable (BusInputContext *context);

/**
* bus_input_context_disable:
*
* Disable the current engine for the context. Request an engine (if needed), call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods
* of the engine for the context, and then emit glib and D-Bus "enabled" signals.
* Disable the current engine for the context. Request an engine (if needed),
* call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods
* of the engine for the context, and then emit glib and D-Bus "enabled"
* signals.
*/
void bus_input_context_disable (BusInputContext *context);
void bus_input_context_disable (BusInputContext *context);

/**
* bus_input_context_page_up:
*
* Call page_up method of the current engine proxy.
*/
void bus_input_context_page_up (BusInputContext *context);
void bus_input_context_page_up (BusInputContext *context);

/**
* bus_input_context_page_down:
*
* Call page_down method of the current engine proxy.
*/
void bus_input_context_page_down (BusInputContext *context);
void bus_input_context_page_down
(BusInputContext *context);

/**
* bus_input_context_cursor_up:
*
* Call cursor_up method of the current engine proxy.
*/
void bus_input_context_cursor_up (BusInputContext *context);
void bus_input_context_cursor_up
(BusInputContext *context);

/**
* bus_input_context_cursor_down:
*
* Call cursor_down method of the current engine proxy.
*/
void bus_input_context_cursor_down (BusInputContext *context);
void bus_input_context_cursor_down
(BusInputContext *context);

/**
* bus_input_context_candidate_clicked:
*
* Call candidate_clicked method of the current engine proxy.
*/
void bus_input_context_candidate_clicked(BusInputContext *context,
guint index,
guint button,
guint state);
void bus_input_context_candidate_clicked
(BusInputContext *context,
guint index,
guint button,
guint state);

/**
* bus_input_context_set_engine:
*
* Use the engine on the context.
*/
void bus_input_context_set_engine (BusInputContext *context,
BusEngineProxy *engine);
void bus_input_context_set_engine
(BusInputContext *context,
BusEngineProxy *engine);

/**
* bus_input_context_set_engine_by_desc:
* @desc: the engine to use on the context.
* @timeout: timeout (in ms) for D-Bus calls.
* @callback: a function to be called when bus_input_context_set_engine_by_desc is finished. if NULL, the default callback
* function, which just calls bus_input_context_set_engine_by_desc_finish, is used.
* @callback: a function to be called when bus_input_context_set_engine_by_desc
* is finished. if NULL, the default callback
* function, which just calls
* bus_input_context_set_engine_by_desc_finish, is used.
*
* Create a new BusEngineProxy object and use it on the context.
*/
void bus_input_context_set_engine_by_desc
(BusInputContext *context,
IBusEngineDesc *desc,
gint timeout,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
(BusInputContext *context,
IBusEngineDesc *desc,
gint timeout,
GCancellable
*cancellable,
GAsyncReadyCallback callback,
gpointer user_data);

/**
* bus_input_context_set_engine_by_desc_finish:
*
* A function to be called by the GAsyncReadyCallback function for bus_input_context_set_engine_by_desc.
* A function to be called by the GAsyncReadyCallback function for
* bus_input_context_set_engine_by_desc.
*/
gboolean bus_input_context_set_engine_by_desc_finish
(BusInputContext *context,
GAsyncResult *res,
GError **error);
(BusInputContext *context,
GAsyncResult *res,
GError **error);

/**
* bus_input_context_get_engine:
*
* Get a BusEngineProxy object of the current engine.
*/
BusEngineProxy *bus_input_context_get_engine (BusInputContext *context);
BusEngineProxy *bus_input_context_get_engine
(BusInputContext *context);

/**
* bus_input_context_get_engine_desc:
*
* Get an IBusEngineDesc object of the current engine.
*/
IBusEngineDesc *bus_input_context_get_engine_desc (BusInputContext *context);
IBusEngineDesc *bus_input_context_get_engine_desc
(BusInputContext *context);

/**
* bus_input_context_property_activate:
*
* Call property_activate method of the current engine proxy.
*/
void bus_input_context_property_activate(BusInputContext *context,
const gchar *prop_name,
gint prop_state);
void bus_input_context_property_activate
(BusInputContext *context,
const gchar *prop_name,
gint
prop_state);

/**
* bus_input_context_get_capabilities:
* @returns: context->capabilities.
*/
guint bus_input_context_get_capabilities (BusInputContext *context);
guint bus_input_context_get_capabilities
(BusInputContext *context);

/**
* bus_input_context_set_capabilities:
*
* Call set_capabilities method of the current engine proxy.
*/
void bus_input_context_set_capabilities (BusInputContext *context,
guint capabilities);
void bus_input_context_set_capabilities
(BusInputContext *context,
guint
capabilities);

/**
* bus_input_context_get_client:
* @returns: context->client.
*/
const gchar *bus_input_context_get_client (BusInputContext *context);
const gchar *bus_input_context_get_client
(BusInputContext *context);

/**
* bus_input_context_get_content_type:
* @purpose: Input purpose.
* @hints: Input hints.
*/
void bus_input_context_get_content_type
(BusInputContext *context,
guint *purpose,
guint *hints);

G_END_DECLS
#endif
22 changes: 20 additions & 2 deletions bus/panelproxy.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
* Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (C) 2008-2013 Red Hat, Inc.
* Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (C) 2008-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -398,6 +398,20 @@ bus_panel_proxy_update_property (BusPanelProxy *panel,
-1, NULL, NULL, NULL);
}

void
bus_panel_proxy_set_content_type (BusPanelProxy *panel,
guint purpose,
guint hints)
{
g_assert (BUS_IS_PANEL_PROXY (panel));

g_dbus_proxy_call ((GDBusProxy *)panel,
"ContentType",
g_variant_new ("(uu)", purpose, hints),
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, NULL, NULL);
}

#define DEFINE_FUNC(name) \
static void \
bus_panel_proxy_##name (BusPanelProxy *panel) \
Expand Down Expand Up @@ -663,6 +677,10 @@ bus_panel_proxy_focus_in (BusPanelProxy *panel,
input_context_signals[i].callback,
panel);
}

guint purpose, hints;
bus_input_context_get_content_type (context, &purpose, &hints);
bus_panel_proxy_set_content_type (panel, purpose, hints);
}

void
Expand Down
8 changes: 6 additions & 2 deletions bus/panelproxy.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
* Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (C) 2008-2013 Red Hat, Inc.
* Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com>
* Copyright (C) 2008-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -109,6 +109,10 @@ void bus_panel_proxy_register_properties
void bus_panel_proxy_update_property
(BusPanelProxy *panel,
IBusProperty *prop);
void bus_panel_proxy_set_content_type
(BusPanelProxy *panel,
guint purpose,
guint hints);
G_END_DECLS
#endif

0 comments on commit 6ca5ddb

Please sign in to comment.