aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2013-09-16 09:41:28 +0200
committerJoakim Verona2013-09-16 09:41:28 +0200
commit91d9cdf98e11c6caf8655f327c38a123b5ff22d8 (patch)
tree6c50918c11d4364c31042895b49191428e038a6a /src
parentdf15e4f6391d475acf15dcb512a28eed9964caac (diff)
parentf8eb15727ae6a5c629e27ab9755e638766b27822 (diff)
downloademacs-91d9cdf98e11c6caf8655f327c38a123b5ff22d8.tar.gz
emacs-91d9cdf98e11c6caf8655f327c38a123b5ff22d8.zip
merge from trunk
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/frame.h5
-rw-r--r--src/xterm.c67
3 files changed, 42 insertions, 40 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0050d949dd2..10349aea412 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12013-09-16 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Fix X event waiting to handle multiple frames.
4 * frame.h (struct frame) [HAVE_X_WINDOWS]: New member wait_event_type.
5 * xterm.c (pending_event_wait): Remove. Adjust users.
6 (x_detect_focus_change): Pass frame arg.
7 (handle_one_xevent): Find related frame early and clear per-frame
8 wait_event_type only if this is an event for the relevant frame.
9 (x_wait_for_event): Use per-frame wait_event_type.
10
12013-09-15 Jan Djärv <jan.h.d@swipnet.se> 112013-09-15 Jan Djärv <jan.h.d@swipnet.se>
2 12
3 * nsfns.m (Fx_create_frame): Fix font driver registration for 13 * nsfns.m (Fx_create_frame): Fix font driver registration for
diff --git a/src/frame.h b/src/frame.h
index d8a6d380090..c5ad71628ab 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -328,6 +328,11 @@ struct frame
328 unsigned int external_menu_bar : 1; 328 unsigned int external_menu_bar : 1;
329#endif 329#endif
330 330
331#if defined (HAVE_X_WINDOWS)
332 /* Used by x_wait_for_event when watching for an X event on this frame. */
333 int wait_event_type;
334#endif
335
331 /* Next two bitfields are mutually exclusive. They might both be 336 /* Next two bitfields are mutually exclusive. They might both be
332 zero if the frame has been made invisible without an icon. */ 337 zero if the frame has been made invisible without an icon. */
333 338
diff --git a/src/xterm.c b/src/xterm.c
index 9c410569b7a..cb29caddb41 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -162,13 +162,6 @@ Lisp_Object x_display_name_list;
162 162
163static struct frame *pending_autoraise_frame; 163static struct frame *pending_autoraise_frame;
164 164
165/* This is a frame waiting for an event matching mask, within XTread_socket. */
166
167static struct {
168 struct frame *f;
169 int eventtype;
170} pending_event_wait;
171
172#ifdef USE_X_TOOLKIT 165#ifdef USE_X_TOOLKIT
173/* The application context for Xt use. */ 166/* The application context for Xt use. */
174XtAppContext Xt_app_con; 167XtAppContext Xt_app_con;
@@ -296,8 +289,6 @@ static void frame_unhighlight (struct frame *);
296static void x_new_focus_frame (struct x_display_info *, struct frame *); 289static void x_new_focus_frame (struct x_display_info *, struct frame *);
297static void x_focus_changed (int, int, struct x_display_info *, 290static void x_focus_changed (int, int, struct x_display_info *,
298 struct frame *, struct input_event *); 291 struct frame *, struct input_event *);
299static void x_detect_focus_change (struct x_display_info *,
300 XEvent *, struct input_event *);
301static void XTframe_rehighlight (struct frame *); 292static void XTframe_rehighlight (struct frame *);
302static void x_frame_rehighlight (struct x_display_info *); 293static void x_frame_rehighlight (struct x_display_info *);
303static void x_draw_hollow_cursor (struct window *, struct glyph_row *); 294static void x_draw_hollow_cursor (struct window *, struct glyph_row *);
@@ -3558,12 +3549,10 @@ x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
3558 Returns FOCUS_IN_EVENT event in *BUFP. */ 3549 Returns FOCUS_IN_EVENT event in *BUFP. */
3559 3550
3560static void 3551static void
3561x_detect_focus_change (struct x_display_info *dpyinfo, XEvent *event, struct input_event *bufp) 3552x_detect_focus_change (struct x_display_info *dpyinfo, struct frame *frame,
3553 XEvent *event, struct input_event *bufp)
3562{ 3554{
3563 struct frame *frame; 3555 if (!frame)
3564
3565 frame = x_any_window_to_frame (dpyinfo, event->xany.window);
3566 if (! frame)
3567 return; 3556 return;
3568 3557
3569 switch (event->type) 3558 switch (event->type)
@@ -5892,7 +5881,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
5892 int count = 0; 5881 int count = 0;
5893 int do_help = 0; 5882 int do_help = 0;
5894 ptrdiff_t nbytes = 0; 5883 ptrdiff_t nbytes = 0;
5895 struct frame *f = NULL; 5884 struct frame *any, *f = NULL;
5896 struct coding_system coding; 5885 struct coding_system coding;
5897 XEvent event = *eventptr; 5886 XEvent event = *eventptr;
5898 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; 5887 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
@@ -5910,8 +5899,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
5910 inev.ie.kind = NO_EVENT; 5899 inev.ie.kind = NO_EVENT;
5911 inev.ie.arg = Qnil; 5900 inev.ie.arg = Qnil;
5912 5901
5913 if (pending_event_wait.eventtype == event.type) 5902 any = x_any_window_to_frame (dpyinfo, event.xany.window);
5914 pending_event_wait.eventtype = 0; /* Indicates we got it. */ 5903
5904 if (any && any->wait_event_type == event.type)
5905 any->wait_event_type = 0; /* Indicates we got it. */
5915 5906
5916 switch (event.type) 5907 switch (event.type)
5917 { 5908 {
@@ -5924,10 +5915,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
5924 if (event.xclient.data.l[0] 5915 if (event.xclient.data.l[0]
5925 == dpyinfo->Xatom_wm_take_focus) 5916 == dpyinfo->Xatom_wm_take_focus)
5926 { 5917 {
5927 /* Use x_any_window_to_frame because this 5918 /* Use the value returned by x_any_window_to_frame
5928 could be the shell widget window 5919 because this could be the shell widget window
5929 if the frame has no title bar. */ 5920 if the frame has no title bar. */
5930 f = x_any_window_to_frame (dpyinfo, event.xclient.window); 5921 f = any;
5931#ifdef HAVE_X_I18N 5922#ifdef HAVE_X_I18N
5932 /* Not quite sure this is needed -pd */ 5923 /* Not quite sure this is needed -pd */
5933 if (f && FRAME_XIC (f)) 5924 if (f && FRAME_XIC (f))
@@ -6004,8 +5995,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6004 if (event.xclient.data.l[0] 5995 if (event.xclient.data.l[0]
6005 == dpyinfo->Xatom_wm_delete_window) 5996 == dpyinfo->Xatom_wm_delete_window)
6006 { 5997 {
6007 f = x_any_window_to_frame (dpyinfo, 5998 f = any;
6008 event.xclient.window);
6009 if (!f) 5999 if (!f)
6010 goto OTHER; /* May be a dialog that is to be removed */ 6000 goto OTHER; /* May be a dialog that is to be removed */
6011 6001
@@ -6044,7 +6034,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6044 if (event.xclient.message_type 6034 if (event.xclient.message_type
6045 == dpyinfo->Xatom_editres) 6035 == dpyinfo->Xatom_editres)
6046 { 6036 {
6047 f = x_any_window_to_frame (dpyinfo, event.xclient.window); 6037 f = any;
6048 if (f) 6038 if (f)
6049 _XEditResCheckMessages (f->output_data.x->widget, NULL, 6039 _XEditResCheckMessages (f->output_data.x->widget, NULL,
6050 &event, NULL); 6040 &event, NULL);
@@ -6088,7 +6078,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6088 { 6078 {
6089 enum xembed_message msg = event.xclient.data.l[1]; 6079 enum xembed_message msg = event.xclient.data.l[1];
6090 if (msg == XEMBED_FOCUS_IN || msg == XEMBED_FOCUS_OUT) 6080 if (msg == XEMBED_FOCUS_IN || msg == XEMBED_FOCUS_OUT)
6091 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6081 x_detect_focus_change (dpyinfo, any, &event, &inev.ie);
6092 6082
6093 *finish = X_EVENT_GOTO_OUT; 6083 *finish = X_EVENT_GOTO_OUT;
6094 goto done; 6084 goto done;
@@ -6096,7 +6086,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6096 6086
6097 xft_settings_event (dpyinfo, &event); 6087 xft_settings_event (dpyinfo, &event);
6098 6088
6099 f = x_any_window_to_frame (dpyinfo, event.xclient.window); 6089 f = any;
6100 if (!f) 6090 if (!f)
6101 goto OTHER; 6091 goto OTHER;
6102 if (x_handle_dnd_message (f, &event.xclient, dpyinfo, &inev.ie)) 6092 if (x_handle_dnd_message (f, &event.xclient, dpyinfo, &inev.ie))
@@ -6358,7 +6348,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6358 goto OTHER; 6348 goto OTHER;
6359#endif 6349#endif
6360 6350
6361 f = x_any_window_to_frame (dpyinfo, event.xkey.window); 6351 f = any;
6362 6352
6363#if ! defined (USE_GTK) 6353#if ! defined (USE_GTK)
6364 /* If mouse-highlight is an integer, input clears out 6354 /* If mouse-highlight is an integer, input clears out
@@ -6692,9 +6682,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6692 6682
6693 case EnterNotify: 6683 case EnterNotify:
6694 dpyinfo->last_user_time = event.xcrossing.time; 6684 dpyinfo->last_user_time = event.xcrossing.time;
6695 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6685 x_detect_focus_change (dpyinfo, any, &event, &inev.ie);
6696 6686
6697 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window); 6687 f = any;
6698 6688
6699 if (f && x_mouse_click_focus_ignore_position) 6689 if (f && x_mouse_click_focus_ignore_position)
6700 ignore_next_mouse_click_timeout = event.xmotion.time + 200; 6690 ignore_next_mouse_click_timeout = event.xmotion.time + 200;
@@ -6712,12 +6702,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6712 goto OTHER; 6702 goto OTHER;
6713 6703
6714 case FocusIn: 6704 case FocusIn:
6715 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6705 x_detect_focus_change (dpyinfo, any, &event, &inev.ie);
6716 goto OTHER; 6706 goto OTHER;
6717 6707
6718 case LeaveNotify: 6708 case LeaveNotify:
6719 dpyinfo->last_user_time = event.xcrossing.time; 6709 dpyinfo->last_user_time = event.xcrossing.time;
6720 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6710 x_detect_focus_change (dpyinfo, any, &event, &inev.ie);
6721 6711
6722 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window); 6712 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
6723 if (f) 6713 if (f)
@@ -6745,7 +6735,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6745 goto OTHER; 6735 goto OTHER;
6746 6736
6747 case FocusOut: 6737 case FocusOut:
6748 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6738 x_detect_focus_change (dpyinfo, any, &event, &inev.ie);
6749 goto OTHER; 6739 goto OTHER;
6750 6740
6751 case MotionNotify: 6741 case MotionNotify:
@@ -6831,7 +6821,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6831 f = x_top_window_to_frame (dpyinfo, event.xconfigure.window); 6821 f = x_top_window_to_frame (dpyinfo, event.xconfigure.window);
6832#ifdef USE_GTK 6822#ifdef USE_GTK
6833 if (!f 6823 if (!f
6834 && (f = x_any_window_to_frame (dpyinfo, event.xconfigure.window)) 6824 && (f = any)
6835 && event.xconfigure.window == FRAME_X_WINDOW (f)) 6825 && event.xconfigure.window == FRAME_X_WINDOW (f))
6836 { 6826 {
6837 xg_frame_resized (f, event.xconfigure.width, 6827 xg_frame_resized (f, event.xconfigure.width,
@@ -8747,15 +8737,14 @@ x_wait_for_event (struct frame *f, int eventtype)
8747 struct timespec tmo, tmo_at, time_now; 8737 struct timespec tmo, tmo_at, time_now;
8748 int fd = ConnectionNumber (FRAME_X_DISPLAY (f)); 8738 int fd = ConnectionNumber (FRAME_X_DISPLAY (f));
8749 8739
8750 pending_event_wait.f = f; 8740 f->wait_event_type = eventtype;
8751 pending_event_wait.eventtype = eventtype;
8752 8741
8753 /* Set timeout to 0.1 second. Hopefully not noticeable. 8742 /* Set timeout to 0.1 second. Hopefully not noticeable.
8754 Maybe it should be configurable. */ 8743 Maybe it should be configurable. */
8755 tmo = make_timespec (0, 100 * 1000 * 1000); 8744 tmo = make_timespec (0, 100 * 1000 * 1000);
8756 tmo_at = timespec_add (current_timespec (), tmo); 8745 tmo_at = timespec_add (current_timespec (), tmo);
8757 8746
8758 while (pending_event_wait.eventtype) 8747 while (f->wait_event_type)
8759 { 8748 {
8760 pending_signals = 1; 8749 pending_signals = 1;
8761 totally_unblock_input (); 8750 totally_unblock_input ();
@@ -8774,8 +8763,8 @@ x_wait_for_event (struct frame *f, int eventtype)
8774 if (pselect (fd + 1, &fds, NULL, NULL, &tmo, NULL) == 0) 8763 if (pselect (fd + 1, &fds, NULL, NULL, &tmo, NULL) == 0)
8775 break; /* Timeout */ 8764 break; /* Timeout */
8776 } 8765 }
8777 pending_event_wait.f = 0; 8766
8778 pending_event_wait.eventtype = 0; 8767 f->wait_event_type = 0;
8779} 8768}
8780 8769
8781 8770
@@ -10702,8 +10691,6 @@ x_initialize (void)
10702#endif 10691#endif
10703 10692
10704 pending_autoraise_frame = 0; 10693 pending_autoraise_frame = 0;
10705 pending_event_wait.f = 0;
10706 pending_event_wait.eventtype = 0;
10707 10694
10708 /* Note that there is no real way portable across R3/R4 to get the 10695 /* Note that there is no real way portable across R3/R4 to get the
10709 original error handler. */ 10696 original error handler. */