unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
@ 2023-07-03 15:59 Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-07-04 16:14 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-07-03 15:59 UTC (permalink / raw)
  To: 64440

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]


Hi,

Here is a set of patches to have highlighting on the menu bar items (for
the non toolkit build only).

The first patch is a bit "intrusive" because it adds a menu_bar_p
selector to 'window_from_coordinates'.  Maybe it is not needed and I
could drop this selector and make 'window_from_coordinates' return
f->menu_bar_window when the mouse is on it.

The second patch is the real meat and is modeled after other
"note_*_highlight" functions.  It seems to work as expected but now I
think I need to define another face (I'm using MENU_FACE_ID now so it is
not really visual) or maybe we should be able to propertize the menu bar
entries.  WDYT?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Possibility-to-get-enter-event-from-menu_bar-window.patch --]
[-- Type: text/x-patch, Size: 12751 bytes --]

From ceb818090de83fe216af3e9b6bcc198eba9188e3 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Sat, 1 Jul 2023 21:19:06 +0200
Subject: [PATCH 1/2] Possibility to get enter event from menu_bar window

---
 src/haikuterm.c |  8 ++++----
 src/keyboard.c  |  2 +-
 src/msdos.c     |  2 +-
 src/pgtkterm.c  |  4 ++--
 src/w32inevt.c  |  2 +-
 src/w32term.c   |  8 ++++----
 src/window.c    | 20 ++++++++++++++++++--
 src/window.h    |  2 +-
 src/xdisp.c     |  4 ++--
 src/xterm.c     | 17 +++++++++--------
 10 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/src/haikuterm.c b/src/haikuterm.c
index ed28a806ff2..0af9aa746a9 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -3472,7 +3472,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		if (!NILP (Vmouse_autoselect_window))
 		  {
 		    static Lisp_Object last_mouse_window;
-		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0);
+		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0, 0);
 
 		    if (WINDOWP (window)
 			&& !EQ (window, last_mouse_window)
@@ -3555,7 +3555,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tab_bar_p = EQ (window, f->tab_bar_window);
 
 		if (tab_bar_p)
@@ -3573,7 +3573,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (type != BUTTON_UP
 				  || f->last_tool_bar_item != -1));
@@ -3834,7 +3834,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 
 	    BView_get_mouse (FRAME_HAIKU_VIEW (f), &x, &y);
 
-	    wheel_window = window_from_coordinates (f, x, y, 0, false, false);
+	    wheel_window = window_from_coordinates (f, x, y, 0, false, false, false);
 
 	    if (NILP (wheel_window))
 	      {
diff --git a/src/keyboard.c b/src/keyboard.c
index b61b1766856..4cc0c70b11e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5414,7 +5414,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
   int xret = 0, yret = 0;
   /* The window or frame under frame pixel coordinates (x,y)  */
   Lisp_Object window_or_frame = f
-    ? window_from_coordinates (f, mx, my, &part, true, true)
+    ? window_from_coordinates (f, mx, my, &part, true, true, true)
     : Qnil;
 #ifdef HAVE_WINDOW_SYSTEM
   bool tool_bar_p = false;
diff --git a/src/msdos.c b/src/msdos.c
index 75a39045cee..6e779ffb2e2 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2655,7 +2655,7 @@ dos_rawgetc (void)
 	      static Lisp_Object last_mouse_window;
 
 	      mouse_window = window_from_coordinates
-		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0);
+		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0, 0);
 	      /* A window will be selected only when it is not
 		 selected now, and the last mouse movement event was
 		 not in it.  A minibuffer window will be selected iff
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index dc2d6477bb5..788d4a7bdfb 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -5891,7 +5891,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
 	{
 	  static Lisp_Object last_mouse_window;
 	  Lisp_Object window = window_from_coordinates
-	    (f, event->motion.x, event->motion.y, 0, false, false);
+	    (f, event->motion.x, event->motion.y, 0, false, false, false);
 
 	  /* A window will be autoselected only when it is not
 	     selected now and the last mouse movement event was
@@ -6044,7 +6044,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
 	  int x = event->button.x;
 	  int y = event->button.y;
 
-	  window = window_from_coordinates (f, x, y, 0, true, true);
+	  window = window_from_coordinates (f, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, f->tab_bar_window);
 
 	  if (tab_bar_p)
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 29717954cfd..630a9f4e5fb 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -496,7 +496,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
 	    if (!NILP (Vmouse_autoselect_window))
 	      {
 		Lisp_Object mouse_window = window_from_coordinates (f, mx, my,
-								    0, 0, 0);
+								    0, 0, 0, 0);
 		/* A window will be selected only when it is not
 		   selected now, and the last mouse movement event was
 		   not in it.  A minibuffer window will be selected iff
diff --git a/src/w32term.c b/src/w32term.c
index 57dc6b465e4..9c5a298a645 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3376,7 +3376,7 @@ w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg,
       if (w32_wheel_scroll_lines == UINT_MAX)
 	{
 	  Lisp_Object window = window_from_coordinates (f, p.x, p.y, NULL,
-							false, false);
+							false, false, false);
 	  if (!WINDOWP (window))
 	    {
 	      result->kind = NO_EVENT;
@@ -5335,7 +5335,7 @@ w32_read_socket (struct terminal *terminal,
 		{
 		  static Lisp_Object last_mouse_window;
 		  Lisp_Object window = window_from_coordinates
-		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0);
+		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0, 0);
 
 		  /* Window will be selected only when it is not
 		     selected now and last mouse movement event was
@@ -5407,7 +5407,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tab_bar_window))
                       {
@@ -5435,7 +5435,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tool_bar_window)
 			/* Make sure the tool bar was previously
diff --git a/src/window.c b/src/window.c
index 2a0c62f5d53..af7dcfdd423 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1680,7 +1680,8 @@ check_window_containing (struct window *w, void *user_data)
 
 Lisp_Object
 window_from_coordinates (struct frame *f, int x, int y,
-			 enum window_part *part, bool tab_bar_p, bool tool_bar_p)
+			 enum window_part *part, bool menu_bar_p,
+			 bool tab_bar_p, bool tool_bar_p)
 {
   Lisp_Object window;
   struct check_window_data cw;
@@ -1693,6 +1694,21 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* If not found above, see if it's in the menu bar window, if a menu
+     bar exists.  */
+  if (NILP (window)
+      && menu_bar_p
+      && WINDOWP (f->menu_bar_window)
+      && WINDOW_TOTAL_LINES (XWINDOW (f->menu_bar_window)) > 0
+      && (coordinates_in_window (XWINDOW (f->menu_bar_window), x, y)
+	  != ON_NOTHING))
+    {
+      *part = ON_TEXT;
+      window = f->menu_bar_window;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* If not found above, see if it's in the tab bar window, if a tab
      bar exists.  */
@@ -1746,7 +1762,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
 				  (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
-				  0, false, false);
+				  0, false, false, false);
 }
 
 ptrdiff_t
diff --git a/src/window.h b/src/window.h
index 2f793ebe438..4f4a0a79216 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1092,7 +1092,7 @@ #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)	\
 
 extern Lisp_Object make_window (void);
 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
-                                            enum window_part *, bool, bool);
+                                            enum window_part *, bool, bool, bool);
 extern void resize_frame_windows (struct frame *, int, bool);
 extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
