to factor out common code used in W32 and X ports.
* dispextern.h (x_redo_mouse_highlight): Add prototype.
* xterm.h (struct x_display_info):
* w32term.h (struct w32_display_info):
* nsterm.h (struct ns_display_info): New members
last_mouse_motion_frame, last_mouse_motion_x and
last_mouse_motion_y, going to replace static variables below.
* xterm.c (last_mouse_motion_event, last_mouse_motion_frame)
(redo_mouse_highlight): Remove.
(note_mouse_movement, syms_of_xterm): Adjust user.
(handle_one_xevent): Likewise. Use x_redo_mouse_highlight.
* w32term.c (last_mouse_motion_event, last_mouse_motion_frame)
(redo_mouse_highlight): Remove.
(note_mouse_movement, syms_of_w32term): Adjust user.
(w32_read_socket): Likewise. Use x_redo_mouse_highlight.
* nsterm.m (last_mouse_motion_position, last_mouse_motion_frame):
Remove.
(note_mouse_movement, mouseMoved, syms_of_nsterm):
* nsfns.m (compute_tip_xy): Adjust user.
+2013-09-18 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * frame.c (x_redo_mouse_highlight): New function
+ to factor out common code used in W32 and X ports.
+ * dispextern.h (x_redo_mouse_highlight): Add prototype.
+ * xterm.h (struct x_display_info):
+ * w32term.h (struct w32_display_info):
+ * nsterm.h (struct ns_display_info): New members
+ last_mouse_motion_frame, last_mouse_motion_x and
+ last_mouse_motion_y, going to replace static variables below.
+ * xterm.c (last_mouse_motion_event, last_mouse_motion_frame)
+ (redo_mouse_highlight): Remove.
+ (note_mouse_movement, syms_of_xterm): Adjust user.
+ (handle_one_xevent): Likewise. Use x_redo_mouse_highlight.
+ * w32term.c (last_mouse_motion_event, last_mouse_motion_frame)
+ (redo_mouse_highlight): Remove.
+ (note_mouse_movement, syms_of_w32term): Adjust user.
+ (w32_read_socket): Likewise. Use x_redo_mouse_highlight.
+ * nsterm.m (last_mouse_motion_position, last_mouse_motion_frame):
+ Remove.
+ (note_mouse_movement, mouseMoved, syms_of_nsterm):
+ * nsfns.m (compute_tip_xy): Adjust user.
+
2013-09-18 Dmitry Antipov <dmantipov@yandex.ru>
* frame.c (x_mouse_grabbed): New function.
enum resource_types);
extern char *x_get_string_resource (XrmDatabase, const char *,
const char *);
+extern void x_redo_mouse_highlight (Display_Info *);
#endif /* HAVE_WINDOW_SYSTEM */
&& FRAME_LIVE_P (dpyinfo->last_mouse_frame));
}
+/* Re-highlight something with mouse-face properties
+ on DPYINFO using saved frame and mouse position. */
+
+void
+x_redo_mouse_highlight (Display_Info *dpyinfo)
+{
+ if (dpyinfo->last_mouse_motion_frame
+ && FRAME_LIVE_P (dpyinfo->last_mouse_motion_frame))
+ note_mouse_highlight (dpyinfo->last_mouse_motion_frame,
+ dpyinfo->last_mouse_motion_x,
+ dpyinfo->last_mouse_motion_y);
+}
+
/* Subroutines of creating an X frame. */
/* Make sure that Vx_resource_name is set to a reasonable value.
{
Lisp_Object left, top;
EmacsView *view = FRAME_NS_VIEW (f);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
NSPoint pt;
/* Start with user-specified or mouse position. */
if (!INTEGERP (left) || !INTEGERP (top))
{
- pt = last_mouse_motion_position;
+ pt.x = dpyinfo->last_mouse_motion_x;
+ pt.y = dpyinfo->last_mouse_motion_y;
/* Convert to screen coordinates */
pt = [view convertPoint: pt toView: nil];
pt = [[view window] convertBaseToScreen: pt];
/* The frame where the mouse was last time we reported a mouse event. */
struct frame *last_mouse_frame;
+
+ /* The frame where the mouse was last time we reported a mouse motion. */
+ struct frame *last_mouse_motion_frame;
+
+ /* Position where the mouse was last time we reported a motion.
+ This is a position on last_mouse_motion_frame. */
+ int last_mouse_motion_x;
+ int last_mouse_motion_y;
};
/* This is a chain of structures for all the NS displays currently in use. */
sigset_t const *sigmask);
extern unsigned long ns_get_rgb_color (struct frame *f,
float r, float g, float b, float a);
-extern NSPoint last_mouse_motion_position;
/* From nsterm.m, needed in nsfont.m. */
#ifdef __OBJC__
long context_menu_value = 0;
/* display update */
-NSPoint last_mouse_motion_position;
static NSRect last_mouse_glyph;
static Time last_mouse_movement_time = 0;
-static Lisp_Object last_mouse_motion_frame;
static EmacsScroller *last_mouse_scroll_bar = nil;
static struct frame *ns_updating_frame;
static NSView *focus_view = NULL;
{
// NSTRACE (note_mouse_movement);
- XSETFRAME (last_mouse_motion_frame, frame);
+ FRAME_DISPLAY_INFO (frame)->last_mouse_motion_frame = frame;
/* Note, this doesn't get called for enter/leave, since we don't have a
position. Those are taken care of in the corresponding NSView methods. */
- (void)mouseMoved: (NSEvent *)e
{
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (emacsframe);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
Lisp_Object frame;
+ NSPoint pt;
// NSTRACE (mouseMoved);
last_mouse_movement_time = EV_TIMESTAMP (e);
- last_mouse_motion_position
- = [self convertPoint: [e locationInWindow] fromView: nil];
+ pt = [self convertPoint: [e locationInWindow] fromView: nil];
+ dpyinfo->last_mouse_motion_x = pt.x;
+ dpyinfo->last_mouse_motion_y = pt.y;
/* update any mouse face */
if (hlinfo->mouse_face_hidden)
{
NSTRACE (mouse_autoselect_window);
static Lisp_Object last_mouse_window;
- Lisp_Object window = window_from_coordinates
- (emacsframe, last_mouse_motion_position.x,
- last_mouse_motion_position.y, 0, 0);
+ Lisp_Object window
+ = window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0);
if (WINDOWP (window)
&& !EQ (window, last_mouse_window)
last_mouse_window = window;
}
- if (!note_mouse_movement (emacsframe, last_mouse_motion_position.x,
- last_mouse_motion_position.y))
+ if (!note_mouse_movement (emacsframe, pt.x, pt.y))
help_echo_string = previous_help_echo_string;
XSETFRAME (frame, emacsframe);
staticpro (&ns_display_name_list);
ns_display_name_list = Qnil;
- staticpro (&last_mouse_motion_frame);
- last_mouse_motion_frame = Qnil;
-
DEFVAR_LISP ("ns-auto-hide-menu-bar", ns_auto_hide_menu_bar,
doc: /* Non-nil means that the menu bar is hidden, but appears when the mouse is near.
Only works on OSX 10.6 or later. */);
the mainstream emacs code by setting mouse_moved. If not, ask for
another motion event, so we can check again the next time it moves. */
-static MSG last_mouse_motion_event;
-static Lisp_Object last_mouse_motion_frame;
-
static int
note_mouse_movement (struct frame *frame, MSG *msg)
{
+ struct w32_display_info *dpyinfo;
int mouse_x = LOWORD (msg->lParam);
int mouse_y = HIWORD (msg->lParam);
- last_mouse_movement_time = msg->time;
- memcpy (&last_mouse_motion_event, msg, sizeof (last_mouse_motion_event));
- XSETFRAME (last_mouse_motion_frame, frame);
-
- if (!FRAME_X_OUTPUT (frame))
+ if (!FRAME_W32_OUTPUT (frame))
return 0;
+ dpyinfo = FRAME_DISPLAY_INFO (frame);
+ last_mouse_movement_time = msg->time;
+ dpyinfo->last_mouse_motion_frame = frame;
+ dpyinfo->last_mouse_motion_x = mouse_x;
+ dpyinfo->last_mouse_motion_y = mouse_y;
+
if (msg->hwnd != FRAME_W32_WINDOW (frame))
{
frame->mouse_moved = 1;
unsigned long *);
static void x_check_fullscreen (struct frame *);
-static void
-redo_mouse_highlight (void)
-{
- if (!NILP (last_mouse_motion_frame)
- && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame)))
- note_mouse_highlight (XFRAME (last_mouse_motion_frame),
- LOWORD (last_mouse_motion_event.lParam),
- HIWORD (last_mouse_motion_event.lParam));
-}
-
static void
w32_define_cursor (Window window, Cursor cursor)
{
if (!msg.msg.wParam && msg.msg.hwnd == tip_window)
{
tip_window = NULL;
- redo_mouse_highlight ();
+ x_redo_mouse_highlight (dpyinfo);
}
/* If window has been obscured or exposed by another window
With MS Windows or Nextstep, the value is t. */);
Vx_toolkit_scroll_bars = Qt;
- staticpro (&last_mouse_motion_frame);
- last_mouse_motion_frame = Qnil;
-
/* Tell Emacs about this window system. */
Fprovide (Qw32, Qnil);
}
/* The frame where the mouse was last time we reported a mouse event. */
struct frame *last_mouse_frame;
+
+ /* The frame where the mouse was last time we reported a mouse motion. */
+ struct frame *last_mouse_motion_frame;
+
+ /* Position where the mouse was last time we reported a motion.
+ This is a position on last_mouse_motion_frame. */
+ int last_mouse_motion_x;
+ int last_mouse_motion_y;
};
/* This is a chain of structures for all the displays currently in use. */
the mainstream emacs code by setting mouse_moved. If not, ask for
another motion event, so we can check again the next time it moves. */
-static XMotionEvent last_mouse_motion_event;
-static Lisp_Object last_mouse_motion_frame;
-
static int
note_mouse_movement (struct frame *frame, const XMotionEvent *event)
{
- last_mouse_movement_time = event->time;
- last_mouse_motion_event = *event;
- XSETFRAME (last_mouse_motion_frame, frame);
+ struct x_display_info *dpyinfo;
if (!FRAME_X_OUTPUT (frame))
return 0;
+ dpyinfo = FRAME_DISPLAY_INFO (frame);
+ last_mouse_movement_time = event->time;
+ dpyinfo->last_mouse_motion_frame = frame;
+ dpyinfo->last_mouse_motion_x = event->x;
+ dpyinfo->last_mouse_motion_y = event->y;
+
if (event->window != FRAME_X_WINDOW (frame))
{
frame->mouse_moved = 1;
return 0;
}
-\f
-/************************************************************************
- Mouse Face
- ************************************************************************/
-
-static void
-redo_mouse_highlight (void)
-{
- if (!NILP (last_mouse_motion_frame)
- && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame)))
- note_mouse_highlight (XFRAME (last_mouse_motion_frame),
- last_mouse_motion_event.x,
- last_mouse_motion_event.y);
-}
-
-
-
/* Return the current position of the mouse.
*FP should be a frame which indicates which display to ask about.
if (event->xunmap.window == tip_window)
{
tip_window = 0;
- redo_mouse_highlight ();
+ x_redo_mouse_highlight (dpyinfo);
}
f = x_top_window_to_frame (dpyinfo, event->xunmap.window);
Vx_toolkit_scroll_bars = Qnil;
#endif
- staticpro (&last_mouse_motion_frame);
- last_mouse_motion_frame = Qnil;
-
Qmodifier_value = intern_c_string ("modifier-value");
Qalt = intern_c_string ("alt");
Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
/* The frame where the mouse was last time we reported a mouse event. */
struct frame *last_mouse_frame;
+ /* The frame where the mouse was last time we reported a mouse motion. */
+ struct frame *last_mouse_motion_frame;
+
/* Time of last user interaction as returned in X events on this display. */
Time last_user_time;
+ /* Position where the mouse was last time we reported a motion.
+ This is a position on last_mouse_motion_frame. */
+ int last_mouse_motion_x;
+ int last_mouse_motion_y;
+
/* The gray pixmap. */
Pixmap gray;