comparison src/event-Xt.c @ 420:41dbb7a9d5f2 r21-2-18

Import from CVS: tag r21-2-18
author cvs
date Mon, 13 Aug 2007 11:24:09 +0200
parents 697ef44129c6
children 95016f13131a
comparison
equal deleted inserted replaced
419:66615b78f1a5 420:41dbb7a9d5f2
76 #endif 76 #endif
77 77
78 #include "events-mod.h" 78 #include "events-mod.h"
79 79
80 static void enqueue_Xt_dispatch_event (Lisp_Object event); 80 static void enqueue_Xt_dispatch_event (Lisp_Object event);
81 static void handle_focus_event_1 (struct frame *f, int in_p);
81 82
82 static struct event_stream *Xt_event_stream; 83 static struct event_stream *Xt_event_stream;
83 84
84 /* With the new event model, all events go through XtDispatchEvent() 85 /* With the new event model, all events go through XtDispatchEvent()
85 and are picked up by an event handler that is added to each frame 86 and are picked up by an event handler that is added to each frame
805 Lookup_String: /* Come-From XBufferOverflow */ 806 Lookup_String: /* Come-From XBufferOverflow */
806 #ifdef XIM_MOTIF 807 #ifdef XIM_MOTIF
807 len = XmImMbLookupString (XtWindowToWidget (event->display, event->window), 808 len = XmImMbLookupString (XtWindowToWidget (event->display, event->window),
808 event, bufptr, bufsiz, &keysym, &status); 809 event, bufptr, bufsiz, &keysym, &status);
809 #else /* XIM_XLIB */ 810 #else /* XIM_XLIB */
810 len = XmbLookupString (xic, event, bufptr, bufsiz, &keysym, &status); 811 if (xic)
812 len = XmbLookupString (xic, event, bufptr, bufsiz, &keysym, &status);
811 #endif /* HAVE_XIM */ 813 #endif /* HAVE_XIM */
812 814
813 #ifdef DEBUG_XEMACS 815 #ifdef DEBUG_XEMACS
814 if (x_debug_events > 0) 816 if (x_debug_events > 0)
815 { 817 {
1044 } 1046 }
1045 else /* Mouse press/release event */ 1047 else /* Mouse press/release event */
1046 { 1048 {
1047 XButtonEvent *ev = &x_event->xbutton; 1049 XButtonEvent *ev = &x_event->xbutton;
1048 struct frame *frame = x_window_to_frame (d, ev->window); 1050 struct frame *frame = x_window_to_frame (d, ev->window);
1051
1049 if (! frame) 1052 if (! frame)
1050 return 0; /* not for us */ 1053 return 0; /* not for us */
1051 XSETFRAME (emacs_event->channel, frame); 1054 XSETFRAME (emacs_event->channel, frame);
1052 1055
1053 emacs_event->event_type = (x_event->type == ButtonPress) ? 1056 emacs_event->event_type = (x_event->type == ButtonPress) ?
1056 emacs_event->event.button.modifiers = modifiers; 1059 emacs_event->event.button.modifiers = modifiers;
1057 emacs_event->timestamp = ev->time; 1060 emacs_event->timestamp = ev->time;
1058 emacs_event->event.button.button = ev->button; 1061 emacs_event->event.button.button = ev->button;
1059 emacs_event->event.button.x = ev->x; 1062 emacs_event->event.button.x = ev->x;
1060 emacs_event->event.button.y = ev->y; 1063 emacs_event->event.button.y = ev->y;
1061 1064 /* because we don't seem to get a FocusIn event for button clicks
1065 when a widget-glyph is selected we will assume that we want the
1066 focus if a button gets pressed. */
1067 if (x_event->type == ButtonPress)
1068 handle_focus_event_1 (frame, 1);
1062 } 1069 }
1063 } 1070 }
1064 break; 1071 break;
1065 1072
1066 case MotionNotify: 1073 case MotionNotify:
1302 /************************************************************************/ 1309 /************************************************************************/
1303 1310
1304 static void 1311 static void
1305 handle_focus_event_1 (struct frame *f, int in_p) 1312 handle_focus_event_1 (struct frame *f, int in_p)
1306 { 1313 {
1307 #ifdef HAVE_XIM 1314 #if XtSpecificationRelease > 5
1308 XIM_focus_event (f, in_p); 1315 Widget focus_widget = XtGetKeyboardFocusWidget (FRAME_X_TEXT_WIDGET (f));
1316 #endif
1317 #if defined(HAVE_XIM) && defined(XIM_XLIB)
1318 if (FRAME_X_XIC(f))
1319 XIM_focus_event (f, in_p);
1309 #endif /* HAVE_XIM */ 1320 #endif /* HAVE_XIM */
1310 1321
1311 /* On focus change, clear all memory of sticky modifiers 1322 /* On focus change, clear all memory of sticky modifiers
1312 to avoid non-intuitive behavior. */ 1323 to avoid non-intuitive behavior. */
1313 clear_sticky_modifiers (XDEVICE (FRAME_DEVICE (f))); 1324 clear_sticky_modifiers (XDEVICE (FRAME_DEVICE (f)));
1317 we enqueue it. 1328 we enqueue it.
1318 1329
1319 Actually, we half handle it: we handle it as far as changing the 1330 Actually, we half handle it: we handle it as far as changing the
1320 box cursor for redisplay, but we don't call any hooks or do any 1331 box cursor for redisplay, but we don't call any hooks or do any
1321 select-frame stuff until after the sit-for. 1332 select-frame stuff until after the sit-for.
1322 */ 1333
1334 Unfortunately native widgets break the model because they grab
1335 the keyboard focus and nothing sets it back again. I cannot find
1336 any reasonable way to do this elsewhere so we assert here that
1337 the keybpard focus is on the emacs text widget. Menus and dialogs
1338 do this in their selection callback, but we don't want that since
1339 a button having focus is legitimate. An edit field having focus
1340 is mandatory. Weirdly you get a FocusOut event when you glick in
1341 a widget-glyph but you don't get a correspondng FocusIn when you
1342 click in the frame. Why is this? */
1343 if (in_p
1344 #if XtSpecificationRelease > 5
1345 && FRAME_X_TEXT_WIDGET (f) != focus_widget
1346 #endif
1347 )
1348 {
1349 lw_set_keyboard_focus (FRAME_X_SHELL_WIDGET (f),
1350 FRAME_X_TEXT_WIDGET (f));
1351 }
1352 /* do the generic event-stream stuff. */
1323 { 1353 {
1324 Lisp_Object frm; 1354 Lisp_Object frm;
1325 Lisp_Object conser; 1355 Lisp_Object conser;
1326 struct gcpro gcpro1; 1356 struct gcpro gcpro1;
1327 1357
1402 { 1432 {
1403 XWindowAttributes xwa; 1433 XWindowAttributes xwa;
1404 1434
1405 /* Bleagh!!!!!! Apparently some window managers (e.g. MWM) 1435 /* Bleagh!!!!!! Apparently some window managers (e.g. MWM)
1406 send synthetic MapNotify events when a window is first 1436 send synthetic MapNotify events when a window is first
1407 created, EVENT IF IT'S CREATED ICONIFIED OR INVISIBLE. 1437 created, EVEN IF IT'S CREATED ICONIFIED OR INVISIBLE.
1408 Or something like that. We initially tried a different 1438 Or something like that. We initially tried a different
1409 solution below, but that ran into a different window- 1439 solution below, but that ran into a different window-
1410 manager bug. 1440 manager bug.
1411 1441
1412 It seems that the only reliable way is to treat a 1442 It seems that the only reliable way is to treat a
1577 } 1607 }
1578 break; 1608 break;
1579 1609
1580 case FocusIn: 1610 case FocusIn:
1581 case FocusOut: 1611 case FocusOut:
1612
1582 #ifdef EXTERNAL_WIDGET 1613 #ifdef EXTERNAL_WIDGET
1583 /* External widget lossage: Ben said: 1614 /* External widget lossage: Ben said:
1584 YUCK. The only way to make focus changes work properly is to 1615 YUCK. The only way to make focus changes work properly is to
1585 completely ignore all FocusIn/FocusOut events and depend only 1616 completely ignore all FocusIn/FocusOut events and depend only
1586 on notifications from the ExternalClient widget. */ 1617 on notifications from the ExternalClient widget. */
1611 != VisibilityFullyObscured) ? 1 : -1); 1642 != VisibilityFullyObscured) ? 1 : -1);
1612 } 1643 }
1613 break; 1644 break;
1614 1645
1615 case ConfigureNotify: 1646 case ConfigureNotify:
1616 #ifdef HAVE_XIM 1647 #if defined(HAVE_XIM) && defined(XIM_XLIB)
1617 XIM_SetGeometry (f); 1648 if (FRAME_X_XIC(f))
1649 XIM_SetGeometry (f);
1618 #endif 1650 #endif
1619 break; 1651 break;
1620 1652
1621 default: 1653 default:
1622 break; 1654 break;