diff --git a/src/xdisp.c b/src/xdisp.c
index 85ece901111..4c02a217cef 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2739,7 +2739,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
       goto virtual_glyph;
     }
   else if (!f->glyphs_initialized_p
-	   || (window = window_from_coordinates (f, gx, gy, &part, false, false),
+	   || (window = window_from_coordinates (f, gx, gy, &part, false, false, false),
 	       NILP (window)))
     {
       width = FRAME_SMALLEST_CHAR_WIDTH (f);
@@ -35124,7 +35124,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
     return;
 
   /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, true, true);
+  window = window_from_coordinates (f, x, y, &part, true, true, true);
 
   /* If displaying active text in another window, clear that.  */
   if (! EQ (window, hlinfo->mouse_face_window)
diff --git a/src/xterm.c b/src/xterm.c
index f84eaeb8cbd..e58e6276aae 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -20925,7 +20925,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  }
 
 		Lisp_Object window = window_from_coordinates
-		  (f, xmotion.x, xmotion.y, 0, false, false);
+		  (f, xmotion.x, xmotion.y, 0, false, false, false);
 
 		/* A window will be autoselected only when it is not
 		   selected now and the last mouse movement event was
@@ -21656,7 +21656,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tab_bar_p = EQ (window, f->tab_bar_window);
 
                 if (tab_bar_p)
@@ -21677,7 +21677,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (event->xbutton.type != ButtonRelease
 				  || f->last_tool_bar_item != -1));
@@ -22398,7 +22398,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			    continue;
 
 			  window = window_from_coordinates (f, real_x, real_y, NULL,
-							    false, false);
+							    false, false, false);
 
 			  if (WINDOWP (window))
 			    scroll_height = XWINDOW (window)->pixel_height;
@@ -22841,7 +22841,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			  || !NILP (focus_follows_mouse)))
 		    {
 		      static Lisp_Object last_mouse_window;
-		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
+		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false,
+								    false);
 
 		      /* A window will be autoselected only when it is not
 			 selected now and the last mouse movement event was
@@ -23419,7 +23420,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      tab_bar_p = EQ (window, f->tab_bar_window);
 
 		      if (tab_bar_p)
@@ -23440,7 +23441,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      /* Ignore button release events if the mouse
 			 wasn't previously pressed on the tool bar.
 			 We do this because otherwise selecting some
@@ -24300,7 +24301,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  int x = xev->event_x;
 		  int y = xev->event_y;
 
-		  window = window_from_coordinates (f, x, y, 0, true, true);
+		  window = window_from_coordinates (f, x, y, 0, true, true, true);
 		  /* Ignore button release events if the mouse
 		     wasn't previously pressed on the tool bar.
 		     We do this because otherwise selecting some
-- 
2.40.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Highlight-on-non-toolkit-menu-bar-items.patch --]
[-- Type: text/x-patch, Size: 4806 bytes --]

From d5ddf8e04d06730917f94cb7d2fcb026c4437788 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Mon, 3 Jul 2023 17:35:06 +0200
Subject: [PATCH 2/2] Highlight on non toolkit menu bar items

* src/xdisp.c (get_menu_bar_item, note_menu_bar_highlight): New
functions to highlight item in the menu-bar.
(note_mouse_highlight): Use it.
---
 src/xdisp.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index 4c02a217cef..25b33e3a8c4 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13859,6 +13859,122 @@ update_menu_bar (struct frame *f, bool save_match_data, bool hooks_run)
   return hooks_run;
 }
 
+/* Get information about the menu-bar item at position X/Y on frame F.
+   Return menu-bar's item char position in H_START/H_END and pixel
+   position in X_START/X_END.  Value is
+
+   -1	if X/Y is not on a menu-bar item
+   0	if X/Y is on the same item that was highlighted before.
+   1	otherwise.  */
+
+static int
+get_menu_bar_item (struct frame *f, int x, int y, int *h_start, int *h_end,
+		   int *x_start, int *x_end, int *vpos)
+{
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+  struct window *w = XWINDOW (f->menu_bar_window);
+  struct glyph_row *row;
+  int dummy;
+  Lisp_Object items;
+  int i;
+
+  /* Find glyph's hpos and vpos under X/Y.  */
+  if (x_y_to_hpos_vpos (w, x, y, h_start, vpos, NULL, NULL, &dummy) == NULL)
+    return -1;
+
+  /* Compute h_start and h_end for this menu bar item.  */
+  items = FRAME_MENU_BAR_ITEMS (f);
+  for (i = 0; i < ASIZE (items); i += 4)
+    {
+      Lisp_Object pos, string;
+      string = AREF (items, i + 1);
+      pos = AREF (items, i + 3);
+      if (NILP (string))
+	return -1;
+      if (*h_start >= XFIXNUM (pos)
+	  && *h_start < XFIXNUM (pos) + SCHARS (string))
+	{
+	  *h_start = XFIXNUM (pos);
+	  *h_end = *h_start + SCHARS (string);
+	  break;
+	}
+    }
+
+  /* Convert to pixels bounds.  */
+  row = MATRIX_ROW (w->current_matrix, *vpos);
+  *x_start = 0;
+  for (i = 0; i < *h_start; ++i)
+    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
+
+  *x_end = *x_start;
+  for (i = *h_start; i < *h_end; ++i)
+    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;
+
+  /* Is mouse on the highlighted item?  */
+  if (EQ (f->menu_bar_window, hlinfo->mouse_face_window)
+      && *vpos >= hlinfo->mouse_face_beg_row
+      && *vpos <= hlinfo->mouse_face_end_row
+      && (*vpos > hlinfo->mouse_face_beg_row
+	  || *h_start >= hlinfo->mouse_face_beg_col)
+      && (*vpos < hlinfo->mouse_face_end_row
+	  || *h_end < hlinfo->mouse_face_end_col
+	  || hlinfo->mouse_face_past_end))
+    return 0;
+
+  return 1;
+}
+
+/* Possibly highlight a menu-bar item on frame F when mouse moves to
+   menu-bar window-relative coordinates X/Y.  Called from
+   note_mouse_highlight.  */
+
+static void
+note_menu_bar_highlight (struct frame *f, int x, int y)
+{
+  Lisp_Object window = f->menu_bar_window;
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+  int h_start, h_end, vpos, x_start, x_end;
+  int rc;
+
+  /* Function note_mouse_highlight is called with negative X/Y
+     values when mouse moves outside of the frame.  */
+  if (x <= 0 || y <= 0)
+    {
+      clear_mouse_face (hlinfo);
+      return;
+    }
+
+  h_start = h_end = 0;
+  rc = get_menu_bar_item (f, x, y, &h_start, &h_end, &x_start, &x_end, &vpos);
+  if (rc < 0)
+    {
+      /* Not on menu-bar item.  */
+      clear_mouse_face (hlinfo);
+      return;
+    }
+  else if (rc == 0)
+    /* On same menu-bar item as before.  */
+    return;
+
+  if (!NILP (Vmouse_highlight))
+    {
+      /* Record this as the current active region.  */
+      hlinfo->mouse_face_beg_col = h_start;
+      hlinfo->mouse_face_beg_row = vpos;
+      hlinfo->mouse_face_beg_x = x_start;
+      hlinfo->mouse_face_past_end = false;
+
+      hlinfo->mouse_face_end_col = h_end;
+      hlinfo->mouse_face_end_row = vpos;
+      hlinfo->mouse_face_end_x = x_end;
+      hlinfo->mouse_face_window = window;
+      hlinfo->mouse_face_face_id = MENU_FACE_ID;
+
+      /* Display it as active.  */
+      show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
+    }
+}
+
 \f
 
 /***********************************************************************
@@ -35223,6 +35339,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* Handle menu-bar window differently since it doesn't display a
+     buffer.  */
+  if (EQ (window, f->menu_bar_window))
+    {
+      note_menu_bar_highlight (f, x, y);
+      return;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* Handle tab-bar window differently since it doesn't display a
      buffer.  */
-- 
2.40.0


[-- Attachment #4: Type: text/plain, Size: 7604 bytes --]




In GNU Emacs 30.0.50 (build 1, x86_64-unknown-openbsd7.3, cairo version
 1.17.8) of 2023-07-03 built on computer
Repository revision: ceb818090de83fe216af3e9b6bcc198eba9188e3
Repository branch: mgi/menu
Windowing system distributor 'The X.Org Foundation', version 11.0.12101006
System Description: OpenBSD computer 7.3 GENERIC.MP#1125 amd64

Configured using:
 'configure --prefix=/home/manuel/emacs --bindir=/home/manuel/bin
 --with-x-toolkit=no --with-toolkit-scroll-bars=no --without-sound
 --without-compress-install CPPFLAGS=-I/usr/local/include
 LDFLAGS=-L/usr/local/lib'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBOTF LIBXML2 MODULES NOTIFY KQUEUE OLDXMENU PDUMPER PNG RSVG
SQLITE3 THREADS TIFF TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Dired by name

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  gnus-dired-mode: t
  display-time-mode: t
  display-battery-mode: t
  server-mode: t
  shell-dirtrack-mode: t
  override-global-mode: t
  repeat-mode: t
  desktop-save-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/manuel/.el/nov hides /home/manuel/.emacs.d/elpa/nov-20230421.1548/nov
/home/manuel/.emacs.d/elpa/ef-themes-1.1.1/theme-loaddefs hides /home/manuel/emacs/share/emacs/30.0.50/lisp/theme-loaddefs

Features:
(shadow sort mail-extr emacsbug whitespace magit-patch misearch
multi-isearch pulse magit-extras face-remap magit-submodule
magit-obsolete magit-blame magit-stash magit-reflog magit-bisect
magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit
magit-sequence magit-notes magit-worktree magit-tag magit-merge
magit-branch magit-reset magit-files magit-refs magit-status magit
magit-repos magit-apply magit-wip magit-log which-func magit-diff
smerge-mode diff git-commit log-edit add-log magit-core magit-autorevert
magit-margin magit-transient magit-process with-editor magit-mode
transient magit-git magit-section magit-utils dash org-agenda
emacs-news-mode org-indent css-mode sgml-mode facemenu imenu vc-cvs
vc-rcs log-view pcvs-util make-mode pascal vc-hg conf-mode org-element
org-persist org-id org-refile avl-tree oc-basic ol-eww eww url-queue
mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect ol-docview
doc-view jka-compr image-mode exif ol-bibtex bibtex ol-bbdb ol-w3m
ol-doi org-link-doi org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-src ob-comint org-pcomplete org-list org-footnote
org-faces org-entities ob-emacs-lisp ob-core ob-eval org-cycle org-table
ol org-fold org-fold-core org-keys oc org-loaddefs org-version
org-compat org-macs view sh-script smie treesit executable gnus-dired
paredit mule-util vc-git diff-mode vc-svn vc vc-dispatcher bug-reference
time battery cus-load exwm-randr xcb-randr exwm-config ido exwm
exwm-input xcb-keysyms xcb-xkb exwm-manage exwm-floating xcb-cursor
xcb-render exwm-layout exwm-workspace exwm-core xcb-ewmh xcb-icccm xcb
xcb-xproto xcb-types xcb-debug server modus-operandi-theme modus-themes
zone speed-type url-http url-auth url-gw nsm compat ytdious mingus
libmpdee reporter edebug debug backtrace detached-init detached
autorevert filenotify transmission color calc-bin calc-ext calc
calc-loaddefs rect calc-macs supercite regi ebdb-message ebdb-gnus
gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig
gnus-sum shr pixel-fill kinsoku url-file svg dom gnus-group gnus-undo
gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo
gnus-spec gnus-int gnus-range message sendmail yank-media puny rfc822
mml mml-sec epa epg rfc6068 epg-config mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums gmm-utils mailheader
gnus-win gnus nnheader gnus-util mail-utils range mm-util mail-prsvr
wid-edit ebdb-mua ebdb-com crm ebdb-format ebdb mailabbrev eieio-opt
speedbar ezimage dframe find-func eieio-base pcase timezone icalendar
visual-basic-mode cl web-mode derived disp-table erlang-start
smart-tabs-mode skeleton cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs slime-asdf grep slime-tramp
tramp rx tramp-loaddefs trampver tramp-integration files-x tramp-compat
xdg shell pcomplete parse-time iso8601 time-date format-spec slime-fancy
slime-indentation slime-cl-indent cl-indent slime-trace-dialog
slime-fontifying-fu slime-package-fu slime-references
slime-compiler-notes-tree advice slime-scratch slime-presentations
bridge slime-macrostep macrostep slime-mdot-fu slime-enclosing-context
slime-fuzzy slime-fancy-trace slime-fancy-inspector slime-c-p-c
slime-editing-commands slime-autodoc slime-repl slime-parse slime
apropos compile text-property-search etags fileloop generator xref
project arc-mode archive-mode noutline outline icons pp comint ansi-osc
ansi-color ring hyperspec thingatpt slime-autoloads edmacro kmacro
use-package-bind-key bind-key appt diary-lib diary-loaddefs cal-menu
calendar cal-loaddefs dired-x dired-aux dired dired-loaddefs
notifications dbus xml cl-extra help-mode use-package-core repeat
easy-mmode desktop frameset debbugs-autoloads detached-autoloads
ebdb-autoloads ef-themes-autoloads exwm-autoloads hyperbole-autoloads
magit-autoloads git-commit-autoloads finder-inf magit-section-autoloads
dash-autoloads nov-autoloads esxml-autoloads kv-autoloads osm-autoloads
paredit-autoloads rust-mode-autoloads speed-type-autoloads
transmission-autoloads visual-fill-column-autoloads
with-editor-autoloads info compat-autoloads ytdious-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache
json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs
cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind kqueue lcms2 dynamic-setting system-font-setting
font-render-setting cairo xinput2 x multi-tty make-network-process
emacs)

Memory information:
((conses 16 1679605 226472) (symbols 48 60222 5)
 (strings 32 194847 17038) (string-bytes 1 6134459)
 (vectors 16 117354) (vector-slots 8 2341200 178993)
 (floats 8 591 3029) (intervals 56 239858 3338) (buffers 984 165))

-- 
Manuel Giraud

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-07-03 15:59 bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-07-04 16:14 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-01 18:55   ` Stefan Kangas
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-07-04 16:14 UTC (permalink / raw)
  To: 64440

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

Hi,

Here is a new set of patches with two more on top of the previous ones
(ie. Number 1 and 2 should be the same as before).

Number 3 sets the default mouse cursor to be an arrow on the default
menu bar area.  Number 4 fixes a flickering I had while moving the mouse
pointer *into* a menu bar entry.

Best regards,
-- 
Manuel Giraud

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Possibility-to-get-enter-event-from-menu_bar-window.patch --]
[-- Type: text/x-patch, Size: 12751 bytes --]

From ceb818090de83fe216af3e9b6bcc198eba9188e3 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Sat, 1 Jul 2023 21:19:06 +0200
Subject: [PATCH 1/4] Possibility to get enter event from menu_bar window

---
 src/haikuterm.c |  8 ++++----
 src/keyboard.c  |  2 +-
 src/msdos.c     |  2 +-
 src/pgtkterm.c  |  4 ++--
 src/w32inevt.c  |  2 +-
 src/w32term.c   |  8 ++++----
 src/window.c    | 20 ++++++++++++++++++--
 src/window.h    |  2 +-
 src/xdisp.c     |  4 ++--
 src/xterm.c     | 17 +++++++++--------
 10 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/src/haikuterm.c b/src/haikuterm.c
index ed28a806ff2..0af9aa746a9 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -3472,7 +3472,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		if (!NILP (Vmouse_autoselect_window))
 		  {
 		    static Lisp_Object last_mouse_window;
-		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0);
+		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0, 0);
 
 		    if (WINDOWP (window)
 			&& !EQ (window, last_mouse_window)
@@ -3555,7 +3555,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tab_bar_p = EQ (window, f->tab_bar_window);
 
 		if (tab_bar_p)
@@ -3573,7 +3573,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (type != BUTTON_UP
 				  || f->last_tool_bar_item != -1));
@@ -3834,7 +3834,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 
 	    BView_get_mouse (FRAME_HAIKU_VIEW (f), &x, &y);
 
-	    wheel_window = window_from_coordinates (f, x, y, 0, false, false);
+	    wheel_window = window_from_coordinates (f, x, y, 0, false, false, false);
 
 	    if (NILP (wheel_window))
 	      {
diff --git a/src/keyboard.c b/src/keyboard.c
index b61b1766856..4cc0c70b11e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5414,7 +5414,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
   int xret = 0, yret = 0;
   /* The window or frame under frame pixel coordinates (x,y)  */
   Lisp_Object window_or_frame = f
-    ? window_from_coordinates (f, mx, my, &part, true, true)
+    ? window_from_coordinates (f, mx, my, &part, true, true, true)
     : Qnil;
 #ifdef HAVE_WINDOW_SYSTEM
   bool tool_bar_p = false;
diff --git a/src/msdos.c b/src/msdos.c
index 75a39045cee..6e779ffb2e2 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2655,7 +2655,7 @@ dos_rawgetc (void)
 	      static Lisp_Object last_mouse_window;
 
 	      mouse_window = window_from_coordinates
-		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0);
+		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0, 0);
 	      /* A window will be selected only when it is not
 		 selected now, and the last mouse movement event was
 		 not in it.  A minibuffer window will be selected iff
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index dc2d6477bb5..788d4a7bdfb 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -5891,7 +5891,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
 	{
 	  static Lisp_Object last_mouse_window;
 	  Lisp_Object window = window_from_coordinates
-	    (f, event->motion.x, event->motion.y, 0, false, false);
+	    (f, event->motion.x, event->motion.y, 0, false, false, false);
 
 	  /* A window will be autoselected only when it is not
 	     selected now and the last mouse movement event was
@@ -6044,7 +6044,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
 	  int x = event->button.x;
 	  int y = event->button.y;
 
-	  window = window_from_coordinates (f, x, y, 0, true, true);
+	  window = window_from_coordinates (f, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, f->tab_bar_window);
 
 	  if (tab_bar_p)
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 29717954cfd..630a9f4e5fb 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -496,7 +496,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
 	    if (!NILP (Vmouse_autoselect_window))
 	      {
 		Lisp_Object mouse_window = window_from_coordinates (f, mx, my,
-								    0, 0, 0);
+								    0, 0, 0, 0);
 		/* A window will be selected only when it is not
 		   selected now, and the last mouse movement event was
 		   not in it.  A minibuffer window will be selected iff
diff --git a/src/w32term.c b/src/w32term.c
index 57dc6b465e4..9c5a298a645 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3376,7 +3376,7 @@ w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg,
       if (w32_wheel_scroll_lines == UINT_MAX)
 	{
 	  Lisp_Object window = window_from_coordinates (f, p.x, p.y, NULL,
-							false, false);
+							false, false, false);
 	  if (!WINDOWP (window))
 	    {
 	      result->kind = NO_EVENT;
@@ -5335,7 +5335,7 @@ w32_read_socket (struct terminal *terminal,
 		{
 		  static Lisp_Object last_mouse_window;
 		  Lisp_Object window = window_from_coordinates
-		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0);
+		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0, 0);
 
 		  /* Window will be selected only when it is not
 		     selected now and last mouse movement event was
@@ -5407,7 +5407,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tab_bar_window))
                       {
@@ -5435,7 +5435,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tool_bar_window)
 			/* Make sure the tool bar was previously
diff --git a/src/window.c b/src/window.c
index 2a0c62f5d53..af7dcfdd423 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1680,7 +1680,8 @@ check_window_containing (struct window *w, void *user_data)
 
 Lisp_Object
 window_from_coordinates (struct frame *f, int x, int y,
-			 enum window_part *part, bool tab_bar_p, bool tool_bar_p)
+			 enum window_part *part, bool menu_bar_p,
+			 bool tab_bar_p, bool tool_bar_p)
 {
   Lisp_Object window;
   struct check_window_data cw;
@@ -1693,6 +1694,21 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* If not found above, see if it's in the menu bar window, if a menu
+     bar exists.  */
+  if (NILP (window)
+      && menu_bar_p
+      && WINDOWP (f->menu_bar_window)
+      && WINDOW_TOTAL_LINES (XWINDOW (f->menu_bar_window)) > 0
+      && (coordinates_in_window (XWINDOW (f->menu_bar_window), x, y)
+	  != ON_NOTHING))
+    {
+      *part = ON_TEXT;
+      window = f->menu_bar_window;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* If not found above, see if it's in the tab bar window, if a tab
      bar exists.  */
@@ -1746,7 +1762,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
 				  (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
-				  0, false, false);
+				  0, false, false, false);
 }
 
 ptrdiff_t
diff --git a/src/window.h b/src/window.h
index 2f793ebe438..4f4a0a79216 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1092,7 +1092,7 @@ #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)	\
 
 extern Lisp_Object make_window (void);
 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
-                                            enum window_part *, bool, bool);
+                                            enum window_part *, bool, bool, bool);
 extern void resize_frame_windows (struct frame *, int, bool);
 extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
diff --git a/src/xdisp.c b/src/xdisp.c
index 85ece901111..4c02a217cef 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2739,7 +2739,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
       goto virtual_glyph;
     }
   else if (!f->glyphs_initialized_p
-	   || (window = window_from_coordinates (f, gx, gy, &part, false, false),
+	   || (window = window_from_coordinates (f, gx, gy, &part, false, false, false),
 	       NILP (window)))
     {
       width = FRAME_SMALLEST_CHAR_WIDTH (f);
@@ -35124,7 +35124,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
     return;
 
   /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, true, true);
+  window = window_from_coordinates (f, x, y, &part, true, true, true);
 
   /* If displaying active text in another window, clear that.  */
   if (! EQ (window, hlinfo->mouse_face_window)
diff --git a/src/xterm.c b/src/xterm.c
index f84eaeb8cbd..e58e6276aae 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -20925,7 +20925,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  }
 
 		Lisp_Object window = window_from_coordinates
-		  (f, xmotion.x, xmotion.y, 0, false, false);
+		  (f, xmotion.x, xmotion.y, 0, false, false, false);
 
 		/* A window will be autoselected only when it is not
 		   selected now and the last mouse movement event was
@@ -21656,7 +21656,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tab_bar_p = EQ (window, f->tab_bar_window);
 
                 if (tab_bar_p)
@@ -21677,7 +21677,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (event->xbutton.type != ButtonRelease
 				  || f->last_tool_bar_item != -1));
@@ -22398,7 +22398,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			    continue;
 
 			  window = window_from_coordinates (f, real_x, real_y, NULL,
-							    false, false);
+							    false, false, false);
 
 			  if (WINDOWP (window))
 			    scroll_height = XWINDOW (window)->pixel_height;
@@ -22841,7 +22841,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			  || !NILP (focus_follows_mouse)))
 		    {
 		      static Lisp_Object last_mouse_window;
-		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
+		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false,
+								    false);
 
 		      /* A window will be autoselected only when it is not
 			 selected now and the last mouse movement event was
@@ -23419,7 +23420,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      tab_bar_p = EQ (window, f->tab_bar_window);
 
 		      if (tab_bar_p)
@@ -23440,7 +23441,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      /* Ignore button release events if the mouse
 			 wasn't previously pressed on the tool bar.
 			 We do this because otherwise selecting some
@@ -24300,7 +24301,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  int x = xev->event_x;
 		  int y = xev->event_y;
 
-		  window = window_from_coordinates (f, x, y, 0, true, true);
+		  window = window_from_coordinates (f, x, y, 0, true, true, true);
 		  /* Ignore button release events if the mouse
 		     wasn't previously pressed on the tool bar.
 		     We do this because otherwise selecting some
-- 
2.40.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Highlight-on-non-toolkit-menu-bar-items.patch --]
[-- Type: text/x-patch, Size: 4806 bytes --]

From d5ddf8e04d06730917f94cb7d2fcb026c4437788 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Mon, 3 Jul 2023 17:35:06 +0200
Subject: [PATCH 2/4] Highlight on non toolkit menu bar items

* src/xdisp.c (get_menu_bar_item, note_menu_bar_highlight): New
functions to highlight item in the menu-bar.
(note_mouse_highlight): Use it.
---
 src/xdisp.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index 4c02a217cef..25b33e3a8c4 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13859,6 +13859,122 @@ update_menu_bar (struct frame *f, bool save_match_data, bool hooks_run)
   return hooks_run;
 }
 
+/* Get information about the menu-bar item at position X/Y on frame F.
+   Return menu-bar's item char position in H_START/H_END and pixel
+   position in X_START/X_END.  Value is
+
+   -1	if X/Y is not on a menu-bar item
+   0	if X/Y is on the same item that was highlighted before.
+   1	otherwise.  */
+
+static int
+get_menu_bar_item (struct frame *f, int x, int y, int *h_start, int *h_end,
+		   int *x_start, int *x_end, int *vpos)
+{
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+  struct window *w = XWINDOW (f->menu_bar_window);
+  struct glyph_row *row;
+  int dummy;
+  Lisp_Object items;
+  int i;
+
+  /* Find glyph's hpos and vpos under X/Y.  */
+  if (x_y_to_hpos_vpos (w, x, y, h_start, vpos, NULL, NULL, &dummy) == NULL)
+    return -1;
+
+  /* Compute h_start and h_end for this menu bar item.  */
+  items = FRAME_MENU_BAR_ITEMS (f);
+  for (i = 0; i < ASIZE (items); i += 4)
+    {
+      Lisp_Object pos, string;
+      string = AREF (items, i + 1);
+      pos = AREF (items, i + 3);
+      if (NILP (string))
+	return -1;
+      if (*h_start >= XFIXNUM (pos)
+	  && *h_start < XFIXNUM (pos) + SCHARS (string))
+	{
+	  *h_start = XFIXNUM (pos);
+	  *h_end = *h_start + SCHARS (string);
+	  break;
+	}
+    }
+
+  /* Convert to pixels bounds.  */
+  row = MATRIX_ROW (w->current_matrix, *vpos);
+  *x_start = 0;
+  for (i = 0; i < *h_start; ++i)
+    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
+
+  *x_end = *x_start;
+  for (i = *h_start; i < *h_end; ++i)
+    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;
+
+  /* Is mouse on the highlighted item?  */
+  if (EQ (f->menu_bar_window, hlinfo->mouse_face_window)
+      && *vpos >= hlinfo->mouse_face_beg_row
+      && *vpos <= hlinfo->mouse_face_end_row
+      && (*vpos > hlinfo->mouse_face_beg_row
+	  || *h_start >= hlinfo->mouse_face_beg_col)
+      && (*vpos < hlinfo->mouse_face_end_row
+	  || *h_end < hlinfo->mouse_face_end_col
+	  || hlinfo->mouse_face_past_end))
+    return 0;
+
+  return 1;
+}
+
+/* Possibly highlight a menu-bar item on frame F when mouse moves to
+   menu-bar window-relative coordinates X/Y.  Called from
+   note_mouse_highlight.  */
+
+static void
+note_menu_bar_highlight (struct frame *f, int x, int y)
+{
+  Lisp_Object window = f->menu_bar_window;
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+  int h_start, h_end, vpos, x_start, x_end;
+  int rc;
+
+  /* Function note_mouse_highlight is called with negative X/Y
+     values when mouse moves outside of the frame.  */
+  if (x <= 0 || y <= 0)
+    {
+      clear_mouse_face (hlinfo);
+      return;
+    }
+
+  h_start = h_end = 0;
+  rc = get_menu_bar_item (f, x, y, &h_start, &h_end, &x_start, &x_end, &vpos);
+  if (rc < 0)
+    {
+      /* Not on menu-bar item.  */
+      clear_mouse_face (hlinfo);
+      return;
+    }
+  else if (rc == 0)
+    /* On same menu-bar item as before.  */
+    return;
+
+  if (!NILP (Vmouse_highlight))
+    {
+      /* Record this as the current active region.  */
+      hlinfo->mouse_face_beg_col = h_start;
+      hlinfo->mouse_face_beg_row = vpos;
+      hlinfo->mouse_face_beg_x = x_start;
+      hlinfo->mouse_face_past_end = false;
+
+      hlinfo->mouse_face_end_col = h_end;
+      hlinfo->mouse_face_end_row = vpos;
+      hlinfo->mouse_face_end_x = x_end;
+      hlinfo->mouse_face_window = window;
+      hlinfo->mouse_face_face_id = MENU_FACE_ID;
+
+      /* Display it as active.  */
+      show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
+    }
+}
+
 \f
 
 /***********************************************************************
@@ -35223,6 +35339,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* Handle menu-bar window differently since it doesn't display a
+     buffer.  */
+  if (EQ (window, f->menu_bar_window))
+    {
+      note_menu_bar_highlight (f, x, y);
+      return;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* Handle tab-bar window differently since it doesn't display a
      buffer.  */
-- 
2.40.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-nontext-cursor-on-the-menu-bar-by-default.patch --]
[-- Type: text/x-patch, Size: 847 bytes --]

From 08279c0754c49b567fda0adedc3ecfd4e11a7ec5 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Tue, 4 Jul 2023 17:48:42 +0200
Subject: [PATCH 3/4] nontext cursor on the menu bar by default

* src/xdisp.c (show_mouse_face): Arrow for DRAW_NORMAL_TEXT on the
menu bar
---
 src/xdisp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index 25b33e3a8c4..e1c4c9ee7b9 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -33878,6 +33878,9 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
   if (FRAME_WINDOW_P (f) && NILP (track_mouse))
     {
       if (draw == DRAW_NORMAL_TEXT
+#ifndef HAVE_EXT_MENU_BAR
+	  && !EQ (hlinfo->mouse_face_window, f->menu_bar_window)
+#endif
 #ifndef HAVE_EXT_TOOL_BAR
 	  && !EQ (hlinfo->mouse_face_window, f->tool_bar_window)
 #endif
-- 
2.40.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-Avoid-mouse-cursor-flicker.patch --]
[-- Type: text/x-patch, Size: 3062 bytes --]

From 159ae74ed2ec452902913690f6d462767aa3a96d Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Tue, 4 Jul 2023 17:57:39 +0200
Subject: [PATCH 4/4] Avoid mouse cursor flicker

* src/dispextern.h (Mouse_HLInfo): Introduce a mouse_cursor_update
set to true by default.
* src/xdisp.c (show_mouse_face): Take it into account.
(note_menu_bar_highlight, note_tab_bar_highlight)
(note_tool_bar_highlight): Don't update the mouse cursor from
here.
---
 src/dispextern.h |  5 +++++
 src/xdisp.c      | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/dispextern.h b/src/dispextern.h
index ece128949f5..ed03a7c244e 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2876,6 +2876,10 @@ #define PRODUCE_GLYPHS(IT)                              \
 
   /* True means that the mouse highlight should not be shown.  */
   bool_bf mouse_face_hidden : 1;
+
+  /* True means that the mouse highlight should update the mouse
+     cursor.  */
+  bool_bf mouse_cursor_update : 1;
 } Mouse_HLInfo;
 
 INLINE void
@@ -2892,6 +2896,7 @@ reset_mouse_highlight (Mouse_HLInfo *hlinfo)
   hlinfo->mouse_face_past_end = false;
   hlinfo->mouse_face_hidden = false;
   hlinfo->mouse_face_defer = false;
+  hlinfo->mouse_cursor_update = true;
 }
 
 /***********************************************************************
diff --git a/src/xdisp.c b/src/xdisp.c
index e1c4c9ee7b9..86bb1be9240 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13956,6 +13956,11 @@ note_menu_bar_highlight (struct frame *f, int x, int y)
     /* On same menu-bar item as before.  */
     return;
 
+  /* Clear mouse face but the mouse cursor.  */
+  hlinfo->mouse_cursor_update = false;
+  clear_mouse_face (hlinfo);
+  hlinfo->mouse_cursor_update = true;
+
   if (!NILP (Vmouse_highlight))
     {
       /* Record this as the current active region.  */
@@ -14838,7 +14843,10 @@ note_tab_bar_highlight (struct frame *f, int x, int y)
     /* On same tab-bar item as before.  */
     goto set_help_echo;
 
+  /* Clear mouse face but the mouse cursor.  */
+  hlinfo->mouse_cursor_update = false;
   clear_mouse_face (hlinfo);
+  hlinfo->mouse_cursor_update = true;
 
   bool mouse_down_p = false;
   /* Mouse is down, but on different tab-bar item?  Or alternatively,
@@ -15793,7 +15801,10 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
     /* On same tool-bar item as before.  */
     goto set_help_echo;
 
+  /* Clear mouse face but the mouse cursor.  */
+  hlinfo->mouse_cursor_update = false;
   clear_mouse_face (hlinfo);
+  hlinfo->mouse_cursor_update = true;
 
   /* Mouse is down, but on different tool-bar item?  */
   mouse_down_p = (gui_mouse_grabbed (dpyinfo)
@@ -33875,7 +33886,7 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
 
 #ifdef HAVE_WINDOW_SYSTEM
   /* Change the mouse cursor.  */
-  if (FRAME_WINDOW_P (f) && NILP (track_mouse))
+  if (FRAME_WINDOW_P (f) && NILP (track_mouse) && hlinfo->mouse_cursor_update)
     {
       if (draw == DRAW_NORMAL_TEXT
 #ifndef HAVE_EXT_MENU_BAR
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-07-04 16:14 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-01 18:55   ` Stefan Kangas
  2023-09-02  0:44     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Stefan Kangas @ 2023-09-01 18:55 UTC (permalink / raw)
  To: Manuel Giraud, Po Lu; +Cc: 64440

> Here is a new set of patches with two more on top of the previous ones
> (ie. Number 1 and 2 should be the same as before).
>
> Number 3 sets the default mouse cursor to be an arrow on the default
> menu bar area.  Number 4 fixes a flickering I had while moving the mouse
> pointer *into* a menu bar entry.

Po Lu, do you have any comments on this patch series?

Thanks in advance.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-01 18:55   ` Stefan Kangas
@ 2023-09-02  0:44     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-02  6:41       ` Eli Zaretskii
  2023-09-02 13:05       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-02  0:44 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 64440, Manuel Giraud

Stefan Kangas <stefankangas@gmail.com> writes:

>> Here is a new set of patches with two more on top of the previous ones
>> (ie. Number 1 and 2 should be the same as before).
>>
>> Number 3 sets the default mouse cursor to be an arrow on the default
>> menu bar area.  Number 4 fixes a flickering I had while moving the mouse
>> pointer *into* a menu bar entry.
>
> Po Lu, do you have any comments on this patch series?
>
> Thanks in advance.

Thanks.  I don't understand why adjustments to note_tab_bar_highlight or
note_tool_bar_highlight are warranted, and I think this ought to be
optional.

ChangeLog entries are also absent from the commit messages.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-02  0:44     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-02  6:41       ` Eli Zaretskii
  2023-09-02 13:09         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-05  9:53         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-02 13:05       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 2 replies; 54+ messages in thread
From: Eli Zaretskii @ 2023-09-02  6:41 UTC (permalink / raw)
  To: Po Lu; +Cc: stefankangas, manuel, 64440

> Cc: 64440@debbugs.gnu.org, Manuel Giraud <manuel@ledu-giraud.fr>
> Date: Sat, 02 Sep 2023 08:44:16 +0800
> From:  Po Lu via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Stefan Kangas <stefankangas@gmail.com> writes:
> 
> >> Here is a new set of patches with two more on top of the previous ones
> >> (ie. Number 1 and 2 should be the same as before).
> >>
> >> Number 3 sets the default mouse cursor to be an arrow on the default
> >> menu bar area.  Number 4 fixes a flickering I had while moving the mouse
> >> pointer *into* a menu bar entry.
> >
> > Po Lu, do you have any comments on this patch series?
> >
> > Thanks in advance.
> 
> Thanks.  I don't understand why adjustments to note_tab_bar_highlight or
> note_tool_bar_highlight are warranted, and I think this ought to be
> optional.
> 
> ChangeLog entries are also absent from the commit messages.

I'd appreciate a walkthrough of the patches with explanations for the
significant hunks.  It's a non-trivial change, so I think the
rationale and the main ideas of the implementation should be described
and discussed.

I also have difficulty understanding comments like this one:

   /* Clear mouse face but the mouse cursor.  */

What does it try to say?





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-02  0:44     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-02  6:41       ` Eli Zaretskii
@ 2023-09-02 13:05       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-02 13:05 UTC (permalink / raw)
  To: Po Lu; +Cc: Stefan Kangas, 64440

Po Lu <luangruo@yahoo.com> writes:

> Stefan Kangas <stefankangas@gmail.com> writes:
>
>>> Here is a new set of patches with two more on top of the previous ones
>>> (ie. Number 1 and 2 should be the same as before).
>>>
>>> Number 3 sets the default mouse cursor to be an arrow on the default
>>> menu bar area.  Number 4 fixes a flickering I had while moving the mouse
>>> pointer *into* a menu bar entry.
>>
>> Po Lu, do you have any comments on this patch series?
>>
>> Thanks in advance.
>
> Thanks.  I don't understand why adjustments to note_tab_bar_highlight or
> note_tool_bar_highlight are warranted, and I think this ought to be
> optional.

Ok, I'll look into those two adjustements.  BTW, I was more hesitant
about the global modification of 'window_from_coordinates' (even on
machines I don't have access to).

> ChangeLog entries are also absent from the commit messages.

Noted.
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-02  6:41       ` Eli Zaretskii
@ 2023-09-02 13:09         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-05  9:53         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-02 13:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Po Lu, stefankangas, 64440

Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: 64440@debbugs.gnu.org, Manuel Giraud <manuel@ledu-giraud.fr>
>> Date: Sat, 02 Sep 2023 08:44:16 +0800
>> From:  Po Lu via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> Stefan Kangas <stefankangas@gmail.com> writes:
>> 
>> >> Here is a new set of patches with two more on top of the previous ones
>> >> (ie. Number 1 and 2 should be the same as before).
>> >>
>> >> Number 3 sets the default mouse cursor to be an arrow on the default
>> >> menu bar area.  Number 4 fixes a flickering I had while moving the mouse
>> >> pointer *into* a menu bar entry.
>> >
>> > Po Lu, do you have any comments on this patch series?
>> >
>> > Thanks in advance.
>> 
>> Thanks.  I don't understand why adjustments to note_tab_bar_highlight or
>> note_tool_bar_highlight are warranted, and I think this ought to be
>> optional.
>> 
>> ChangeLog entries are also absent from the commit messages.
>
> I'd appreciate a walkthrough of the patches with explanations for the
> significant hunks.  It's a non-trivial change, so I think the
> rationale and the main ideas of the implementation should be described
> and discussed.

I'll try to come up with such a walkthrough.

> I also have difficulty understanding comments like this one:
>
>    /* Clear mouse face but the mouse cursor.  */
>
> What does it try to say?

Yes sorry it should read "Clear the mouse face but not the mouse cursor"
and it is a bit hacky.  It was to avoid the flicker of the mouse cursor
when moving *into* a menu entry.
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-02  6:41       ` Eli Zaretskii
  2023-09-02 13:09         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-05  9:53         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-10  7:31           ` Eli Zaretskii
  1 sibling, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-05  9:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Po Lu, stefankangas, 64440

Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: 64440@debbugs.gnu.org, Manuel Giraud <manuel@ledu-giraud.fr>
>> Date: Sat, 02 Sep 2023 08:44:16 +0800
>> From:  Po Lu via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> Stefan Kangas <stefankangas@gmail.com> writes:
>> 
>> >> Here is a new set of patches with two more on top of the previous ones
>> >> (ie. Number 1 and 2 should be the same as before).
>> >>
>> >> Number 3 sets the default mouse cursor to be an arrow on the default
>> >> menu bar area.  Number 4 fixes a flickering I had while moving the mouse
>> >> pointer *into* a menu bar entry.
>> >
>> > Po Lu, do you have any comments on this patch series?
>> >
>> > Thanks in advance.
>> 
>> Thanks.  I don't understand why adjustments to note_tab_bar_highlight or
>> note_tool_bar_highlight are warranted, and I think this ought to be
>> optional.
>> 
>> ChangeLog entries are also absent from the commit messages.
>
> I'd appreciate a walkthrough of the patches with explanations for the
> significant hunks.  It's a non-trivial change, so I think the
> rationale and the main ideas of the implementation should be described
> and discussed.

Hi,

For this walkthrough, I have inserted the 4 patches, made some elisions
and comment inline.

From ceb818090de83fe216af3e9b6bcc198eba9188e3 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Sat, 1 Jul 2023 21:19:06 +0200
Subject: [PATCH 1/4] Possibility to get enter event from menu_bar window

[...]

This first patch is really about being able to get the menu-bar window
from 'window_from_coordinates'.  Without this I would not be able to get
a mouse event that happen on this window.

diff --git a/src/window.c b/src/window.c
index 2a0c62f5d53..af7dcfdd423 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1680,7 +1680,8 @@ check_window_containing (struct window *w, void *user_data)
 
 Lisp_Object
 window_from_coordinates (struct frame *f, int x, int y,
-			 enum window_part *part, bool tab_bar_p, bool tool_bar_p)
+			 enum window_part *part, bool menu_bar_p,
+			 bool tab_bar_p, bool tool_bar_p)
 {
   Lisp_Object window;
   struct check_window_data cw;
@@ -1693,6 +1694,21 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* If not found above, see if it's in the menu bar window, if a menu
+     bar exists.  */
+  if (NILP (window)
+      && menu_bar_p
+      && WINDOWP (f->menu_bar_window)
+      && WINDOW_TOTAL_LINES (XWINDOW (f->menu_bar_window)) > 0
+      && (coordinates_in_window (XWINDOW (f->menu_bar_window), x, y)
+	  != ON_NOTHING))
+    {
+      *part = ON_TEXT;
+      window = f->menu_bar_window;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* If not found above, see if it's in the tab bar window, if a tab
      bar exists.  */

In window_from_coordinates, I tried to mimic what is done for the
tab_bar and the tool_bar.  So I add a menu_bar_p boolean as argument
(before the toolbar one to respect a top to bottom order) and use it to
return the menu_bar window when it is asked and we are in this window.

The rest is this patch is really just adding this new argument in all of
the calls to window_from_coordinates.  I've just copy tool_bar_p and
tab_bar_p values in those call: true when true and false when false.

[...]

From d5ddf8e04d06730917f94cb7d2fcb026c4437788 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Mon, 3 Jul 2023 17:35:06 +0200
Subject: [PATCH 2/4] Highlight on non toolkit menu bar items

This patch introduce two new functions: get_menu_bar_item and
note_menu_bar_highlight.  I tried to have the same behaviour as
get_tool_bar_item and note_tool_bar_highlight.

AFAIU, get_menu_bar_item job is to determine if we are on a menu entry
and what are its spatial limits.  note_menu_bar_highlight job is to do
something with those limits: for instance, highlight this area.

[...]

+/* Get information about the menu-bar item at position X/Y on frame F.
+   Return menu-bar's item char position in H_START/H_END and pixel
+   position in X_START/X_END.  Value is
+
+   -1	if X/Y is not on a menu-bar item
+   0	if X/Y is on the same item that was highlighted before.
+   1	otherwise.  */
+
+static int
+get_menu_bar_item (struct frame *f, int x, int y, int *h_start, int *h_end,
+		   int *x_start, int *x_end, int *vpos)
+{
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+  struct window *w = XWINDOW (f->menu_bar_window);
+  struct glyph_row *row;
+  int dummy;
+  Lisp_Object items;
+  int i;
+
+  /* Find glyph's hpos and vpos under X/Y.  */
+  if (x_y_to_hpos_vpos (w, x, y, h_start, vpos, NULL, NULL, &dummy) == NULL)
+    return -1;
+
+  /* Compute h_start and h_end for this menu bar item.  */
+  items = FRAME_MENU_BAR_ITEMS (f);
+  for (i = 0; i < ASIZE (items); i += 4)
+    {
+      Lisp_Object pos, string;
+      string = AREF (items, i + 1);
+      pos = AREF (items, i + 3);
+      if (NILP (string))
+	return -1;
+      if (*h_start >= XFIXNUM (pos)
+	  && *h_start < XFIXNUM (pos) + SCHARS (string))
+	{
+	  *h_start = XFIXNUM (pos);
+	  *h_end = *h_start + SCHARS (string);
+	  break;
+	}
+    }

So in this loop above, I'm trying to find what menu bar item I'm on and
get horizontal start and end (in char numbers).

+  /* Convert to pixels bounds.  */
+  row = MATRIX_ROW (w->current_matrix, *vpos);
+  *x_start = 0;
+  for (i = 0; i < *h_start; ++i)
+    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
+
+  *x_end = *x_start;
+  for (i = *h_start; i < *h_end; ++i)
+    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;

Here, I convert those limits from chars to pixels.

+
+  /* Is mouse on the highlighted item?  */
+  if (EQ (f->menu_bar_window, hlinfo->mouse_face_window)
+      && *vpos >= hlinfo->mouse_face_beg_row
+      && *vpos <= hlinfo->mouse_face_end_row
+      && (*vpos > hlinfo->mouse_face_beg_row
+	  || *h_start >= hlinfo->mouse_face_beg_col)
+      && (*vpos < hlinfo->mouse_face_end_row
+	  || *h_end < hlinfo->mouse_face_end_col
+	  || hlinfo->mouse_face_past_end))
+    return 0;
+
+  return 1;
+}

Finally, I compute the correct return value for get_*_item functions:
              . 0 means we already were on this item
              . 1 means we changed position to a new item
                  
+/* Possibly highlight a menu-bar item on frame F when mouse moves to
+   menu-bar window-relative coordinates X/Y.  Called from
+   note_mouse_highlight.  */
+
+static void
+note_menu_bar_highlight (struct frame *f, int x, int y)
+{
+  Lisp_Object window = f->menu_bar_window;
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+  int h_start, h_end, vpos, x_start, x_end;
+  int rc;
+
+  /* Function note_mouse_highlight is called with negative X/Y
+     values when mouse moves outside of the frame.  */
+  if (x <= 0 || y <= 0)
+    {
+      clear_mouse_face (hlinfo);
+      return;
+    }
+
+  h_start = h_end = 0;
+  rc = get_menu_bar_item (f, x, y, &h_start, &h_end, &x_start, &x_end, &vpos);
+  if (rc < 0)
+    {
+      /* Not on menu-bar item.  */
+      clear_mouse_face (hlinfo);
+      return;
+    }
+  else if (rc == 0)
+    /* On same menu-bar item as before.  */
+    return;

In note_menu_bar_highlight here, I'm testing (from get_menu_bar_item
result): 
      . if we are not a menu bar item, I clear the mouse face (as done
        on other note_*_highlight functions)
      . if we are on the same item: do nothing
           
+  if (!NILP (Vmouse_highlight))
+    {
+      /* Record this as the current active region.  */
+      hlinfo->mouse_face_beg_col = h_start;
+      hlinfo->mouse_face_beg_row = vpos;
+      hlinfo->mouse_face_beg_x = x_start;
+      hlinfo->mouse_face_past_end = false;
+
+      hlinfo->mouse_face_end_col = h_end;
+      hlinfo->mouse_face_end_row = vpos;
+      hlinfo->mouse_face_end_x = x_end;
+      hlinfo->mouse_face_window = window;
+      hlinfo->mouse_face_face_id = MENU_FACE_ID;
+
+      /* Display it as active.  */
+      show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
+    }
+}

Here, if the user want mouse highlight, I set the highlight info on the
given area and activate it.  I have used MENU_FACE_ID so there should be
no user visible changes here but later we might introduce a new face for
this (MENU_HIGHLIGHT_FACE_ID for instance).  I also used DRAW_MOUSE_FACE
in the show_mouse_face call to have the mouse cursor changed to the
« little hand »: so far it is the only visible feedback that I have.

 
 /***********************************************************************
@@ -35223,6 +35339,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* Handle menu-bar window differently since it doesn't display a
+     buffer.  */
+  if (EQ (window, f->menu_bar_window))
+    {
+      note_menu_bar_highlight (f, x, y);
+      return;
+    }
+#endif
+

Here, I'm just using note_menu_bar_highlight in the toplevel
note_mouse_highlight.

From 08279c0754c49b567fda0adedc3ecfd4e11a7ec5 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Tue, 4 Jul 2023 17:48:42 +0200
Subject: [PATCH 3/4] nontext cursor on the menu bar by default

* src/xdisp.c (show_mouse_face): Arrow for DRAW_NORMAL_TEXT on the
menu bar
---
 src/xdisp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index 25b33e3a8c4..e1c4c9ee7b9 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -33878,6 +33878,9 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
   if (FRAME_WINDOW_P (f) && NILP (track_mouse))
     {
       if (draw == DRAW_NORMAL_TEXT
+#ifndef HAVE_EXT_MENU_BAR
+	  && !EQ (hlinfo->mouse_face_window, f->menu_bar_window)
+#endif
 #ifndef HAVE_EXT_TOOL_BAR
 	  && !EQ (hlinfo->mouse_face_window, f->tool_bar_window)
 #endif

Here, I thought I was toggling the mouse cursor to an arrow when
entering the menu bar but it does not seem to work.  It does not work
for tool bar either BTW.

From 159ae74ed2ec452902913690f6d462767aa3a96d Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Tue, 4 Jul 2023 17:57:39 +0200
Subject: [PATCH 4/4] Avoid mouse cursor flicker

This last patch works for me but is a kludge and, as Po said, I
shouldn't be touching note_tool_bar_highlight and note_tab_bar_highlight
here.  I should rework this.

It fixes the following issue: when I'm over the same menu item and
moving, the mouse cursor flickers.

* src/dispextern.h (Mouse_HLInfo): Introduce a mouse_cursor_update
set to true by default.
* src/xdisp.c (show_mouse_face): Take it into account.
(note_menu_bar_highlight, note_tab_bar_highlight)
(note_tool_bar_highlight): Don't update the mouse cursor from
here.
---
 src/dispextern.h |  5 +++++
 src/xdisp.c      | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/dispextern.h b/src/dispextern.h
index ece128949f5..ed03a7c244e 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2876,6 +2876,10 @@ #define PRODUCE_GLYPHS(IT)                              \
 
   /* True means that the mouse highlight should not be shown.  */
   bool_bf mouse_face_hidden : 1;
+
+  /* True means that the mouse highlight should update the mouse
+     cursor.  */
+  bool_bf mouse_cursor_update : 1;
 } Mouse_HLInfo;
 
 INLINE void
@@ -2892,6 +2896,7 @@ reset_mouse_highlight (Mouse_HLInfo *hlinfo)
   hlinfo->mouse_face_past_end = false;
   hlinfo->mouse_face_hidden = false;
   hlinfo->mouse_face_defer = false;
+  hlinfo->mouse_cursor_update = true;
 }
 
 /***********************************************************************
diff --git a/src/xdisp.c b/src/xdisp.c
index e1c4c9ee7b9..86bb1be9240 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13956,6 +13956,11 @@ note_menu_bar_highlight (struct frame *f, int x, int y)
     /* On same menu-bar item as before.  */
     return;
 
+  /* Clear mouse face but the mouse cursor.  */
+  hlinfo->mouse_cursor_update = false;
+  clear_mouse_face (hlinfo);
+  hlinfo->mouse_cursor_update = true;
+
   if (!NILP (Vmouse_highlight))
     {
       /* Record this as the current active region.  */
@@ -14838,7 +14843,10 @@ note_tab_bar_highlight (struct frame *f, int x, int y)
     /* On same tab-bar item as before.  */
     goto set_help_echo;
 
+  /* Clear mouse face but the mouse cursor.  */
+  hlinfo->mouse_cursor_update = false;
   clear_mouse_face (hlinfo);
+  hlinfo->mouse_cursor_update = true;
 
   bool mouse_down_p = false;
   /* Mouse is down, but on different tab-bar item?  Or alternatively,
@@ -15793,7 +15801,10 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
     /* On same tool-bar item as before.  */
     goto set_help_echo;
 
+  /* Clear mouse face but the mouse cursor.  */
+  hlinfo->mouse_cursor_update = false;
   clear_mouse_face (hlinfo);
+  hlinfo->mouse_cursor_update = true;
 
   /* Mouse is down, but on different tool-bar item?  */
   mouse_down_p = (gui_mouse_grabbed (dpyinfo)
@@ -33875,7 +33886,7 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
 
 #ifdef HAVE_WINDOW_SYSTEM
   /* Change the mouse cursor.  */
-  if (FRAME_WINDOW_P (f) && NILP (track_mouse))
+  if (FRAME_WINDOW_P (f) && NILP (track_mouse) && hlinfo->mouse_cursor_update)
     {
       if (draw == DRAW_NORMAL_TEXT
 #ifndef HAVE_EXT_MENU_BAR
-- 
2.40.0

-- 
Manuel Giraud





^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-05  9:53         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-10  7:31           ` Eli Zaretskii
  2023-09-10  7:33             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
                               ` (2 more replies)
  0 siblings, 3 replies; 54+ messages in thread
From: Eli Zaretskii @ 2023-09-10  7:31 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: luangruo, stefankangas, 64440

> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Cc: Po Lu <luangruo@yahoo.com>,  stefankangas@gmail.com,  64440@debbugs.gnu.org
> Date: Tue, 05 Sep 2023 11:53:38 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > I'd appreciate a walkthrough of the patches with explanations for the
> > significant hunks.  It's a non-trivial change, so I think the
> > rationale and the main ideas of the implementation should be described
> > and discussed.
> 
> Hi,
> 
> For this walkthrough, I have inserted the 4 patches, made some elisions
> and comment inline.

Thanks.

> +  /* Convert to pixels bounds.  */
> +  row = MATRIX_ROW (w->current_matrix, *vpos);
> +  *x_start = 0;
> +  for (i = 0; i < *h_start; ++i)
> +    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
> +
> +  *x_end = *x_start;
> +  for (i = *h_start; i < *h_end; ++i)
> +    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;
> 
> Here, I convert those limits from chars to pixels.

What does this glyph_row look like?  Does it include several strings
one after the other or something?

In general, we always test the index of a glyph in a glyph row against
glyphs[TEXT_AREA].used, and I'm worried that these tests are absent
from the code above.  Which is why I'm asking for more details about
the arrangement of the menu text in these glyph rows.

> +/* Possibly highlight a menu-bar item on frame F when mouse moves to
> +   menu-bar window-relative coordinates X/Y.  Called from
> +   note_mouse_highlight.  */
> +
> +static void
> +note_menu_bar_highlight (struct frame *f, int x, int y)
> +{

Is this function under a suitable #if condition?  AFAIU, it is only
appropriate in a build with X but without any toolkit, so it shouldn't
be compiled in other configurations.

> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -33878,6 +33878,9 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
>    if (FRAME_WINDOW_P (f) && NILP (track_mouse))
>      {
>        if (draw == DRAW_NORMAL_TEXT
> +#ifndef HAVE_EXT_MENU_BAR
> +	  && !EQ (hlinfo->mouse_face_window, f->menu_bar_window)
> +#endif

Won't this cpp conditional be true in a build --without-x?  Should it?

Thanks for working on this.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-10  7:31           ` Eli Zaretskii
@ 2023-09-10  7:33             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-11 12:32             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-11 12:51             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2 siblings, 0 replies; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-10  7:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: stefankangas, Manuel Giraud, 64440

Eli Zaretskii <eliz@gnu.org> writes:

> Is this function under a suitable #if condition?  AFAIU, it is only
> appropriate in a build with X but without any toolkit, so it shouldn't

Or on Android, which also utilizes our own menu bars.  The right
conditional is:

#if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-10  7:31           ` Eli Zaretskii
  2023-09-10  7:33             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-11 12:32             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-11 13:41               ` Eli Zaretskii
  2023-09-11 12:51             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-11 12:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, stefankangas, 64440

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Manuel Giraud <manuel@ledu-giraud.fr>
>> Cc: Po Lu <luangruo@yahoo.com>,  stefankangas@gmail.com,  64440@debbugs.gnu.org
>> Date: Tue, 05 Sep 2023 11:53:38 +0200
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> > I'd appreciate a walkthrough of the patches with explanations for the
>> > significant hunks.  It's a non-trivial change, so I think the
>> > rationale and the main ideas of the implementation should be described
>> > and discussed.
>> 
>> Hi,
>> 
>> For this walkthrough, I have inserted the 4 patches, made some elisions
>> and comment inline.
>
> Thanks.
>
>> +  /* Convert to pixels bounds.  */
>> +  row = MATRIX_ROW (w->current_matrix, *vpos);
>> +  *x_start = 0;
>> +  for (i = 0; i < *h_start; ++i)
>> +    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
>> +
>> +  *x_end = *x_start;
>> +  for (i = *h_start; i < *h_end; ++i)
>> +    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;
>> 
>> Here, I convert those limits from chars to pixels.
>
> What does this glyph_row look like?  Does it include several strings
> one after the other or something?
>
> In general, we always test the index of a glyph in a glyph row against
> glyphs[TEXT_AREA].used, and I'm worried that these tests are absent
> from the code above.  Which is why I'm asking for more details about
> the arrangement of the menu text in these glyph rows.

Hi,

Here's what a "p *row" returns right after the "row = MATRIX_ROW
(w->current_matrix, *vpos);" line:

(gdb) p *row
$9 = {
  glyphs = {0xef4a19dd000, 0xef4a19dd000, 0xef4a19e0510, 0xef4a19e0510},
  used = {0, 120, 0, 0},
  hash = 221095522,
  x = 0,
  y = 0,
  pixel_width = 840,
  ascent = 11,
  height = 13,
  phys_ascent = 10,
  phys_height = 12,
  visible_height = 13,
  extra_line_spacing = 0,
  start = {
    pos = {
      charpos = 0,
      bytepos = 0
    },
    overlay_string_index = 0,
    string_pos = {
      charpos = 0,
      bytepos = 0
    },
    dpvec_index = 0
  },
  end = {
    pos = {
      charpos = 0,
      bytepos = 0
    },
    overlay_string_index = 0,
    string_pos = {
      charpos = 0,
      bytepos = 0
    },
    dpvec_index = 0
  },
  minpos = {
    charpos = 0,
    bytepos = 0
  },
  maxpos = {
    charpos = 0,
    bytepos = 0
  },
  overlay_arrow_bitmap = 0,
  left_user_fringe_bitmap = 0,
  right_user_fringe_bitmap = 0,
  left_fringe_bitmap = 0,
  right_fringe_bitmap = 0,
  left_user_fringe_face_id = 0,
  right_user_fringe_face_id = 0,
  left_fringe_face_id = 0,
  right_fringe_face_id = 0,
  left_fringe_offset = 0,
  right_fringe_offset = 0,
  fringe_bitmap_periodic_p = false,
  redraw_fringe_bitmaps_p = false,
  enabled_p = true,
  truncated_on_left_p = false,
  truncated_on_right_p = false,
  continued_p = false,
  displays_text_p = false,
  ends_at_zv_p = false,
  fill_line_p = false,
  indicate_empty_line_p = false,
  contains_overlapping_glyphs_p = false,
  full_width_p = true,
  mode_line_p = false,
  tab_line_p = false,
  overlapped_p = false,
  ends_in_middle_of_char_p = false,
  starts_in_middle_of_char_p = false,
  overlapping_p = false,
  mouse_face_p = false,
  ends_in_newline_from_string_p = false,
  exact_window_width_line_p = false,
  cursor_in_fringe_p = false,
  ends_in_ellipsis_p = false,
  indicate_bob_p = false,
  indicate_top_line_p = false,
  indicate_eob_p = false,
  indicate_bottom_line_p = false,
  reversed_p = false,
  stipple_p = false,
  continuation_lines_width = 0,
  clip = 0x0
}

Is that what you are looking for?

>> +/* Possibly highlight a menu-bar item on frame F when mouse moves to
>> +   menu-bar window-relative coordinates X/Y.  Called from
>> +   note_mouse_highlight.  */
>> +
>> +static void
>> +note_menu_bar_highlight (struct frame *f, int x, int y)
>> +{
>
> Is this function under a suitable #if condition?  AFAIU, it is only
> appropriate in a build with X but without any toolkit, so it shouldn't
> be compiled in other configurations.

Yes, you are right.  I'll had the #ifdef proposed by Po.

>> --- a/src/xdisp.c
>> +++ b/src/xdisp.c
>> @@ -33878,6 +33878,9 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
>>    if (FRAME_WINDOW_P (f) && NILP (track_mouse))
>>      {
>>        if (draw == DRAW_NORMAL_TEXT
>> +#ifndef HAVE_EXT_MENU_BAR
>> +	  && !EQ (hlinfo->mouse_face_window, f->menu_bar_window)
>> +#endif
>
> Won't this cpp conditional be true in a build --without-x?  Should it?

Same.
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-10  7:31           ` Eli Zaretskii
  2023-09-10  7:33             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-11 12:32             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-11 12:51             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2 siblings, 0 replies; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-11 12:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, stefankangas, 64440

Eli Zaretskii <eliz@gnu.org> writes:

[...]

>> --- a/src/xdisp.c
>> +++ b/src/xdisp.c
>> @@ -33878,6 +33878,9 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
>>    if (FRAME_WINDOW_P (f) && NILP (track_mouse))
>>      {
>>        if (draw == DRAW_NORMAL_TEXT
>> +#ifndef HAVE_EXT_MENU_BAR
>> +	  && !EQ (hlinfo->mouse_face_window, f->menu_bar_window)
>> +#endif
>
> Won't this cpp conditional be true in a build --without-x?  Should it?

No, I was wrong.  This one is ok because, we already are into an "#ifdef
HAVE_WINDOW_SYSTEM" here.
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-11 12:32             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-11 13:41               ` Eli Zaretskii
  2023-09-11 14:59                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Eli Zaretskii @ 2023-09-11 13:41 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: luangruo, stefankangas, 64440

> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Cc: luangruo@yahoo.com,  stefankangas@gmail.com,  64440@debbugs.gnu.org
> Date: Mon, 11 Sep 2023 14:32:39 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> +  *x_end = *x_start;
> >> +  for (i = *h_start; i < *h_end; ++i)
> >> +    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;
> >> 
> >> Here, I convert those limits from chars to pixels.
> >
> > What does this glyph_row look like?  Does it include several strings
> > one after the other or something?
> >
> > In general, we always test the index of a glyph in a glyph row against
> > glyphs[TEXT_AREA].used, and I'm worried that these tests are absent
> > from the code above.  Which is why I'm asking for more details about
> > the arrangement of the menu text in these glyph rows.
> 
> Hi,
> 
> Here's what a "p *row" returns right after the "row = MATRIX_ROW
> (w->current_matrix, *vpos);" line:
> 
> (gdb) p *row
> $9 = {
>   glyphs = {0xef4a19dd000, 0xef4a19dd000, 0xef4a19e0510, 0xef4a19e0510},
>   used = {0, 120, 0, 0},
>   hash = 221095522,
>   x = 0,
>   y = 0,
>   pixel_width = 840,
>   ascent = 11,
>   height = 13,
>   phys_ascent = 10,
>   phys_height = 12,
>   visible_height = 13,
>   extra_line_spacing = 0,
>   start = {
>     pos = {
>       charpos = 0,
>       bytepos = 0
>     },
>     overlay_string_index = 0,
>     string_pos = {
>       charpos = 0,
>       bytepos = 0
>     },
>     dpvec_index = 0
>   },
>   end = {
>     pos = {
>       charpos = 0,
>       bytepos = 0
>     },
>     overlay_string_index = 0,
>     string_pos = {
>       charpos = 0,
>       bytepos = 0
>     },
>     dpvec_index = 0
>   },
>   minpos = {
>     charpos = 0,
>     bytepos = 0
>   },
>   maxpos = {
>     charpos = 0,
>     bytepos = 0
>   },
>   overlay_arrow_bitmap = 0,
>   left_user_fringe_bitmap = 0,
>   right_user_fringe_bitmap = 0,
>   left_fringe_bitmap = 0,
>   right_fringe_bitmap = 0,
>   left_user_fringe_face_id = 0,
>   right_user_fringe_face_id = 0,
>   left_fringe_face_id = 0,
>   right_fringe_face_id = 0,
>   left_fringe_offset = 0,
>   right_fringe_offset = 0,
>   fringe_bitmap_periodic_p = false,
>   redraw_fringe_bitmaps_p = false,
>   enabled_p = true,
>   truncated_on_left_p = false,
>   truncated_on_right_p = false,
>   continued_p = false,
>   displays_text_p = false,
>   ends_at_zv_p = false,
>   fill_line_p = false,
>   indicate_empty_line_p = false,
>   contains_overlapping_glyphs_p = false,
>   full_width_p = true,
>   mode_line_p = false,
>   tab_line_p = false,
>   overlapped_p = false,
>   ends_in_middle_of_char_p = false,
>   starts_in_middle_of_char_p = false,
>   overlapping_p = false,
>   mouse_face_p = false,
>   ends_in_newline_from_string_p = false,
>   exact_window_width_line_p = false,
>   cursor_in_fringe_p = false,
>   ends_in_ellipsis_p = false,
>   indicate_bob_p = false,
>   indicate_top_line_p = false,
>   indicate_eob_p = false,
>   indicate_bottom_line_p = false,
>   reversed_p = false,
>   stipple_p = false,
>   continuation_lines_width = 0,
>   clip = 0x0
> }
> 
> Is that what you are looking for?

This gives some of the answers, but the command 'pgrow' (defined on
src/.gdbinit) would have done that better, and would also show the
glyphs themselves.  Can you show what 'pgrow' produces in this case?





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-11 13:41               ` Eli Zaretskii
@ 2023-09-11 14:59                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-11 15:58                   ` Eli Zaretskii
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-11 14:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, stefankangas, 64440

Eli Zaretskii <eliz@gnu.org> writes:

[...]

>> Is that what you are looking for?
>
> This gives some of the answers, but the command 'pgrow' (defined on
> src/.gdbinit) would have done that better, and would also show the
> glyphs themselves.  Can you show what 'pgrow' produces in this case?

Here is what I get:

(gdb) pgrow
TEXT: 120 glyphs
  0    0: CHAR[F] str=0x66f834da[0] blev=0,btyp=L w=7 a+d=11+2 face=10
  1    7: CHAR[i] str=0x66f834da[1] blev=0,btyp=L w=7 a+d=11+2 face=10
  2   14: CHAR[l] str=0x66f834da[2] blev=0,btyp=L w=7 a+d=11+2 face=10
  3   21: CHAR[e] str=0x66f834da[3] blev=0,btyp=L w=7 a+d=11+2 face=10
  4   28: CHAR[ ] str=0x66f834da[-1] blev=0,btyp=B w=7 a+d=11+2 face=10
  5   35: CHAR[E] str=0x66fede1c[0] blev=0,btyp=L w=7 a+d=11+2 face=10
  6   42: CHAR[d] str=0x66fede1c[1] blev=0,btyp=L w=7 a+d=11+2 face=10
  7   49: CHAR[i] str=0x66fede1c[2] blev=0,btyp=L w=7 a+d=11+2 face=10
  8   56: CHAR[t] str=0x66fede1c[3] blev=0,btyp=L w=7 a+d=11+2 face=10
  9   63: CHAR[ ] str=0x66fede1c[-1] blev=0,btyp=B w=7 a+d=11+2 face=10
 10   70: CHAR[O] str=0x670530d4[0] blev=0,btyp=L w=7 a+d=11+2 face=10
 11   77: CHAR[p] str=0x670530d4[1] blev=0,btyp=L w=7 a+d=11+2 face=10
 12   84: CHAR[t] str=0x670530d4[2] blev=0,btyp=L w=7 a+d=11+2 face=10
 13   91: CHAR[i] str=0x670530d4[3] blev=0,btyp=L w=7 a+d=11+2 face=10
 14   98: CHAR[o] str=0x670530d4[4] blev=0,btyp=L w=7 a+d=11+2 face=10
 15  105: CHAR[n] str=0x670530d4[5] blev=0,btyp=L w=7 a+d=11+2 face=10
 16  112: CHAR[s] str=0x670530d4[6] blev=0,btyp=L w=7 a+d=11+2 face=10
 17  119: CHAR[ ] str=0x670530d4[-1] blev=0,btyp=B w=7 a+d=11+2 face=10
 18  126: CHAR[B] str=0x66fe6eaf[0] blev=0,btyp=L w=7 a+d=11+2 face=10
 19  133: CHAR[u] str=0x66fe6eaf[1] blev=0,btyp=L w=7 a+d=11+2 face=10
 20  140: CHAR[f] str=0x66fe6eaf[2] blev=0,btyp=L w=7 a+d=11+2 face=10
 21  147: CHAR[f] str=0x66fe6eaf[3] blev=0,btyp=L w=7 a+d=11+2 face=10
 22  154: CHAR[e] str=0x66fe6eaf[4] blev=0,btyp=L w=7 a+d=11+2 face=10
 23  161: CHAR[r] str=0x66fe6eaf[5] blev=0,btyp=L w=7 a+d=11+2 face=10
 24  168: CHAR[s] str=0x66fe6eaf[6] blev=0,btyp=L w=7 a+d=11+2 face=10
 25  175: CHAR[ ] str=0x66fe6eaf[-1] blev=0,btyp=B w=7 a+d=11+2 face=10
 26  182: CHAR[T] str=0x6705081b[0] blev=0,btyp=L w=7 a+d=11+2 face=10
 27  189: CHAR[o] str=0x6705081b[1] blev=0,btyp=L w=7 a+d=11+2 face=10
 28  196: CHAR[o] str=0x6705081b[2] blev=0,btyp=L w=7 a+d=11+2 face=10
 29  203: CHAR[l] str=0x6705081b[3] blev=0,btyp=L w=7 a+d=11+2 face=10
 30  210: CHAR[s] str=0x6705081b[4] blev=0,btyp=L w=7 a+d=11+2 face=10
 31  217: CHAR[ ] str=0x6705081b[-1] blev=0,btyp=B w=7 a+d=11+2 face=10
 32  224: CHAR[L] str=0x6703c7ae[0] blev=0,btyp=L w=7 a+d=11+2 face=10
 33  231: CHAR[i] str=0x6703c7ae[1] blev=0,btyp=L w=7 a+d=11+2 face=10
 34  238: CHAR[s] str=0x6703c7ae[2] blev=0,btyp=L w=7 a+d=11+2 face=10
 35  245: CHAR[p] str=0x6703c7ae[3] blev=0,btyp=L w=7 a+d=11+2 face=10
 36  252: CHAR[-] str=0x6703c7ae[4] blev=0,btyp=L w=7 a+d=11+2 face=10
 37  259: CHAR[I] str=0x6703c7ae[5] blev=0,btyp=L w=7 a+d=11+2 face=10
 38  266: CHAR[n] str=0x6703c7ae[6] blev=0,btyp=L w=7 a+d=11+2 face=10
 39  273: CHAR[t] str=0x6703c7ae[7] blev=0,btyp=L w=7 a+d=11+2 face=10
 40  280: CHAR[e] str=0x6703c7ae[8] blev=0,btyp=L w=7 a+d=11+2 face=10
 41  287: CHAR[r] str=0x6703c7ae[9] blev=0,btyp=L w=7 a+d=11+2 face=10
 42  294: CHAR[a] str=0x6703c7ae[10] blev=0,btyp=L w=7 a+d=11+2 face=10
 43  301: CHAR[c] str=0x6703c7ae[11] blev=0,btyp=L w=7 a+d=11+2 face=10
 44  308: CHAR[t] str=0x6703c7ae[12] blev=0,btyp=L w=7 a+d=11+2 face=10
 45  315: CHAR[i] str=0x6703c7ae[13] blev=0,btyp=L w=7 a+d=11+2 face=10
 46  322: CHAR[o] str=0x6703c7ae[14] blev=0,btyp=L w=7 a+d=11+2 face=10
 47  329: CHAR[n] str=0x6703c7ae[15] blev=0,btyp=L w=7 a+d=11+2 face=10
 48  336: CHAR[ ] str=0x6703c7ae[-1] blev=0,btyp=B w=7 a+d=11+2 face=10
 49  343: CHAR[H] str=0x66fd99ec[0] blev=0,btyp=L w=7 a+d=11+2 face=10
 50  350: CHAR[e] str=0x66fd99ec[1] blev=0,btyp=L w=7 a+d=11+2 face=10
 51  357: CHAR[l] str=0x66fd99ec[2] blev=0,btyp=L w=7 a+d=11+2 face=10
 52  364: CHAR[p] str=0x66fd99ec[3] blev=0,btyp=L w=7 a+d=11+2 face=10
 53  371: CHAR[ ] str=0x66fd99ec[-1] blev=0,btyp=B w=7 a+d=11+2 face=10
 54  378: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 55  385: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 56  392: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 57  399: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 58  406: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 59  413: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 60  420: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 61  427: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 62  434: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 63  441: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 64  448: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 65  455: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 66  462: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 67  469: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 68  476: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 69  483: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 70  490: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 71  497: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 72  504: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 73  511: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 74  518: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 75  525: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 76  532: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 77  539: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 78  546: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 79  553: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 80  560: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 81  567: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 82  574: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 83  581: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 84  588: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 85  595: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 86  602: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 87  609: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 88  616: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 89  623: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 90  630: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 91  637: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 92  644: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 93  651: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 94  658: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 95  665: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 96  672: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 97  679: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 98  686: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
 99  693: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
100  700: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
101  707: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
102  714: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
103  721: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
104  728: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
105  735: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
106  742: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
107  749: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
108  756: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
109  763: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
110  770: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
111  777: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
112  784: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
113  791: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
114  798: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
115  805: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
116  812: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
117  819: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
118  826: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
119  833: CHAR[ ] pos=-1 blev=0,btyp=B w=7 a+d=11+2 face=10
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-11 14:59                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-11 15:58                   ` Eli Zaretskii
  2023-09-11 18:56                     ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Eli Zaretskii @ 2023-09-11 15:58 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: luangruo, stefankangas, 64440

> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Cc: luangruo@yahoo.com,  stefankangas@gmail.com,  64440@debbugs.gnu.org
> Date: Mon, 11 Sep 2023 16:59:11 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> [...]
> 
> >> Is that what you are looking for?
> >
> > This gives some of the answers, but the command 'pgrow' (defined on
> > src/.gdbinit) would have done that better, and would also show the
> > glyphs themselves.  Can you show what 'pgrow' produces in this case?
> 
> Here is what I get:
> 
> (gdb) pgrow
> TEXT: 120 glyphs
>   0    0: CHAR[F] str=0x66f834da[0] blev=0,btyp=L w=7 a+d=11+2 face=10
>   1    7: CHAR[i] str=0x66f834da[1] blev=0,btyp=L w=7 a+d=11+2 face=10
>   2   14: CHAR[l] str=0x66f834da[2] blev=0,btyp=L w=7 a+d=11+2 face=10
>   3   21: CHAR[e] str=0x66f834da[3] blev=0,btyp=L w=7 a+d=11+2 face=10
>   4   28: CHAR[ ] str=0x66f834da[-1] blev=0,btyp=B w=7 a+d=11+2 face=10
>   5   35: CHAR[E] str=0x66fede1c[0] blev=0,btyp=L w=7 a+d=11+2 face=10
>   6   42: CHAR[d] str=0x66fede1c[1] blev=0,btyp=L w=7 a+d=11+2 face=10
>   7   49: CHAR[i] str=0x66fede1c[2] blev=0,btyp=L w=7 a+d=11+2 face=10
>   8   56: CHAR[t] str=0x66fede1c[3] blev=0,btyp=L w=7 a+d=11+2 face=10
>   9   63: CHAR[ ] str=0x66fede1c[-1] blev=0,btyp=B w=7 a+d=11+2 face=10

Thanks.  That's what I imagined we have there.  So I guess considering
that a string ends where is SCHARS end is reasonable.

But note that the above means you could also detect where each item
ends by looking for the glyph whose string position is -1.  So maybe
add an assertion there that the glyph after the last character has its
position as -1, in case we could have some complications there with
double-width characters or something.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-11 15:58                   ` Eli Zaretskii
@ 2023-09-11 18:56                     ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-11 19:12                       ` Eli Zaretskii
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-11 18:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, stefankangas, 64440

Eli Zaretskii <eliz@gnu.org> writes:

[...]

> Thanks.  That's what I imagined we have there.  So I guess considering
> that a string ends where is SCHARS end is reasonable.
>
> But note that the above means you could also detect where each item
> ends by looking for the glyph whose string position is -1.  So maybe
> add an assertion there that the glyph after the last character has its
> position as -1, in case we could have some complications there with
> double-width characters or something.

What do you think of this:

+  /* Convert to pixels bounds.  */
+  row = MATRIX_ROW (w->current_matrix, *vpos);
+  *x_start = 0;
+  for (i = 0; i < *h_start; ++i)
+    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
+
+  *x_end = *x_start;
+  for (i = *h_start; CHARPOS (row->glyphs[TEXT_AREA][i]) != -1; ++i)
+    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-11 18:56                     ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-11 19:12                       ` Eli Zaretskii
  2023-09-11 20:51                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Eli Zaretskii @ 2023-09-11 19:12 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: luangruo, stefankangas, 64440

> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Cc: luangruo@yahoo.com,  stefankangas@gmail.com,  64440@debbugs.gnu.org
> Date: Mon, 11 Sep 2023 20:56:37 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> [...]
> 
> > Thanks.  That's what I imagined we have there.  So I guess considering
> > that a string ends where is SCHARS end is reasonable.
> >
> > But note that the above means you could also detect where each item
> > ends by looking for the glyph whose string position is -1.  So maybe
> > add an assertion there that the glyph after the last character has its
> > position as -1, in case we could have some complications there with
> > double-width characters or something.
> 
> What do you think of this:
> 
> +  /* Convert to pixels bounds.  */
> +  row = MATRIX_ROW (w->current_matrix, *vpos);
> +  *x_start = 0;
> +  for (i = 0; i < *h_start; ++i)
> +    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
> +
> +  *x_end = *x_start;
> +  for (i = *h_start; CHARPOS (row->glyphs[TEXT_AREA][i]) != -1; ++i)
> +    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;

That's OK, but I think we should also make sure 'i' never exceeds the
value row->used[TEXT_AREA] - 1.  This is only important for the last
item, but still.

And I would also add an assertion that row->reversed_p is false.  We
don't currently support R2L menu bars, but if we ever do, the above
loops should go backwards in such glyph rows.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-11 19:12                       ` Eli Zaretskii
@ 2023-09-11 20:51                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-12 11:13                           ` Eli Zaretskii
  2023-09-12 11:26                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-11 20:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: luangruo, stefankangas, 64440

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Manuel Giraud <manuel@ledu-giraud.fr>
>> Cc: luangruo@yahoo.com,  stefankangas@gmail.com,  64440@debbugs.gnu.org
>> Date: Mon, 11 Sep 2023 20:56:37 +0200
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> [...]
>> 
>> > Thanks.  That's what I imagined we have there.  So I guess considering
>> > that a string ends where is SCHARS end is reasonable.
>> >
>> > But note that the above means you could also detect where each item
>> > ends by looking for the glyph whose string position is -1.  So maybe
>> > add an assertion there that the glyph after the last character has its
>> > position as -1, in case we could have some complications there with
>> > double-width characters or something.
>> 
>> What do you think of this:
>> 
>> +  /* Convert to pixels bounds.  */
>> +  row = MATRIX_ROW (w->current_matrix, *vpos);
>> +  *x_start = 0;
>> +  for (i = 0; i < *h_start; ++i)
>> +    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
>> +
>> +  *x_end = *x_start;
>> +  for (i = *h_start; CHARPOS (row->glyphs[TEXT_AREA][i]) != -1; ++i)
>> +    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;
>
> That's OK, but I think we should also make sure 'i' never exceeds the
> value row->used[TEXT_AREA] - 1.  This is only important for the last
> item, but still.
>
> And I would also add an assertion that row->reversed_p is false.  We
> don't currently support R2L menu bars, but if we ever do, the above
> loops should go backwards in such glyph rows.

Ok.  Here is the full version of the second patch:

From 4420fde7757a9b02087c4330c6102cb40c9e4038 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Mon, 3 Jul 2023 17:35:06 +0200
Subject: [PATCH 2/2] Highlight on non toolkit menu bar items

* src/xdisp.c (get_menu_bar_item, note_menu_bar_highlight): New
functions to highlight item in the menu-bar.
(note_mouse_highlight): Use it.
---
 src/xdisp.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 135 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index ca7e3b9743e..b194837e69c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13922,6 +13922,131 @@ update_menu_bar (struct frame *f, bool save_match_data, bool hooks_run)
   return hooks_run;
 }
 
+#if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR
+
+/* Get information about the menu-bar item at position X/Y on frame F.
+   Return menu-bar's item char position in H_START/H_END and pixel
+   position in X_START/X_END.  Value is
+
+   -1	if X/Y is not on a menu-bar item
+   0	if X/Y is on the same item that was highlighted before.
+   1	otherwise.  */
+
+static int
+get_menu_bar_item (struct frame *f, int x, int y, int *h_start, int *h_end,
+		   int *x_start, int *x_end, int *vpos)
+{
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+  struct window *w = XWINDOW (f->menu_bar_window);
+  struct glyph_row *row;
+  int dummy;
+  Lisp_Object items;
+  int i;
+
+  /* Find glyph's hpos and vpos under X/Y.  */
+  if (x_y_to_hpos_vpos (w, x, y, h_start, vpos, NULL, NULL, &dummy) == NULL)
+    return -1;
+
+  /* We do not support R2L menu bar.  */
+  row = MATRIX_ROW (w->current_matrix, *vpos);
+  if (row->reversed_p)
+    return -1;
+
+  /* Compute h_start and h_end for this menu bar item.  */
+  items = FRAME_MENU_BAR_ITEMS (f);
+  for (i = 0; i < ASIZE (items); i += 4)
+    {
+      Lisp_Object pos, string;
+      string = AREF (items, i + 1);
+      pos = AREF (items, i + 3);
+      if (NILP (string))
+	return -1;
+      if (*h_start >= XFIXNUM (pos)
+	  && *h_start < XFIXNUM (pos) + SCHARS (string))
+	{
+	  *h_start = XFIXNUM (pos);
+	  *h_end = *h_start + SCHARS (string);
+	  break;
+	}
+    }
+
+  /* Convert to pixels bounds.  */
+  *x_start = 0;
+  for (i = 0; i < *h_start; ++i)
+    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
+
+  *x_end = *x_start;
+  for (i = *h_start;
+       CHARPOS (row->glyphs[TEXT_AREA][i]) != -1
+	 && i < row->used[TEXT_AREA];
+       ++i)
+    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;
+
+  /* Is mouse on the highlighted item?  */
+  if (EQ (f->menu_bar_window, hlinfo->mouse_face_window)
+      && *vpos >= hlinfo->mouse_face_beg_row
+      && *vpos <= hlinfo->mouse_face_end_row
+      && (*vpos > hlinfo->mouse_face_beg_row
+	  || *h_start >= hlinfo->mouse_face_beg_col)
+      && (*vpos < hlinfo->mouse_face_end_row
+	  || *h_end < hlinfo->mouse_face_end_col
+	  || hlinfo->mouse_face_past_end))
+    return 0;
+
+  return 1;
+}
+
+/* Possibly highlight a menu-bar item on frame F when mouse moves to
+   menu-bar window-relative coordinates X/Y.  Called from
+   note_mouse_highlight.  */
+
+static void
+note_menu_bar_highlight (struct frame *f, int x, int y)
+{
+  Lisp_Object window = f->menu_bar_window;
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+  int h_start, h_end, vpos, x_start, x_end;
+  int rc;
+
+  /* Function note_mouse_highlight is called with negative X/Y
+     values when mouse moves outside of the frame.  */
+  if (x <= 0 || y <= 0)
+    {
+      clear_mouse_face (hlinfo);
+      return;
+    }
+
+  h_start = h_end = 0;
+  rc = get_menu_bar_item (f, x, y, &h_start, &h_end, &x_start, &x_end, &vpos);
+  if (rc < 0)
+    {
+      /* Not on menu-bar item.  */
+      clear_mouse_face (hlinfo);
+      return;
+    }
+  else if (rc == 0)
+    /* On same menu-bar item as before.  */
+    return;
+
+  if (!NILP (Vmouse_highlight))
+    {
+      /* Record this as the current active region.  */
+      hlinfo->mouse_face_beg_col = h_start;
+      hlinfo->mouse_face_beg_row = vpos;
+      hlinfo->mouse_face_beg_x = x_start;
+      hlinfo->mouse_face_past_end = false;
+
+      hlinfo->mouse_face_end_col = h_end;
+      hlinfo->mouse_face_end_row = vpos;
+      hlinfo->mouse_face_end_x = x_end;
+      hlinfo->mouse_face_window = window;
+      hlinfo->mouse_face_face_id = MENU_FACE_ID;
+
+      /* Display it as active.  */
+      show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
+    }
+}
+#endif
 \f
 
 /***********************************************************************
@@ -35538,6 +35663,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
 
+#if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR
+  /* Handle menu-bar window differently since it doesn't display a
+     buffer.  */
+  if (EQ (window, f->menu_bar_window))
+    {
+      note_menu_bar_highlight (f, x, y);
+      return;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* Handle tab-bar window differently since it doesn't display a
      buffer.  */
-- 
2.40.0

-- 
Manuel Giraud





^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-11 20:51                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-12 11:13                           ` Eli Zaretskii
  2023-09-12 11:26                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 54+ messages in thread
From: Eli Zaretskii @ 2023-09-12 11:13 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: luangruo, stefankangas, 64440

> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Cc: luangruo@yahoo.com,  stefankangas@gmail.com,  64440@debbugs.gnu.org
> Date: Mon, 11 Sep 2023 22:51:31 +0200
> 
> Ok.  Here is the full version of the second patch:

LGTM, thanks.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-11 20:51                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-12 11:13                           ` Eli Zaretskii
@ 2023-09-12 11:26                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-12 12:48                             ` Eli Zaretskii
  1 sibling, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-12 11:26 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, stefankangas, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> +#if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR
> +
> +/* Get information about the menu-bar item at position X/Y on frame F.
> +   Return menu-bar's item char position in H_START/H_END and pixel
> +   position in X_START/X_END.  Value is
> +
> +   -1	if X/Y is not on a menu-bar item
> +   0	if X/Y is on the same item that was highlighted before.
> +   1	otherwise.  */
> +
> +static int
> +get_menu_bar_item (struct frame *f, int x, int y, int *h_start, int *h_end,
> +		   int *x_start, int *x_end, int *vpos)
> +{
> +  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
> +  struct window *w = XWINDOW (f->menu_bar_window);
> +  struct glyph_row *row;
> +  int dummy;
> +  Lisp_Object items;
> +  int i;
> +
> +  /* Find glyph's hpos and vpos under X/Y.  */
> +  if (x_y_to_hpos_vpos (w, x, y, h_start, vpos, NULL, NULL, &dummy) == NULL)
> +    return -1;
> +
> +  /* We do not support R2L menu bar.  */
> +  row = MATRIX_ROW (w->current_matrix, *vpos);
> +  if (row->reversed_p)
> +    return -1;
> +
> +  /* Compute h_start and h_end for this menu bar item.  */
> +  items = FRAME_MENU_BAR_ITEMS (f);
> +  for (i = 0; i < ASIZE (items); i += 4)
> +    {
> +      Lisp_Object pos, string;
> +      string = AREF (items, i + 1);
> +      pos = AREF (items, i + 3);
> +      if (NILP (string))
> +	return -1;
> +      if (*h_start >= XFIXNUM (pos)
> +	  && *h_start < XFIXNUM (pos) + SCHARS (string))
> +	{
> +	  *h_start = XFIXNUM (pos);
> +	  *h_end = *h_start + SCHARS (string);
> +	  break;
> +	}
> +    }
> +
> +  /* Convert to pixels bounds.  */
> +  *x_start = 0;
> +  for (i = 0; i < *h_start; ++i)
> +    *x_start += row->glyphs[TEXT_AREA][i].pixel_width;
> +
> +  *x_end = *x_start;
> +  for (i = *h_start;
> +       CHARPOS (row->glyphs[TEXT_AREA][i]) != -1
> +	 && i < row->used[TEXT_AREA];
> +       ++i)
> +    *x_end += row->glyphs[TEXT_AREA][i].pixel_width;
> +
> +  /* Is mouse on the highlighted item?  */
> +  if (EQ (f->menu_bar_window, hlinfo->mouse_face_window)
> +      && *vpos >= hlinfo->mouse_face_beg_row
> +      && *vpos <= hlinfo->mouse_face_end_row
> +      && (*vpos > hlinfo->mouse_face_beg_row
> +	  || *h_start >= hlinfo->mouse_face_beg_col)
> +      && (*vpos < hlinfo->mouse_face_end_row
> +	  || *h_end < hlinfo->mouse_face_end_col
> +	  || hlinfo->mouse_face_past_end))
> +    return 0;
> +
> +  return 1;
> +}
> +
> +/* Possibly highlight a menu-bar item on frame F when mouse moves to
> +   menu-bar window-relative coordinates X/Y.  Called from
> +   note_mouse_highlight.  */
> +
> +static void
> +note_menu_bar_highlight (struct frame *f, int x, int y)
> +{
> +  Lisp_Object window = f->menu_bar_window;
> +  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
> +  int h_start, h_end, vpos, x_start, x_end;
> +  int rc;
> +
> +  /* Function note_mouse_highlight is called with negative X/Y
> +     values when mouse moves outside of the frame.  */
> +  if (x <= 0 || y <= 0)
> +    {
> +      clear_mouse_face (hlinfo);
> +      return;
> +    }
> +
> +  h_start = h_end = 0;
> +  rc = get_menu_bar_item (f, x, y, &h_start, &h_end, &x_start, &x_end, &vpos);
> +  if (rc < 0)
> +    {
> +      /* Not on menu-bar item.  */
> +      clear_mouse_face (hlinfo);
> +      return;
> +    }
> +  else if (rc == 0)
> +    /* On same menu-bar item as before.  */
> +    return;
> +
> +  if (!NILP (Vmouse_highlight))
> +    {
> +      /* Record this as the current active region.  */
> +      hlinfo->mouse_face_beg_col = h_start;
> +      hlinfo->mouse_face_beg_row = vpos;
> +      hlinfo->mouse_face_beg_x = x_start;
> +      hlinfo->mouse_face_past_end = false;
> +
> +      hlinfo->mouse_face_end_col = h_end;
> +      hlinfo->mouse_face_end_row = vpos;
> +      hlinfo->mouse_face_end_x = x_end;
> +      hlinfo->mouse_face_window = window;
> +      hlinfo->mouse_face_face_id = MENU_FACE_ID;
> +
> +      /* Display it as active.  */
> +      show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
> +    }
> +}
> +#endif
>  \f
>  
>  /***********************************************************************
> @@ -35538,6 +35663,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
>    w = XWINDOW (window);
>    frame_to_window_pixel_xy (w, &x, &y);
>  
> +#if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR
> +  /* Handle menu-bar window differently since it doesn't display a
> +     buffer.  */
> +  if (EQ (window, f->menu_bar_window))
> +    {
> +      note_menu_bar_highlight (f, x, y);
> +      return;
> +    }
> +#endif
> +

Thanks, but I'd prefer an option to disable this.  Additionally, could
you insert the preprocessor condition in a comment after each #endif?
Some of the preprocessor blocks are very long.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 11:26                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-12 12:48                             ` Eli Zaretskii
  2023-09-12 13:06                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Eli Zaretskii @ 2023-09-12 12:48 UTC (permalink / raw)
  To: Po Lu; +Cc: stefankangas, manuel, 64440

> From: Po Lu <luangruo@yahoo.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,  stefankangas@gmail.com,
>   64440@debbugs.gnu.org
> Date: Tue, 12 Sep 2023 19:26:20 +0800
> 
> Thanks, but I'd prefer an option to disable this.

We already have it: mouse-highlight.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 12:48                             ` Eli Zaretskii
@ 2023-09-12 13:06                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-12 13:15                                 ` Eli Zaretskii
  0 siblings, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-12 13:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: stefankangas, manuel, 64440

Eli Zaretskii <eliz@gnu.org> writes:

> We already have it: mouse-highlight.

mouse-highlight disables all mouse highlighting, while I specifically
want to disable mouse highlight on the menu bar.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 13:06                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-12 13:15                                 ` Eli Zaretskii
  2023-09-12 13:19                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Eli Zaretskii @ 2023-09-12 13:15 UTC (permalink / raw)
  To: Po Lu; +Cc: stefankangas, manuel, 64440

> From: Po Lu <luangruo@yahoo.com>
> Cc: manuel@ledu-giraud.fr,  stefankangas@gmail.com,  64440@debbugs.gnu.org
> Date: Tue, 12 Sep 2023 21:06:48 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > We already have it: mouse-highlight.
> 
> mouse-highlight disables all mouse highlighting, while I specifically
> want to disable mouse highlight on the menu bar.

Why?  In a GUI build, hovering the mouse above the menu bar causes the
buttons to react, at least here on MS-Windows.

And how is this different from, say, mouse-highlight of the mode line
or tool bar?





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 13:15                                 ` Eli Zaretskii
@ 2023-09-12 13:19                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-12 13:34                                     ` Eli Zaretskii
  0 siblings, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-12 13:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: stefankangas, manuel, 64440

Eli Zaretskii <eliz@gnu.org> writes:

> Why?  In a GUI build, hovering the mouse above the menu bar causes the
> buttons to react, at least here on MS-Windows.

No X toolkit does: GTK, Lucid, Motif, among others.

> And how is this different from, say, mouse-highlight of the mode line
> or tool bar?

I don't find the latter distracting, but I do when the highlight is on
the menu bar.  Please, let's not argue over this, when the alternative
is to introduce what is at the maximum 10 lines of straightforward code.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 13:19                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-12 13:34                                     ` Eli Zaretskii
  2023-09-12 13:42                                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Eli Zaretskii @ 2023-09-12 13:34 UTC (permalink / raw)
  To: Po Lu; +Cc: stefankangas, manuel, 64440

> From: Po Lu <luangruo@yahoo.com>
> Cc: manuel@ledu-giraud.fr,  stefankangas@gmail.com,  64440@debbugs.gnu.org
> Date: Tue, 12 Sep 2023 21:19:58 +0800
> 
> Please, let's not argue over this, when the alternative is to
> introduce what is at the maximum 10 lines of straightforward code.

I could agree if you applied the same standards and criteria to
arguments where you are the party that is being asked to write or
change a few lines.  There, you tend to argue endlessly, it seems.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 13:34                                     ` Eli Zaretskii
@ 2023-09-12 13:42                                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-12 13:56                                         ` Stefan Kangas
  2023-09-13 16:48                                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-12 13:42 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: stefankangas, manuel, 64440

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Po Lu <luangruo@yahoo.com>
>> Cc: manuel@ledu-giraud.fr,  stefankangas@gmail.com,  64440@debbugs.gnu.org
>> Date: Tue, 12 Sep 2023 21:19:58 +0800
>> 
>> Please, let's not argue over this, when the alternative is to
>> introduce what is at the maximum 10 lines of straightforward code.
>
> I could agree if you applied the same standards and criteria to
> arguments where you are the party that is being asked to write or
> change a few lines.  There, you tend to argue endlessly, it seems.

I try my best, but sometimes it's challenging not to get worked up over
these things.  I hope that doesn't happen here: no other program on Unix
systems highlight menu bar entries as the mouse pointer enters them.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 13:42                                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-12 13:56                                         ` Stefan Kangas
  2023-09-12 14:06                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-13 16:48                                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 54+ messages in thread
From: Stefan Kangas @ 2023-09-12 13:56 UTC (permalink / raw)
  To: Po Lu, Eli Zaretskii; +Cc: 64440, manuel

Po Lu <luangruo@yahoo.com> writes:

> no other program on Unix systems highlight menu bar entries as the
> mouse pointer enters them.

I don't think that's true?  See the below screenshots.

X11:
https://i.stack.imgur.com/TjgyR.png

Gnome:
https://www.howtogeek.com/wp-content/uploads/2014/05/08_gnome_desktop_with_menu.png

KDE:
https://news-cdn.softpedia.com/images/news2/kde-kicks-off-2017-in-style-with-kde-plasma-5-9-beta-brings-back-global-menus-511786-4.jpg





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 13:56                                         ` Stefan Kangas
@ 2023-09-12 14:06                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-12 14:27                                             ` Stefan Kangas
  0 siblings, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-12 14:06 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Eli Zaretskii, 64440, manuel

Stefan Kangas <stefankangas@gmail.com> writes:

> Po Lu <luangruo@yahoo.com> writes:
>
>> no other program on Unix systems highlight menu bar entries as the
>> mouse pointer enters them.
>
> I don't think that's true?  See the below screenshots.
>
> X11:
> https://i.stack.imgur.com/TjgyR.png
>
> Gnome:
> https://www.howtogeek.com/wp-content/uploads/2014/05/08_gnome_desktop_with_menu.png
>
> KDE:
> https://news-cdn.softpedia.com/images/news2/kde-kicks-off-2017-in-style-with-kde-plasma-5-9-beta-brings-back-global-menus-511786-4.jpg

These are menu entries, not menu _bar_ entries.  The latter are not
highlighted upon the mouse entering them, but after they are selected,
making this all moot in Emacs as the popup menu obscures the menu bar.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 14:06                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-09-12 14:27                                             ` Stefan Kangas
  0 siblings, 0 replies; 54+ messages in thread
From: Stefan Kangas @ 2023-09-12 14:27 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, 64440, manuel

Po Lu <luangruo@yahoo.com> writes:

> These are menu entries, not menu _bar_ entries.  The latter are not
> highlighted upon the mouse entering them, but after they are selected,
> making this all moot in Emacs as the popup menu obscures the menu bar.

Thanks, I seem to have misunderstood what this was about.  Please ignore
the noise.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-12 13:42                                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-12 13:56                                         ` Stefan Kangas
@ 2023-09-13 16:48                                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-06 12:49                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-13 16:48 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

Po Lu <luangruo@yahoo.com> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Po Lu <luangruo@yahoo.com>
>>> Cc: manuel@ledu-giraud.fr,  stefankangas@gmail.com,  64440@debbugs.gnu.org
>>> Date: Tue, 12 Sep 2023 21:19:58 +0800
>>> 
>>> Please, let's not argue over this, when the alternative is to
>>> introduce what is at the maximum 10 lines of straightforward code.
>>
>> I could agree if you applied the same standards and criteria to
>> arguments where you are the party that is being asked to write or
>> change a few lines.  There, you tend to argue endlessly, it seems.
>
> I try my best, but sometimes it's challenging not to get worked up over
> these things.  I hope that doesn't happen here: no other program on Unix
> systems highlight menu bar entries as the mouse pointer enters them.

Ok.  I'm going to explain my history behind this patch:

I was annoyed by the fact that moving the mouse pointer from a buffer to
the menu bar most of the time (in no toolkit build anyway), the mouse
pointer keeps its "vertical bar" form.  So that was, at first, what I
wanted to change.

I then look at the code and discover those 'note_*_highlight' functions
and how they are used to highlight areas (buttons) on the tool bar or
the tab bar.  And I thought "why not use this feature?  it could be even
better than what I wanted!"

But now, I'm not so sure.  Just changing the mouse pointer (to an arrow,
for instance) when entering the menu bar might be sufficient (and what
was my first intent).  And I don't think that it should respect
'mouse-highlight' BTW.

What do you think, if I rework my patch with this idea in mind?
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-09-13 16:48                                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-06 12:49                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-06 13:14                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-06 12:49 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

[-- Attachment #1: Type: text/plain, Size: 223 bytes --]

Hi,

Here is an updated set of patches that address the issue I had.  There
is no more highlighting above menu entries now and just a change in the
mouse cursor.  This only affects the "no" toolkit build.
-- 
Manuel Giraud

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Possibility-to-get-enter-event-from-menu_bar-window.patch --]
[-- Type: text/x-patch, Size: 12751 bytes --]

From a0c8f7e5909c6b4f84f21030680da2bd09fa229a Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 6 Oct 2023 14:27:00 +0200
Subject: [PATCH 1/2] Possibility to get enter event from menu_bar window

---
 src/haikuterm.c |  8 ++++----
 src/keyboard.c  |  2 +-
 src/msdos.c     |  2 +-
 src/pgtkterm.c  |  4 ++--
 src/w32inevt.c  |  2 +-
 src/w32term.c   |  8 ++++----
 src/window.c    | 20 ++++++++++++++++++--
 src/window.h    |  2 +-
 src/xdisp.c     |  4 ++--
 src/xterm.c     | 17 +++++++++--------
 10 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/src/haikuterm.c b/src/haikuterm.c
index b1a016b49a9..bcb5055ea42 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -3472,7 +3472,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		if (!NILP (Vmouse_autoselect_window))
 		  {
 		    static Lisp_Object last_mouse_window;
-		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0);
+		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0, 0);
 
 		    if (WINDOWP (window)
 			&& !EQ (window, last_mouse_window)
@@ -3555,7 +3555,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tab_bar_p = EQ (window, f->tab_bar_window);
 
 		if (tab_bar_p)
@@ -3573,7 +3573,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (type != BUTTON_UP
 				  || f->last_tool_bar_item != -1));
@@ -3834,7 +3834,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 
 	    BView_get_mouse (FRAME_HAIKU_VIEW (f), &x, &y);
 
-	    wheel_window = window_from_coordinates (f, x, y, 0, false, false);
+	    wheel_window = window_from_coordinates (f, x, y, 0, false, false, false);
 
 	    if (NILP (wheel_window))
 	      {
diff --git a/src/keyboard.c b/src/keyboard.c
index f756f163e87..fc567488e7c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5549,7 +5549,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
   int xret = 0, yret = 0;
   /* The window or frame under frame pixel coordinates (x,y)  */
   Lisp_Object window_or_frame = f
-    ? window_from_coordinates (f, mx, my, &part, true, true)
+    ? window_from_coordinates (f, mx, my, &part, true, true, true)
     : Qnil;
 #ifdef HAVE_WINDOW_SYSTEM
   bool tool_bar_p = false;
diff --git a/src/msdos.c b/src/msdos.c
index 1b7f2d4ae21..5dd7c1573c4 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2662,7 +2662,7 @@ dos_rawgetc (void)
 	      static Lisp_Object last_mouse_window;
 
 	      mouse_window = window_from_coordinates
-		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0);
+		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0, 0);
 	      /* A window will be selected only when it is not
 		 selected now, and the last mouse movement event was
 		 not in it.  A minibuffer window will be selected iff
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index a7c687d811d..461c9d6d899 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -5894,7 +5894,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
 	{
 	  static Lisp_Object last_mouse_window;
 	  Lisp_Object window = window_from_coordinates
-	    (f, event->motion.x, event->motion.y, 0, false, false);
+	    (f, event->motion.x, event->motion.y, 0, false, false, false);
 
 	  /* A window will be autoselected only when it is not
 	     selected now and the last mouse movement event was
@@ -6047,7 +6047,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
 	  int x = event->button.x;
 	  int y = event->button.y;
 
-	  window = window_from_coordinates (f, x, y, 0, true, true);
+	  window = window_from_coordinates (f, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, f->tab_bar_window);
 
 	  if (tab_bar_p)
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 29717954cfd..630a9f4e5fb 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -496,7 +496,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
 	    if (!NILP (Vmouse_autoselect_window))
 	      {
 		Lisp_Object mouse_window = window_from_coordinates (f, mx, my,
-								    0, 0, 0);
+								    0, 0, 0, 0);
 		/* A window will be selected only when it is not
 		   selected now, and the last mouse movement event was
 		   not in it.  A minibuffer window will be selected iff
diff --git a/src/w32term.c b/src/w32term.c
index a5f17a18213..301d8f4ef12 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3376,7 +3376,7 @@ w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg,
       if (w32_wheel_scroll_lines == UINT_MAX)
 	{
 	  Lisp_Object window = window_from_coordinates (f, p.x, p.y, NULL,
-							false, false);
+							false, false, false);
 	  if (!WINDOWP (window))
 	    {
 	      result->kind = NO_EVENT;
@@ -5335,7 +5335,7 @@ w32_read_socket (struct terminal *terminal,
 		{
 		  static Lisp_Object last_mouse_window;
 		  Lisp_Object window = window_from_coordinates
-		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0);
+		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0, 0);
 
 		  /* Window will be selected only when it is not
 		     selected now and last mouse movement event was
@@ -5407,7 +5407,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tab_bar_window))
                       {
@@ -5435,7 +5435,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tool_bar_window)
 			/* Make sure the tool bar was previously
diff --git a/src/window.c b/src/window.c
index 968b982c135..e802ffb3fe2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1680,7 +1680,8 @@ check_window_containing (struct window *w, void *user_data)
 
 Lisp_Object
 window_from_coordinates (struct frame *f, int x, int y,
-			 enum window_part *part, bool tab_bar_p, bool tool_bar_p)
+			 enum window_part *part, bool menu_bar_p,
+			 bool tab_bar_p, bool tool_bar_p)
 {
   Lisp_Object window;
   struct check_window_data cw;
@@ -1693,6 +1694,21 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* If not found above, see if it's in the menu bar window, if a menu
+     bar exists.  */
+  if (NILP (window)
+      && menu_bar_p
+      && WINDOWP (f->menu_bar_window)
+      && WINDOW_TOTAL_LINES (XWINDOW (f->menu_bar_window)) > 0
+      && (coordinates_in_window (XWINDOW (f->menu_bar_window), x, y)
+	  != ON_NOTHING))
+    {
+      *part = ON_TEXT;
+      window = f->menu_bar_window;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* If not found above, see if it's in the tab bar window, if a tab
      bar exists.  */
@@ -1746,7 +1762,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
 				  (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
-				  0, false, false);
+				  0, false, false, false);
 }
 
 ptrdiff_t
diff --git a/src/window.h b/src/window.h
index 413293420fd..9ef8434af18 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1111,7 +1111,7 @@ #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)	\
 
 extern Lisp_Object make_window (void);
 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
-                                            enum window_part *, bool, bool);
+                                            enum window_part *, bool, bool, bool);
 extern void resize_frame_windows (struct frame *, int, bool);
 extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
