From: Po Lu Date: Tue, 30 Nov 2021 05:55:16 +0000 (+0800) Subject: Enable shallow menu bar updates on PGTK X-Git-Tag: emacs-29.0.90~3640 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=72d223a5445831d681a1fbc6f23370cef5252cd3;p=emacs.git Enable shallow menu bar updates on PGTK * src/gtkutil.c (menu_bar_button_pressed_cb): New function. (create_menus): Connect button press event signal. * src/pgtkmenu.c (set_frame_menubar): Allow shallow updates. --- diff --git a/src/gtkutil.c b/src/gtkutil.c index c2b33912efb..d872d393caf 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -3141,6 +3141,20 @@ xg_create_one_menuitem (widget_value *item, return w; } +#ifdef HAVE_PGTK +static gboolean +menu_bar_button_pressed_cb (GtkWidget *widget, GdkEvent *event, + gpointer user_data) +{ + struct frame *f = user_data; + + if (event->button.button < 4) + set_frame_menubar (f, true); + + return false; +} +#endif + /* Create a full menu tree specified by DATA. F is the frame the created menu belongs to. SELECT_CB is the callback to use when a menu item is selected. @@ -3198,6 +3212,10 @@ create_menus (widget_value *data, else { wmenu = gtk_menu_bar_new (); +#ifdef HAVE_PGTK + g_signal_connect (G_OBJECT (wmenu), "button-press-event", + G_CALLBACK (menu_bar_button_pressed_cb), f); +#endif /* Set width of menu bar to a small value so it doesn't enlarge a small initial frame size. The width will be set to the width of the frame later on when it is added to a container. diff --git a/src/pgtkmenu.c b/src/pgtkmenu.c index 88020c3044b..6f8f8720ded 100644 --- a/src/pgtkmenu.c +++ b/src/pgtkmenu.c @@ -297,10 +297,6 @@ set_frame_menubar (struct frame *f, bool deep_p) if (!menubar_widget) deep_p = true; - /* Since button_event handler in pgtk emacs doesn't handle mouse - * events in menubars, the menu needs to be built now. */ - deep_p = true; - if (deep_p) { struct buffer *prev = current_buffer;