[uim-commit] r587 - trunk/gtk

makeinu at freedesktop.org makeinu at freedesktop.org
Sun Feb 6 21:58:45 PST 2005


Author: makeinu
Date: 2005-02-06 21:58:43 -0800 (Sun, 06 Feb 2005)
New Revision: 587

Modified:
   trunk/gtk/gtk-im-uim.c
   trunk/gtk/uim-cand-win-gtk.c
   trunk/gtk/uim-cand-win-gtk.h
Log:
* gtk/uim-cand-win-gtk.h, gtk/uim-cand-win-gtk.c
  - (uim_cand_win_gtk_layout):
    Added "topwin_width" and "topwin_height" arguments to set window
    position according to the user setting.
* gtk/gtk-im-uim.c
  - (im_uim_set_cursor_location): Simplified.
  - (toplevel_window_candidate_cb): Follow above change.
  - (cand_activate_cb): Ditto.
  - (cand_select_cb): Ditto.
  - (cand_shift_page_cb): Ditto.


Modified: trunk/gtk/gtk-im-uim.c
===================================================================
--- trunk/gtk/gtk-im-uim.c	2005-02-07 04:16:35 UTC (rev 586)
+++ trunk/gtk/gtk-im-uim.c	2005-02-07 05:58:43 UTC (rev 587)
@@ -423,14 +423,8 @@
 {
   IMUIMContext *uic = IM_UIM_CONTEXT(ic);
 
-  if (uic->cwin->left &&  uic->nr_psegs > 1) {
-    return;
-  }
-
+  uic->preedit_pos = *area;
   uim_cand_win_gtk_set_cursor_location(uic->cwin, area);
-
-  uic->preedit_pos.x = area->x;
-  uic->preedit_pos.y = area->y;
 }
 
 
@@ -589,10 +583,11 @@
     return GDK_FILTER_CONTINUE;
 
   if (uic->cwin && uic->cwin_is_active) {
-    gint topwin_x, topwin_y;
+    gint x, y, width, height, depth;
 
-    gdk_window_get_origin(uic->win, &topwin_x, &topwin_y);
-    uim_cand_win_gtk_layout(uic->cwin, topwin_x, topwin_y);
+    gdk_window_get_geometry(uic->win, &x, &y, &width, &height, &depth);
+    gdk_window_get_origin(uic->win, &x, &y);
+    uim_cand_win_gtk_layout(uic->cwin, x, y, width, height);
   }
   return GDK_FILTER_CONTINUE;
 }