diff --git a/src/xdisp.c b/src/xdisp.c
index 2c53527c25e..7f9e62f05e8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2778,7 +2778,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
       goto virtual_glyph;
     }
   else if (!f->glyphs_initialized_p
-	   || (window = window_from_coordinates (f, gx, gy, &part, false, false),
+	   || (window = window_from_coordinates (f, gx, gy, &part, false, false, false),
 	       NILP (window)))
     {
       width = FRAME_SMALLEST_CHAR_WIDTH (f);
@@ -35438,7 +35438,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
     return;
 
   /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, true, true);
+  window = window_from_coordinates (f, x, y, &part, true, true, true);
 
   /* If displaying active text in another window, clear that.  */
   if (! EQ (window, hlinfo->mouse_face_window)
diff --git a/src/xterm.c b/src/xterm.c
index 517bdf57aab..d5ca60089d7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -21161,7 +21161,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  }
 
 		Lisp_Object window = window_from_coordinates
-		  (f, xmotion.x, xmotion.y, 0, false, false);
+		  (f, xmotion.x, xmotion.y, 0, false, false, false);
 
 		/* A window will be autoselected only when it is not
 		   selected now and the last mouse movement event was
@@ -21892,7 +21892,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tab_bar_p = EQ (window, f->tab_bar_window);
 
                 if (tab_bar_p)
@@ -21913,7 +21913,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (event->xbutton.type != ButtonRelease
 				  || f->last_tool_bar_item != -1));
@@ -22646,7 +22646,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			    continue;
 
 			  window = window_from_coordinates (f, real_x, real_y, NULL,
-							    false, false);
+							    false, false, false);
 
 			  if (WINDOWP (window))
 			    scroll_height = XWINDOW (window)->pixel_height;
@@ -23089,7 +23089,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			  || !NILP (focus_follows_mouse)))
 		    {
 		      static Lisp_Object last_mouse_window;
-		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
+		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false,
+								    false);
 
 		      /* A window will be autoselected only when it is not
 			 selected now and the last mouse movement event was
@@ -23667,7 +23668,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      tab_bar_p = EQ (window, f->tab_bar_window);
 
 		      if (tab_bar_p)
@@ -23688,7 +23689,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      /* Ignore button release events if the mouse
 			 wasn't previously pressed on the tool bar.
 			 We do this because otherwise selecting some
@@ -24694,7 +24695,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  int x = xev->event_x;
 		  int y = xev->event_y;
 
-		  window = window_from_coordinates (f, x, y, 0, true, true);
+		  window = window_from_coordinates (f, x, y, 0, true, true, true);
 		  /* Ignore button release events if the mouse
 		     wasn't previously pressed on the tool bar.
 		     We do this because otherwise selecting some
-- 
2.40.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Set-non-text-mouse-cursor-on-menu-bar.patch --]
[-- Type: text/x-patch, Size: 1043 bytes --]

From 9200d69b49fa57269e5357383d138872a372127a Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 6 Oct 2023 14:27:02 +0200
Subject: [PATCH 2/2] Set non-text mouse cursor on menu bar

* src/xdisp.c (note_mouse_highlight): Set non-text mouse cursor on
menu bar.
---
 src/xdisp.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index 7f9e62f05e8..df3076cf499 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -35537,6 +35537,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* Handle menu-bar window differently since it doesn't display a
+     buffer.  */
+  if (EQ (window, f->menu_bar_window))
+    {
+      cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
+      goto set_cursor;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* Handle tab-bar window differently since it doesn't display a
      buffer.  */
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-06 12:49                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-06 13:14                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-06 15:39                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-06 13:14 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, stefankangas, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Hi,
>
> Here is an updated set of patches that address the issue I had.  There
> is no more highlighting above menu entries now and just a change in the
> mouse cursor.  This only affects the "no" toolkit build.

If I'm not mistaken, you've neglected to update many other callers of
window_from_coordinates to account for the new calling convention.
Please grep for window_from_coordinates within src/ and update each call
you find.

TIA.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-06 13:14                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-06 15:39                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-06 15:59                                                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-06 15:39 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

Po Lu <luangruo@yahoo.com> writes:

> Manuel Giraud <manuel@ledu-giraud.fr> writes:
>
>> Hi,
>>
>> Here is an updated set of patches that address the issue I had.  There
>> is no more highlighting above menu entries now and just a change in the
>> mouse cursor.  This only affects the "no" toolkit build.
>
> If I'm not mistaken, you've neglected to update many other callers of
> window_from_coordinates to account for the new calling convention.
> Please grep for window_from_coordinates within src/ and update each call
> you find.

Oups sorry when I first did this patch there was no androidterm in the
source tree :-)
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-06 15:39                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-06 15:59                                                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 10:19                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-06 15:59 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

[-- Attachment #1: Type: text/plain, Size: 100 bytes --]

So here is the new version of the first patch.  The second still applies
onto it.
-- 
Manuel Giraud

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Possibility-to-get-enter-event-from-menu_bar-window.patch --]
[-- Type: text/x-patch, Size: 15659 bytes --]

From e4481544b4ce87af2bbc42980d96d35fa8d4a7b8 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 6 Oct 2023 17:54:15 +0200
Subject: [PATCH] Possibility to get enter event from menu_bar window

---
 src/androidterm.c | 10 +++++-----
 src/haikuterm.c   |  8 ++++----
 src/keyboard.c    |  2 +-
 src/msdos.c       |  2 +-
 src/nsterm.m      |  4 ++--
 src/pgtkterm.c    |  4 ++--
 src/w32inevt.c    |  2 +-
 src/w32term.c     |  8 ++++----
 src/window.c      | 20 ++++++++++++++++++--
 src/window.h      |  2 +-
 src/xdisp.c       |  4 ++--
 src/xterm.c       | 17 +++++++++--------
 12 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/src/androidterm.c b/src/androidterm.c
index 9b00ad85642..d6db1359d97 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -1142,7 +1142,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      Lisp_Object window
 		= window_from_coordinates (f, event->xmotion.x,
 					   event->xmotion.y, 0,
-					   false, false);
+					   false, false, false);
 
 	      /* A window will be autoselected only when it is not
 		 selected now and the last mouse movement event was
@@ -1291,7 +1291,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tab_bar_p = EQ (window, f->tab_bar_window);
 
 	      if (tab_bar_p)
@@ -1313,7 +1313,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tool_bar_p = (EQ (window, f->tool_bar_window)
 			    && ((event->xbutton.type
 				 != ANDROID_BUTTON_RELEASE)
@@ -1409,7 +1409,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  int y = event->touch.y;
 
 	  window = window_from_coordinates (any, x, y, 0, true,
-					    true);
+					    true, true);
 
 	  /* If this touch has started in the tool bar, do not
 	     send it to Lisp.  Instead, simulate a tool bar
@@ -1606,7 +1606,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  /* Figure out how much to scale the deltas by.  */
 	  window = window_from_coordinates (any, event->wheel.x,
 					    event->wheel.y, NULL,
-					    false, false);
+					    false, false, false);
 
 	  if (WINDOWP (window))
 	    scroll_height = XWINDOW (window)->pixel_height;
