comparison src/event-Xt.c @ 450:98528da0b7fc r21-2-40

Import from CVS: tag r21-2-40
author cvs
date Mon, 13 Aug 2007 11:39:20 +0200
parents 3078fd1074e8
children 3d3049ae1304
comparison
equal deleted inserted replaced
449:c83749d23eb5 450:98528da0b7fc
90 int debug_x_events; 90 int debug_x_events;
91 #endif 91 #endif
92 92
93 static int process_events_occurred; 93 static int process_events_occurred;
94 static int tty_events_occurred; 94 static int tty_events_occurred;
95 static Widget widget_with_focus;
95 96
96 /* Mask of bits indicating the descriptors that we wait for input on */ 97 /* Mask of bits indicating the descriptors that we wait for input on */
97 extern SELECT_TYPE input_wait_mask, process_only_mask, tty_only_mask; 98 extern SELECT_TYPE input_wait_mask, process_only_mask, tty_only_mask;
98 99
99 static const String x_fallback_resources[] = 100 static const String x_fallback_resources[] =
1534 1535
1535 static void 1536 static void
1536 handle_focus_event_1 (struct frame *f, int in_p) 1537 handle_focus_event_1 (struct frame *f, int in_p)
1537 { 1538 {
1538 #if XtSpecificationRelease > 5 1539 #if XtSpecificationRelease > 5
1539 Widget focus_widget = XtGetKeyboardFocusWidget (FRAME_X_TEXT_WIDGET (f)); 1540 widget_with_focus = XtGetKeyboardFocusWidget (FRAME_X_TEXT_WIDGET (f));
1540 #endif 1541 #endif
1541 #ifdef HAVE_XIM 1542 #ifdef HAVE_XIM
1542 XIM_focus_event (f, in_p); 1543 XIM_focus_event (f, in_p);
1543 #endif /* HAVE_XIM */ 1544 #endif /* HAVE_XIM */
1545
1544 /* On focus change, clear all memory of sticky modifiers 1546 /* On focus change, clear all memory of sticky modifiers
1545 to avoid non-intuitive behavior. */ 1547 to avoid non-intuitive behavior. */
1546 clear_sticky_modifiers (XDEVICE (FRAME_DEVICE (f))); 1548 clear_sticky_modifiers (XDEVICE (FRAME_DEVICE (f)));
1547 1549
1548 /* We don't want to handle the focus change now, because we might 1550 /* We don't want to handle the focus change now, because we might
1562 is mandatory. Weirdly you get a FocusOut event when you click in 1564 is mandatory. Weirdly you get a FocusOut event when you click in
1563 a widget-glyph but you don't get a corresponding FocusIn when you 1565 a widget-glyph but you don't get a corresponding FocusIn when you
1564 click in the frame. Why is this? */ 1566 click in the frame. Why is this? */
1565 if (in_p 1567 if (in_p
1566 #if XtSpecificationRelease > 5 1568 #if XtSpecificationRelease > 5
1567 && FRAME_X_TEXT_WIDGET (f) != focus_widget 1569 && FRAME_X_TEXT_WIDGET (f) != widget_with_focus
1568 #endif 1570 #endif
1569 ) 1571 )
1570 { 1572 {
1571 lw_set_keyboard_focus (FRAME_X_SHELL_WIDGET (f), 1573 lw_set_keyboard_focus (FRAME_X_SHELL_WIDGET (f),
1572 FRAME_X_TEXT_WIDGET (f)); 1574 FRAME_X_TEXT_WIDGET (f));
1573 } 1575 }
1576
1577 /* We have the focus now. See comment in
1578 emacs_Xt_handle_widget_losing_focus (). */
1579 if (in_p)
1580 widget_with_focus = NULL;
1581
1574 /* do the generic event-stream stuff. */ 1582 /* do the generic event-stream stuff. */
1575 { 1583 {
1576 Lisp_Object frm; 1584 Lisp_Object frm;
1577 Lisp_Object conser; 1585 Lisp_Object conser;
1578 struct gcpro gcpro1; 1586 struct gcpro gcpro1;
1583 emacs_handle_focus_change_preliminary (conser); 1591 emacs_handle_focus_change_preliminary (conser);
1584 enqueue_magic_eval_event (emacs_handle_focus_change_final, 1592 enqueue_magic_eval_event (emacs_handle_focus_change_final,
1585 conser); 1593 conser);
1586 UNGCPRO; 1594 UNGCPRO;
1587 } 1595 }
1596 }
1597
1598 /* The idea here is that when a widget glyph gets unmapped we don't
1599 want the focus to stay with it if it has focus - because it may
1600 well just get deleted next andthen we have lost the focus until the
1601 user does something. So handle_focus_event_1 records the widget
1602 with keyboard focus when FocusOut is processed, and then, when a
1603 widget gets unmapped, it calls this function to restore focus if
1604 appropriate. */
1605 void emacs_Xt_handle_widget_losing_focus (struct frame* f, Widget losing_widget);
1606 void
1607 emacs_Xt_handle_widget_losing_focus (struct frame* f, Widget losing_widget)
1608 {
1609 if (losing_widget == widget_with_focus)
1610 {
1611 handle_focus_event_1 (f, 1);
1612 }
1588 } 1613 }
1589 1614
1590 /* This is called from the external-widget code */ 1615 /* This is called from the external-widget code */
1591 1616
1592 void emacs_Xt_handle_focus_event (XEvent *event); 1617 void emacs_Xt_handle_focus_event (XEvent *event);