comparison src/xterm.c @ 49434:a4d0ee33dcce

Fix input methods for GTK. Don't right justify GTK help menu.
author Jan Djärv <jan.h.d@swipnet.se>
date Sat, 25 Jan 2003 16:25:39 +0000
parents f5372eee5041
children 23a1cea22d13
comparison
equal deleted inserted replaced
49433:d8479f6ef62d 49434:a4d0ee33dcce
10212 X_EVENT_NORMAL, 10212 X_EVENT_NORMAL,
10213 X_EVENT_GOTO_OUT, 10213 X_EVENT_GOTO_OUT,
10214 X_EVENT_DROP 10214 X_EVENT_DROP
10215 }; 10215 };
10216 10216
10217 /* Filter events for the current X input method.
10218 DPYINFO is the display this event is for.
10219 EVENT is the X event to filter.
10220
10221 Returns non-zero if the event was filtered, caller shall not process
10222 this event further.
10223 Returns zero if event is wasn't filtered. */
10224
10225 #ifdef HAVE_X_I18N
10226 static int
10227 x_filter_event (dpyinfo, event)
10228 struct x_display_info *dpyinfo;
10229 XEvent *event;
10230 {
10231 /* XFilterEvent returns non-zero if the input method has
10232 consumed the event. We pass the frame's X window to
10233 XFilterEvent because that's the one for which the IC
10234 was created. */
10235
10236 struct frame *f1 = x_any_window_to_frame (dpyinfo,
10237 event->xclient.window);
10238
10239 return XFilterEvent (event, f1 ? FRAME_X_WINDOW (f1) : None);
10240 }
10241 #endif
10242
10217 #ifdef USE_GTK 10243 #ifdef USE_GTK
10218 static struct x_display_info *current_dpyinfo; 10244 static struct x_display_info *current_dpyinfo;
10219 static struct input_event **current_bufp; 10245 static struct input_event **current_bufp;
10220 static int *current_numcharsp; 10246 static int *current_numcharsp;
10221 static int current_count; 10247 static int current_count;
10231 gpointer data; 10257 gpointer data;
10232 { 10258 {
10233 XEvent *xev = (XEvent*)gxev; 10259 XEvent *xev = (XEvent*)gxev;
10234 10260
10235 if (current_numcharsp) 10261 if (current_numcharsp)
10236 current_count += handle_one_xevent (current_dpyinfo, 10262 {
10237 xev, 10263 #ifdef HAVE_X_I18N
10238 current_bufp, 10264 /* Filter events for the current X input method.
10239 current_numcharsp, 10265 GTK calls XFilterEvent but not for key press and release,
10240 &current_finish); 10266 so we do it here. */
10267 if (xev->type == KeyPress || xev->type == KeyRelease)
10268 if (x_filter_event (current_dpyinfo, xev))
10269 return GDK_FILTER_REMOVE;
10270 #endif
10271 current_count += handle_one_xevent (current_dpyinfo,
10272 xev,
10273 current_bufp,
10274 current_numcharsp,
10275 &current_finish);
10276 }
10241 else 10277 else
10242 x_dispatch_event (xev, GDK_DISPLAY ()); 10278 current_finish = x_dispatch_event (xev, GDK_DISPLAY ());
10243 10279
10244 if (current_finish == X_EVENT_GOTO_OUT || current_finish == X_EVENT_DROP) 10280 if (current_finish == X_EVENT_GOTO_OUT || current_finish == X_EVENT_DROP)
10245 return GDK_FILTER_REMOVE; 10281 return GDK_FILTER_REMOVE;
10246 10282
10247 return GDK_FILTER_CONTINUE; 10283 return GDK_FILTER_CONTINUE;
11518 } 11554 }
11519 11555
11520 11556
11521 /* Handles the XEvent EVENT on display DISPLAY. 11557 /* Handles the XEvent EVENT on display DISPLAY.
11522 This is used for event loops outside the normal event handling, 11558 This is used for event loops outside the normal event handling,
11523 i.e. looping while a popup menu or a dialog is posted. */ 11559 i.e. looping while a popup menu or a dialog is posted.
11524 void 11560
11561 Returns the value handle_one_xevent sets in the finish argument. */
11562 int
11525 x_dispatch_event (event, display) 11563 x_dispatch_event (event, display)
11526 XEvent *event; 11564 XEvent *event;
11527 Display *display; 11565 Display *display;
11528 { 11566 {
11529 struct x_display_info *dpyinfo; 11567 struct x_display_info *dpyinfo;
11530 struct input_event bufp[10]; 11568 struct input_event bufp[10];
11531 struct input_event *bufpp = bufp; 11569 struct input_event *bufpp = bufp;
11532 int numchars = 10; 11570 int numchars = 10;
11533 int finish; 11571 int finish = X_EVENT_NORMAL;
11534 11572
11535 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) 11573 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
11536 if (dpyinfo->display == display) 11574 if (dpyinfo->display == display)
11537 break; 11575 break;
11538 11576
11545 &numchars, 11583 &numchars,
11546 &finish); 11584 &finish);
11547 for (i = 0; i < events; ++i) 11585 for (i = 0; i < events; ++i)
11548 kbd_buffer_store_event (&bufp[i]); 11586 kbd_buffer_store_event (&bufp[i]);
11549 } 11587 }
11588
11589 return finish;
11550 } 11590 }
11551 11591
11552 11592
11553 /* Read events coming from the X server. 11593 /* Read events coming from the X server.
11554 This routine is called by the SIGIO handler. 11594 This routine is called by the SIGIO handler.
11665 int finish; 11705 int finish;
11666 11706
11667 XNextEvent (dpyinfo->display, &event); 11707 XNextEvent (dpyinfo->display, &event);
11668 11708
11669 #ifdef HAVE_X_I18N 11709 #ifdef HAVE_X_I18N
11670 { 11710 /* Filter events for the current X input method. */
11671 /* Filter events for the current X input method. 11711 if (x_filter_event (dpyinfo, &event))
11672 XFilterEvent returns non-zero if the input method has 11712 break;
11673 consumed the event. We pass the frame's X window to
11674 XFilterEvent because that's the one for which the IC
11675 was created. */
11676 struct frame *f1 = x_any_window_to_frame (dpyinfo,
11677 event.xclient.window);
11678 if (XFilterEvent (&event, f1 ? FRAME_X_WINDOW (f1) : None))
11679 break;
11680 }
11681 #endif 11713 #endif
11682 event_found = 1; 11714 event_found = 1;
11683 11715
11684 count += handle_one_xevent (dpyinfo, 11716 count += handle_one_xevent (dpyinfo,
11685 &event, 11717 &event,
13023 struct x_display_info *dpyinfo; 13055 struct x_display_info *dpyinfo;
13024 char *resource_name; 13056 char *resource_name;
13025 }; 13057 };
13026 13058
13027 /* XIM instantiate callback function, which is called whenever an XIM 13059 /* XIM instantiate callback function, which is called whenever an XIM
13028 server is available. DISPLAY is teh display of the XIM. 13060 server is available. DISPLAY is the display of the XIM.
13029 CLIENT_DATA contains a pointer to an xim_inst_t structure created 13061 CLIENT_DATA contains a pointer to an xim_inst_t structure created
13030 when the callback was registered. */ 13062 when the callback was registered. */
13031 13063
13032 static void 13064 static void
13033 xim_instantiate_callback (display, client_data, call_data) 13065 xim_instantiate_callback (display, client_data, call_data)
15165 } 15197 }
15166 15198
15167 argv[argc++] = "--name"; 15199 argv[argc++] = "--name";
15168 argv[argc++] = resource_name; 15200 argv[argc++] = resource_name;
15169 15201
15202 #ifdef HAVE_X11R5
15203 XSetLocaleModifiers ("");
15204 #endif
15205
15170 gtk_init (&argc, &argv2); 15206 gtk_init (&argc, &argv2);
15171 15207
15172 /* gtk_init does set_locale. We must fix locale after calling it. */ 15208 /* gtk_init does set_locale. We must fix locale after calling it. */
15173 fixup_locale (); 15209 fixup_locale ();
15174 xg_initialize (); 15210 xg_initialize ();