diff --git a/src/haikuterm.c b/src/haikuterm.c
index b1a016b49a9..bcb5055ea42 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -3472,7 +3472,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		if (!NILP (Vmouse_autoselect_window))
 		  {
 		    static Lisp_Object last_mouse_window;
-		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0);
+		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0, 0);
 
 		    if (WINDOWP (window)
 			&& !EQ (window, last_mouse_window)
@@ -3555,7 +3555,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tab_bar_p = EQ (window, f->tab_bar_window);
 
 		if (tab_bar_p)
@@ -3573,7 +3573,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (type != BUTTON_UP
 				  || f->last_tool_bar_item != -1));
@@ -3834,7 +3834,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 
 	    BView_get_mouse (FRAME_HAIKU_VIEW (f), &x, &y);
 
-	    wheel_window = window_from_coordinates (f, x, y, 0, false, false);
+	    wheel_window = window_from_coordinates (f, x, y, 0, false, false, false);
 
 	    if (NILP (wheel_window))
 	      {
diff --git a/src/keyboard.c b/src/keyboard.c
index f756f163e87..fc567488e7c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5549,7 +5549,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
   int xret = 0, yret = 0;
   /* The window or frame under frame pixel coordinates (x,y)  */
   Lisp_Object window_or_frame = f
-    ? window_from_coordinates (f, mx, my, &part, true, true)
+    ? window_from_coordinates (f, mx, my, &part, true, true, true)
     : Qnil;
 #ifdef HAVE_WINDOW_SYSTEM
   bool tool_bar_p = false;
diff --git a/src/msdos.c b/src/msdos.c
index 1b7f2d4ae21..5dd7c1573c4 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2662,7 +2662,7 @@ dos_rawgetc (void)
 	      static Lisp_Object last_mouse_window;
 
 	      mouse_window = window_from_coordinates
-		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0);
+		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0, 0);
 	      /* A window will be selected only when it is not
 		 selected now, and the last mouse movement event was
 		 not in it.  A minibuffer window will be selected iff
diff --git a/src/nsterm.m b/src/nsterm.m
index 4e0dfa58c63..96661b8e227 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7404,7 +7404,7 @@ - (void)mouseDown: (NSEvent *)theEvent
 	  int x = lrint (p.x);
 	  int y = lrint (p.y);
 
-	  window = window_from_coordinates (emacsframe, x, y, 0, true, true);
+	  window = window_from_coordinates (emacsframe, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, emacsframe->tab_bar_window);
 
 	  if (tab_bar_p)
@@ -7510,7 +7510,7 @@ - (void)mouseMoved: (NSEvent *)e
       NSTRACE_MSG ("mouse_autoselect_window");
       static Lisp_Object last_mouse_window;
       Lisp_Object window
-	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0);
+	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0, 0);
 
       if (WINDOWP (window)
           && !EQ (window, last_mouse_window)
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index a7c687d811d..461c9d6d899 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -5894,7 +5894,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
 	{
 	  static Lisp_Object last_mouse_window;
 	  Lisp_Object window = window_from_coordinates
-	    (f, event->motion.x, event->motion.y, 0, false, false);
+	    (f, event->motion.x, event->motion.y, 0, false, false, false);
 
 	  /* A window will be autoselected only when it is not
 	     selected now and the last mouse movement event was
@@ -6047,7 +6047,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
 	  int x = event->button.x;
 	  int y = event->button.y;
 
-	  window = window_from_coordinates (f, x, y, 0, true, true);
+	  window = window_from_coordinates (f, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, f->tab_bar_window);
 
 	  if (tab_bar_p)
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 29717954cfd..630a9f4e5fb 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -496,7 +496,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
 	    if (!NILP (Vmouse_autoselect_window))
 	      {
 		Lisp_Object mouse_window = window_from_coordinates (f, mx, my,
-								    0, 0, 0);
+								    0, 0, 0, 0);
 		/* A window will be selected only when it is not
 		   selected now, and the last mouse movement event was
 		   not in it.  A minibuffer window will be selected iff
diff --git a/src/w32term.c b/src/w32term.c
index a5f17a18213..301d8f4ef12 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3376,7 +3376,7 @@ w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg,
       if (w32_wheel_scroll_lines == UINT_MAX)
 	{
 	  Lisp_Object window = window_from_coordinates (f, p.x, p.y, NULL,
-							false, false);
+							false, false, false);
 	  if (!WINDOWP (window))
 	    {
 	      result->kind = NO_EVENT;
@@ -5335,7 +5335,7 @@ w32_read_socket (struct terminal *terminal,
 		{
 		  static Lisp_Object last_mouse_window;
 		  Lisp_Object window = window_from_coordinates
-		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0);
+		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0, 0);
 
 		  /* Window will be selected only when it is not
 		     selected now and last mouse movement event was
@@ -5407,7 +5407,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tab_bar_window))
                       {
@@ -5435,7 +5435,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tool_bar_window)
 			/* Make sure the tool bar was previously
diff --git a/src/window.c b/src/window.c
index 968b982c135..e802ffb3fe2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1680,7 +1680,8 @@ check_window_containing (struct window *w, void *user_data)
 
 Lisp_Object
 window_from_coordinates (struct frame *f, int x, int y,
-			 enum window_part *part, bool tab_bar_p, bool tool_bar_p)
+			 enum window_part *part, bool menu_bar_p,
+			 bool tab_bar_p, bool tool_bar_p)
 {
   Lisp_Object window;
   struct check_window_data cw;
@@ -1693,6 +1694,21 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* If not found above, see if it's in the menu bar window, if a menu
+     bar exists.  */
+  if (NILP (window)
+      && menu_bar_p
+      && WINDOWP (f->menu_bar_window)
+      && WINDOW_TOTAL_LINES (XWINDOW (f->menu_bar_window)) > 0
+      && (coordinates_in_window (XWINDOW (f->menu_bar_window), x, y)
+	  != ON_NOTHING))
+    {
+      *part = ON_TEXT;
+      window = f->menu_bar_window;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* If not found above, see if it's in the tab bar window, if a tab
      bar exists.  */
@@ -1746,7 +1762,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
 				  (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
-				  0, false, false);
+				  0, false, false, false);
 }
 
 ptrdiff_t
