1 /* 2 3 Copyright (c) 2003-2013 uim Project https://github.com/uim/uim 4 5 All rights reserved. 6 7 Redistribution and use in source and binary forms, with or without 8 modification, are permitted provided that the following conditions 9 are met: 10 11 1. Redistributions of source code must retain the above copyright 12 notice, this list of conditions and the following disclaimer. 13 2. Redistributions in binary form must reproduce the above copyright 14 notice, this list of conditions and the following disclaimer in the 15 documentation and/or other materials provided with the distribution. 16 3. Neither the name of authors nor the names of its contributors 17 may be used to endorse or promote products derived from this software 18 without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 21 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 24 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 SUCH DAMAGE. 31 32 */ 33 34 /* 35 * gtk+-immodule 36 */ 37 #include <config.h> 38 39 #include <gtk/gtk.h> 40 #include <gtk/gtkimmodule.h> 41 #ifdef GDK_WINDOWING_X11 42 #include <gdk/gdkx.h> 43 #endif 44 45 #include "uim/uim.h" 46 47 #include "uim-cand-win-gtk.h" 48 #ifdef GDK_WINDOWING_X11 49 #include "compose.h" 50 #endif 51 52 /* select either of these two, or filter key event will be used */ 53 #define IM_UIM_USE_SNOOPER 0 54 #define IM_UIM_USE_TOPLEVEL 1 55 56 /* enable per page candidates handling */ 57 #define IM_UIM_USE_NEW_PAGE_HANDLING 1 58 /* enable delay showing candidate window */ 59 #define IM_UIM_USE_DELAY 1 60 61 typedef struct _IMUIMContext { 62 struct _GtkIMContext parent; 63 struct _GtkIMContext *slave; 64 uim_context uc; 65 UIMCandWinGtk *cwin; 66 gboolean cwin_is_active; 67 int nr_psegs; 68 int prev_preedit_len; 69 struct preedit_segment *pseg; 70 71 GdkWindow *win; 72 73 GtkWidget *caret_state_indicator; 74 GdkRectangle preedit_pos; 75 76 /* following two members are used when use_preedit == FALSE */ 77 GtkWidget *preedit_window; 78 gulong preedit_handler_id; 79 80 GtkWidget *widget; 81 #if IM_UIM_USE_TOPLEVEL 82 /* 83 * event_rec is used to check the incoming event is already handled 84 * in our toplevel handler. Some widgets (e.g. OOo2.0's vcl plugin) 85 * have already connected key press/release event handlers to the 86 * toplevel window before our handler attempts to connect. 87 */ 88 GdkEventKey event_rec; 89 #endif 90 #ifdef GDK_WINDOWING_X11 91 Compose *compose; 92 #endif 93 94 struct _IMUIMContext *prev, *next; 95 } IMUIMContext; 96 97 void im_uim_commit_string(void *ptr, const char *str); 98