aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Antipov2013-09-18 10:48:11 +0400
committerDmitry Antipov2013-09-18 10:48:11 +0400
commit7a0c745ad134aff0bb8f4258ea607137a819b58d (patch)
treeae24a427e9425302a7953eea18b311214c9664b4
parent12679bfd15020087eca82df8dcb5df2c48bcef02 (diff)
downloademacs-7a0c745ad134aff0bb8f4258ea607137a819b58d.tar.gz
emacs-7a0c745ad134aff0bb8f4258ea607137a819b58d.zip
* frame.c (x_mouse_grabbed): New function.
* dispextern.h (x_mouse_grabbed): Add prototype. (last_mouse_frame): Remove declaration. * xterm.h (struct x_display_info): * w32term.h (struct w32_display_info): * nsterm.h (struct ns_display_info): New member last_mouse_frame, going to replace... * xdisp.c (last_mouse_frame): ...global variable. (note_tool_bar_highlight): * w32term.c (w32_mouse_position, w32_read_socket): * xterm.c (XTmouse_position, handle_one_xevent): Use x_mouse_grabbed. * nsterm.m (ns_mouse_position, mouseDown): Adjust user.
-rw-r--r--src/ChangeLog16
-rw-r--r--src/dispextern.h2
-rw-r--r--src/frame.c11
-rw-r--r--src/nsterm.h3
-rw-r--r--src/nsterm.m10
-rw-r--r--src/w32term.c44
-rw-r--r--src/w32term.h3
-rw-r--r--src/xdisp.c10
-rw-r--r--src/xterm.c36
-rw-r--r--src/xterm.h3
10 files changed, 75 insertions, 63 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4223573a6ff..b5bdf1dca70 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,19 @@
12013-09-18 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * frame.c (x_mouse_grabbed): New function.
4 * dispextern.h (x_mouse_grabbed): Add prototype.
5 (last_mouse_frame): Remove declaration.
6 * xterm.h (struct x_display_info):
7 * w32term.h (struct w32_display_info):
8 * nsterm.h (struct ns_display_info): New member
9 last_mouse_frame, going to replace...
10 * xdisp.c (last_mouse_frame): ...global variable.
11 (note_tool_bar_highlight):
12 * w32term.c (w32_mouse_position, w32_read_socket):
13 * xterm.c (XTmouse_position, handle_one_xevent):
14 Use x_mouse_grabbed.
15 * nsterm.m (ns_mouse_position, mouseDown): Adjust user.
16
12013-09-17 Dmitry Antipov <dmantipov@yandex.ru> 172013-09-17 Dmitry Antipov <dmantipov@yandex.ru>
2 18
3 * w32term.c (w32_read_socket): Avoid temporary 19 * w32term.c (w32_read_socket): Avoid temporary
diff --git a/src/dispextern.h b/src/dispextern.h
index e91403bce68..c8af00ad915 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3194,7 +3194,6 @@ extern int help_echo_showing_p;
3194extern Lisp_Object help_echo_string, help_echo_window; 3194extern Lisp_Object help_echo_string, help_echo_window;
3195extern Lisp_Object help_echo_object, previous_help_echo_string; 3195extern Lisp_Object help_echo_object, previous_help_echo_string;
3196extern ptrdiff_t help_echo_pos; 3196extern ptrdiff_t help_echo_pos;
3197extern struct frame *last_mouse_frame;
3198extern int last_tool_bar_item; 3197extern int last_tool_bar_item;
3199extern void reseat_at_previous_visible_line_start (struct it *); 3198extern void reseat_at_previous_visible_line_start (struct it *);
3200extern Lisp_Object lookup_glyphless_char_display (int, struct it *); 3199extern Lisp_Object lookup_glyphless_char_display (int, struct it *);
@@ -3531,6 +3530,7 @@ enum resource_types
3531 RES_TYPE_BOOLEAN_NUMBER 3530 RES_TYPE_BOOLEAN_NUMBER
3532}; 3531};
3533 3532
3533extern bool x_mouse_grabbed (Display_Info *);
3534extern Display_Info *check_x_display_info (Lisp_Object); 3534extern Display_Info *check_x_display_info (Lisp_Object);
3535extern Lisp_Object x_get_arg (Display_Info *, Lisp_Object, 3535extern Lisp_Object x_get_arg (Display_Info *, Lisp_Object,
3536 Lisp_Object, const char *, const char *class, 3536 Lisp_Object, const char *, const char *class,
diff --git a/src/frame.c b/src/frame.c
index 365629d0f48..a31bf35aa6b 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -3432,7 +3432,16 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3432 return; 3432 return;
3433} 3433}
3434 3434
3435 3435/* Non-zero if mouse is grabbed on DPYINFO
3436 and we know the frame where it is. */
3437
3438bool x_mouse_grabbed (Display_Info *dpyinfo)
3439{
3440 return (dpyinfo->grabbed
3441 && dpyinfo->last_mouse_frame
3442 && FRAME_LIVE_P (dpyinfo->last_mouse_frame));
3443}
3444
3436/* Subroutines of creating an X frame. */ 3445/* Subroutines of creating an X frame. */
3437 3446
3438/* Make sure that Vx_resource_name is set to a reasonable value. 3447/* Make sure that Vx_resource_name is set to a reasonable value.
diff --git a/src/nsterm.h b/src/nsterm.h
index 30ae871da83..373e06cefd2 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -597,6 +597,9 @@ struct ns_display_info
597 597
598 struct frame *x_highlight_frame; 598 struct frame *x_highlight_frame;
599 struct frame *x_focus_frame; 599 struct frame *x_focus_frame;
600
601 /* The frame where the mouse was last time we reported a mouse event. */
602 struct frame *last_mouse_frame;
600}; 603};
601 604
602/* This is a chain of structures for all the NS displays currently in use. */ 605/* This is a chain of structures for all the NS displays currently in use. */
diff --git a/src/nsterm.m b/src/nsterm.m
index 6c5f5f54cb9..d41bd856b0c 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1812,8 +1812,9 @@ ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
1812 XFRAME (frame)->mouse_moved = 0; 1812 XFRAME (frame)->mouse_moved = 0;
1813 1813
1814 last_mouse_scroll_bar = nil; 1814 last_mouse_scroll_bar = nil;
1815 if (last_mouse_frame && FRAME_LIVE_P (last_mouse_frame)) 1815 if (dpyinfo->last_mouse_frame
1816 f = last_mouse_frame; 1816 && FRAME_LIVE_P (dpyinfo->last_mouse_frame))
1817 f = dpyinfo->last_mouse_frame;
1817 else 1818 else
1818 f = dpyinfo->x_focus_frame ? dpyinfo->x_focus_frame 1819 f = dpyinfo->x_focus_frame ? dpyinfo->x_focus_frame
1819 : SELECTED_FRAME (); 1820 : SELECTED_FRAME ();
@@ -5362,6 +5363,7 @@ not_in_argv (NSString *arg)
5362/* This is what happens when the user presses a mouse button. */ 5363/* This is what happens when the user presses a mouse button. */
5363- (void)mouseDown: (NSEvent *)theEvent 5364- (void)mouseDown: (NSEvent *)theEvent
5364{ 5365{
5366 struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
5365 NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil]; 5367 NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil];
5366 5368
5367 NSTRACE (mouseDown); 5369 NSTRACE (mouseDown);
@@ -5371,10 +5373,10 @@ not_in_argv (NSString *arg)
5371 if (!emacs_event) 5373 if (!emacs_event)
5372 return; 5374 return;
5373 5375
5374 last_mouse_frame = emacsframe; 5376 dpyinfo->last_mouse_frame = emacsframe;
5375 /* appears to be needed to prevent spurious movement events generated on 5377 /* appears to be needed to prevent spurious movement events generated on
5376 button clicks */ 5378 button clicks */
5377 last_mouse_frame->mouse_moved = 0; 5379 emacsframe->mouse_moved = 0;
5378 5380
5379 if ([theEvent type] == NSScrollWheel) 5381 if ([theEvent type] == NSScrollWheel)
5380 { 5382 {
diff --git a/src/w32term.c b/src/w32term.c
index 331a86ef7d7..97dda0e8c55 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3404,6 +3404,7 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
3404 unsigned long *time) 3404 unsigned long *time)
3405{ 3405{
3406 struct frame *f1; 3406 struct frame *f1;
3407 struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
3407 3408
3408 block_input (); 3409 block_input ();
3409 3410
@@ -3426,19 +3427,11 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
3426 /* Now we have a position on the root; find the innermost window 3427 /* Now we have a position on the root; find the innermost window
3427 containing the pointer. */ 3428 containing the pointer. */
3428 { 3429 {
3429 if (FRAME_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame 3430 /* If mouse was grabbed on a frame, give coords for that
3430 && FRAME_LIVE_P (last_mouse_frame)) 3431 frame even if the mouse is now outside it. Otherwise
3431 { 3432 check for window under mouse on one of our frames. */
3432 /* If mouse was grabbed on a frame, give coords for that frame 3433 f1 = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
3433 even if the mouse is now outside it. */ 3434 : x_any_window_to_frame (dpyinfo, WindowFromPoint (pt)));
3434 f1 = last_mouse_frame;
3435 }
3436 else
3437 {
3438 /* Is window under mouse one of our frames? */
3439 f1 = x_any_window_to_frame (FRAME_DISPLAY_INFO (*fp),
3440 WindowFromPoint (pt));
3441 }
3442 3435
3443 /* If not, is it one of our scroll bars? */ 3436 /* If not, is it one of our scroll bars? */
3444 if (! f1) 3437 if (! f1)
@@ -4479,11 +4472,8 @@ w32_read_socket (struct terminal *terminal,
4479 previous_help_echo_string = help_echo_string; 4472 previous_help_echo_string = help_echo_string;
4480 help_echo_string = Qnil; 4473 help_echo_string = Qnil;
4481 4474
4482 if (dpyinfo->grabbed && last_mouse_frame 4475 f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
4483 && FRAME_LIVE_P (last_mouse_frame)) 4476 : x_window_to_frame (dpyinfo, msg.msg.hwnd));
4484 f = last_mouse_frame;
4485 else
4486 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4487 4477
4488 if (hlinfo->mouse_face_hidden) 4478 if (hlinfo->mouse_face_hidden)
4489 { 4479 {
@@ -4559,11 +4549,8 @@ w32_read_socket (struct terminal *terminal,
4559 int button; 4549 int button;
4560 int up; 4550 int up;
4561 4551
4562 if (dpyinfo->grabbed && last_mouse_frame 4552 f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
4563 && FRAME_LIVE_P (last_mouse_frame)) 4553 : x_window_to_frame (dpyinfo, msg.msg.hwnd));
4564 f = last_mouse_frame;
4565 else
4566 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4567 4554
4568 if (f) 4555 if (f)
4569 { 4556 {
@@ -4602,7 +4589,7 @@ w32_read_socket (struct terminal *terminal,
4602 else 4589 else
4603 { 4590 {
4604 dpyinfo->grabbed |= (1 << button); 4591 dpyinfo->grabbed |= (1 << button);
4605 last_mouse_frame = f; 4592 dpyinfo->last_mouse_frame = f;
4606 /* Ignore any mouse motion that happened 4593 /* Ignore any mouse motion that happened
4607 before this event; any subsequent mouse-movement 4594 before this event; any subsequent mouse-movement
4608 Emacs events should reflect only motion after 4595 Emacs events should reflect only motion after
@@ -4619,11 +4606,8 @@ w32_read_socket (struct terminal *terminal,
4619 case WM_MOUSEWHEEL: 4606 case WM_MOUSEWHEEL:
4620 case WM_MOUSEHWHEEL: 4607 case WM_MOUSEHWHEEL:
4621 { 4608 {
4622 if (dpyinfo->grabbed && last_mouse_frame 4609 f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
4623 && FRAME_LIVE_P (last_mouse_frame)) 4610 : x_window_to_frame (dpyinfo, msg.msg.hwnd));
4624 f = last_mouse_frame;
4625 else
4626 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4627 4611
4628 if (f) 4612 if (f)
4629 { 4613 {
@@ -4640,7 +4624,7 @@ w32_read_socket (struct terminal *terminal,
4640 ButtonPress. */ 4624 ButtonPress. */
4641 f->mouse_moved = 0; 4625 f->mouse_moved = 0;
4642 } 4626 }
4643 last_mouse_frame = f; 4627 dpyinfo->last_mouse_frame = f;
4644 last_tool_bar_item = -1; 4628 last_tool_bar_item = -1;
4645 } 4629 }
4646 break; 4630 break;
diff --git a/src/w32term.h b/src/w32term.h
index 99253627e64..d29cab35ded 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -182,6 +182,9 @@ struct w32_display_info
182 182
183 /* The frame waiting to be auto-raised in w32_read_socket. */ 183 /* The frame waiting to be auto-raised in w32_read_socket. */
184 struct frame *w32_pending_autoraise_frame; 184 struct frame *w32_pending_autoraise_frame;
185
186 /* The frame where the mouse was last time we reported a mouse event. */
187 struct frame *last_mouse_frame;
185}; 188};
186 189
187/* This is a chain of structures for all the displays currently in use. */ 190/* This is a chain of structures for all the displays currently in use. */
diff --git a/src/xdisp.c b/src/xdisp.c
index b07aad51bc9..c4f7b205119 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -11454,10 +11454,6 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run)
11454 11454
11455#ifdef HAVE_WINDOW_SYSTEM 11455#ifdef HAVE_WINDOW_SYSTEM
11456 11456
11457/* Where the mouse was last time we reported a mouse event. */
11458
11459struct frame *last_mouse_frame;
11460
11461/* Tool-bar item index of the item on which a mouse button was pressed 11457/* Tool-bar item index of the item on which a mouse button was pressed
11462 or -1. */ 11458 or -1. */
11463 11459
@@ -12320,9 +12316,9 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
12320 clear_mouse_face (hlinfo); 12316 clear_mouse_face (hlinfo);
12321 12317
12322 /* Mouse is down, but on different tool-bar item? */ 12318 /* Mouse is down, but on different tool-bar item? */
12323 mouse_down_p = (dpyinfo->grabbed 12319 mouse_down_p = (x_mouse_grabbed (dpyinfo)
12324 && f == last_mouse_frame 12320 && f == dpyinfo->last_mouse_frame);
12325 && FRAME_LIVE_P (f)); 12321
12326 if (mouse_down_p 12322 if (mouse_down_p
12327 && last_tool_bar_item != prop_idx) 12323 && last_tool_bar_item != prop_idx)
12328 return; 12324 return;
diff --git a/src/xterm.c b/src/xterm.c
index 08a360fd52c..7d8c40b8cf0 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3945,6 +3945,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
3945 Time *timestamp) 3945 Time *timestamp)
3946{ 3946{
3947 struct frame *f1; 3947 struct frame *f1;
3948 struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
3948 3949
3949 block_input (); 3950 block_input ();
3950 3951
@@ -4004,22 +4005,24 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
4004 4005
4005 x_catch_errors (FRAME_X_DISPLAY (*fp)); 4006 x_catch_errors (FRAME_X_DISPLAY (*fp));
4006 4007
4007 if (FRAME_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame 4008 if (x_mouse_grabbed (dpyinfo))
4008 && FRAME_LIVE_P (last_mouse_frame))
4009 { 4009 {
4010 /* If mouse was grabbed on a frame, give coords for that frame 4010 /* If mouse was grabbed on a frame, give coords for that frame
4011 even if the mouse is now outside it. */ 4011 even if the mouse is now outside it. */
4012 XTranslateCoordinates (FRAME_X_DISPLAY (*fp), 4012 XTranslateCoordinates (FRAME_X_DISPLAY (*fp),
4013 4013
4014 /* From-window, to-window. */ 4014 /* From-window. */
4015 root, FRAME_X_WINDOW (last_mouse_frame), 4015 root,
4016
4017 /* To-window. */
4018 FRAME_X_WINDOW (dpyinfo->last_mouse_frame),
4016 4019
4017 /* From-position, to-position. */ 4020 /* From-position, to-position. */
4018 root_x, root_y, &win_x, &win_y, 4021 root_x, root_y, &win_x, &win_y,
4019 4022
4020 /* Child of win. */ 4023 /* Child of win. */
4021 &child); 4024 &child);
4022 f1 = last_mouse_frame; 4025 f1 = dpyinfo->last_mouse_frame;
4023 } 4026 }
4024 else 4027 else
4025 { 4028 {
@@ -4043,7 +4046,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
4043 want the edit window. For non-Gtk+ the innermost 4046 want the edit window. For non-Gtk+ the innermost
4044 window is the edit window. For Gtk+ it might not 4047 window is the edit window. For Gtk+ it might not
4045 be. It might be the tool bar for example. */ 4048 be. It might be the tool bar for example. */
4046 if (x_window_to_frame (FRAME_DISPLAY_INFO (*fp), win)) 4049 if (x_window_to_frame (dpyinfo, win))
4047 break; 4050 break;
4048#endif 4051#endif
4049 win = child; 4052 win = child;
@@ -4065,10 +4068,10 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
4065#ifdef USE_GTK 4068#ifdef USE_GTK
4066 /* We don't wan't to know the innermost window. We 4069 /* We don't wan't to know the innermost window. We
4067 want the edit window. */ 4070 want the edit window. */
4068 f1 = x_window_to_frame (FRAME_DISPLAY_INFO (*fp), win); 4071 f1 = x_window_to_frame (dpyinfo, win);
4069#else 4072#else
4070 /* Is win one of our frames? */ 4073 /* Is win one of our frames? */
4071 f1 = x_any_window_to_frame (FRAME_DISPLAY_INFO (*fp), win); 4074 f1 = x_any_window_to_frame (dpyinfo, win);
4072#endif 4075#endif
4073 4076
4074#ifdef USE_X_TOOLKIT 4077#ifdef USE_X_TOOLKIT
@@ -6704,11 +6707,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
6704 previous_help_echo_string = help_echo_string; 6707 previous_help_echo_string = help_echo_string;
6705 help_echo_string = Qnil; 6708 help_echo_string = Qnil;
6706 6709
6707 if (dpyinfo->grabbed && last_mouse_frame 6710 f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
6708 && FRAME_LIVE_P (last_mouse_frame)) 6711 : x_window_to_frame (dpyinfo, event->xmotion.window));
6709 f = last_mouse_frame;
6710 else
6711 f = x_window_to_frame (dpyinfo, event->xmotion.window);
6712 6712
6713 if (hlinfo->mouse_face_hidden) 6713 if (hlinfo->mouse_face_hidden)
6714 { 6714 {
@@ -6845,12 +6845,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
6845 last_mouse_glyph_frame = 0; 6845 last_mouse_glyph_frame = 0;
6846 dpyinfo->last_user_time = event->xbutton.time; 6846 dpyinfo->last_user_time = event->xbutton.time;
6847 6847
6848 if (dpyinfo->grabbed 6848 f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
6849 && last_mouse_frame 6849 : x_window_to_frame (dpyinfo, event->xbutton.window));
6850 && FRAME_LIVE_P (last_mouse_frame))
6851 f = last_mouse_frame;
6852 else
6853 f = x_window_to_frame (dpyinfo, event->xbutton.window);
6854 6850
6855#ifdef USE_GTK 6851#ifdef USE_GTK
6856 if (f && xg_event_is_for_scrollbar (f, event)) 6852 if (f && xg_event_is_for_scrollbar (f, event))
@@ -6923,7 +6919,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
6923 if (event->type == ButtonPress) 6919 if (event->type == ButtonPress)
6924 { 6920 {
6925 dpyinfo->grabbed |= (1 << event->xbutton.button); 6921 dpyinfo->grabbed |= (1 << event->xbutton.button);
6926 last_mouse_frame = f; 6922 dpyinfo->last_mouse_frame = f;
6927 6923
6928 if (!tool_bar_p) 6924 if (!tool_bar_p)
6929 last_tool_bar_item = -1; 6925 last_tool_bar_item = -1;
diff --git a/src/xterm.h b/src/xterm.h
index e1556de36b9..f1bfc883a64 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -305,6 +305,9 @@ struct x_display_info
305 /* The frame waiting to be auto-raised in XTread_socket. */ 305 /* The frame waiting to be auto-raised in XTread_socket. */
306 struct frame *x_pending_autoraise_frame; 306 struct frame *x_pending_autoraise_frame;
307 307
308 /* The frame where the mouse was last time we reported a mouse event. */
309 struct frame *last_mouse_frame;
310
308 /* Time of last user interaction as returned in X events on this display. */ 311 /* Time of last user interaction as returned in X events on this display. */
309 Time last_user_time; 312 Time last_user_time;
310 313