* 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.
+2013-09-18 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * 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.
+
2013-09-17 Dmitry Antipov <dmantipov@yandex.ru>
* w32term.c (w32_read_socket): Avoid temporary
extern Lisp_Object help_echo_string, help_echo_window;
extern Lisp_Object help_echo_object, previous_help_echo_string;
extern ptrdiff_t help_echo_pos;
-extern struct frame *last_mouse_frame;
extern int last_tool_bar_item;
extern void reseat_at_previous_visible_line_start (struct it *);
extern Lisp_Object lookup_glyphless_char_display (int, struct it *);
RES_TYPE_BOOLEAN_NUMBER
};
+extern bool x_mouse_grabbed (Display_Info *);
extern Display_Info *check_x_display_info (Lisp_Object);
extern Lisp_Object x_get_arg (Display_Info *, Lisp_Object,
Lisp_Object, const char *, const char *class,
return;
}
-\f
+/* Non-zero if mouse is grabbed on DPYINFO
+ and we know the frame where it is. */
+
+bool x_mouse_grabbed (Display_Info *dpyinfo)
+{
+ return (dpyinfo->grabbed
+ && dpyinfo->last_mouse_frame
+ && FRAME_LIVE_P (dpyinfo->last_mouse_frame));
+}
+
/* Subroutines of creating an X frame. */
/* Make sure that Vx_resource_name is set to a reasonable value.
struct frame *x_highlight_frame;
struct frame *x_focus_frame;
+
+ /* The frame where the mouse was last time we reported a mouse event. */
+ struct frame *last_mouse_frame;
};
/* This is a chain of structures for all the NS displays currently in use. */
XFRAME (frame)->mouse_moved = 0;
last_mouse_scroll_bar = nil;
- if (last_mouse_frame && FRAME_LIVE_P (last_mouse_frame))
- f = last_mouse_frame;
+ if (dpyinfo->last_mouse_frame
+ && FRAME_LIVE_P (dpyinfo->last_mouse_frame))
+ f = dpyinfo->last_mouse_frame;
else
f = dpyinfo->x_focus_frame ? dpyinfo->x_focus_frame
: SELECTED_FRAME ();
/* This is what happens when the user presses a mouse button. */
- (void)mouseDown: (NSEvent *)theEvent
{
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil];
NSTRACE (mouseDown);
if (!emacs_event)
return;
- last_mouse_frame = emacsframe;
+ dpyinfo->last_mouse_frame = emacsframe;
/* appears to be needed to prevent spurious movement events generated on
button clicks */
- last_mouse_frame->mouse_moved = 0;
+ emacsframe->mouse_moved = 0;
if ([theEvent type] == NSScrollWheel)
{
unsigned long *time)
{
struct frame *f1;
+ struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
block_input ();
/* Now we have a position on the root; find the innermost window
containing the pointer. */
{
- if (FRAME_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame
- && FRAME_LIVE_P (last_mouse_frame))
- {
- /* If mouse was grabbed on a frame, give coords for that frame
- even if the mouse is now outside it. */
- f1 = last_mouse_frame;
- }
- else
- {
- /* Is window under mouse one of our frames? */
- f1 = x_any_window_to_frame (FRAME_DISPLAY_INFO (*fp),
- WindowFromPoint (pt));
- }
+ /* If mouse was grabbed on a frame, give coords for that
+ frame even if the mouse is now outside it. Otherwise
+ check for window under mouse on one of our frames. */
+ f1 = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+ : x_any_window_to_frame (dpyinfo, WindowFromPoint (pt)));
/* If not, is it one of our scroll bars? */
if (! f1)
previous_help_echo_string = help_echo_string;
help_echo_string = Qnil;
- if (dpyinfo->grabbed && last_mouse_frame
- && FRAME_LIVE_P (last_mouse_frame))
- f = last_mouse_frame;
- else
- f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+ f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+ : x_window_to_frame (dpyinfo, msg.msg.hwnd));
if (hlinfo->mouse_face_hidden)
{
int button;
int up;
- if (dpyinfo->grabbed && last_mouse_frame
- && FRAME_LIVE_P (last_mouse_frame))
- f = last_mouse_frame;
- else
- f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+ f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+ : x_window_to_frame (dpyinfo, msg.msg.hwnd));
if (f)
{
else
{
dpyinfo->grabbed |= (1 << button);
- last_mouse_frame = f;
+ dpyinfo->last_mouse_frame = f;
/* Ignore any mouse motion that happened
before this event; any subsequent mouse-movement
Emacs events should reflect only motion after
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
{
- if (dpyinfo->grabbed && last_mouse_frame
- && FRAME_LIVE_P (last_mouse_frame))
- f = last_mouse_frame;
- else
- f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+ f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+ : x_window_to_frame (dpyinfo, msg.msg.hwnd));
if (f)
{
ButtonPress. */
f->mouse_moved = 0;
}
- last_mouse_frame = f;
+ dpyinfo->last_mouse_frame = f;
last_tool_bar_item = -1;
}
break;
/* The frame waiting to be auto-raised in w32_read_socket. */
struct frame *w32_pending_autoraise_frame;
+
+ /* The frame where the mouse was last time we reported a mouse event. */
+ struct frame *last_mouse_frame;
};
/* This is a chain of structures for all the displays currently in use. */
#ifdef HAVE_WINDOW_SYSTEM
-/* Where the mouse was last time we reported a mouse event. */
-
-struct frame *last_mouse_frame;
-
/* Tool-bar item index of the item on which a mouse button was pressed
or -1. */
clear_mouse_face (hlinfo);
/* Mouse is down, but on different tool-bar item? */
- mouse_down_p = (dpyinfo->grabbed
- && f == last_mouse_frame
- && FRAME_LIVE_P (f));
+ mouse_down_p = (x_mouse_grabbed (dpyinfo)
+ && f == dpyinfo->last_mouse_frame);
+
if (mouse_down_p
&& last_tool_bar_item != prop_idx)
return;
Time *timestamp)
{
struct frame *f1;
+ struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
block_input ();
x_catch_errors (FRAME_X_DISPLAY (*fp));
- if (FRAME_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame
- && FRAME_LIVE_P (last_mouse_frame))
+ if (x_mouse_grabbed (dpyinfo))
{
/* If mouse was grabbed on a frame, give coords for that frame
even if the mouse is now outside it. */
XTranslateCoordinates (FRAME_X_DISPLAY (*fp),
- /* From-window, to-window. */
- root, FRAME_X_WINDOW (last_mouse_frame),
+ /* From-window. */
+ root,
+
+ /* To-window. */
+ FRAME_X_WINDOW (dpyinfo->last_mouse_frame),
/* From-position, to-position. */
root_x, root_y, &win_x, &win_y,
/* Child of win. */
&child);
- f1 = last_mouse_frame;
+ f1 = dpyinfo->last_mouse_frame;
}
else
{
want the edit window. For non-Gtk+ the innermost
window is the edit window. For Gtk+ it might not
be. It might be the tool bar for example. */
- if (x_window_to_frame (FRAME_DISPLAY_INFO (*fp), win))
+ if (x_window_to_frame (dpyinfo, win))
break;
#endif
win = child;
#ifdef USE_GTK
/* We don't wan't to know the innermost window. We
want the edit window. */
- f1 = x_window_to_frame (FRAME_DISPLAY_INFO (*fp), win);
+ f1 = x_window_to_frame (dpyinfo, win);
#else
/* Is win one of our frames? */
- f1 = x_any_window_to_frame (FRAME_DISPLAY_INFO (*fp), win);
+ f1 = x_any_window_to_frame (dpyinfo, win);
#endif
#ifdef USE_X_TOOLKIT
previous_help_echo_string = help_echo_string;
help_echo_string = Qnil;
- if (dpyinfo->grabbed && last_mouse_frame
- && FRAME_LIVE_P (last_mouse_frame))
- f = last_mouse_frame;
- else
- f = x_window_to_frame (dpyinfo, event->xmotion.window);
+ f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+ : x_window_to_frame (dpyinfo, event->xmotion.window));
if (hlinfo->mouse_face_hidden)
{
last_mouse_glyph_frame = 0;
dpyinfo->last_user_time = event->xbutton.time;
- if (dpyinfo->grabbed
- && last_mouse_frame
- && FRAME_LIVE_P (last_mouse_frame))
- f = last_mouse_frame;
- else
- f = x_window_to_frame (dpyinfo, event->xbutton.window);
+ f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+ : x_window_to_frame (dpyinfo, event->xbutton.window));
#ifdef USE_GTK
if (f && xg_event_is_for_scrollbar (f, event))
if (event->type == ButtonPress)
{
dpyinfo->grabbed |= (1 << event->xbutton.button);
- last_mouse_frame = f;
+ dpyinfo->last_mouse_frame = f;
if (!tool_bar_p)
last_tool_bar_item = -1;
/* The frame waiting to be auto-raised in XTread_socket. */
struct frame *x_pending_autoraise_frame;
+ /* The frame where the mouse was last time we reported a mouse event. */
+ struct frame *last_mouse_frame;
+
/* Time of last user interaction as returned in X events on this display. */
Time last_user_time;