Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: bus/inputcontext.c

Issue 1784007: Merge xkb related changes. (Closed) Base URL: ssh://git@chromiumos-git/ibus.git
Patch Set: Revert the default values of some configs. Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« bus/ibusimpl.c ('K') | « bus/ibusimpl.c ('k') | ibus/bus.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* vim:set et sts=4: */ 1 /* vim:set et sts=4: */
2 /* ibus - The Input Bus 2 /* ibus - The Input Bus
3 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com> 3 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
4 * Copyright (C) 2008-2010 Red Hat, Inc. 4 * Copyright (C) 2008-2010 Red Hat, Inc.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public 7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 PAGE_UP_LOOKUP_TABLE, 43 PAGE_UP_LOOKUP_TABLE,
44 PAGE_DOWN_LOOKUP_TABLE, 44 PAGE_DOWN_LOOKUP_TABLE,
45 CURSOR_UP_LOOKUP_TABLE, 45 CURSOR_UP_LOOKUP_TABLE,
46 CURSOR_DOWN_LOOKUP_TABLE, 46 CURSOR_DOWN_LOOKUP_TABLE,
47 REGISTER_PROPERTIES, 47 REGISTER_PROPERTIES,
48 UPDATE_PROPERTY, 48 UPDATE_PROPERTY,
49 ENABLED, 49 ENABLED,
50 DISABLED, 50 DISABLED,
51 ENGINE_CHANGED, 51 ENGINE_CHANGED,
52 REQUEST_ENGINE, 52 REQUEST_ENGINE,
53 REQUEST_NEXT_ENGINE,
54 REQUEST_PREV_ENGINE,
55 LAST_SIGNAL, 53 LAST_SIGNAL,
56 }; 54 };
57 55
58 enum { 56 enum {
59 PROP_0, 57 PROP_0,
60 }; 58 };
61 59
62 typedef struct _BusInputContextPrivate BusInputContextPrivate; 60 typedef struct _BusInputContextPrivate BusInputContextPrivate;
63 61
64 static guint context_signals[LAST_SIGNAL] = { 0 }; 62 static guint context_signals[LAST_SIGNAL] = { 0 };
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 g_signal_new (I_("request-engine"), 421 g_signal_new (I_("request-engine"),
424 G_TYPE_FROM_CLASS (klass), 422 G_TYPE_FROM_CLASS (klass),
425 G_SIGNAL_RUN_LAST, 423 G_SIGNAL_RUN_LAST,
426 0, 424 0,
427 NULL, NULL, 425 NULL, NULL,
428 ibus_marshal_VOID__STRING, 426 ibus_marshal_VOID__STRING,
429 G_TYPE_NONE, 427 G_TYPE_NONE,
430 1, 428 1,
431 G_TYPE_STRING); 429 G_TYPE_STRING);
432 430
433 context_signals[REQUEST_NEXT_ENGINE] =
434 g_signal_new (I_("request-next-engine"),
435 G_TYPE_FROM_CLASS (klass),
436 G_SIGNAL_RUN_LAST,
437 0,
438 NULL, NULL,
439 ibus_marshal_VOID__VOID,
440 G_TYPE_NONE,
441 0);
442
443 context_signals[REQUEST_PREV_ENGINE] =
444 g_signal_new (I_("request-prev-engine"),
445 G_TYPE_FROM_CLASS (klass),
446 G_SIGNAL_RUN_LAST,
447 0,
448 NULL, NULL,
449 ibus_marshal_VOID__VOID,
450 G_TYPE_NONE,
451 0);
452
453 text_empty = ibus_text_new_from_string (""); 431 text_empty = ibus_text_new_from_string ("");
454 g_object_ref_sink (text_empty); 432 g_object_ref_sink (text_empty);
455 lookup_table_empty = ibus_lookup_table_new (9, 0, FALSE, FALSE); 433 lookup_table_empty = ibus_lookup_table_new (9, 0, FALSE, FALSE);
456 g_object_ref_sink (lookup_table_empty); 434 g_object_ref_sink (lookup_table_empty);
457 props_empty = ibus_prop_list_new (); 435 props_empty = ibus_prop_list_new ();
458 g_object_ref_sink (props_empty); 436 g_object_ref_sink (props_empty);
459 } 437 }
460 438
461 static void 439 static void
462 bus_input_context_init (BusInputContext *context) 440 bus_input_context_init (BusInputContext *context)
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 DEFINE_FUNCTION (page_down_lookup_table) 1849 DEFINE_FUNCTION (page_down_lookup_table)
1872 DEFINE_FUNCTION (cursor_up_lookup_table) 1850 DEFINE_FUNCTION (cursor_up_lookup_table)
1873 DEFINE_FUNCTION (cursor_down_lookup_table) 1851 DEFINE_FUNCTION (cursor_down_lookup_table)
1874 #undef DEFINE_FUNCTION 1852 #undef DEFINE_FUNCTION
1875 1853
1876 void 1854 void
1877 bus_input_context_enable (BusInputContext *context) 1855 bus_input_context_enable (BusInputContext *context)
1878 { 1856 {
1879 g_assert (BUS_IS_INPUT_CONTEXT (context)); 1857 g_assert (BUS_IS_INPUT_CONTEXT (context));
1880 1858
1859 if (!context->has_focus) {
1860 context->enabled = TRUE;
1861 /* TODO: Do we need to emit "enabled" signal? */
1862 return;
1863 }
1864
1881 if (context->engine == NULL) { 1865 if (context->engine == NULL) {
1882 g_signal_emit (context, context_signals[REQUEST_ENGINE], 0, NULL); 1866 g_signal_emit (context, context_signals[REQUEST_ENGINE], 0, NULL);
1883 } 1867 }
1884 1868
1885 if (context->engine == NULL) 1869 if (context->engine == NULL)
1886 return; 1870 return;
1887 1871
1888 context->enabled = TRUE; 1872 context->enabled = TRUE;
1889 1873
1890 if (context->has_focus) { 1874 bus_engine_proxy_enable (context->engine);
1891 bus_engine_proxy_enable (context->engine); 1875 bus_engine_proxy_focus_in (context->engine);
1892 bus_engine_proxy_focus_in (context->engine); 1876 bus_engine_proxy_set_capabilities (context->engine, context->capabilities);
1893 bus_engine_proxy_set_capabilities (context->engine, context->capabilitie s); 1877 bus_engine_proxy_set_cursor_location (context->engine, context->x, context-> y, context->w, context->h);
1894 bus_engine_proxy_set_cursor_location (context->engine, context->x, conte xt->y, context->w, context->h); 1878
1895 }
1896 bus_input_context_send_signal (context, 1879 bus_input_context_send_signal (context,
1897 "Enabled", 1880 "Enabled",
1898 G_TYPE_INVALID); 1881 G_TYPE_INVALID);
1899 g_signal_emit (context, 1882 g_signal_emit (context,
1900 context_signals[ENABLED], 1883 context_signals[ENABLED],
1901 0); 1884 0);
1902 } 1885 }
1903 1886
1904 void 1887 void
1905 bus_input_context_disable (BusInputContext *context) 1888 bus_input_context_disable (BusInputContext *context)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 context->engine = NULL; 1963 context->engine = NULL;
1981 } 1964 }
1982 } 1965 }
1983 1966
1984 void 1967 void
1985 bus_input_context_set_engine (BusInputContext *context, 1968 bus_input_context_set_engine (BusInputContext *context,
1986 BusEngineProxy *engine) 1969 BusEngineProxy *engine)
1987 { 1970 {
1988 g_assert (BUS_IS_INPUT_CONTEXT (context)); 1971 g_assert (BUS_IS_INPUT_CONTEXT (context));
1989 1972
1973 if (context->engine == engine)
1974 return;
1975
1990 if (context->engine != NULL) { 1976 if (context->engine != NULL) {
1991 bus_input_context_unset_engine (context); 1977 bus_input_context_unset_engine (context);
1992 } 1978 }
1993 1979
1994 if (engine == NULL) { 1980 if (engine == NULL) {
1995 bus_input_context_disable (context); 1981 bus_input_context_disable (context);
1996 } 1982 }
1997 else { 1983 else {
1998 gint i; 1984 gint i;
1999 context->engine = engine; 1985 context->engine = engine;
(...skipping 28 matching lines...) Expand all
2028 static gboolean 2014 static gboolean
2029 bus_input_context_filter_keyboard_shortcuts (BusInputContext *context, 2015 bus_input_context_filter_keyboard_shortcuts (BusInputContext *context,
2030 guint keyval, 2016 guint keyval,
2031 guint keycode, 2017 guint keycode,
2032 guint modifiers) 2018 guint modifiers)
2033 { 2019 {
2034 g_assert (BUS_IS_INPUT_CONTEXT (context)); 2020 g_assert (BUS_IS_INPUT_CONTEXT (context));
2035 2021
2036 gboolean retval = FALSE; 2022 gboolean retval = FALSE;
2037 2023
2038 static GQuark trigger; 2024 if (context->filter_release){
2039 static GQuark next_factory; 2025 if(modifiers & IBUS_RELEASE_MASK) {
2040 static GQuark prev_factory; 2026 /* filter release key event */
2041 2027 return TRUE;
2042 GQuark event; 2028 }
2029 else {
2030 /* stop filter release key event */
2031 context->filter_release = FALSE;
2032 }
2033 }
2043 2034
2044 if (keycode != 0 && !BUS_DEFAULT_IBUS->use_sys_layout) { 2035 if (keycode != 0 && !BUS_DEFAULT_IBUS->use_sys_layout) {
2045 IBusKeymap *keymap = BUS_DEFAULT_KEYMAP; 2036 IBusKeymap *keymap = BUS_DEFAULT_KEYMAP;
2046 if (keymap != NULL) { 2037 if (keymap != NULL) {
2047 guint tmp = ibus_keymap_lookup_keysym (keymap, 2038 guint tmp = ibus_keymap_lookup_keysym (keymap,
2048 keycode, 2039 keycode,
2049 modifiers); 2040 modifiers);
2050 if (tmp != IBUS_VoidSymbol) 2041 if (tmp != IBUS_VoidSymbol)
2051 keyval = tmp; 2042 keyval = tmp;
2052 } 2043 }
2053 } 2044 }
2054 2045
2055 if (trigger == 0) { 2046 retval = bus_ibus_impl_filter_keyboard_shortcuts (BUS_DEFAULT_IBUS,
2056 trigger = g_quark_from_static_string ("trigger"); 2047 context,
2057 next_factory = g_quark_from_static_string ("next-engine"); 2048 keyval,
2058 prev_factory = g_quark_from_static_string ("prev-engine"); 2049 modifiers,
2059 } 2050 context->prev_keyval,
2060 2051 context->prev_modifiers);
2061 if (context->filter_release){
2062 if(modifiers & IBUS_RELEASE_MASK) {
2063 /* filter release key event */
2064 return TRUE;
2065 }
2066 else {
2067 /* stop filter release key event */
2068 context->filter_release = FALSE;
2069 }
2070 }
2071
2072 event = ibus_hotkey_profile_filter_key_event (BUS_DEFAULT_HOTKEY_PROFILE,
2073 keyval,
2074 modifiers,
2075 context->prev_keyval,
2076 context->prev_modifiers,
2077 0);
2078 context->prev_keyval = keyval; 2052 context->prev_keyval = keyval;
2079 context->prev_modifiers = modifiers; 2053 context->prev_modifiers = modifiers;
2080 2054
2081 if (event == trigger) {
2082 gboolean enabled = context->enabled;
2083
2084 if (context->enabled) {
2085 bus_input_context_disable (context);
2086 }
2087 else {
2088 bus_input_context_enable (context);
2089 }
2090
2091 retval = (enabled != context->enabled);
2092 }
2093 else if (event == next_factory) {
2094 if (context->engine == NULL || context->enabled == FALSE) {
2095 retval = FALSE;
2096 }
2097 else {
2098 g_signal_emit (context, context_signals[REQUEST_NEXT_ENGINE], 0);
2099 retval = TRUE;
2100 }
2101 }
2102 else if (event == prev_factory) {
2103 if (context->engine == NULL || context->enabled == FALSE) {
2104 retval = FALSE;
2105 }
2106 else {
2107 g_signal_emit (context, context_signals[REQUEST_PREV_ENGINE], 0);
2108 retval = TRUE;
2109 }
2110 }
2111
2112 if (retval == TRUE) { 2055 if (retval == TRUE) {
2113 /* begin filter release key event */ 2056 /* begin filter release key event */
2114 context->filter_release = TRUE; 2057 context->filter_release = TRUE;
2115 } 2058 }
2116 2059
2117 return retval; 2060 return retval;
2118 } 2061 }
2119 2062
2120 2063
2121 static gboolean 2064 static gboolean
(...skipping 25 matching lines...) Expand all
2147 2090
2148 return retval; 2091 return retval;
2149 } 2092 }
2150 2093
2151 guint 2094 guint
2152 bus_input_context_get_capabilities (BusInputContext *context) 2095 bus_input_context_get_capabilities (BusInputContext *context)
2153 { 2096 {
2154 g_assert (BUS_IS_INPUT_CONTEXT (context)); 2097 g_assert (BUS_IS_INPUT_CONTEXT (context));
2155 return context->capabilities; 2098 return context->capabilities;
2156 } 2099 }
OLDNEW
« bus/ibusimpl.c ('K') | « bus/ibusimpl.c ('k') | ibus/bus.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698