@@ -758,7 +753,7 @@
 cand_activate_cb(void *ptr, int nr, int display_limit)
 {
   IMUIMContext *uic = (IMUIMContext *)ptr;
-  gint topwin_x, topwin_y;
+  gint x, y, width, height, depth;
   GSList *list = NULL;
   uim_candidate cand;
   gint i;
@@ -775,8 +770,9 @@
   g_slist_foreach(list, (GFunc)uim_candidate_free, NULL);
   g_slist_free(list);
 
-  gdk_window_get_origin(uic->win, &topwin_x, &topwin_y);
-  uim_cand_win_gtk_layout(uic->cwin, topwin_x, topwin_y);
+  gdk_window_get_geometry(uic->win, &x, &y, &width, &height, &depth);
+  gdk_window_get_origin(uic->win, &x, &y);
+  uim_cand_win_gtk_layout(uic->cwin, x, y, width, height);
   gtk_widget_show(GTK_WIDGET(uic->cwin));
 
   if (uic->win) {
@@ -797,10 +793,11 @@
 cand_select_cb(void *ptr, int index)
 {
   IMUIMContext *uic = (IMUIMContext *)ptr;
-  gint topwin_x, topwin_y;
+  gint x, y, width, height, depth;
 
-  gdk_window_get_origin(uic->win, &topwin_x, &topwin_y);
-  uim_cand_win_gtk_layout(uic->cwin, topwin_x, topwin_y);
+  gdk_window_get_geometry(uic->win, &x, &y, &width, &height, &depth);
+  gdk_window_get_origin(uic->win, &x, &y);
+  uim_cand_win_gtk_layout(uic->cwin, x, y, width, height);
   g_signal_handlers_block_by_func(uic->cwin, (gpointer)index_changed_cb, uic);
   uim_cand_win_gtk_set_index(uic->cwin, index);
   g_signal_handlers_unblock_by_func(uic->cwin, (gpointer)index_changed_cb, uic);
@@ -810,10 +807,11 @@
 cand_shift_page_cb(void *ptr, int direction)
 {
   IMUIMContext *uic = (IMUIMContext *)ptr;
-  gint topwin_x, topwin_y;
+  gint x, y, width, height, depth;
 
-  gdk_window_get_origin(uic->win, &topwin_x, &topwin_y);
-  uim_cand_win_gtk_layout(uic->cwin, topwin_x, topwin_y);
+  gdk_window_get_geometry(uic->win, &x, &y, &width, &height, &depth);
+  gdk_window_get_origin(uic->win, &x, &y);
+  uim_cand_win_gtk_layout(uic->cwin, x, y, width, height);
   g_signal_handlers_block_by_func(uic->cwin, (gpointer)index_changed_cb, uic);
   uim_cand_win_gtk_shift_page(uic->cwin, direction);
   uim_set_candidate_index(uic->uc, uic->cwin->candidate_index);

Modified: trunk/gtk/uim-cand-win-gtk.c
===================================================================
--- trunk/gtk/uim-cand-win-gtk.c	2005-02-07 04:16:35 UTC (rev 586)
+++ trunk/gtk/uim-cand-win-gtk.c	2005-02-07 05:58:43 UTC (rev 587)
@@ -312,17 +312,19 @@
 				GSList *candidates)
 {
   gint i, nr_stores = 1;
-  gchar *leftp;
+  gchar *win_pos;
 
   g_return_if_fail(UIM_IS_CAND_WIN_GTK(cwin));
 
-  leftp = uim_symbol_value_str("candidate-window-position");
-  if (leftp && !strcmp(leftp, "left")) {
-    cwin->left = TRUE;
+  win_pos = uim_symbol_value_str("candidate-window-position");
+  if (win_pos && !strcmp(win_pos, "left")) {
+    cwin->position = UIM_CAND_WIN_POS_LEFT;
+  } else if (win_pos && !strcmp(win_pos, "right")) {
+    cwin->position = UIM_CAND_WIN_POS_RIGHT;
   } else {
-    cwin->left = FALSE;
+    cwin->position = UIM_CAND_WIN_POS_CARET;
   }
-  g_free(leftp);
+  g_free(win_pos);
 
   if (cwin->stores == NULL)
     cwin->stores = g_ptr_array_new();
@@ -544,10 +546,13 @@
 }
 
 void
-uim_cand_win_gtk_layout(UIMCandWinGtk *cwin, gint topwin_x, int topwin_y)
+uim_cand_win_gtk_layout(UIMCandWinGtk *cwin,
+			gint topwin_x, gint topwin_y,
+			gint topwin_width, gint topwin_height)
 {
   GtkRequisition req;
   int  x, y;
+  int  cursor_x, cursor_y;
   int  sc_he, cw_he; /*screen height, candidate window height*/
   int  sc_wi, cw_wi;
 
@@ -560,18 +565,27 @@
   sc_he = gdk_screen_get_height(gdk_screen_get_default ());
   sc_wi = gdk_screen_get_width (gdk_screen_get_default ());
 
-  if (sc_wi <  topwin_x + cwin->cursor.x + cw_wi) {
-    x = topwin_x + cwin->cursor.x - cw_wi;
+  if (cwin->position == UIM_CAND_WIN_POS_LEFT) {
+    cursor_x = 0;
+  } else if (cwin->position == UIM_CAND_WIN_POS_RIGHT) {
+    cursor_x = topwin_width - cw_wi;
   } else {
-    x = topwin_x + cwin->cursor.x;
+    cursor_x = cwin->cursor.x;
   }
+  cursor_y = cwin->cursor.y;
 
-  if (sc_he <  topwin_y + cwin->cursor.y +  cwin->cursor.height + cw_he ) {
-    y = topwin_y + cwin->cursor.y - cw_he;
+  if (sc_wi <  topwin_x + cursor_x + cw_wi) {
+    x = topwin_x + cursor_x - cw_wi;
   } else {
-    y = topwin_y + cwin->cursor.y +  cwin->cursor.height;
+    x = topwin_x + cursor_x;
   }
 
+  if (sc_he <  topwin_y + cursor_y +  cwin->cursor.height + cw_he ) {
+    y = topwin_y + cursor_y - cw_he;
+  } else {
+    y = topwin_y + cursor_y +  cwin->cursor.height;
+  }
+
   gtk_window_move(GTK_WINDOW(cwin), x, y );
 }
 

Modified: trunk/gtk/uim-cand-win-gtk.h
===================================================================
--- trunk/gtk/uim-cand-win-gtk.h	2005-02-07 04:16:35 UTC (rev 586)
+++ trunk/gtk/uim-cand-win-gtk.h	2005-02-07 05:58:43 UTC (rev 587)
@@ -48,6 +48,12 @@
 typedef struct _UIMCandWinGtk      UIMCandWinGtk;
 typedef struct _UIMCandWinGtkClass UIMCandWinGtkClass;
 
+typedef enum {
+  UIM_CAND_WIN_POS_CARET,
+  UIM_CAND_WIN_POS_LEFT,
+  UIM_CAND_WIN_POS_RIGHT
+} UimCandWinPos;
+
 struct _UIMCandWinGtk {
   GtkWindow	 parent;
 
@@ -62,7 +68,7 @@
   gint		 candidate_index;
   gint		 page_index;
 
-  gboolean	 left;
+  UimCandWinPos	 position;
 
   GdkRectangle	 cursor;
 };
@@ -100,7 +106,9 @@
 
 void		uim_cand_win_gtk_layout			(UIMCandWinGtk *cwin,
 							 gint topwin_x,
-							 gint topwin_y);
+							 gint topwin_y,
+							 gint topwin_width,
+							 gint topwin_height);
 void		uim_cand_win_gtk_set_cursor_location	(UIMCandWinGtk *cwin,
 							 GdkRectangle *area);
 



More information about the Uim-commit mailing list