diff --git a/src/window.h b/src/window.h
index 413293420fd..9ef8434af18 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1111,7 +1111,7 @@ #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)	\
 
 extern Lisp_Object make_window (void);
 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
-                                            enum window_part *, bool, bool);
+                                            enum window_part *, bool, bool, bool);
 extern void resize_frame_windows (struct frame *, int, bool);
 extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
diff --git a/src/xdisp.c b/src/xdisp.c
index 2c53527c25e..7f9e62f05e8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2778,7 +2778,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
       goto virtual_glyph;
     }
   else if (!f->glyphs_initialized_p
-	   || (window = window_from_coordinates (f, gx, gy, &part, false, false),
+	   || (window = window_from_coordinates (f, gx, gy, &part, false, false, false),
 	       NILP (window)))
     {
       width = FRAME_SMALLEST_CHAR_WIDTH (f);
@@ -35438,7 +35438,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
     return;
 
   /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, true, true);
+  window = window_from_coordinates (f, x, y, &part, true, true, true);
 
   /* If displaying active text in another window, clear that.  */
   if (! EQ (window, hlinfo->mouse_face_window)
diff --git a/src/xterm.c b/src/xterm.c
index 517bdf57aab..d5ca60089d7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -21161,7 +21161,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  }
 
 		Lisp_Object window = window_from_coordinates
-		  (f, xmotion.x, xmotion.y, 0, false, false);
+		  (f, xmotion.x, xmotion.y, 0, false, false, false);
 
 		/* A window will be autoselected only when it is not
 		   selected now and the last mouse movement event was
@@ -21892,7 +21892,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tab_bar_p = EQ (window, f->tab_bar_window);
 
                 if (tab_bar_p)
@@ -21913,7 +21913,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (event->xbutton.type != ButtonRelease
 				  || f->last_tool_bar_item != -1));
@@ -22646,7 +22646,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			    continue;
 
 			  window = window_from_coordinates (f, real_x, real_y, NULL,
-							    false, false);
+							    false, false, false);
 
 			  if (WINDOWP (window))
 			    scroll_height = XWINDOW (window)->pixel_height;
@@ -23089,7 +23089,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			  || !NILP (focus_follows_mouse)))
 		    {
 		      static Lisp_Object last_mouse_window;
-		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
+		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false,
+								    false);
 
 		      /* A window will be autoselected only when it is not
 			 selected now and the last mouse movement event was
@@ -23667,7 +23668,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      tab_bar_p = EQ (window, f->tab_bar_window);
 
 		      if (tab_bar_p)
@@ -23688,7 +23689,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      /* Ignore button release events if the mouse
 			 wasn't previously pressed on the tool bar.
 			 We do this because otherwise selecting some
@@ -24694,7 +24695,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  int x = xev->event_x;
 		  int y = xev->event_y;
 
-		  window = window_from_coordinates (f, x, y, 0, true, true);
+		  window = window_from_coordinates (f, x, y, 0, true, true, true);
 		  /* Ignore button release events if the mouse
 		     wasn't previously pressed on the tool bar.
 		     We do this because otherwise selecting some
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-06 15:59                                                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 10:19                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 10:28                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 10:31                                                     ` Stefan Kangas
  0 siblings, 2 replies; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 10:19 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

[-- Attachment #1: Type: text/plain, Size: 108 bytes --]

Hi,

Do you think those two patches could go in?  They still apply and
compile on master.
-- 
Manuel Giraud

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Possibility-to-get-enter-event-from-menu_bar-window.patch --]
[-- Type: text/x-patch, Size: 15660 bytes --]

>From e4481544b4ce87af2bbc42980d96d35fa8d4a7b8 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 6 Oct 2023 17:54:15 +0200
Subject: [PATCH] Possibility to get enter event from menu_bar window

---
 src/androidterm.c | 10 +++++-----
 src/haikuterm.c   |  8 ++++----
 src/keyboard.c    |  2 +-
 src/msdos.c       |  2 +-
 src/nsterm.m      |  4 ++--
 src/pgtkterm.c    |  4 ++--
 src/w32inevt.c    |  2 +-
 src/w32term.c     |  8 ++++----
 src/window.c      | 20 ++++++++++++++++++--
 src/window.h      |  2 +-
 src/xdisp.c       |  4 ++--
 src/xterm.c       | 17 +++++++++--------
 12 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/src/androidterm.c b/src/androidterm.c
index 9b00ad85642..d6db1359d97 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -1142,7 +1142,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      Lisp_Object window
 		= window_from_coordinates (f, event->xmotion.x,
 					   event->xmotion.y, 0,
-					   false, false);
+					   false, false, false);
 
 	      /* A window will be autoselected only when it is not
 		 selected now and the last mouse movement event was
@@ -1291,7 +1291,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tab_bar_p = EQ (window, f->tab_bar_window);
 
 	      if (tab_bar_p)
@@ -1313,7 +1313,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tool_bar_p = (EQ (window, f->tool_bar_window)
 			    && ((event->xbutton.type
 				 != ANDROID_BUTTON_RELEASE)
@@ -1409,7 +1409,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  int y = event->touch.y;
 
 	  window = window_from_coordinates (any, x, y, 0, true,
-					    true);
+					    true, true);
 
 	  /* If this touch has started in the tool bar, do not
 	     send it to Lisp.  Instead, simulate a tool bar
@@ -1606,7 +1606,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  /* Figure out how much to scale the deltas by.  */
 	  window = window_from_coordinates (any, event->wheel.x,
 					    event->wheel.y, NULL,
-					    false, false);
+					    false, false, false);
 
 	  if (WINDOWP (window))
 	    scroll_height = XWINDOW (window)->pixel_height;
