}
/* Haiku doesn't provide any way to get the frame actually underneath
- the pointer, so we typically return dpyinfo->last_mouse_frame, and
- refrain from returning anything if that doesn't exist. */
+ the pointer, so we typically return dpyinfo->last_mouse_frame if
+ the display is grabbed and `track-mouse' is not `dropping' or
+ `drag-source'; failing that, we return the selected frame, and
+ finally a random window system frame (as long as `track-mouse' is
+ not `drag-source') if that didn't work either. */
static void
haiku_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y,
Time *timestamp)
{
Lisp_Object frame, tail;
- struct frame *f1 = NULL;
+ struct frame *f1;
+ int screen_x, screen_y;
+ void *view;
if (!fp)
return;
+ f1 = NULL;
block_input ();
FOR_EACH_FRAME (tail, frame)
&& !EQ (track_mouse, Qdropping)
&& !EQ (track_mouse, Qdrag_source))
f1 = x_display_list->last_mouse_frame;
+ else
+ f1 = x_display_list->last_mouse_motion_frame;
- if (!f1 || FRAME_TOOLTIP_P (f1))
- f1 = ((EQ (track_mouse, Qdropping) && gui_mouse_grabbed (x_display_list))
- ? x_display_list->last_mouse_frame
- : NULL);
-
- if (!f1 && insist > 0)
+ if (!f1 && FRAME_HAIKU_P (SELECTED_FRAME ()))
f1 = SELECTED_FRAME ();
if (!f1 || (!FRAME_HAIKU_P (f1) && (insist > 0)))
!FRAME_TOOLTIP_P (XFRAME (frame)))
f1 = XFRAME (frame);
- if (FRAME_TOOLTIP_P (f1))
+ if (f1 && FRAME_TOOLTIP_P (f1))
f1 = NULL;
if (f1 && FRAME_HAIKU_P (f1))
{
- int sx, sy;
- void *view = FRAME_HAIKU_VIEW (f1);
+ view = FRAME_HAIKU_VIEW (f1);
+
if (view)
{
- BView_get_mouse (view, &sx, &sy);
-
- remember_mouse_glyph (f1, sx, sy, &x_display_list->last_mouse_glyph);
+ BView_get_mouse (view, &screen_x, &screen_y);
+ remember_mouse_glyph (f1, screen_x, screen_y,
+ &x_display_list->last_mouse_glyph);
x_display_list->last_mouse_glyph_frame = f1;
*bar_window = Qnil;
*part = scroll_bar_above_handle;
- *fp = f1;
+
+ /* If track-mouse is `drag-source' and the mouse pointer is
+ certain to not be actually under the chosen frame, return
+ NULL in FP to at least try being consistent with X. */
+ if (EQ (track_mouse, Qdrag_source)
+ && (screen_x < 0 || screen_y < 0
+ || screen_x >= FRAME_PIXEL_WIDTH (f1)
+ || screen_y >= FRAME_PIXEL_HEIGHT (f1)))
+ *fp = NULL;
+ else
+ *fp = f1;
+
*timestamp = x_display_list->last_mouse_movement_time;
- XSETINT (*x, sx);
- XSETINT (*y, sy);
+ XSETINT (*x, screen_x);
+ XSETINT (*y, screen_y);
}
}