Mercurial > hg > xemacs-beta
comparison src/event-Xt.c @ 863:42375619fa45
[xemacs-hg @ 2002-06-04 06:03:59 by andyp]
merge 21.4 windows changes, minimally tested
author | andyp |
---|---|
date | Tue, 04 Jun 2002 06:05:53 +0000 |
parents | 2b6fa2618f76 |
children | 804517e16990 |
comparison
equal
deleted
inserted
replaced
862:278c743f1578 | 863:42375619fa45 |
---|---|
66 #if defined (HAVE_OFFIX_DND) | 66 #if defined (HAVE_OFFIX_DND) |
67 #include "offix.h" | 67 #include "offix.h" |
68 #endif | 68 #endif |
69 | 69 |
70 static void handle_focus_event_1 (struct frame *f, int in_p); | 70 static void handle_focus_event_1 (struct frame *f, int in_p); |
71 static void handle_focus_event_2 (Window w, struct frame *f, int in_p); | |
71 | 72 |
72 static struct event_stream *Xt_event_stream; | 73 static struct event_stream *Xt_event_stream; |
73 | 74 |
74 /* With the new event model, all events go through XtDispatchEvent() | 75 /* With the new event model, all events go through XtDispatchEvent() |
75 and are picked up by an event handler that is added to each frame | 76 and are picked up by an event handler that is added to each frame |
1534 /************************************************************************/ | 1535 /************************************************************************/ |
1535 | 1536 |
1536 static void | 1537 static void |
1537 handle_focus_event_1 (struct frame *f, int in_p) | 1538 handle_focus_event_1 (struct frame *f, int in_p) |
1538 { | 1539 { |
1540 handle_focus_event_2 (XtWindow (FRAME_X_TEXT_WIDGET (f)), f, in_p); | |
1541 } | |
1542 | |
1543 static void | |
1544 handle_focus_event_2 (Window win, struct frame *f, int in_p) | |
1545 { | |
1546 /* Although this treats focus differently for all widgets (including | |
1547 the frame) it seems to work ok. */ | |
1548 Widget needs_it = XtWindowToWidget (FRAME_X_DISPLAY (f), win); | |
1549 | |
1539 #if XtSpecificationRelease > 5 | 1550 #if XtSpecificationRelease > 5 |
1540 widget_with_focus = XtGetKeyboardFocusWidget (FRAME_X_TEXT_WIDGET (f)); | 1551 widget_with_focus = XtGetKeyboardFocusWidget (FRAME_X_TEXT_WIDGET (f)); |
1541 #endif | 1552 #endif |
1542 #ifdef HAVE_XIM | 1553 #ifdef HAVE_XIM |
1543 XIM_focus_event (f, in_p); | 1554 XIM_focus_event (f, in_p); |
1564 is mandatory. Weirdly you get a FocusOut event when you click in | 1575 is mandatory. Weirdly you get a FocusOut event when you click in |
1565 a widget-glyph but you don't get a corresponding FocusIn when you | 1576 a widget-glyph but you don't get a corresponding FocusIn when you |
1566 click in the frame. Why is this? */ | 1577 click in the frame. Why is this? */ |
1567 if (in_p | 1578 if (in_p |
1568 #if XtSpecificationRelease > 5 | 1579 #if XtSpecificationRelease > 5 |
1569 && FRAME_X_TEXT_WIDGET (f) != widget_with_focus | 1580 && needs_it != widget_with_focus |
1570 #endif | 1581 #endif |
1571 ) | 1582 ) |
1572 { | 1583 { |
1573 lw_set_keyboard_focus (FRAME_X_SHELL_WIDGET (f), | 1584 lw_set_keyboard_focus (FRAME_X_SHELL_WIDGET (f), needs_it); |
1574 FRAME_X_TEXT_WIDGET (f)); | 1585 } |
1575 } | 1586 |
1587 /* If we are focusing on a native widget then record and exit. */ | |
1588 if (needs_it != FRAME_X_TEXT_WIDGET (f)) { | |
1589 widget_with_focus = needs_it; | |
1590 return; | |
1591 } | |
1576 | 1592 |
1577 /* We have the focus now. See comment in | 1593 /* We have the focus now. See comment in |
1578 emacs_Xt_handle_widget_losing_focus (). */ | 1594 emacs_Xt_handle_widget_losing_focus (). */ |
1579 if (in_p) | 1595 if (in_p) |
1580 widget_with_focus = NULL; | 1596 widget_with_focus = NULL; |
1593 conser); | 1609 conser); |
1594 UNGCPRO; | 1610 UNGCPRO; |
1595 } | 1611 } |
1596 } | 1612 } |
1597 | 1613 |
1614 /* Create a synthetic X focus event. */ | |
1615 void | |
1616 enqueue_focus_event (Widget wants_it, Lisp_Object frame, int in_p) | |
1617 { | |
1618 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil); | |
1619 Lisp_Event *ev = XEVENT (emacs_event); | |
1620 XEvent *x_event = &ev->event.magic.underlying_x_event; | |
1621 | |
1622 x_event->type = in_p ? FocusIn : FocusOut; | |
1623 x_event->xfocus.window = XtWindow (wants_it); | |
1624 | |
1625 ev->channel = frame; | |
1626 ev->event_type = magic_event; | |
1627 | |
1628 enqueue_Xt_dispatch_event (emacs_event); | |
1629 } | |
1630 | |
1598 /* The idea here is that when a widget glyph gets unmapped we don't | 1631 /* 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 | 1632 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 | 1633 well just get deleted next and then we have lost the focus until the |
1601 user does something. So handle_focus_event_1 records the widget | 1634 user does something. So handle_focus_event_1 records the widget |
1602 with keyboard focus when FocusOut is processed, and then, when a | 1635 with keyboard focus when FocusOut is processed, and then, when a |
1603 widget gets unmapped, it calls this function to restore focus if | 1636 widget gets unmapped, it calls this function to restore focus if |
1604 appropriate. */ | 1637 appropriate. */ |
1605 void emacs_Xt_handle_widget_losing_focus (struct frame *f, Widget losing_widget); | 1638 void emacs_Xt_handle_widget_losing_focus (struct frame *f, Widget losing_widget); |
1972 completely ignore all FocusIn/FocusOut events and depend only | 2005 completely ignore all FocusIn/FocusOut events and depend only |
1973 on notifications from the ExternalClient widget. */ | 2006 on notifications from the ExternalClient widget. */ |
1974 if (FRAME_X_EXTERNAL_WINDOW_P (f)) | 2007 if (FRAME_X_EXTERNAL_WINDOW_P (f)) |
1975 break; | 2008 break; |
1976 #endif | 2009 #endif |
1977 handle_focus_event_1 (f, event->type == FocusIn); | 2010 handle_focus_event_2 (event->xfocus.window, f, event->type == FocusIn); |
1978 break; | 2011 break; |
1979 | 2012 |
1980 case ClientMessage: | 2013 case ClientMessage: |
1981 handle_client_message (f, event); | 2014 handle_client_message (f, event); |
1982 break; | 2015 break; |