diff --git a/src/haikuterm.c b/src/haikuterm.c
index b1a016b49a9..bcb5055ea42 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -3472,7 +3472,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		if (!NILP (Vmouse_autoselect_window))
 		  {
 		    static Lisp_Object last_mouse_window;
-		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0);
+		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0, 0);
 
 		    if (WINDOWP (window)
 			&& !EQ (window, last_mouse_window)
@@ -3555,7 +3555,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tab_bar_p = EQ (window, f->tab_bar_window);
 
 		if (tab_bar_p)
@@ -3573,7 +3573,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (type != BUTTON_UP
 				  || f->last_tool_bar_item != -1));
@@ -3834,7 +3834,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 
 	    BView_get_mouse (FRAME_HAIKU_VIEW (f), &x, &y);
 
-	    wheel_window = window_from_coordinates (f, x, y, 0, false, false);
+	    wheel_window = window_from_coordinates (f, x, y, 0, false, false, false);
 
 	    if (NILP (wheel_window))
 	      {
diff --git a/src/keyboard.c b/src/keyboard.c
index f756f163e87..fc567488e7c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5549,7 +5549,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
   int xret = 0, yret = 0;
   /* The window or frame under frame pixel coordinates (x,y)  */
   Lisp_Object window_or_frame = f
-    ? window_from_coordinates (f, mx, my, &part, true, true)
+    ? window_from_coordinates (f, mx, my, &part, true, true, true)
     : Qnil;
 #ifdef HAVE_WINDOW_SYSTEM
   bool tool_bar_p = false;
diff --git a/src/msdos.c b/src/msdos.c
index 1b7f2d4ae21..5dd7c1573c4 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2662,7 +2662,7 @@ dos_rawgetc (void)
 	      static Lisp_Object last_mouse_window;
 
 	      mouse_window = window_from_coordinates
-		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0);
+		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0, 0);
 	      /* A window will be selected only when it is not
 		 selected now, and the last mouse movement event was
 		 not in it.  A minibuffer window will be selected iff
diff --git a/src/nsterm.m b/src/nsterm.m
index 4e0dfa58c63..96661b8e227 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7404,7 +7404,7 @@ - (void)mouseDown: (NSEvent *)theEvent
 	  int x = lrint (p.x);
 	  int y = lrint (p.y);
 
-	  window = window_from_coordinates (emacsframe, x, y, 0, true, true);
+	  window = window_from_coordinates (emacsframe, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, emacsframe->tab_bar_window);
 
 	  if (tab_bar_p)
@@ -7510,7 +7510,7 @@ - (void)mouseMoved: (NSEvent *)e
       NSTRACE_MSG ("mouse_autoselect_window");
       static Lisp_Object last_mouse_window;
       Lisp_Object window
-	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0);
+	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0, 0);
 
       if (WINDOWP (window)
           && !EQ (window, last_mouse_window)
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index a7c687d811d..461c9d6d899 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -5894,7 +5894,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
 	{
 	  static Lisp_Object last_mouse_window;
 	  Lisp_Object window = window_from_coordinates
-	    (f, event->motion.x, event->motion.y, 0, false, false);
+	    (f, event->motion.x, event->motion.y, 0, false, false, false);
 
 	  /* A window will be autoselected only when it is not
 	     selected now and the last mouse movement event was
@@ -6047,7 +6047,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
 	  int x = event->button.x;
 	  int y = event->button.y;
 
-	  window = window_from_coordinates (f, x, y, 0, true, true);
+	  window = window_from_coordinates (f, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, f->tab_bar_window);
 
 	  if (tab_bar_p)
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 29717954cfd..630a9f4e5fb 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -496,7 +496,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
 	    if (!NILP (Vmouse_autoselect_window))
 	      {
 		Lisp_Object mouse_window = window_from_coordinates (f, mx, my,
-								    0, 0, 0);
+								    0, 0, 0, 0);
 		/* A window will be selected only when it is not
 		   selected now, and the last mouse movement event was
 		   not in it.  A minibuffer window will be selected iff
diff --git a/src/w32term.c b/src/w32term.c
index a5f17a18213..301d8f4ef12 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3376,7 +3376,7 @@ w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg,
       if (w32_wheel_scroll_lines == UINT_MAX)
 	{
 	  Lisp_Object window = window_from_coordinates (f, p.x, p.y, NULL,
-							false, false);
+							false, false, false);
 	  if (!WINDOWP (window))
 	    {
 	      result->kind = NO_EVENT;
@@ -5335,7 +5335,7 @@ w32_read_socket (struct terminal *terminal,
 		{
 		  static Lisp_Object last_mouse_window;
 		  Lisp_Object window = window_from_coordinates
-		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0);
+		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0, 0);
 
 		  /* Window will be selected only when it is not
 		     selected now and last mouse movement event was
@@ -5407,7 +5407,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tab_bar_window))
                       {
@@ -5435,7 +5435,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tool_bar_window)
 			/* Make sure the tool bar was previously
diff --git a/src/window.c b/src/window.c
index 968b982c135..e802ffb3fe2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1680,7 +1680,8 @@ check_window_containing (struct window *w, void *user_data)
 
 Lisp_Object
 window_from_coordinates (struct frame *f, int x, int y,
-			 enum window_part *part, bool tab_bar_p, bool tool_bar_p)
+			 enum window_part *part, bool menu_bar_p,
+			 bool tab_bar_p, bool tool_bar_p)
 {
   Lisp_Object window;
   struct check_window_data cw;
@@ -1693,6 +1694,21 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* If not found above, see if it's in the menu bar window, if a menu
+     bar exists.  */
+  if (NILP (window)
+      && menu_bar_p
+      && WINDOWP (f->menu_bar_window)
+      && WINDOW_TOTAL_LINES (XWINDOW (f->menu_bar_window)) > 0
+      && (coordinates_in_window (XWINDOW (f->menu_bar_window), x, y)
+	  != ON_NOTHING))
+    {
+      *part = ON_TEXT;
+      window = f->menu_bar_window;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* If not found above, see if it's in the tab bar window, if a tab
      bar exists.  */
@@ -1746,7 +1762,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
 				  (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
-				  0, false, false);
+				  0, false, false, false);
 }
 
 ptrdiff_t
diff --git a/src/window.h b/src/window.h
index 413293420fd..9ef8434af18 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1111,7 +1111,7 @@ #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)	\
 
 extern Lisp_Object make_window (void);
 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
-                                            enum window_part *, bool, bool);
+                                            enum window_part *, bool, bool, bool);
 extern void resize_frame_windows (struct frame *, int, bool);
 extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
diff --git a/src/xdisp.c b/src/xdisp.c
index 2c53527c25e..7f9e62f05e8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2778,7 +2778,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
       goto virtual_glyph;
     }
   else if (!f->glyphs_initialized_p
-	   || (window = window_from_coordinates (f, gx, gy, &part, false, false),
+	   || (window = window_from_coordinates (f, gx, gy, &part, false, false, false),
 	       NILP (window)))
     {
       width = FRAME_SMALLEST_CHAR_WIDTH (f);
@@ -35438,7 +35438,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
     return;
 
   /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, true, true);
+  window = window_from_coordinates (f, x, y, &part, true, true, true);
 
   /* If displaying active text in another window, clear that.  */
   if (! EQ (window, hlinfo->mouse_face_window)
diff --git a/src/xterm.c b/src/xterm.c
index 517bdf57aab..d5ca60089d7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -21161,7 +21161,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  }
 
 		Lisp_Object window = window_from_coordinates
-		  (f, xmotion.x, xmotion.y, 0, false, false);
+		  (f, xmotion.x, xmotion.y, 0, false, false, false);
 
 		/* A window will be autoselected only when it is not
 		   selected now and the last mouse movement event was
@@ -21892,7 +21892,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tab_bar_p = EQ (window, f->tab_bar_window);
 
                 if (tab_bar_p)
@@ -21913,7 +21913,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (event->xbutton.type != ButtonRelease
 				  || f->last_tool_bar_item != -1));
@@ -22646,7 +22646,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			    continue;
 
 			  window = window_from_coordinates (f, real_x, real_y, NULL,
-							    false, false);
+							    false, false, false);
 
 			  if (WINDOWP (window))
 			    scroll_height = XWINDOW (window)->pixel_height;
@@ -23089,7 +23089,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			  || !NILP (focus_follows_mouse)))
 		    {
 		      static Lisp_Object last_mouse_window;
-		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
+		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false,
+								    false);
 
 		      /* A window will be autoselected only when it is not
 			 selected now and the last mouse movement event was
@@ -23667,7 +23668,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      tab_bar_p = EQ (window, f->tab_bar_window);
 
 		      if (tab_bar_p)
@@ -23688,7 +23689,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      /* Ignore button release events if the mouse
 			 wasn't previously pressed on the tool bar.
 			 We do this because otherwise selecting some
@@ -24694,7 +24695,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  int x = xev->event_x;
 		  int y = xev->event_y;
 
-		  window = window_from_coordinates (f, x, y, 0, true, true);
+		  window = window_from_coordinates (f, x, y, 0, true, true, true);
 		  /* Ignore button release events if the mouse
 		     wasn't previously pressed on the tool bar.
 		     We do this because otherwise selecting some
-- 
2.40.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Set-non-text-mouse-cursor-on-menu-bar.patch --]
[-- Type: text/x-patch, Size: 1044 bytes --]

>From 9200d69b49fa57269e5357383d138872a372127a Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 6 Oct 2023 14:27:02 +0200
Subject: [PATCH 2/2] Set non-text mouse cursor on menu bar

* src/xdisp.c (note_mouse_highlight): Set non-text mouse cursor on
menu bar.
---
 src/xdisp.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index 7f9e62f05e8..df3076cf499 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -35537,6 +35537,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* Handle menu-bar window differently since it doesn't display a
+     buffer.  */
+  if (EQ (window, f->menu_bar_window))
+    {
+      cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
+      goto set_cursor;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* Handle tab-bar window differently since it doesn't display a
      buffer.  */
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 10:19                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 10:28                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 11:02                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 10:31                                                     ` Stefan Kangas
  1 sibling, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 10:28 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, stefankangas, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Hi,
>
> Do you think those two patches could go in?  They still apply and
> compile on master.
> -- 
> Manuel Giraud
>
>>From e4481544b4ce87af2bbc42980d96d35fa8d4a7b8 Mon Sep 17 00:00:00 2001
> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Date: Fri, 6 Oct 2023 17:54:15 +0200
> Subject: [PATCH] Possibility to get enter event from menu_bar window
>

A log message is absent from this patch, so one must be written first.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 10:19                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 10:28                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 10:31                                                     ` Stefan Kangas
  1 sibling, 0 replies; 54+ messages in thread
From: Stefan Kangas @ 2023-10-21 10:31 UTC (permalink / raw)
  To: Manuel Giraud, Po Lu; +Cc: Eli Zaretskii, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Do you think those two patches could go in?  They still apply and
> compile on master.

Po Lu, what do you think?





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 10:28                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 11:02                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 11:10                                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 11:10                                                         ` Stefan Kangas
  0 siblings, 2 replies; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 11:02 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

Po Lu <luangruo@yahoo.com> writes:

[...]

>>From e4481544b4ce87af2bbc42980d96d35fa8d4a7b8 Mon Sep 17 00:00:00 2001
>> From: Manuel Giraud <manuel@ledu-giraud.fr>
>> Date: Fri, 6 Oct 2023 17:54:15 +0200
>> Subject: [PATCH] Possibility to get enter event from menu_bar window
>>
>
> A log message is absent from this patch, so one must be written first.

Ok.  Does it have to enumerate all the files it touches?
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 11:02                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 11:10                                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 12:02                                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 11:10                                                         ` Stefan Kangas
  1 sibling, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 11:10 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, stefankangas, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Ok.  Does it have to enumerate all the files it touches?

Yes, and each function within.  Try to avoid writing perfunctory
descriptions of the changes in log messages merely for conforming to
protocol.  It is fine to be pithy, but not to be remiss.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 11:02                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 11:10                                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 11:10                                                         ` Stefan Kangas
  2023-10-21 12:06                                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 54+ messages in thread
From: Stefan Kangas @ 2023-10-21 11:10 UTC (permalink / raw)
  To: Manuel Giraud, Po Lu; +Cc: Eli Zaretskii, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Po Lu <luangruo@yahoo.com> writes:
>
> [...]
>
>>>From e4481544b4ce87af2bbc42980d96d35fa8d4a7b8 Mon Sep 17 00:00:00 2001
>>> From: Manuel Giraud <manuel@ledu-giraud.fr>
>>> Date: Fri, 6 Oct 2023 17:54:15 +0200
>>> Subject: [PATCH] Possibility to get enter event from menu_bar window
>>>
>>
>> A log message is absent from this patch, so one must be written first.
>
> Ok.  Does it have to enumerate all the files it touches?

Yes, the only exception is NEWS, which is optional.

See the file CONTRIBUTE, section "Generating ChangeLog entries" for some
help with automating parts of the work.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 11:10                                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 12:02                                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 12:27                                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 12:02 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

Po Lu <luangruo@yahoo.com> writes:

> Manuel Giraud <manuel@ledu-giraud.fr> writes:
>
>> Ok.  Does it have to enumerate all the files it touches?
>
> Yes, and each function within.  Try to avoid writing perfunctory
> descriptions of the changes in log messages merely for conforming to
> protocol.  It is fine to be pithy, but not to be remiss.

Alright.  But in such case, I do not really know what to say: I am
adding one argument to all callers based on its siblings' values.

(BTW, thanks for your vocabulary: it makes me use 'dictionary-search'
more 😄)
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 11:10                                                         ` Stefan Kangas
@ 2023-10-21 12:06                                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 12:06 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Po Lu, Eli Zaretskii, 64440

Stefan Kangas <stefankangas@gmail.com> writes:

>> Ok.  Does it have to enumerate all the files it touches?
>
> Yes, the only exception is NEWS, which is optional.
>
> See the file CONTRIBUTE, section "Generating ChangeLog entries" for some
> help with automating parts of the work.

Thanks.  I was already using 'C-x 4 a'.  I'll try the others method.
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 12:02                                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 12:27                                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 12:44                                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 12:27 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, stefankangas, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Alright.  But in such case, I do not really know what to say: I am
> adding one argument to all callers based on its siblings' values.

In this (and only this) case, our practice is to omit functions modified
solely to introduce the new argument from the log message, and to append
to the entry designating the recipient of the new argument the words
``All callers changed.''

So long as the default value for the argument is straightforward, of
course.  If computing the argument demands non-trivial changes, then the
ChangeLog should relate them as it would any other.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 12:27                                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 12:44                                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 12:48                                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 12:44 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

Po Lu <luangruo@yahoo.com> writes:

> Manuel Giraud <manuel@ledu-giraud.fr> writes:
>
>> Alright.  But in such case, I do not really know what to say: I am
>> adding one argument to all callers based on its siblings' values.
>
> In this (and only this) case, our practice is to omit functions modified
> solely to introduce the new argument from the log message, and to append
> to the entry designating the recipient of the new argument the words
> ``All callers changed.''
>
> So long as the default value for the argument is straightforward, of
> course.  If computing the argument demands non-trivial changes, then the
> ChangeLog should relate them as it would any other.

What about this patch then?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Support-for-menu-bar-in-window_from_coordinates.patch --]
[-- Type: text/x-patch, Size: 15856 bytes --]

From 5047d98ecd209c514eec50b9c84a32bbddfa414f Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Sat, 21 Oct 2023 14:36:24 +0200
Subject: [PATCH] Support for menu bar in window_from_coordinates

* src/window.c (window_from_coordinates): In the no toolkit build, add
support for the menu bar window.  Add a new 'menu_bar_p' argument so
the function's signature has changed.  All callers changed.
---
 src/androidterm.c | 10 +++++-----
 src/haikuterm.c   |  8 ++++----
 src/keyboard.c    |  2 +-
 src/msdos.c       |  2 +-
 src/nsterm.m      |  4 ++--
 src/pgtkterm.c    |  4 ++--
 src/w32inevt.c    |  2 +-
 src/w32term.c     |  8 ++++----
 src/window.c      | 20 ++++++++++++++++++--
 src/window.h      |  2 +-
 src/xdisp.c       |  4 ++--
 src/xterm.c       | 17 +++++++++--------
 12 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/src/androidterm.c b/src/androidterm.c
index 9d6517cce2b..e95e854d1d7 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -1142,7 +1142,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      Lisp_Object window
 		= window_from_coordinates (f, event->xmotion.x,
 					   event->xmotion.y, 0,
-					   false, false);
+					   false, false, false);
 
 	      /* A window will be autoselected only when it is not
 		 selected now and the last mouse movement event was
@@ -1291,7 +1291,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tab_bar_p = EQ (window, f->tab_bar_window);
 
 	      if (tab_bar_p)
@@ -1313,7 +1313,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tool_bar_p = (EQ (window, f->tool_bar_window)
 			    && ((event->xbutton.type
 				 != ANDROID_BUTTON_RELEASE)
@@ -1409,7 +1409,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  int y = event->touch.y;
 
 	  window = window_from_coordinates (any, x, y, 0, true,
-					    true);
+					    true, true);
 
 	  /* If this touch has started in the tool bar, do not
 	     send it to Lisp.  Instead, simulate a tool bar
@@ -1606,7 +1606,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  /* Figure out how much to scale the deltas by.  */
 	  window = window_from_coordinates (any, event->wheel.x,
 					    event->wheel.y, NULL,
-					    false, false);
+					    false, false, false);
 
 	  if (WINDOWP (window))
 	    scroll_height = XWINDOW (window)->pixel_height;
