Back to index

im-sdk  12.3.91
palette_method.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2003 Sun Microsystems Inc.
00003  *
00004  * This is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  *
00019  * Authors: Karl Park <karl.park@sun.com>
00020  */
00021 #ifdef HAVE_CONFIG_H
00022 #include <config.h>
00023 #endif
00024 
00025 #include <stdio.h>
00026 #include <gdk/gdk.h>
00027 #include <gtk/gtk.h>
00028 #include <gdk/gdkx.h>
00029 #include <X11/Xlib.h>
00030 #include <X11/Xmd.h>
00031 
00032 #include "xaux_locale.h"
00033 #include "xaux_common.h"
00034 #include "xaux_ext_common.h"
00035 #include "koinput.h"
00036 #include "palette_aux.h"
00037 #include "OptionConfig.h"
00038 #include "../common/kolelog.h"
00039 #include "aux-message.h"
00040 #include "engine-property.h"
00041 
00042 /* Define Aux class */
00043 xaux_class_t *xc_ = 0;
00044 int im_ = 0;
00045 int ic_ = 0;
00046 
00047 
00048 /* Define Aux class */
00049 xaux_class_t xaux_class = {
00050   XAUX_PALETTE_CLASS_NAME, 1,
00051   NULL,
00052   (Window)0, (Window)0,
00053   (Atom)0, (Atom)0, (Atom)0,
00054   { (Atom)0 }, ATOM_NUM_PALETTEAUX, 0,
00055   { (Atom)0 }, ATOM_NUM_PALETTEAUX, 0,
00056   NULL,
00057 };
00058 
00059 int gLocaleID = 0;
00060 Display *gDisplay = NULL;
00061 Window  gWindow  = 0;
00062 KOLE_property *p_engine_property = NULL;
00063 
00064 
00065 /*  Auxiliary Window User Input Method Information  */
00066 extern PaletteInfoRecord palettecore;
00067 extern gint _toolbar_window_drag_x;
00068 extern gint _toolbar_window_drag_y;
00069 
00070 /*
00071   extern IMEListRec  AllIMEList, SelectedIMEList;
00072   extern int         gIMEOptionsNum;
00073   extern IMEOption_Item     *gIMEOptions[];
00074 */
00075 
00076 void dummy (aux_ext_data_t *aux_ext_data);
00077 
00078 void PaletteAux_Set_Options_Request();
00079 void PaletteAux_Connect_To_LE_Request();
00080 void PaletteAux_Lost_Focus_Request();
00081 static void paletteaux_notification_handler();
00082 void PaletteAux_Proc_LE_Set_IMEInfo_Notify();
00083 void PaletteAux_Proc_LE_Update_IMEInfo_Notify();
00084 void palette_process_le_message_switch_conversion ();
00085 void PaletteAux_Proc_LE_Switch_IME_Notify();
00086 void PaletteAux_Proc_LE_Switch_QjBj_Notify();
00087 void PaletteAux_Proc_LE_Switch_Punct_Notify();
00088 void PaletteAux_Proc_LE_Change_Focus_Notify();
00089 void PaletteAux_Proc_LE_Set_IMEInfo_End_Notify(aux_ext_data_t *aux_ext_data);
00090 /*
00091 void PaletteAux_Proc_LE_New_IMEInfo_Notify(aux_ext_data_t *aux_ext_data);
00092 */
00093 void paletteaux_set_session_property(aux_ext_data_t *aux_ext_data);
00094 void PaletteAux_Proc_LE_Update_KeymapInfo_Notify(aux_ext_data_t *aux_ext_data);
00095 static void PaletteAux_Set_Selection_Owner ();
00096 
00097 
00098 /*   
00099      Event Handler 
00100 */
00101 GdkFilterReturn
00102 xaux_ext_event_handler (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer user_data)
00103 {
00104   XEvent *xevent = (XEvent *) gdk_xevent;
00105 
00106   switch (xevent->type) {
00107   case ClientMessage:
00108     xaux_ext_process_client_message((Display *)gDisplay,
00109                                 (XClientMessageEvent *) xevent);
00110     break;
00111   case SelectionClear:
00112     break;
00113   }
00114   return GDK_FILTER_CONTINUE;
00115 }
00116 
00117 /*
00118   xaux_ext_init_classes(): Initialize the Atom of Auxiliary Window.
00119   It is in ../xaux_common/xaux_ext_common.c
00120 */
00121 int
00122 xaux_ext_register_classes (GdkWindow *window)
00123 {
00124   gDisplay = (Display *)GDK_WINDOW_XDISPLAY(window);
00125   gWindow  = (Window)GDK_WINDOW_XWINDOW(window);
00126   /* Register aux class */
00127   int xaux_result =
00128     xaux_ext_init_classes (gDisplay,
00129                         (xaux_class_t *)&xaux_class,
00130                         gWindow);
00131   if (xaux_result  == False)
00132     return(False);
00133 
00134   return(True);
00135 }
00136 
00137 /* 
00138    Note:
00139    xaux_ext_Start(), xaux_ext_Draw(), xaux_ext_Done() 
00140    These three functions are all called by xaux_ext_process_client_message()
00141 
00142    xaux_ext_SetValue() will send auxiliary window information to language engine;
00143 */
00144 
00145 /* Method - Start */
00146 Bool
00147 xaux_ext_Start (xaux_class_t *xc, aux_ext_data_t *aux_ext_data, Atom atom)
00148 {
00149   char *locale = NULL;
00150   int  locale_id = 0;
00151 #if 0
00152   int i = 1;
00153   while (i);
00154 #endif
00155   
00156   KOLE_LOG (LOGDEST_STDOUT,
00157            "xaux_ext_Start: im:%d, ic:%d",
00158            aux_ext_data->im, aux_ext_data->ic);
00159   
00160   im_ = aux_ext_data->im;
00161   ic_ = aux_ext_data->ic;
00162   xc_ = xc;
00163   
00164   p_engine_property = leproperty_init ();
00165   
00166   /* inform Language Engine that PaletteAux has started. */
00167   locale = (char *) getenv("LANG");
00168   if (locale != NULL) {
00169     locale_id = 0;
00170     PaletteAux_Connect_To_LE_Request(locale_id);
00171   } else
00172     PaletteAux_Connect_To_LE_Request(locale_id);
00173     
00174   return True;
00175 }
00176 
00177 /* Method - Draw */
00178 Bool
00179 xaux_ext_Draw (xaux_class_t *xc, aux_ext_data_t *aux_ext_data, Atom atom)
00180 {
00181   KOLE_LOG (LOGDEST_STDOUT, "Palette ext_Draw == im:0x%x, ic:0x%x\n",aux_ext_data->im, aux_ext_data->ic);
00182   im_ = aux_ext_data->im;
00183   ic_ = aux_ext_data->ic;
00184   xc_ = xc;
00185 
00186   paletteaux_notification_handler (aux_ext_data);
00187   return True;
00188 }
00189 
00190 /* Method - Done */
00191 Bool xaux_ext_Done(xaux_class_t *xc, aux_ext_data_t *aux_ext_data, Atom atom)
00192 {
00193   KOLE_LOG (LOGDEST_STDOUT,
00194            "ext_Done im:0x%x, ic_id:0x%x",
00195            aux_ext_data->im, aux_ext_data->ic);
00196   leproperty_done (p_engine_property);
00197   
00198   return True;
00199 }
00200 
00201 
00202 /* ================================================================= */
00203 /*       Process Notify information From Language Engine             */
00204 /* ================================================================= */
00205 static void
00206 paletteaux_notification_handler (aux_ext_data_t *aux_ext_data)
00207 {
00208   int nIntegerCount, notification_type;
00209 
00210   nIntegerCount = aux_ext_data->integer_count;
00211   if (nIntegerCount <= 0) return;
00212 
00213   notification_type = aux_ext_data->integer_list[0];
00214 
00215   switch (notification_type)
00216     {
00217     case PALETTEAUX_SWITCH_INPUT_MODE_NOTIFY:
00218       KOLE_LOG (LOGDEST_STDOUT, "PALETTEAUX_SWITCH_CONVERSION_NOTIFY Notify Received\n");
00219       palette_process_le_message_switch_conversion (aux_ext_data);
00220       break;
00221       /* I wouldn't need this */
00222     case PALETTEAUX_SWITCH_CONVERSION_NOTIFY:
00223       KOLE_LOG (LOGDEST_STDOUT, "PALETTEAUX_SWITCH_CONVERSION_NOTIFY Notify Received\n");
00224       palette_process_le_message_switch_conversion (aux_ext_data);
00225       break;
00226       
00227       /*
00228        case PALETTEAUX_SWITCH_IME_NOTIFY:
00229        KOLE_LOG (LOGDEST_STDOUT, "PALETTEAUX_SWITCH_IME_NOTIFY Notify Received\n");
00230        PaletteAux_Proc_LE_Switch_IME_Notify(aux_ext_data);
00231        break;
00232       */
00233     case PALETTEAUX_SWITCH_QJBJ_NOTIFY:
00234       KOLE_LOG (LOGDEST_STDOUT, "PALETTEAUX_SWITCH_QJBJ_NOTIFY Notify Received\n");
00235       PaletteAux_Proc_LE_Switch_QjBj_Notify(aux_ext_data);
00236       break;
00237       
00238     case PALETTEAUX_SWITCH_PUNCT_NOTIFY:
00239       KOLE_LOG (LOGDEST_STDOUT, "PALETTEAUX_SWITCH_PUNCT_NOTIFY Notify Received\n");
00240       PaletteAux_Proc_LE_Switch_Punct_Notify(aux_ext_data);
00241       break;
00242       /*
00243        case PALETTEAUX_UPDATE_IMEINFO_NOTIFY:
00244        KOLE_LOG (LOGDEST_STDOUT, "PALETTEAUX_UPDATE_IMEINFO Notify Received\n");
00245        PaletteAux_Proc_LE_Update_IMEInfo_Notify(aux_ext_data);
00246        break;
00247       */
00248     case COMMONAUX_CHANGE_FOCUS_NOTIFY:
00249       KOLE_LOG (LOGDEST_STDOUT, "COMMONAUX_CHANGE_FOCUS_NOTIFY Notify Received\n");
00250       PaletteAux_Proc_LE_Change_Focus_Notify(aux_ext_data);
00251       break;
00252     case COMMONAUX_SET_IME_NEW_NOTIFY:
00253       KOLE_LOG (LOGDEST_STDOUT, "COMMONAUX_SET_IME_NEW_NOTIFY Notify Received\n");
00254       /*
00255        PaletteAux_Proc_LE_New_IMEInfo_Notify(aux_ext_data);
00256       */
00257       break;
00258     case COMMONAUX_SET_IME_INFO_NOTIFY:
00259       KOLE_LOG (LOGDEST_STDOUT, "COMMONAUX_SET_IMEINFO Notify Received");
00260       PaletteAux_Proc_LE_Set_IMEInfo_Notify(aux_ext_data);
00261       break;
00262     case KOLE_AUX_SESSION_PROPERTY:
00263       paletteaux_set_session_property (aux_ext_data);
00264       break;
00265       
00266     case COMMONAUX_SET_IME_END_NOTIFY:
00267       KOLE_LOG (LOGDEST_STDOUT, "COMMONAUX_SET_IME_END_NOTIFY Notify Received\n");
00268       PaletteAux_Proc_LE_Set_IMEInfo_End_Notify(aux_ext_data);
00269       break;
00270     case COMMONAUX_UPDATE_KEYMAPINFO_NOTIFY:
00271       KOLE_LOG (LOGDEST_STDOUT, "PALETTEAUX_UPDATE_KEYMAPINFO_NOTIFY Notify Received\n");
00272       PaletteAux_Proc_LE_Update_KeymapInfo_Notify(aux_ext_data);
00273       break;
00274     }
00275 }
00276 
00277 static void
00278 PaletteAux_Set_Selection_Owner ()
00279 {
00280   Atom aux_atom =
00281     XInternAtom (gDisplay,
00282                "CH_PALETTEAUX_MODULE_ATOM", False);
00283   XSetSelectionOwner(gDisplay, aux_atom, gWindow, CurrentTime);
00284 }
00285 
00286 #if 0
00287 void
00288 PaletteAux_Proc_LE_New_IMEInfo_Notify(aux_ext_data_t *aux_ext_data)
00289 {
00290   /*
00291     IMEList_Free();
00292   */
00293 }
00294 #endif
00295 
00296 void
00297 paletteaux_set_session_property (aux_ext_data_t *aux_ext_data)
00298 {
00299   int n_integer_count;
00300   n_integer_count = aux_ext_data->integer_count;
00301   if (n_integer_count <= 0) return;
00302 
00303   /*if (p_engine_property ||
00304       !( p_engine_property = leproperty_init () )) {
00305       KOLE_LOG (LOGDEST_STDOUT, "Critical Error");
00306       return;
00307   }*/
00308   if( p_engine_property == NULL)
00309        p_engine_property = leproperty_init ();
00310   
00311   leproperty_set_input_mode (p_engine_property, aux_ext_data->integer_list[1]);
00312   leproperty_set_keyboard (p_engine_property, aux_ext_data->integer_list[2]);
00313   leproperty_set_charset (p_engine_property, aux_ext_data->integer_list[3]);
00314   leproperty_set_deletion (p_engine_property, aux_ext_data->integer_list[4]);
00315   leproperty_set_commit (p_engine_property, aux_ext_data->integer_list[5]);
00316   
00317   paletteaux_update_display (p_engine_property);
00318 }
00319 
00320 
00321 
00322 void
00323 PaletteAux_Proc_LE_Set_IMEInfo_Notify (aux_ext_data_t *aux_ext_data)
00324 {
00325   IMEBaseRec baseinfo;
00326   int i, nIntegerCount, engine_num;
00327 
00328   nIntegerCount = aux_ext_data->integer_count;
00329   if (nIntegerCount <= 0) return;
00330 
00331   KOLE_LOG (LOGDEST_STDOUT, "PaletteAux_Proc_LE_Set_IMEInfo_Notify\n");
00332 
00333   baseinfo.engine_id = aux_ext_data->integer_list[1];
00334   baseinfo.locale_id = aux_ext_data->integer_list[2];
00335   baseinfo.encode_id = aux_ext_data->integer_list[3];
00336   baseinfo.status = aux_ext_data->integer_list[4];
00337 
00338   baseinfo.ename = (char *)(aux_ext_data->string_list[0].ptr);
00339   baseinfo.kname = (char *)(aux_ext_data->string_list[1].ptr);
00340   /*
00341     Add_IME_To_AllList(&baseinfo);
00342   */
00343 }
00344 
00345 void PaletteAux_Proc_LE_Set_IMEInfo_End_Notify(aux_ext_data_t *aux_ext_data)
00346 {
00347 #if 0
00348   /* process user defined imes, such as user prefer IMEs*/
00349   Select_IMEs_From_Profile();
00350 
00351   /* create IME list menu */
00352 
00353   PaletteAux_CreateIMEListMenu();
00354 #endif
00355 }
00356 
00357 void PaletteAux_Proc_LE_Update_IMEInfo_Notify(aux_ext_data_t *aux_ext_data)
00358 {
00359 #if 0
00360   /* process user defined imes, such as user prefer IMEs*/
00361   Select_IMEs_From_Profile ();
00362 
00363   /* create IME list menu */
00364 
00365   PaletteAux_CreateIMEListMenu();
00366 #endif
00367 
00368 }
00369 
00370 void PaletteAux_Proc_LE_Update_KeymapInfo_Notify(aux_ext_data_t *aux_ext_data)
00371 {
00372   /*
00373     int i, engine_id, ime_id;
00374 
00375     engine_id = aux_ext_data->integer_list[1];
00376 
00377     if (IMEVKB_Check_If_Exist(engine_id)) return;
00378 
00379     ime_id = get_ime_id_by_engine_id(&AllIMEList, engine_id);
00380     if (ime_id == -1) return;
00381 
00382     IMEVKB_Name_List_Add(engine_id, AllIMEList.arrIME_Base[ime_id]->kname);
00383   */
00384 }
00385 
00386 void
00387 palette_process_le_message_switch_conversion (aux_ext_data_t *aux_ext_data)
00388 {
00389   int on_status;
00390   INPUT_MODE_T new_mode  =  aux_ext_data->integer_list[1];
00391   gboolean visibility;
00392 
00393   if (!p_engine_property) 
00394        p_engine_property = leproperty_init(); 
00395   
00396   leproperty_set_input_mode (p_engine_property, aux_ext_data->integer_list[1]);
00397   visibility = new_mode == INPUT_MODE_ENGLISH ? FALSE : TRUE;
00398 
00399   aux_palette_position_set (_toolbar_window_drag_x, _toolbar_window_drag_y );
00400   paletteaux_update_display (p_engine_property);
00401   paletteaux_change_visibility (visibility);
00402 
00403 }
00404 
00405 /* if find item by engine_id, return its index, else return -1 */
00406 int get_ime_id_by_engine_id(IMEListRec *imelist, int engine_id)
00407 {
00408   int i;
00409 
00410   for (i = 0; i < imelist->nIME_Num; i++) {
00411     if (imelist->arrIME_Base[i] && 
00412        imelist->arrIME_Base[i]->engine_id == engine_id) 
00413       return(i);
00414   }
00415   return(-1);
00416 }
00417 
00418 void
00419 PaletteAux_Proc_LE_Switch_IME_Notify (aux_ext_data_t *aux_ext_data)
00420 {
00421 #if 0
00422   
00423   int switch_type;
00424   int engine_id, ime_id, nIME_Num;
00425        
00426   switch_type = aux_ext_data->integer_list[1];
00427   /*
00428     nIME_Num = SelectedIMEList.nIME_Num;
00429   */
00430   KOLE_LOG (LOGDEST_STDOUT, "SelectedIMEList.nIME_Num:%d\n", nIME_Num);
00431   if (nIME_Num <= 0) return;
00432 
00433   switch(switch_type)
00434     {
00435     case IME_ROUND_SWITCH:
00436       /* select next available IME */
00437       /*
00438        engine_id = gPAData.engine_id;
00439       */
00440       engine_id = 0;
00441       ime_id = get_ime_id_by_engine_id(&SelectedIMEList, engine_id);
00442       KOLE_LOG (LOGDEST_STDOUT, "IME_ROUND_SWITCH == current ime_id:%d\n", ime_id);
00443       ime_id = (ime_id + 1) % nIME_Num;
00444       break;  
00445 
00446     case IME_SELECT_SWITCH:
00447       /* select a specific available IME */
00448       ime_id = aux_ext_data->integer_list[2];
00449       KOLE_LOG (LOGDEST_STDOUT, "IME_SELECT_SWITCH == ime_no:%d\n", ime_id);
00450       break;  
00451     }
00452 
00453   KOLE_LOG (LOGDEST_STDOUT, "IME_SWITCH == ime_id:%d\n", ime_id);
00454 
00455   /* Change IME logo on the control bar */
00456   /* and need notify LE to switch IME */
00457   /*
00458     PaletteAux_ChangeIME(ime_id, True);
00459   */
00460 #endif
00461 }
00462 
00463 void PaletteAux_Proc_LE_Switch_QjBj_Notify(aux_ext_data_t *aux_ext_data)
00464 {
00465   /* Change auxiliary window Full_Width/half_Width information */
00466 #if 0
00467   ui_toggle_letter (aux_ext_data->integer_list[1]);
00468 #endif
00469 }
00470 
00471 void PaletteAux_Proc_LE_Switch_Punct_Notify(aux_ext_data_t *aux_ext_data)
00472 {
00473   /* Change auxiliary window English/Chinese Punctuation information */
00474 #if 0
00475   ui_toggle_punct (aux_ext_data->integer_list[1]);
00476 #endif
00477 }
00478 
00479 void
00480 PaletteAux_Proc_LE_Change_Focus_Notify (aux_ext_data_t *aux_ext_data)
00481 {
00482   int pos_x, pos_y;
00483   int toolbar_window_show_status;
00484   gboolean full_width_letter_status, full_width_punct_status;
00485   int engine_id;
00486   INPUT_MODE_T input_mode;
00487   
00488   OPTION_KEYBOARD_LAYOUT kbd;
00489   OPTION_CHARSET charset;
00490   OPTION_DELETION deletion;
00491   OPTION_COMMIT_MODE commit;
00492 
00493    KOLE_LOG (LOGDEST_STDOUT, "testing: enter PaletteAux_Proc_LE_Change_Focus_Notify\n");
00494 
00495   pos_x       = aux_ext_data->integer_list[1];
00496   pos_y       = aux_ext_data->integer_list[2];
00497   toolbar_window_show_status       = aux_ext_data->integer_list[3];
00498   full_width_letter_status  = aux_ext_data->integer_list[4];
00499   full_width_punct_status   = aux_ext_data->integer_list[5];
00500   engine_id   = aux_ext_data->integer_list[6];
00501   input_mode = aux_ext_data->integer_list[7];
00502   kbd = aux_ext_data->integer_list[8];
00503   charset = aux_ext_data->integer_list[9];
00504   deletion  = aux_ext_data->integer_list[10];
00505   commit = aux_ext_data->integer_list[11];
00506 
00507 /*  if (p_engine_property ||
00508       !( p_engine_property = leproperty_init () )) {
00509       KOLE_LOG (LOGDEST_STDOUT, "Critical Error");
00510       return;
00511   }
00512 */
00513 
00514 /*  leproperty_set_keyboard (p_engine_property, kbd);
00515   leproperty_set_charset (p_engine_property, charset);
00516   leproperty_set_deletion (p_engine_property, deletion);
00517   leproperty_set_commit (p_engine_property, commit);
00518 */  
00519 #ifdef EVIL
00520 #endif  
00521 
00522   if (toolbar_window_show_status)
00523     PaletteAux_Set_Selection_Owner();
00524 
00525   if (input_mode == INPUT_MODE_NONE ||input_mode == INPUT_MODE_ENGLISH){
00526     
00527     paletteaux_change_visibility (FALSE);
00528     
00529   } else {
00530     
00531      
00532      KOLE_LOG (LOGDEST_STDOUT,"testing: before gtk_window_get_position()\n");
00533     gtk_window_get_position (palettecore.ppalette, pos_x, pos_y);
00534 #if 0
00535     ui_toggle_letter (full_width_letter_status);
00536     ui_toggle_punct (full_width_punct_status);
00537 #endif
00538      KOLE_LOG (LOGDEST_STDOUT,"testing: before paletteaux_update_display()\n");
00539     paletteaux_update_display (p_engine_property);
00540     
00541   }
00542 }
00543 
00544 /* ================================================================= */
00545 /*             Send information to Language Engine                   */
00546 /* ================================================================= */
00547 void
00548 PaletteAux_Connect_To_LE_Request (int locale_id)
00549 {
00550   int nIntegerCount, pIntegerList[2];
00551 
00552   DEBUG_printf("begin PaletteAux_Connect_To_LE_Request\n");  
00553 
00554   nIntegerCount = 2;
00555   pIntegerList[0] = PALETTEAUX_CONNECT;
00556   pIntegerList[1] = locale_id;
00557   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00558 }
00559 
00560 void PaletteAux_Switch_LE_Conversion_Request(int on)
00561 {
00562   int nIntegerCount, pIntegerList[2];
00563 
00564   nIntegerCount = 2;
00565   
00566   DEBUG_printf("begin PaletteAux_Switch_LE_Conversion_Request\n"); 
00567  
00568   /* Fix Me */
00569   pIntegerList[0] = PALETTEAUX_SWITCH_CONVERSION_NOTIFY;
00570   pIntegerList[1] = on;
00571   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00572 }
00573 
00574 void PaletteAux_Switch_LE_Engine_Request(int engine_id)
00575 {
00576   int nIntegerCount, pIntegerList[2];
00577 
00578   nIntegerCount = 2;
00579  
00580   DEBUG_printf("begin PaletteAux_Switch_LE_Engine_Request\n");
00581  
00582   pIntegerList[0] = PALETTEAUX_SWITCH_IME;
00583   pIntegerList[1] = engine_id;
00584   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00585 }
00586 
00587 void
00588 paletteaux_send_switch_charset_request (int charset)
00589 {
00590   int nIntegerCount, pIntegerList[2];
00591 
00592   nIntegerCount = 2;
00593   
00594   DEBUG_printf("begin paletteaux_send_switch_charset_request\n");
00595 
00596   pIntegerList[0] = PALETTEAUX_SWITCH_CHARSET_NOTIFY;
00597   pIntegerList[1] = charset;
00598   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00599 }
00600 
00601 void PaletteAux_Switch_LE_QjBj_Request(int qjbj)
00602 {
00603   int nIntegerCount, pIntegerList[2];
00604 
00605   nIntegerCount = 2;
00606 
00607   DEBUG_printf("begin PaletteAux_Switch_LE_QjBj_Request\n");
00608 
00609   pIntegerList[0] = PALETTEAUX_SWITCH_QJBJ;
00610   pIntegerList[1] = qjbj;
00611   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00612 }
00613 
00614 /*
00615   void PaletteAux_Switch_LE_Punct_Request(int punct)
00616   {
00617   int nIntegerCount, pIntegerList[2];
00618 
00619   nIntegerCount = 2;
00620   pIntegerList[0] = PALETTEAUX_SWITCH_PUNCT;
00621   pIntegerList[1] = punct;
00622   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00623   }
00624 */
00625 void PaletteAux_Change_LE_Position_Request(int x, int y)
00626 {
00627   int nIntegerCount, pIntegerList[3];
00628 
00629   nIntegerCount = 3;
00630 
00631   DEBUG_printf("begin PaletteAux_Change_LE_Position_Request\n");
00632 
00633   pIntegerList[0] = PALETTEAUX_CHANGE_POSITION;
00634   pIntegerList[1] = x;
00635   pIntegerList[2] = y;
00636   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00637 }
00638 
00639 void PaletteAux_Show_SelectAux_Request()
00640 {
00641   int nIntegerCount, pIntegerList[1];
00642 
00643   nIntegerCount = 1;
00644 
00645   DEBUG_printf("begin PaletteAux_Show_SelectAux_Request\n");
00646   pIntegerList[0] = PALETTEAUX_SHOW_SELECTAUX;
00647   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00648 }
00649 
00650 void PaletteAux_Show_OptionAux_Request()
00651 {
00652   int nIntegerCount, pIntegerList[1];
00653 
00654   nIntegerCount = 1;
00655  
00656   DEBUG_printf("begin PaletteAux_Show_OptionAux_Request\n");
00657 
00658   pIntegerList[0] = PALETTEAUX_SHOW_OPTIONAUX;
00659   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00660 }
00661 
00662 void
00663 paletteaux_send_show_keyboardaux_request (int n_keyboard_id)
00664 {
00665   int nIntegerCount, pIntegerList[2];
00666 
00667   nIntegerCount = 2;
00668   /* change the layout first */
00669   pIntegerList[0] = PALETTEAUX_SWITCH_KEYBOARDLAYOUT;
00670   pIntegerList[1] = n_keyboard_id;
00671   DEBUG_printf("begin paletteaux_send_show_keyboardaux_request\n");
00672   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00673 
00674   /* Then show the keyboard first */
00675 /*  fprintf (stderr, "AUX->SRV: PALETTEAUX_SHOW_KEYBOARDAUX\n");
00676   pIntegerList[0] =  PALETTEAUX_SHOW_KEYBOARDAUX;
00677   pIntegerList[1] = n_keyboard_id;
00678   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00679  */ 
00680 }
00681 
00682 void
00683 PaletteAux_Show_LookupAux_Request()
00684 {
00685   int nIntegerCount, pIntegerList[1];
00686 
00687   nIntegerCount = 1;
00688 
00689   DEBUG_printf("begin PaletteAux_Show_LookupAux_Request\n");
00690   
00691   pIntegerList[0] = PALETTEAUX_SHOW_LOOKUPAUX;
00692   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00693 }
00694 
00695 void PaletteAux_StartAction_Request(char *command)
00696 {
00697   int nIntegerCount, pIntegerList[1];
00698   int nStringCount, pStringLen[1];
00699   char *pStringList[1];
00700 
00701   DEBUG_printf("begin PaletteAux_StartAction_Request\n");
00702   nIntegerCount = 1;
00703   pIntegerList[0] = PALETTEAUX_START_ACTION;
00704   nStringCount = 1;
00705   pStringLen[0] = strlen(command);
00706   pStringList[0] = command;
00707   NotifyStringListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList,
00708                                    nStringCount, pStringLen,
00709                                    pStringList);
00710 
00711 }
00712 
00713 void PaletteAux_Lost_Focus_Request()
00714 {
00715   int nIntegerCount, pIntegerList[1];
00716 
00717   nIntegerCount = 1;
00718 
00719   DEBUG_printf("begin PaletteAux_Lost_Focus_Request\n");
00720 
00721   pIntegerList[0] = COMMONAUX_LOST_FOCUS;
00722   NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00723 }
00724 
00725 void PaletteAux_Set_Options_Request()
00726 {
00727   /*
00728     int nIntegerCount, pIntegerList[MAX_ENGINE_NUM + 1];
00729     int nStringCount, pStringLen[MAX_ENGINE_NUM];
00730     char *pStringList[MAX_ENGINE_NUM], *name;
00731     int i, nNum;
00732 
00733     if (gIMEOptionsNum <= 0) return;
00734 
00735     nNum = gIMEOptionsNum;
00736     if (nNum > MAX_ENGINE_NUM) nNum = MAX_ENGINE_NUM;
00737 
00738     nIntegerCount = nNum + 1;
00739     pIntegerList[0] = COMMONAUX_UPDATE_OPTIONSINFO;
00740 
00741     nStringCount = nNum;
00742     for (i=0; i<nNum; i++) {
00743     name = gIMEOptions[i]->ime_ename;
00744     pStringLen[i] = strlen(name);
00745     pStringList[i] = name;
00746     pIntegerList[i + 1] = gIMEOptions[i]->opt_value;
00747     }
00748     NotifyStringListDataToLanguageEngine(GDK_DISPLAY(), nIntegerCount, pIntegerList,
00749     nStringCount, pStringLen,
00750   */
00751 }
00752 
00753 NotifyIntegerListDataToLanguageEngine(Display *display, 
00754                                   int nIntegerCount, int *pIntegerList)
00755 {
00756   aux_ext_data_t aux_ext_data;
00757 
00758   KOLE_LOG (LOGDEST_STDOUT,
00759            "NotifyIntegerListDataToLanguageEngine(im_:%d, ic_:%d)",
00760            im_, ic_);
00761   
00762 #if 0
00763   /* This is really hack */
00764   if (!im_ || !ic_ || !xc_)
00765     return;
00766 #endif
00767   
00768   aux_ext_data.im = im_;
00769   aux_ext_data.ic = ic_;
00770   aux_ext_data.integer_count = nIntegerCount;
00771   aux_ext_data.integer_list = pIntegerList;
00772   aux_ext_data.string_count = 0;
00773   aux_ext_data.string_list = NULL;
00774   aux_ext_data.string_ptr = NULL;
00775   aux_ext_data.point.x = 0;
00776   aux_ext_data.point.y = 0;
00777 
00778   xaux_ext_SetValue(display, xc_, &aux_ext_data);
00779   XFlush(display);
00780 }
00781 
00782 NotifyStringListDataToLanguageEngine(Display *display, 
00783                                  int nIntegerCount, int *pIntegerList,
00784                                  int nStringCount,  int *pStringLen,
00785                                  char **pStringList)
00786 {
00787   int i;
00788 
00789   aux_ext_data_t aux_ext_data;
00790   aux_ext_string_t *p;
00791   
00792   KOLE_LOG (LOGDEST_STDOUT,
00793            "NotifyStringListDataToLanguageEngine(im_:%d, ic_:%d)",
00794            im_, ic_);
00795   
00796 #if 0
00797   /* This is really hack */
00798   if (!im_ || !ic_ || !xc_)
00799     return;
00800 #endif
00801 
00802   aux_ext_data.im = im_;
00803   aux_ext_data.ic = ic_;
00804   aux_ext_data.integer_count = nIntegerCount;
00805   aux_ext_data.integer_list = pIntegerList;
00806   aux_ext_data.point.x = 0;
00807   aux_ext_data.point.y = 0;
00808 
00809   aux_ext_data.string_count = nStringCount;
00810   aux_ext_data.string_ptr = NULL;
00811 
00812   if (nStringCount > 0) {
00813     aux_ext_data.string_list = (aux_ext_string_t *) calloc(nStringCount, sizeof(aux_ext_string_t));
00814     for (i = 0; i < nStringCount; i++) {
00815       aux_ext_string_t *p = &aux_ext_data.string_list[i];
00816       p->length = pStringLen[i];
00817       p->ptr = (unsigned char *) (pStringList[i]);
00818     }
00819   }
00820 
00821   xaux_ext_SetValue(display, xc_, &aux_ext_data);
00822   XFlush(display);
00823 
00824   free(aux_ext_data.string_list);
00825 }
00826 
00827 
00828 
00829 void palette_aux_Commit_String_Request(char *commit_str)
00830 {
00831 #if 0   
00832     int nIntegerCount, pIntegerList[3];
00833     int nStringCount, pStringLen[1];
00834     char *pStringList[1];
00835 
00836     if (!commit_str || !*commit_str) return;
00837 
00838     DEBUG_printf("palette_aux_Commit_String_Request: encode_id:%d, commit_str:%s, len: %d\n",
00839                  ENCODE_UTF8,  commit_str, strlen(commit_str));
00840 
00841     nIntegerCount = 3;
00842     pIntegerList[0] = COMMONAUX_COMMIT_STRING;
00843     pIntegerList[1] = ENCODE_UTF8;
00844     pIntegerList[2] = strlen(commit_str);
00845 
00846     nStringCount = 1;
00847     pStringLen[0] = strlen(commit_str) + 1;
00848     pStringList[0] = commit_str;
00849 
00850     NotifyStringListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList,
00851                                          nStringCount, pStringLen, pStringList);
00852 #endif 
00853 }
00854 
00855 
00856 void palette_aux_Commit_Key_Request(int nKeyCode, int nKeyChar, int nKeyStatus)
00857 {
00858     int nIntegerCount, pIntegerList[4];
00859    
00860     DEBUG_printf("palette_aux_Commit_Key_Request: nKeyCode is %d, nKeyChar is %c\n", nKeyCode, nKeyChar); 
00861     pIntegerList[0] = COMMONAUX_COMMIT_KEY;
00862     pIntegerList[1] = nKeyCode;
00863     pIntegerList[2] = nKeyChar;
00864     pIntegerList[3] = nKeyStatus;
00865     nIntegerCount = 4;
00866     NotifyIntegerListDataToLanguageEngine(gDisplay, nIntegerCount, pIntegerList);
00867 
00868 }
00869