emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 45011b77f4: Fix various bugs with mouse dragging on Haiku


From: Po Lu
Subject: master 45011b77f4: Fix various bugs with mouse dragging on Haiku
Date: Sun, 3 Apr 2022 09:38:51 -0400 (EDT)

branch: master
commit 45011b77f42ad87844e757c218a9d4283348d410
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix various bugs with mouse dragging on Haiku
    
    * src/haikuterm.c (haiku_mouse_position): Rewrite so that
    different track-mouse types can be handled more consistently.
---
 src/haikuterm.c | 50 ++++++++++++++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/src/haikuterm.c b/src/haikuterm.c
index 374d066787..91e985e196 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -2568,19 +2568,25 @@ haiku_scroll_run (struct window *w, struct run *run)
 }
 
 /* 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)
@@ -2593,13 +2599,10 @@ haiku_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
       && !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)))
@@ -2608,26 +2611,37 @@ haiku_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
          !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);
        }
     }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]