diff --git a/src/haikuterm.c b/src/haikuterm.c
index b1a016b49a9..bcb5055ea42 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -3472,7 +3472,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		if (!NILP (Vmouse_autoselect_window))
 		  {
 		    static Lisp_Object last_mouse_window;
-		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0);
+		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0, 0);
 
 		    if (WINDOWP (window)
 			&& !EQ (window, last_mouse_window)
@@ -3555,7 +3555,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tab_bar_p = EQ (window, f->tab_bar_window);
 
 		if (tab_bar_p)
@@ -3573,7 +3573,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (type != BUTTON_UP
 				  || f->last_tool_bar_item != -1));
@@ -3834,7 +3834,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 
 	    BView_get_mouse (FRAME_HAIKU_VIEW (f), &x, &y);
 
-	    wheel_window = window_from_coordinates (f, x, y, 0, false, false);
+	    wheel_window = window_from_coordinates (f, x, y, 0, false, false, false);
 
 	    if (NILP (wheel_window))
 	      {
diff --git a/src/keyboard.c b/src/keyboard.c
index 76dec637cb1..00e178f2b93 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5558,7 +5558,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
   int xret = 0, yret = 0;
   /* The window or frame under frame pixel coordinates (x,y)  */
   Lisp_Object window_or_frame = f
-    ? window_from_coordinates (f, mx, my, &part, true, true)
+    ? window_from_coordinates (f, mx, my, &part, true, true, true)
     : Qnil;
 #ifdef HAVE_WINDOW_SYSTEM
   bool tool_bar_p = false;
diff --git a/src/msdos.c b/src/msdos.c
index 1b7f2d4ae21..5dd7c1573c4 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2662,7 +2662,7 @@ dos_rawgetc (void)
 	      static Lisp_Object last_mouse_window;
 
 	      mouse_window = window_from_coordinates
-		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0);
+		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0, 0);
 	      /* A window will be selected only when it is not
 		 selected now, and the last mouse movement event was
 		 not in it.  A minibuffer window will be selected iff
diff --git a/src/nsterm.m b/src/nsterm.m
index 11535f071eb..46a5e8870e8 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7412,7 +7412,7 @@ - (void)mouseDown: (NSEvent *)theEvent
 	  int x = lrint (p.x);
 	  int y = lrint (p.y);
 
-	  window = window_from_coordinates (emacsframe, x, y, 0, true, true);
+	  window = window_from_coordinates (emacsframe, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, emacsframe->tab_bar_window);
 
 	  if (tab_bar_p)
@@ -7518,7 +7518,7 @@ - (void)mouseMoved: (NSEvent *)e
       NSTRACE_MSG ("mouse_autoselect_window");
       static Lisp_Object last_mouse_window;
       Lisp_Object window
-	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0);
+	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0, 0);
 
       if (WINDOWP (window)
           && !EQ (window, last_mouse_window)
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index a7c687d811d..461c9d6d899 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -5894,7 +5894,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
 	{
 	  static Lisp_Object last_mouse_window;
 	  Lisp_Object window = window_from_coordinates
-	    (f, event->motion.x, event->motion.y, 0, false, false);
+	    (f, event->motion.x, event->motion.y, 0, false, false, false);
 
 	  /* A window will be autoselected only when it is not
 	     selected now and the last mouse movement event was
@@ -6047,7 +6047,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
 	  int x = event->button.x;
 	  int y = event->button.y;
 
-	  window = window_from_coordinates (f, x, y, 0, true, true);
+	  window = window_from_coordinates (f, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, f->tab_bar_window);
 
 	  if (tab_bar_p)
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 29717954cfd..630a9f4e5fb 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -496,7 +496,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
 	    if (!NILP (Vmouse_autoselect_window))
 	      {
 		Lisp_Object mouse_window = window_from_coordinates (f, mx, my,
-								    0, 0, 0);
+								    0, 0, 0, 0);
 		/* A window will be selected only when it is not
 		   selected now, and the last mouse movement event was
 		   not in it.  A minibuffer window will be selected iff
diff --git a/src/w32term.c b/src/w32term.c
index a5f17a18213..301d8f4ef12 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3376,7 +3376,7 @@ w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg,
       if (w32_wheel_scroll_lines == UINT_MAX)
 	{
 	  Lisp_Object window = window_from_coordinates (f, p.x, p.y, NULL,
-							false, false);
+							false, false, false);
 	  if (!WINDOWP (window))
 	    {
 	      result->kind = NO_EVENT;
@@ -5335,7 +5335,7 @@ w32_read_socket (struct terminal *terminal,
 		{
 		  static Lisp_Object last_mouse_window;
 		  Lisp_Object window = window_from_coordinates
-		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0);
+		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0, 0);
 
 		  /* Window will be selected only when it is not
 		     selected now and last mouse movement event was
@@ -5407,7 +5407,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tab_bar_window))
                       {
@@ -5435,7 +5435,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tool_bar_window)
 			/* Make sure the tool bar was previously
diff --git a/src/window.c b/src/window.c
index 968b982c135..e802ffb3fe2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1680,7 +1680,8 @@ check_window_containing (struct window *w, void *user_data)
 
 Lisp_Object
 window_from_coordinates (struct frame *f, int x, int y,
-			 enum window_part *part, bool tab_bar_p, bool tool_bar_p)
+			 enum window_part *part, bool menu_bar_p,
+			 bool tab_bar_p, bool tool_bar_p)
 {
   Lisp_Object window;
   struct check_window_data cw;
@@ -1693,6 +1694,21 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* If not found above, see if it's in the menu bar window, if a menu
+     bar exists.  */
+  if (NILP (window)
+      && menu_bar_p
+      && WINDOWP (f->menu_bar_window)
+      && WINDOW_TOTAL_LINES (XWINDOW (f->menu_bar_window)) > 0
+      && (coordinates_in_window (XWINDOW (f->menu_bar_window), x, y)
+	  != ON_NOTHING))
+    {
+      *part = ON_TEXT;
+      window = f->menu_bar_window;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* If not found above, see if it's in the tab bar window, if a tab
      bar exists.  */
@@ -1746,7 +1762,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
 				  (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
-				  0, false, false);
+				  0, false, false, false);
 }
 
 ptrdiff_t
diff --git a/src/window.h b/src/window.h
index 413293420fd..9ef8434af18 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1111,7 +1111,7 @@ #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)	\
 
 extern Lisp_Object make_window (void);
 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
-                                            enum window_part *, bool, bool);
+                                            enum window_part *, bool, bool, bool);
 extern void resize_frame_windows (struct frame *, int, bool);
 extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
diff --git a/src/xdisp.c b/src/xdisp.c
index b9009df5df9..578131a4005 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2778,7 +2778,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
       goto virtual_glyph;
     }
   else if (!f->glyphs_initialized_p
-	   || (window = window_from_coordinates (f, gx, gy, &part, false, false),
+	   || (window = window_from_coordinates (f, gx, gy, &part, false, false, false),
 	       NILP (window)))
     {
       width = FRAME_SMALLEST_CHAR_WIDTH (f);
@@ -35438,7 +35438,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
     return;
 
   /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, true, true);
+  window = window_from_coordinates (f, x, y, &part, true, true, true);
 
   /* If displaying active text in another window, clear that.  */
   if (! EQ (window, hlinfo->mouse_face_window)
diff --git a/src/xterm.c b/src/xterm.c
index 517bdf57aab..d5ca60089d7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -21161,7 +21161,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  }
 
 		Lisp_Object window = window_from_coordinates
-		  (f, xmotion.x, xmotion.y, 0, false, false);
+		  (f, xmotion.x, xmotion.y, 0, false, false, false);
 
 		/* A window will be autoselected only when it is not
 		   selected now and the last mouse movement event was
@@ -21892,7 +21892,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tab_bar_p = EQ (window, f->tab_bar_window);
 
                 if (tab_bar_p)
@@ -21913,7 +21913,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (event->xbutton.type != ButtonRelease
 				  || f->last_tool_bar_item != -1));
@@ -22646,7 +22646,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			    continue;
 
 			  window = window_from_coordinates (f, real_x, real_y, NULL,
-							    false, false);
+							    false, false, false);
 
 			  if (WINDOWP (window))
 			    scroll_height = XWINDOW (window)->pixel_height;
@@ -23089,7 +23089,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			  || !NILP (focus_follows_mouse)))
 		    {
 		      static Lisp_Object last_mouse_window;
-		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
+		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false,
+								    false);
 
 		      /* A window will be autoselected only when it is not
 			 selected now and the last mouse movement event was
@@ -23667,7 +23668,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      tab_bar_p = EQ (window, f->tab_bar_window);
 
 		      if (tab_bar_p)
@@ -23688,7 +23689,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      /* Ignore button release events if the mouse
 			 wasn't previously pressed on the tool bar.
 			 We do this because otherwise selecting some
@@ -24694,7 +24695,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  int x = xev->event_x;
 		  int y = xev->event_y;
 
-		  window = window_from_coordinates (f, x, y, 0, true, true);
+		  window = window_from_coordinates (f, x, y, 0, true, true, true);
 		  /* Ignore button release events if the mouse
 		     wasn't previously pressed on the tool bar.
 		     We do this because otherwise selecting some
-- 
2.42.0


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 12:44                                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 12:48                                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 13:03                                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 12:48 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, stefankangas, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Po Lu <luangruo@yahoo.com> writes:
>
>> Manuel Giraud <manuel@ledu-giraud.fr> writes:
>>
>>> Alright.  But in such case, I do not really know what to say: I am
>>> adding one argument to all callers based on its siblings' values.
>>
>> In this (and only this) case, our practice is to omit functions modified
>> solely to introduce the new argument from the log message, and to append
>> to the entry designating the recipient of the new argument the words
>> ``All callers changed.''
>>
>> So long as the default value for the argument is straightforward, of
>> course.  If computing the argument demands non-trivial changes, then the
>> ChangeLog should relate them as it would any other.
>
> What about this patch then?
>
> From 5047d98ecd209c514eec50b9c84a32bbddfa414f Mon Sep 17 00:00:00 2001
> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Date: Sat, 21 Oct 2023 14:36:24 +0200
> Subject: [PATCH] Support for menu bar in window_from_coordinates
>
> * src/window.c (window_from_coordinates): In the no toolkit build, add
> support for the menu bar window.  Add a new 'menu_bar_p' argument so
> the function's signature has changed.  All callers changed.

Better, thanks.  Although the commit message must be filled to 64
columns, and I'd rather callers passing true be enumerated there.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 12:48                                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 13:03                                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 13:24                                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 13:03 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

Po Lu <luangruo@yahoo.com> writes:

> Better, thanks.  Although the commit message must be filled to 64
> columns, and I'd rather callers passing true be enumerated there.

What about this one?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Support-for-menu-bar-in-window_from_coordinates.patch --]
[-- Type: text/x-patch, Size: 16230 bytes --]

From d2ed7c704854082e5f84a717d18f29c92785a638 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Sat, 21 Oct 2023 14:36:24 +0200
Subject: [PATCH] Support for menu bar in window_from_coordinates

* src/window.h:
* src/window.c (window_from_coordinates): In the no toolkit
build, add support for the menu bar window.  Add a new
'menu_bar_p' argument so the function's signature has changed.
All callers changed.

* src/androidterm.c (handle_one_android_event):
* src/haikuterm.c (haiku_read_socket):
* src/keyboard.c (make_lispy_position):
* src/nsterm.m ([EmacsView mouseDown:]):
* src/pgtkterm.c (button_event):
* src/w32term.c (w32_read_socket):
* src/xdisp.c (note_mouse_highlight):
* src/xterm.c (handle_one_xevent): All those callers have
'menu_bar_p' set to true.
---
 src/androidterm.c | 10 +++++-----
 src/haikuterm.c   |  8 ++++----
 src/keyboard.c    |  2 +-
 src/msdos.c       |  2 +-
 src/nsterm.m      |  4 ++--
 src/pgtkterm.c    |  4 ++--
 src/w32inevt.c    |  2 +-
 src/w32term.c     |  8 ++++----
 src/window.c      | 20 ++++++++++++++++++--
 src/window.h      |  2 +-
 src/xdisp.c       |  4 ++--
 src/xterm.c       | 17 +++++++++--------
 12 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/src/androidterm.c b/src/androidterm.c
index 9d6517cce2b..e95e854d1d7 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -1142,7 +1142,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      Lisp_Object window
 		= window_from_coordinates (f, event->xmotion.x,
 					   event->xmotion.y, 0,
-					   false, false);
+					   false, false, false);
 
 	      /* A window will be autoselected only when it is not
 		 selected now and the last mouse movement event was
@@ -1291,7 +1291,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tab_bar_p = EQ (window, f->tab_bar_window);
 
 	      if (tab_bar_p)
@@ -1313,7 +1313,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tool_bar_p = (EQ (window, f->tool_bar_window)
 			    && ((event->xbutton.type
 				 != ANDROID_BUTTON_RELEASE)
@@ -1409,7 +1409,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  int y = event->touch.y;
 
 	  window = window_from_coordinates (any, x, y, 0, true,
-					    true);
+					    true, true);
 
 	  /* If this touch has started in the tool bar, do not
 	     send it to Lisp.  Instead, simulate a tool bar
@@ -1606,7 +1606,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  /* Figure out how much to scale the deltas by.  */
 	  window = window_from_coordinates (any, event->wheel.x,
 					    event->wheel.y, NULL,
-					    false, false);
+					    false, false, false);
 
 	  if (WINDOWP (window))
 	    scroll_height = XWINDOW (window)->pixel_height;
diff --git a/src/haikuterm.c b/src/haikuterm.c
index b1a016b49a9..bcb5055ea42 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -3472,7 +3472,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		if (!NILP (Vmouse_autoselect_window))
 		  {
 		    static Lisp_Object last_mouse_window;
-		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0);
+		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0, 0);
 
 		    if (WINDOWP (window)
 			&& !EQ (window, last_mouse_window)
@@ -3555,7 +3555,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tab_bar_p = EQ (window, f->tab_bar_window);
 
 		if (tab_bar_p)
@@ -3573,7 +3573,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (type != BUTTON_UP
 				  || f->last_tool_bar_item != -1));
@@ -3834,7 +3834,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 
 	    BView_get_mouse (FRAME_HAIKU_VIEW (f), &x, &y);
 
-	    wheel_window = window_from_coordinates (f, x, y, 0, false, false);
+	    wheel_window = window_from_coordinates (f, x, y, 0, false, false, false);
 
 	    if (NILP (wheel_window))
 	      {
diff --git a/src/keyboard.c b/src/keyboard.c
index 76dec637cb1..00e178f2b93 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5558,7 +5558,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
   int xret = 0, yret = 0;
   /* The window or frame under frame pixel coordinates (x,y)  */
   Lisp_Object window_or_frame = f
-    ? window_from_coordinates (f, mx, my, &part, true, true)
+    ? window_from_coordinates (f, mx, my, &part, true, true, true)
     : Qnil;
 #ifdef HAVE_WINDOW_SYSTEM
   bool tool_bar_p = false;
diff --git a/src/msdos.c b/src/msdos.c
index 1b7f2d4ae21..5dd7c1573c4 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2662,7 +2662,7 @@ dos_rawgetc (void)
 	      static Lisp_Object last_mouse_window;
 
 	      mouse_window = window_from_coordinates
-		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0);
+		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0, 0);
 	      /* A window will be selected only when it is not
 		 selected now, and the last mouse movement event was
 		 not in it.  A minibuffer window will be selected iff
diff --git a/src/nsterm.m b/src/nsterm.m
index 11535f071eb..46a5e8870e8 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7412,7 +7412,7 @@ - (void)mouseDown: (NSEvent *)theEvent
 	  int x = lrint (p.x);
 	  int y = lrint (p.y);
 
-	  window = window_from_coordinates (emacsframe, x, y, 0, true, true);
+	  window = window_from_coordinates (emacsframe, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, emacsframe->tab_bar_window);
 
 	  if (tab_bar_p)
@@ -7518,7 +7518,7 @@ - (void)mouseMoved: (NSEvent *)e
       NSTRACE_MSG ("mouse_autoselect_window");
       static Lisp_Object last_mouse_window;
       Lisp_Object window
-	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0);
+	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0, 0);
 
       if (WINDOWP (window)
           && !EQ (window, last_mouse_window)
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index a7c687d811d..461c9d6d899 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -5894,7 +5894,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
 	{
 	  static Lisp_Object last_mouse_window;
 	  Lisp_Object window = window_from_coordinates
-	    (f, event->motion.x, event->motion.y, 0, false, false);
+	    (f, event->motion.x, event->motion.y, 0, false, false, false);
 
 	  /* A window will be autoselected only when it is not
 	     selected now and the last mouse movement event was
@@ -6047,7 +6047,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
 	  int x = event->button.x;
 	  int y = event->button.y;
 
-	  window = window_from_coordinates (f, x, y, 0, true, true);
+	  window = window_from_coordinates (f, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, f->tab_bar_window);
 
 	  if (tab_bar_p)
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 29717954cfd..630a9f4e5fb 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -496,7 +496,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
 	    if (!NILP (Vmouse_autoselect_window))
 	      {
 		Lisp_Object mouse_window = window_from_coordinates (f, mx, my,
-								    0, 0, 0);
+								    0, 0, 0, 0);
 		/* A window will be selected only when it is not
 		   selected now, and the last mouse movement event was
 		   not in it.  A minibuffer window will be selected iff
diff --git a/src/w32term.c b/src/w32term.c
index a5f17a18213..301d8f4ef12 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3376,7 +3376,7 @@ w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg,
       if (w32_wheel_scroll_lines == UINT_MAX)
 	{
 	  Lisp_Object window = window_from_coordinates (f, p.x, p.y, NULL,
-							false, false);
+							false, false, false);
 	  if (!WINDOWP (window))
 	    {
 	      result->kind = NO_EVENT;
@@ -5335,7 +5335,7 @@ w32_read_socket (struct terminal *terminal,
 		{
 		  static Lisp_Object last_mouse_window;
 		  Lisp_Object window = window_from_coordinates
-		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0);
+		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0, 0);
 
 		  /* Window will be selected only when it is not
 		     selected now and last mouse movement event was
@@ -5407,7 +5407,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tab_bar_window))
                       {
@@ -5435,7 +5435,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tool_bar_window)
 			/* Make sure the tool bar was previously
diff --git a/src/window.c b/src/window.c
index 968b982c135..e802ffb3fe2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1680,7 +1680,8 @@ check_window_containing (struct window *w, void *user_data)
 
 Lisp_Object
 window_from_coordinates (struct frame *f, int x, int y,
-			 enum window_part *part, bool tab_bar_p, bool tool_bar_p)
+			 enum window_part *part, bool menu_bar_p,
+			 bool tab_bar_p, bool tool_bar_p)
 {
   Lisp_Object window;
   struct check_window_data cw;
@@ -1693,6 +1694,21 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* If not found above, see if it's in the menu bar window, if a menu
+     bar exists.  */
+  if (NILP (window)
+      && menu_bar_p
+      && WINDOWP (f->menu_bar_window)
+      && WINDOW_TOTAL_LINES (XWINDOW (f->menu_bar_window)) > 0
+      && (coordinates_in_window (XWINDOW (f->menu_bar_window), x, y)
+	  != ON_NOTHING))
+    {
+      *part = ON_TEXT;
+      window = f->menu_bar_window;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* If not found above, see if it's in the tab bar window, if a tab
      bar exists.  */
@@ -1746,7 +1762,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
 				  (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
-				  0, false, false);
+				  0, false, false, false);
 }
 
 ptrdiff_t
diff --git a/src/window.h b/src/window.h
index 413293420fd..9ef8434af18 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1111,7 +1111,7 @@ #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)	\
 
 extern Lisp_Object make_window (void);
 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
-                                            enum window_part *, bool, bool);
+                                            enum window_part *, bool, bool, bool);
 extern void resize_frame_windows (struct frame *, int, bool);
 extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
