Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Delta Between Two Patch Sets: bus/test-client.c

Issue 5517048: Merge the devel branch (Closed) Base URL: git@github.com:phuang/ibus.git@devel
Left Patch Set: Rebase Created 13 years, 2 months ago
Right Patch Set: Rebase on HEAD Created 13 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « bus/server.c ('k') | bus/test-matchrule.c » ('j') | src/ibusbus.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ 1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */ 2 /* vim:set et sts=4: */
3 /* bus - The Input Bus 3 /* bus - The Input Bus
4 * Copyright (C) 2010 Google Inc. 4 * Copyright (C) 2010 Google 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ibus_input_context_set_capabilities (client->ibuscontext, client->caps); 105 ibus_input_context_set_capabilities (client->ibuscontext, client->caps);
106 106
107 active_engine_name = _get_active_engine_name (); 107 active_engine_name = _get_active_engine_name ();
108 108
109 g_return_if_fail (active_engine_name != NULL); 109 g_return_if_fail (active_engine_name != NULL);
110 IDEBUG ("engine:%s", active_engine_name); 110 IDEBUG ("engine:%s", active_engine_name);
111 ibus_input_context_focus_in (client->ibuscontext); 111 ibus_input_context_focus_in (client->ibuscontext);
112 ibus_input_context_set_engine (client->ibuscontext, active_engine_name); 112 ibus_input_context_set_engine (client->ibuscontext, active_engine_name);
113 g_free (active_engine_name); 113 g_free (active_engine_name);
114 114
115 ibus_input_context_enable (client->ibuscontext);
116 client->enabled = TRUE; 115 client->enabled = TRUE;
117 } 116 }
118 117
119 static void 118 static void
120 bus_test_client_destroy (IBusObject *object) 119 bus_test_client_destroy (IBusObject *object)
121 { 120 {
122 IDEBUG ("%s", __FUNCTION__); 121 IDEBUG ("%s", __FUNCTION__);
123 BusTestClient *client = BUS_TEST_CLIENT (object); 122 BusTestClient *client = BUS_TEST_CLIENT (object);
124 123
125 g_object_unref (client->ibuscontext); 124 g_object_unref (client->ibuscontext);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 keysym, 172 keysym,
174 keycode, 173 keycode,
175 state); 174 state);
176 _store_modifier_state (client, keysym); 175 _store_modifier_state (client, keysym);
177 } else { 176 } else {
178 IDEBUG ("key: %d is not modifier.", keysym); 177 IDEBUG ("key: %d is not modifier.", keysym);
179 gboolean is_upper = !gdk_keyval_is_lower (keysym); 178 gboolean is_upper = !gdk_keyval_is_lower (keysym);
180 gboolean is_shift_set = _is_shift_set (client); 179 gboolean is_shift_set = _is_shift_set (client);
181 180
182 if (is_upper && !is_shift_set) { 181 if (is_upper && !is_shift_set) {
183 _store_modifier_state (client, IBUS_Shift_L); 182 _store_modifier_state (client, IBUS_KEY_Shift_L);
184 } 183 }
185 keycode = _get_keysym_to_keycode (keysym); 184 keycode = _get_keysym_to_keycode (keysym);
186 state = _get_modifiers_to_mask (client); 185 state = _get_modifiers_to_mask (client);
187 ibus_input_context_process_key_event (client->ibuscontext, 186 ibus_input_context_process_key_event (client->ibuscontext,
188 keysym, 187 keysym,
189 keycode, 188 keycode,
190 state); 189 state);
191 state |= IBUS_RELEASE_MASK; 190 state |= IBUS_RELEASE_MASK;
192 ibus_input_context_process_key_event (client->ibuscontext, 191 ibus_input_context_process_key_event (client->ibuscontext,
193 keysym, 192 keysym,
194 keycode, 193 keycode,
195 state); 194 state);
196 if (is_upper && !is_shift_set) { 195 if (is_upper && !is_shift_set) {
197 _store_modifier_state (client, IBUS_Shift_L); 196 _store_modifier_state (client, IBUS_KEY_Shift_L);
198 } 197 }
199 } 198 }
200 return TRUE; 199 return TRUE;
201 } 200 }
202 201
203 void bus_test_client_clear_modifier (BusTestClient *client) 202 void bus_test_client_clear_modifier (BusTestClient *client)
204 { 203 {
205 int i; 204 int i;
206 for (i = 0; i < MODIFIER_KEY_NUM; i++) { 205 for (i = 0; i < MODIFIER_KEY_NUM; i++) {
207 (client->modifier)[i] = FALSE; 206 (client->modifier)[i] = FALSE;
208 } 207 }
209 } 208 }
210 209
211 static gchar * 210 static gchar *
212 _get_active_engine_name (void) 211 _get_active_engine_name (void)
213 { 212 {
214 GList *engines; 213 GList *engines;
215 gchar *result; 214 gchar *result;
216 215
217 engines = ibus_bus_list_active_engines (_bus); 216 engines = ibus_bus_list_active_engines (_bus);
218 if (engines == NULL) { 217 if (engines == NULL) {
219 return NULL; 218 return NULL;
220 } 219 }
221 220
222 IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (engines->data); 221 IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (engines->data);
223 if (engine_desc != NULL) { 222 if (engine_desc != NULL) {
224 result = g_strdup (engine_desc->name); 223 result = g_strdup (ibus_engine_desc_get_name(engine_desc));
225 } else { 224 } else {
226 result = NULL; 225 result = NULL;
227 } 226 }
228 227
229 for (; engines != NULL; engines = g_list_next (engines)) { 228 for (; engines != NULL; engines = g_list_next (engines)) {
230 g_object_unref (IBUS_ENGINE_DESC (engines->data)); 229 g_object_unref (IBUS_ENGINE_DESC (engines->data));
231 } 230 }
232 g_list_free (engines); 231 g_list_free (engines);
233 232
234 return result; 233 return result;
235 } 234 }
236 235
237 static void 236 static void
238 _store_modifier_state (BusTestClient *client, 237 _store_modifier_state (BusTestClient *client,
239 guint modifier) 238 guint modifier)
240 { 239 {
241 switch(modifier) { 240 switch(modifier) {
242 case IBUS_Shift_L: 241 case IBUS_KEY_Shift_L:
243 case IBUS_Shift_R: 242 case IBUS_KEY_Shift_R:
244 /* ShiftMask */ 243 /* ShiftMask */
245 client->modifier[0] = !client->modifier[0]; 244 client->modifier[0] = !client->modifier[0];
246 break; 245 break;
247 case IBUS_Shift_Lock: 246 case IBUS_KEY_Shift_Lock:
248 case IBUS_Caps_Lock: 247 case IBUS_KEY_Caps_Lock:
249 /* LockMask */ 248 /* LockMask */
250 client->modifier[1] = !client->modifier[1]; 249 client->modifier[1] = !client->modifier[1];
251 break; 250 break;
252 case IBUS_Control_L: 251 case IBUS_KEY_Control_L:
253 case IBUS_Control_R: 252 case IBUS_KEY_Control_R:
254 /* ControlMask */ 253 /* ControlMask */
255 client->modifier[2] = !client->modifier[2]; 254 client->modifier[2] = !client->modifier[2];
256 break; 255 break;
257 case IBUS_Alt_L: 256 case IBUS_KEY_Alt_L:
258 case IBUS_Alt_R: 257 case IBUS_KEY_Alt_R:
259 case IBUS_Meta_L: 258 case IBUS_KEY_Meta_L:
260 /* Mod1Mask */ 259 /* Mod1Mask */
261 client->modifier[3] = !client->modifier[3]; 260 client->modifier[3] = !client->modifier[3];
262 break; 261 break;
263 case IBUS_Num_Lock: 262 case IBUS_KEY_Num_Lock:
264 /* Mod2Mask */ 263 /* Mod2Mask */
265 client->modifier[4] = !client->modifier[4]; 264 client->modifier[4] = !client->modifier[4];
266 break; 265 break;
267 case IBUS_Super_L: 266 case IBUS_KEY_Super_L:
268 case IBUS_Hyper_L: 267 case IBUS_KEY_Hyper_L:
269 /* Mod4Mask */ 268 /* Mod4Mask */
270 client->modifier[5] = !client->modifier[5]; 269 client->modifier[5] = !client->modifier[5];
271 break; 270 break;
272 case IBUS_ISO_Level3_Shift: 271 case IBUS_KEY_ISO_Level3_Shift:
273 case IBUS_Mode_switch: 272 case IBUS_KEY_Mode_switch:
274 /* Mod5Mask */ 273 /* Mod5Mask */
275 client->modifier[6] = !client->modifier[6]; 274 client->modifier[6] = !client->modifier[6];
276 break; 275 break;
277 default: 276 default:
278 break; 277 break;
279 } 278 }
280 } 279 }
281 280
282 static gint16 281 static gint16
283 _get_keysym_to_keycode (guint keysym) 282 _get_keysym_to_keycode (guint keysym)
284 { 283 {
285 return XKeysymToKeycode (_xdisplay, keysym); 284 return XKeysymToKeycode (_xdisplay, keysym);
286 } 285 }
287 286
288 static gboolean 287 static gboolean
289 _is_shift_set (BusTestClient *client) 288 _is_shift_set (BusTestClient *client)
290 { 289 {
291 return client->modifier[0]; 290 return client->modifier[0];
292 } 291 }
293 292
294 static gboolean 293 static gboolean
295 _is_modifier_set (BusTestClient *client, 294 _is_modifier_set (BusTestClient *client,
296 guint modifier) 295 guint modifier)
297 { 296 {
298 switch(modifier) { 297 switch(modifier) {
299 case IBUS_Shift_L: 298 case IBUS_KEY_Shift_L:
300 case IBUS_Shift_R: 299 case IBUS_KEY_Shift_R:
301 /* ShiftMask */ 300 /* ShiftMask */
302 return client->modifier[0]; 301 return client->modifier[0];
303 case IBUS_Shift_Lock: 302 case IBUS_KEY_Shift_Lock:
304 case IBUS_Caps_Lock: 303 case IBUS_KEY_Caps_Lock:
305 /* LockMask */ 304 /* LockMask */
306 return client->modifier[1]; 305 return client->modifier[1];
307 case IBUS_Control_L: 306 case IBUS_KEY_Control_L:
308 case IBUS_Control_R: 307 case IBUS_KEY_Control_R:
309 /* ControlMask */ 308 /* ControlMask */
310 return client->modifier[2]; 309 return client->modifier[2];
311 case IBUS_Alt_L: 310 case IBUS_KEY_Alt_L:
312 case IBUS_Alt_R: 311 case IBUS_KEY_Alt_R:
313 case IBUS_Meta_L: 312 case IBUS_KEY_Meta_L:
314 /* Mod1Mask */ 313 /* Mod1Mask */
315 return client->modifier[3]; 314 return client->modifier[3];
316 case IBUS_Num_Lock: 315 case IBUS_KEY_Num_Lock:
317 /* Mod2Mask */ 316 /* Mod2Mask */
318 return client->modifier[4]; 317 return client->modifier[4];
319 case IBUS_Super_L: 318 case IBUS_KEY_Super_L:
320 case IBUS_Hyper_L: 319 case IBUS_KEY_Hyper_L:
321 /* Mod4Mask */ 320 /* Mod4Mask */
322 return client->modifier[5]; 321 return client->modifier[5];
323 case IBUS_ISO_Level3_Shift: 322 case IBUS_KEY_ISO_Level3_Shift:
324 case IBUS_Mode_switch: 323 case IBUS_KEY_Mode_switch:
325 /* Mod5Mask */ 324 /* Mod5Mask */
326 return client->modifier[6]; 325 return client->modifier[6];
327 default: 326 default:
328 return FALSE; 327 return FALSE;
329 } 328 }
330 } 329 }
331 330
332 static gboolean 331 static gboolean
333 _is_modifier_key (guint modifier) 332 _is_modifier_key (guint modifier)
334 { 333 {
335 switch(modifier) { 334 switch(modifier) {
336 case IBUS_Shift_L: 335 case IBUS_KEY_Shift_L:
337 case IBUS_Shift_R: 336 case IBUS_KEY_Shift_R:
338 case IBUS_Shift_Lock: 337 case IBUS_KEY_Shift_Lock:
339 case IBUS_Caps_Lock: 338 case IBUS_KEY_Caps_Lock:
340 case IBUS_Control_L: 339 case IBUS_KEY_Control_L:
341 case IBUS_Control_R: 340 case IBUS_KEY_Control_R:
342 case IBUS_Alt_L: 341 case IBUS_KEY_Alt_L:
343 case IBUS_Alt_R: 342 case IBUS_KEY_Alt_R:
344 case IBUS_Meta_L: 343 case IBUS_KEY_Meta_L:
345 case IBUS_Num_Lock: 344 case IBUS_KEY_Num_Lock:
346 case IBUS_Super_L: 345 case IBUS_KEY_Super_L:
347 case IBUS_Hyper_L: 346 case IBUS_KEY_Hyper_L:
348 case IBUS_ISO_Level3_Shift: 347 case IBUS_KEY_ISO_Level3_Shift:
349 case IBUS_Mode_switch: 348 case IBUS_KEY_Mode_switch:
350 return TRUE; 349 return TRUE;
351 default: 350 default:
352 return FALSE; 351 return FALSE;
353 } 352 }
354 } 353 }
355 354
356 static guint 355 static guint
357 _get_modifiers_to_mask (BusTestClient *client) 356 _get_modifiers_to_mask (BusTestClient *client)
358 { 357 {
359 guint retval = 0; 358 guint retval = 0;
(...skipping 29 matching lines...) Expand all
389 _bus_disabled_cb (IBusInputContext *ibuscontext, 388 _bus_disabled_cb (IBusInputContext *ibuscontext,
390 BusTestClient *client) 389 BusTestClient *client)
391 { 390 {
392 g_assert (IBUS_IS_INPUT_CONTEXT (ibuscontext)); 391 g_assert (IBUS_IS_INPUT_CONTEXT (ibuscontext));
393 g_assert (BUS_IS_TEST_CLIENT (client)); 392 g_assert (BUS_IS_TEST_CLIENT (client));
394 IDEBUG ("%s", __FUNCTION__); 393 IDEBUG ("%s", __FUNCTION__);
395 client->enabled = FALSE; 394 client->enabled = FALSE;
396 IDEBUG ("Disabled ibus engine"); 395 IDEBUG ("Disabled ibus engine");
397 } 396 }
398 397
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b