diff --git a/src/xdisp.c b/src/xdisp.c
index b9009df5df9..578131a4005 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2778,7 +2778,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
       goto virtual_glyph;
     }
   else if (!f->glyphs_initialized_p
-	   || (window = window_from_coordinates (f, gx, gy, &part, false, false),
+	   || (window = window_from_coordinates (f, gx, gy, &part, false, false, false),
 	       NILP (window)))
     {
       width = FRAME_SMALLEST_CHAR_WIDTH (f);
@@ -35438,7 +35438,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
     return;
 
   /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, true, true);
+  window = window_from_coordinates (f, x, y, &part, true, true, true);
 
   /* If displaying active text in another window, clear that.  */
   if (! EQ (window, hlinfo->mouse_face_window)
diff --git a/src/xterm.c b/src/xterm.c
index 517bdf57aab..d5ca60089d7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -21161,7 +21161,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  }
 
 		Lisp_Object window = window_from_coordinates
-		  (f, xmotion.x, xmotion.y, 0, false, false);
+		  (f, xmotion.x, xmotion.y, 0, false, false, false);
 
 		/* A window will be autoselected only when it is not
 		   selected now and the last mouse movement event was
@@ -21892,7 +21892,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tab_bar_p = EQ (window, f->tab_bar_window);
 
                 if (tab_bar_p)
@@ -21913,7 +21913,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (event->xbutton.type != ButtonRelease
 				  || f->last_tool_bar_item != -1));
@@ -22646,7 +22646,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			    continue;
 
 			  window = window_from_coordinates (f, real_x, real_y, NULL,
-							    false, false);
+							    false, false, false);
 
 			  if (WINDOWP (window))
 			    scroll_height = XWINDOW (window)->pixel_height;
@@ -23089,7 +23089,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			  || !NILP (focus_follows_mouse)))
 		    {
 		      static Lisp_Object last_mouse_window;
-		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
+		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false,
+								    false);
 
 		      /* A window will be autoselected only when it is not
 			 selected now and the last mouse movement event was
@@ -23667,7 +23668,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      tab_bar_p = EQ (window, f->tab_bar_window);
 
 		      if (tab_bar_p)
@@ -23688,7 +23689,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      /* Ignore button release events if the mouse
 			 wasn't previously pressed on the tool bar.
 			 We do this because otherwise selecting some
@@ -24694,7 +24695,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  int x = xev->event_x;
 		  int y = xev->event_y;
 
-		  window = window_from_coordinates (f, x, y, 0, true, true);
+		  window = window_from_coordinates (f, x, y, 0, true, true, true);
 		  /* Ignore button release events if the mouse
 		     wasn't previously pressed on the tool bar.
 		     We do this because otherwise selecting some
-- 
2.42.0


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 13:03                                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 13:24                                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-21 13:56                                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 13:24 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, stefankangas, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Po Lu <luangruo@yahoo.com> writes:
>
>> Better, thanks.  Although the commit message must be filled to 64
>> columns, and I'd rather callers passing true be enumerated there.
>
> What about this one?
>
> From d2ed7c704854082e5f84a717d18f29c92785a638 Mon Sep 17 00:00:00 2001
> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Date: Sat, 21 Oct 2023 14:36:24 +0200
> Subject: [PATCH] Support for menu bar in window_from_coordinates
>
> * src/window.h:
> * src/window.c (window_from_coordinates): In the no toolkit
> build, add support for the menu bar window.  Add a new
> 'menu_bar_p' argument so the function's signature has changed.
> All callers changed.
>
> * src/androidterm.c (handle_one_android_event):
> * src/haikuterm.c (haiku_read_socket):
> * src/keyboard.c (make_lispy_position):
> * src/nsterm.m ([EmacsView mouseDown:]):
> * src/pgtkterm.c (button_event):
> * src/w32term.c (w32_read_socket):
> * src/xdisp.c (note_mouse_highlight):
> * src/xterm.c (handle_one_xevent): All those callers have
> 'menu_bar_p' set to true.

I would write:

[...]
* src/xterm.c (handle_one_xevent): Set menu_bar_p to true.

With that aside, LGTM.  Thanks.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 13:24                                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-21 13:56                                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-27  8:11                                                                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-21 13:56 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

Po Lu <luangruo@yahoo.com> writes:

[...]

> I would write:
>
> [...]
> * src/xterm.c (handle_one_xevent): Set menu_bar_p to true.
>
> With that aside, LGTM.  Thanks.

A new one.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Support-for-menu-bar-in-window_from_coordinates.patch --]
[-- Type: text/x-patch, Size: 16205 bytes --]

From fc447fffab2c9cc0228528b1686480c10be505ce Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Sat, 21 Oct 2023 14:36:24 +0200
Subject: [PATCH] Support for menu bar in window_from_coordinates

* src/window.h:
* src/window.c (window_from_coordinates): In the no toolkit
build, add support for the menu bar window.  Add a new
'menu_bar_p' argument so the function's signature has changed.
All callers changed.

* src/androidterm.c (handle_one_android_event):
* src/haikuterm.c (haiku_read_socket):
* src/keyboard.c (make_lispy_position):
* src/nsterm.m ([EmacsView mouseDown:]):
* src/pgtkterm.c (button_event):
* src/w32term.c (w32_read_socket):
* src/xdisp.c (note_mouse_highlight):
* src/xterm.c (handle_one_xevent): Set menu_bar_p to true.
---
 src/androidterm.c | 10 +++++-----
 src/haikuterm.c   |  8 ++++----
 src/keyboard.c    |  2 +-
 src/msdos.c       |  2 +-
 src/nsterm.m      |  4 ++--
 src/pgtkterm.c    |  4 ++--
 src/w32inevt.c    |  2 +-
 src/w32term.c     |  8 ++++----
 src/window.c      | 20 ++++++++++++++++++--
 src/window.h      |  2 +-
 src/xdisp.c       |  4 ++--
 src/xterm.c       | 17 +++++++++--------
 12 files changed, 50 insertions(+), 33 deletions(-)

diff --git a/src/androidterm.c b/src/androidterm.c
index 9d6517cce2b..e95e854d1d7 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -1142,7 +1142,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      Lisp_Object window
 		= window_from_coordinates (f, event->xmotion.x,
 					   event->xmotion.y, 0,
-					   false, false);
+					   false, false, false);
 
 	      /* A window will be autoselected only when it is not
 		 selected now and the last mouse movement event was
@@ -1291,7 +1291,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tab_bar_p = EQ (window, f->tab_bar_window);
 
 	      if (tab_bar_p)
@@ -1313,7 +1313,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	      int x = event->xbutton.x;
 	      int y = event->xbutton.y;
 
-	      window = window_from_coordinates (f, x, y, 0, true, true);
+	      window = window_from_coordinates (f, x, y, 0, true, true, true);
 	      tool_bar_p = (EQ (window, f->tool_bar_window)
 			    && ((event->xbutton.type
 				 != ANDROID_BUTTON_RELEASE)
@@ -1409,7 +1409,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  int y = event->touch.y;
 
 	  window = window_from_coordinates (any, x, y, 0, true,
-					    true);
+					    true, true);
 
 	  /* If this touch has started in the tool bar, do not
 	     send it to Lisp.  Instead, simulate a tool bar
@@ -1606,7 +1606,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 	  /* Figure out how much to scale the deltas by.  */
 	  window = window_from_coordinates (any, event->wheel.x,
 					    event->wheel.y, NULL,
-					    false, false);
+					    false, false, false);
 
 	  if (WINDOWP (window))
 	    scroll_height = XWINDOW (window)->pixel_height;
diff --git a/src/haikuterm.c b/src/haikuterm.c
index b1a016b49a9..bcb5055ea42 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -3472,7 +3472,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		if (!NILP (Vmouse_autoselect_window))
 		  {
 		    static Lisp_Object last_mouse_window;
-		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0);
+		    Lisp_Object window = window_from_coordinates (f, b->x, b->y, 0, 0, 0, 0);
 
 		    if (WINDOWP (window)
 			&& !EQ (window, last_mouse_window)
@@ -3555,7 +3555,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tab_bar_p = EQ (window, f->tab_bar_window);
 
 		if (tab_bar_p)
@@ -3573,7 +3573,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 		int x = b->x;
 		int y = b->y;
 
-		window = window_from_coordinates (f, x, y, 0, true, true);
+		window = window_from_coordinates (f, x, y, 0, true, true, true);
 		tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (type != BUTTON_UP
 				  || f->last_tool_bar_item != -1));
@@ -3834,7 +3834,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 
 	    BView_get_mouse (FRAME_HAIKU_VIEW (f), &x, &y);
 
-	    wheel_window = window_from_coordinates (f, x, y, 0, false, false);
+	    wheel_window = window_from_coordinates (f, x, y, 0, false, false, false);
 
 	    if (NILP (wheel_window))
 	      {
diff --git a/src/keyboard.c b/src/keyboard.c
index 76dec637cb1..00e178f2b93 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5558,7 +5558,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
   int xret = 0, yret = 0;
   /* The window or frame under frame pixel coordinates (x,y)  */
   Lisp_Object window_or_frame = f
-    ? window_from_coordinates (f, mx, my, &part, true, true)
+    ? window_from_coordinates (f, mx, my, &part, true, true, true)
     : Qnil;
 #ifdef HAVE_WINDOW_SYSTEM
   bool tool_bar_p = false;
diff --git a/src/msdos.c b/src/msdos.c
index 1b7f2d4ae21..5dd7c1573c4 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2662,7 +2662,7 @@ dos_rawgetc (void)
 	      static Lisp_Object last_mouse_window;
 
 	      mouse_window = window_from_coordinates
-		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0);
+		(SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0, 0);
 	      /* A window will be selected only when it is not
 		 selected now, and the last mouse movement event was
 		 not in it.  A minibuffer window will be selected iff
diff --git a/src/nsterm.m b/src/nsterm.m
index 11535f071eb..46a5e8870e8 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7412,7 +7412,7 @@ - (void)mouseDown: (NSEvent *)theEvent
 	  int x = lrint (p.x);
 	  int y = lrint (p.y);
 
-	  window = window_from_coordinates (emacsframe, x, y, 0, true, true);
+	  window = window_from_coordinates (emacsframe, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, emacsframe->tab_bar_window);
 
 	  if (tab_bar_p)
@@ -7518,7 +7518,7 @@ - (void)mouseMoved: (NSEvent *)e
       NSTRACE_MSG ("mouse_autoselect_window");
       static Lisp_Object last_mouse_window;
       Lisp_Object window
-	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0);
+	= window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0, 0, 0);
 
       if (WINDOWP (window)
           && !EQ (window, last_mouse_window)
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index a7c687d811d..461c9d6d899 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -5894,7 +5894,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
 	{
 	  static Lisp_Object last_mouse_window;
 	  Lisp_Object window = window_from_coordinates
-	    (f, event->motion.x, event->motion.y, 0, false, false);
+	    (f, event->motion.x, event->motion.y, 0, false, false, false);
 
 	  /* A window will be autoselected only when it is not
 	     selected now and the last mouse movement event was
@@ -6047,7 +6047,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
 	  int x = event->button.x;
 	  int y = event->button.y;
 
-	  window = window_from_coordinates (f, x, y, 0, true, true);
+	  window = window_from_coordinates (f, x, y, 0, true, true, true);
 	  tab_bar_p = EQ (window, f->tab_bar_window);
 
 	  if (tab_bar_p)
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 29717954cfd..630a9f4e5fb 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -496,7 +496,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
 	    if (!NILP (Vmouse_autoselect_window))
 	      {
 		Lisp_Object mouse_window = window_from_coordinates (f, mx, my,
-								    0, 0, 0);
+								    0, 0, 0, 0);
 		/* A window will be selected only when it is not
 		   selected now, and the last mouse movement event was
 		   not in it.  A minibuffer window will be selected iff
diff --git a/src/w32term.c b/src/w32term.c
index a5f17a18213..301d8f4ef12 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3376,7 +3376,7 @@ w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg,
       if (w32_wheel_scroll_lines == UINT_MAX)
 	{
 	  Lisp_Object window = window_from_coordinates (f, p.x, p.y, NULL,
-							false, false);
+							false, false, false);
 	  if (!WINDOWP (window))
 	    {
 	      result->kind = NO_EVENT;
@@ -5335,7 +5335,7 @@ w32_read_socket (struct terminal *terminal,
 		{
 		  static Lisp_Object last_mouse_window;
 		  Lisp_Object window = window_from_coordinates
-		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0);
+		    (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0, 0, 0);
 
 		  /* Window will be selected only when it is not
 		     selected now and last mouse movement event was
@@ -5407,7 +5407,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tab_bar_window))
                       {
@@ -5435,7 +5435,7 @@ w32_read_socket (struct terminal *terminal,
 		    int x = XFIXNAT (inev.x);
 		    int y = XFIXNAT (inev.y);
 
-                    window = window_from_coordinates (f, x, y, 0, 1, 1);
+                    window = window_from_coordinates (f, x, y, 0, 1, 1, 1);
 
                     if (EQ (window, f->tool_bar_window)
 			/* Make sure the tool bar was previously
diff --git a/src/window.c b/src/window.c
index 968b982c135..e802ffb3fe2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1680,7 +1680,8 @@ check_window_containing (struct window *w, void *user_data)
 
 Lisp_Object
 window_from_coordinates (struct frame *f, int x, int y,
-			 enum window_part *part, bool tab_bar_p, bool tool_bar_p)
+			 enum window_part *part, bool menu_bar_p,
+			 bool tab_bar_p, bool tool_bar_p)
 {
   Lisp_Object window;
   struct check_window_data cw;
@@ -1693,6 +1694,21 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* If not found above, see if it's in the menu bar window, if a menu
+     bar exists.  */
+  if (NILP (window)
+      && menu_bar_p
+      && WINDOWP (f->menu_bar_window)
+      && WINDOW_TOTAL_LINES (XWINDOW (f->menu_bar_window)) > 0
+      && (coordinates_in_window (XWINDOW (f->menu_bar_window), x, y)
+	  != ON_NOTHING))
+    {
+      *part = ON_TEXT;
+      window = f->menu_bar_window;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* If not found above, see if it's in the tab bar window, if a tab
      bar exists.  */
@@ -1746,7 +1762,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
 				  (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
 				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
-				  0, false, false);
+				  0, false, false, false);
 }
 
 ptrdiff_t
diff --git a/src/window.h b/src/window.h
index 413293420fd..9ef8434af18 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1111,7 +1111,7 @@ #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)	\
 
 extern Lisp_Object make_window (void);
 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
-                                            enum window_part *, bool, bool);
+                                            enum window_part *, bool, bool, bool);
 extern void resize_frame_windows (struct frame *, int, bool);
 extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
diff --git a/src/xdisp.c b/src/xdisp.c
index b9009df5df9..578131a4005 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2778,7 +2778,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
       goto virtual_glyph;
     }
   else if (!f->glyphs_initialized_p
-	   || (window = window_from_coordinates (f, gx, gy, &part, false, false),
+	   || (window = window_from_coordinates (f, gx, gy, &part, false, false, false),
 	       NILP (window)))
     {
       width = FRAME_SMALLEST_CHAR_WIDTH (f);
@@ -35438,7 +35438,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
     return;
 
   /* Which window is that in?  */
-  window = window_from_coordinates (f, x, y, &part, true, true);
+  window = window_from_coordinates (f, x, y, &part, true, true, true);
 
   /* If displaying active text in another window, clear that.  */
   if (! EQ (window, hlinfo->mouse_face_window)
diff --git a/src/xterm.c b/src/xterm.c
index 517bdf57aab..d5ca60089d7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -21161,7 +21161,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  }
 
 		Lisp_Object window = window_from_coordinates
-		  (f, xmotion.x, xmotion.y, 0, false, false);
+		  (f, xmotion.x, xmotion.y, 0, false, false, false);
 
 		/* A window will be autoselected only when it is not
 		   selected now and the last mouse movement event was
@@ -21892,7 +21892,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tab_bar_p = EQ (window, f->tab_bar_window);
 
                 if (tab_bar_p)
@@ -21913,7 +21913,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 int x = event->xbutton.x;
                 int y = event->xbutton.y;
 
-                window = window_from_coordinates (f, x, y, 0, true, true);
+                window = window_from_coordinates (f, x, y, 0, true, true, true);
                 tool_bar_p = (EQ (window, f->tool_bar_window)
 			      && (event->xbutton.type != ButtonRelease
 				  || f->last_tool_bar_item != -1));
@@ -22646,7 +22646,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			    continue;
 
 			  window = window_from_coordinates (f, real_x, real_y, NULL,
-							    false, false);
+							    false, false, false);
 
 			  if (WINDOWP (window))
 			    scroll_height = XWINDOW (window)->pixel_height;
@@ -23089,7 +23089,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 			  || !NILP (focus_follows_mouse)))
 		    {
 		      static Lisp_Object last_mouse_window;
-		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
+		      Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false,
+								    false);
 
 		      /* A window will be autoselected only when it is not
 			 selected now and the last mouse movement event was
@@ -23667,7 +23668,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      tab_bar_p = EQ (window, f->tab_bar_window);
 
 		      if (tab_bar_p)
@@ -23688,7 +23689,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		      int x = bv.x;
 		      int y = bv.y;
 
-		      window = window_from_coordinates (f, x, y, 0, true, true);
+		      window = window_from_coordinates (f, x, y, 0, true, true, true);
 		      /* Ignore button release events if the mouse
 			 wasn't previously pressed on the tool bar.
 			 We do this because otherwise selecting some
@@ -24694,7 +24695,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 		  int x = xev->event_x;
 		  int y = xev->event_y;
 
-		  window = window_from_coordinates (f, x, y, 0, true, true);
+		  window = window_from_coordinates (f, x, y, 0, true, true, true);
 		  /* Ignore button release events if the mouse
 		     wasn't previously pressed on the tool bar.
 		     We do this because otherwise selecting some
-- 
2.42.0


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-21 13:56                                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-27  8:11                                                                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-27  8:18                                                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-27  8:11 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440

Hi Po,

Do you think that you could commit it on master?

Thanks,
-- 
Manuel Giraud





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-27  8:11                                                                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-27  8:18                                                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-27 10:35                                                                             ` Eli Zaretskii
  0 siblings, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-27  8:18 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, stefankangas, 64440

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Hi Po,
>
> Do you think that you could commit it on master?
>
> Thanks,

I was awaiting comments from Eli and Stefan.  To them: does this meet
with your approbation?  If so, I will commit this to master.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-27  8:18                                                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-27 10:35                                                                             ` Eli Zaretskii
  2023-10-28  5:26                                                                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Eli Zaretskii @ 2023-10-27 10:35 UTC (permalink / raw)
  To: Po Lu; +Cc: stefankangas, manuel, 64440

> From: Po Lu <luangruo@yahoo.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,  stefankangas@gmail.com,
>   64440@debbugs.gnu.org
> Date: Fri, 27 Oct 2023 16:18:56 +0800
> 
> Manuel Giraud <manuel@ledu-giraud.fr> writes:
> 
> > Hi Po,
> >
> > Do you think that you could commit it on master?
> >
> > Thanks,
> 
> I was awaiting comments from Eli and Stefan.  To them: does this meet
> with your approbation?  If so, I will commit this to master.

I don't have time ATM to invest in this more than I already did,
sorry.  So please go ahead and install this, and let's take it from
there.

Thanks.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-27 10:35                                                                             ` Eli Zaretskii
@ 2023-10-28  5:26                                                                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-29  9:02                                                                                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-28  5:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: stefankangas, manuel, 64440-done

Now done, and thanks.





^ permalink raw reply	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-28  5:26                                                                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-29  9:02                                                                                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-10-29 10:18                                                                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 54+ messages in thread
From: Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-29  9:02 UTC (permalink / raw)
  To: Po Lu; +Cc: Eli Zaretskii, stefankangas, 64440-done

[-- Attachment #1: Type: text/plain, Size: 209 bytes --]

Po Lu <luangruo@yahoo.com> writes:

> Now done, and thanks.

Thanks Po.  But could you also commit this one.  It is the one and only
usage for all those changes.  It is used to set cursor as an arrow.
Thanks.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Set-non-text-mouse-cursor-on-menu-bar.patch --]
[-- Type: text/x-patch, Size: 1044 bytes --]

>From 9200d69b49fa57269e5357383d138872a372127a Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Fri, 6 Oct 2023 14:27:02 +0200
Subject: [PATCH 2/2] Set non-text mouse cursor on menu bar

* src/xdisp.c (note_mouse_highlight): Set non-text mouse cursor on
menu bar.
---
 src/xdisp.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index 7f9e62f05e8..df3076cf499 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -35537,6 +35537,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
+  /* Handle menu-bar window differently since it doesn't display a
+     buffer.  */
+  if (EQ (window, f->menu_bar_window))
+    {
+      cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
+      goto set_cursor;
+    }
+#endif
+
 #if defined (HAVE_WINDOW_SYSTEM)
   /* Handle tab-bar window differently since it doesn't display a
      buffer.  */
-- 
2.40.0


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items
  2023-10-29  9:02                                                                                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-10-29 10:18                                                                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 54+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-10-29 10:18 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Eli Zaretskii, stefankangas, 64440-done

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Po Lu <luangruo@yahoo.com> writes:
>
>> Now done, and thanks.
>
> Thanks Po.  But could you also commit this one.  It is the one and only
> usage for all those changes.  It is used to set cursor as an arrow.
> Thanks.
>
>>From 9200d69b49fa57269e5357383d138872a372127a Mon Sep 17 00:00:00 2001
> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Date: Fri, 6 Oct 2023 14:27:02 +0200
> Subject: [PATCH 2/2] Set non-text mouse cursor on menu bar
>
> * src/xdisp.c (note_mouse_highlight): Set non-text mouse cursor on
> menu bar.
> ---
>  src/xdisp.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/src/xdisp.c b/src/xdisp.c
> index 7f9e62f05e8..df3076cf499 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -35537,6 +35537,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
>    w = XWINDOW (window);
>    frame_to_window_pixel_xy (w, &x, &y);
>  
> +#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_MENU_BAR)
> +  /* Handle menu-bar window differently since it doesn't display a
> +     buffer.  */
> +  if (EQ (window, f->menu_bar_window))
> +    {
> +      cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
> +      goto set_cursor;
> +    }
> +#endif
> +
>  #if defined (HAVE_WINDOW_SYSTEM)
>    /* Handle tab-bar window differently since it doesn't display a
>       buffer.  */
> -- 
> 2.40.0

Now done, thanks.





^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2023-10-29 10:18 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03 15:59 bug#64440: 30.0.50; [PATCH] Highlight on non toolkit menu bar items Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-04 16:14 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-01 18:55   ` Stefan Kangas
2023-09-02  0:44     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-02  6:41       ` Eli Zaretskii
2023-09-02 13:09         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-05  9:53         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-10  7:31           ` Eli Zaretskii
2023-09-10  7:33             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 12:32             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 13:41               ` Eli Zaretskii
2023-09-11 14:59                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 15:58                   ` Eli Zaretskii
2023-09-11 18:56                     ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 19:12                       ` Eli Zaretskii
2023-09-11 20:51                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12 11:13                           ` Eli Zaretskii
2023-09-12 11:26                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12 12:48                             ` Eli Zaretskii
2023-09-12 13:06                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12 13:15                                 ` Eli Zaretskii
2023-09-12 13:19                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12 13:34                                     ` Eli Zaretskii
2023-09-12 13:42                                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12 13:56                                         ` Stefan Kangas
2023-09-12 14:06                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12 14:27                                             ` Stefan Kangas
2023-09-13 16:48                                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-06 12:49                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-06 13:14                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-06 15:39                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-06 15:59                                                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 10:19                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 10:28                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 11:02                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 11:10                                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 12:02                                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 12:27                                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 12:44                                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 12:48                                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 13:03                                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 13:24                                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 13:56                                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-27  8:11                                                                         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-27  8:18                                                                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-27 10:35                                                                             ` Eli Zaretskii
2023-10-28  5:26                                                                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-29  9:02                                                                                 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-29 10:18                                                                                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 11:10                                                         ` Stefan Kangas
2023-10-21 12:06                                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-21 10:31                                                     ` Stefan Kangas
2023-09-11 12:51             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-02 13:05       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).