All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] gtk: make it possible to hide the menu bar
@ 2018-05-10 23:07 Peter Wu
  2018-05-10 23:07 ` [Qemu-devel] [PATCH 2/2] gtk: disable the F10 menubar key Peter Wu
  2018-05-15  8:32 ` [Qemu-devel] [PATCH 1/2] gtk: make it possible to hide the menu bar Gerd Hoffmann
  0 siblings, 2 replies; 7+ messages in thread
From: Peter Wu @ 2018-05-10 23:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Saves some space and disables the F10 button as side-effect.

Fixes: https://bugs.launchpad.net/qemu/+bug/1726910
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
---
 ui/gtk.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index bb3214cffb..9e5390f2c2 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -145,6 +145,7 @@
 #define GDK_KEY_2 GDK_2
 #define GDK_KEY_f GDK_f
 #define GDK_KEY_g GDK_g
+#define GDK_KEY_m GDK_m
 #define GDK_KEY_q GDK_q
 #define GDK_KEY_plus GDK_plus
 #define GDK_KEY_equal GDK_equal
@@ -208,6 +209,7 @@ struct GtkDisplayState {
 
     GtkWidget *show_tabs_item;
     GtkWidget *untabify_item;
+    GtkWidget *show_menubar_item;
 
     GtkWidget *vbox;
     GtkWidget *notebook;
@@ -1387,6 +1389,30 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
     }
 }
 
+static void gd_menu_show_menubar(GtkMenuItem *item, void *opaque)
+{
+    GtkDisplayState *s = opaque;
+    VirtualConsole *vc = gd_vc_find_current(s);
+
+    if (s->full_screen) {
+        return;
+    }
+
+    if (gtk_check_menu_item_get_active(
+                GTK_CHECK_MENU_ITEM(s->show_menubar_item))) {
+        gtk_widget_show(s->menu_bar);
+    } else {
+        gtk_widget_hide(s->menu_bar);
+    }
+    gd_update_windowsize(vc);
+}
+
+static void gd_accel_show_menubar(void *opaque)
+{
+    GtkDisplayState *s = opaque;
+    gtk_menu_item_activate(GTK_MENU_ITEM(s->show_menubar_item));
+}
+
 static void gd_menu_full_screen(GtkMenuItem *item, void *opaque)
 {
     GtkDisplayState *s = opaque;
@@ -1403,7 +1429,10 @@ static void gd_menu_full_screen(GtkMenuItem *item, void *opaque)
     } else {
         gtk_window_unfullscreen(GTK_WINDOW(s->window));
         gd_menu_show_tabs(GTK_MENU_ITEM(s->show_tabs_item), s);
-        gtk_widget_show(s->menu_bar);
+        if (gtk_check_menu_item_get_active(
+                    GTK_CHECK_MENU_ITEM(s->show_menubar_item))) {
+            gtk_widget_show(s->menu_bar);
+        }
         s->full_screen = FALSE;
         if (vc->type == GD_VC_GFX) {
             vc->gfx.scale_x = 1.0;
@@ -2036,6 +2065,8 @@ static void gd_connect_signals(GtkDisplayState *s)
                      G_CALLBACK(gd_menu_show_tabs), s);
     g_signal_connect(s->untabify_item, "activate",
                      G_CALLBACK(gd_menu_untabify), s);
+    g_signal_connect(s->show_menubar_item, "activate",
+                     G_CALLBACK(gd_menu_show_menubar), s);
 
     g_signal_connect(s->window, "delete-event",
                      G_CALLBACK(gd_window_close), s);
@@ -2272,6 +2303,19 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
     s->untabify_item = gtk_menu_item_new_with_mnemonic(_("Detach Tab"));
     gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->untabify_item);
 
+    s->show_menubar_item = gtk_check_menu_item_new_with_mnemonic(
+            _("Show Menubar"));
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->show_menubar_item),
+                                   TRUE);
+    gtk_accel_group_connect(s->accel_group, GDK_KEY_m, HOTKEY_MODIFIERS, 0,
+            g_cclosure_new_swap(G_CALLBACK(gd_accel_show_menubar), s, NULL));
+#if GTK_CHECK_VERSION(3, 8, 0)
+    gtk_accel_label_set_accel(
+            GTK_ACCEL_LABEL(gtk_bin_get_child(GTK_BIN(s->show_menubar_item))),
+            GDK_KEY_m, HOTKEY_MODIFIERS);
+#endif
+    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->show_menubar_item);
+
     return view_menu;
 }
 
-- 
2.17.0

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

* [Qemu-devel] [PATCH 2/2] gtk: disable the F10 menubar key
  2018-05-10 23:07 [Qemu-devel] [PATCH 1/2] gtk: make it possible to hide the menu bar Peter Wu
@ 2018-05-10 23:07 ` Peter Wu
  2018-05-15  8:30   ` Gerd Hoffmann
  2018-05-15  8:32 ` [Qemu-devel] [PATCH 1/2] gtk: make it possible to hide the menu bar Gerd Hoffmann
  1 sibling, 1 reply; 7+ messages in thread
From: Peter Wu @ 2018-05-10 23:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

The F10 key is used in various applications, disable it unconditionally
(do not limit it to grab mode). Note that this property is deprecated
and might be removed in the future (GTK+ commit b082fb598d).

Fixes: https://bugs.launchpad.net/qemu/+bug/1726910
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
---
 ui/gtk.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ui/gtk.c b/ui/gtk.c
index 9e5390f2c2..6ad6cacfaa 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2321,6 +2321,8 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
 
 static void gd_create_menus(GtkDisplayState *s)
 {
+    GtkSettings *settings;
+
     s->accel_group = gtk_accel_group_new();
     s->machine_menu = gd_create_menu_machine(s);
     s->view_menu = gd_create_menu_view(s);
@@ -2336,6 +2338,10 @@ static void gd_create_menus(GtkDisplayState *s)
 
     g_object_set_data(G_OBJECT(s->window), "accel_group", s->accel_group);
     gtk_window_add_accel_group(GTK_WINDOW(s->window), s->accel_group);
+
+    /* Disable the default "F10" menu shortcut. */
+    settings = gtk_widget_get_settings(s->window);
+    g_object_set(G_OBJECT(settings), "gtk-menu-bar-accel", "", NULL);
 }
 
 
-- 
2.17.0

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

* Re: [Qemu-devel] [PATCH 2/2] gtk: disable the F10 menubar key
  2018-05-10 23:07 ` [Qemu-devel] [PATCH 2/2] gtk: disable the F10 menubar key Peter Wu
@ 2018-05-15  8:30   ` Gerd Hoffmann
  2018-05-15  8:39     ` Daniel P. Berrangé
  0 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2018-05-15  8:30 UTC (permalink / raw)
  To: Peter Wu; +Cc: qemu-devel

On Fri, May 11, 2018 at 01:07:39AM +0200, Peter Wu wrote:
> The F10 key is used in various applications, disable it unconditionally
> (do not limit it to grab mode). Note that this property is deprecated
> and might be removed in the future (GTK+ commit b082fb598d).

Any replacement provided by gtk?

I don't feel like adding new code depending on already deprecated
features ...

Also note that there is the "grab-on-hover" option in the view menu,
which will make qemu grab the keyboard if the mouse pointer is inside
the qemu window.  Which is pretty convinient for hotkeys, they go to the
guest if you work in the qemu window and to the host otherwise.

cheers,
  Gerd

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

* Re: [Qemu-devel] [PATCH 1/2] gtk: make it possible to hide the menu bar
  2018-05-10 23:07 [Qemu-devel] [PATCH 1/2] gtk: make it possible to hide the menu bar Peter Wu
  2018-05-10 23:07 ` [Qemu-devel] [PATCH 2/2] gtk: disable the F10 menubar key Peter Wu
@ 2018-05-15  8:32 ` Gerd Hoffmann
  1 sibling, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-05-15  8:32 UTC (permalink / raw)
  To: Peter Wu; +Cc: qemu-devel

On Fri, May 11, 2018 at 01:07:38AM +0200, Peter Wu wrote:
> Saves some space and disables the F10 button as side-effect.

Added to ui patch queue.

thanks,
  Gerd

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

* Re: [Qemu-devel] [PATCH 2/2] gtk: disable the F10 menubar key
  2018-05-15  8:30   ` Gerd Hoffmann
@ 2018-05-15  8:39     ` Daniel P. Berrangé
  2018-05-15  8:46       ` Gerd Hoffmann
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel P. Berrangé @ 2018-05-15  8:39 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Peter Wu, qemu-devel

On Tue, May 15, 2018 at 10:30:09AM +0200, Gerd Hoffmann wrote:
> On Fri, May 11, 2018 at 01:07:39AM +0200, Peter Wu wrote:
> > The F10 key is used in various applications, disable it unconditionally
> > (do not limit it to grab mode). Note that this property is deprecated
> > and might be removed in the future (GTK+ commit b082fb598d).
> 
> Any replacement provided by gtk?

It doesn't look like it

> I don't feel like adding new code depending on already deprecated
> features ...
> 
> Also note that there is the "grab-on-hover" option in the view menu,
> which will make qemu grab the keyboard if the mouse pointer is inside
> the qemu window.  Which is pretty convinient for hotkeys, they go to the
> guest if you work in the qemu window and to the host otherwise.

IMHO the right thing todo long term is to kill the menu bar from the
GTK UI entirely, and replace with the GTK HeaderBar. This allows the
menu items to be provided via popups directly from the title bar of
the windows, which is more vertically space efficient. This would
probably have to wait for us to ditch GTK2, so I think this fix is
reasonable until that time.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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

* Re: [Qemu-devel] [PATCH 2/2] gtk: disable the F10 menubar key
  2018-05-15  8:39     ` Daniel P. Berrangé
@ 2018-05-15  8:46       ` Gerd Hoffmann
  2018-05-15  8:55         ` Peter Wu
  0 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2018-05-15  8:46 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: Peter Wu, qemu-devel

On Tue, May 15, 2018 at 09:39:12AM +0100, Daniel P. Berrangé wrote:
> On Tue, May 15, 2018 at 10:30:09AM +0200, Gerd Hoffmann wrote:
> > On Fri, May 11, 2018 at 01:07:39AM +0200, Peter Wu wrote:
> > > The F10 key is used in various applications, disable it unconditionally
> > > (do not limit it to grab mode). Note that this property is deprecated
> > > and might be removed in the future (GTK+ commit b082fb598d).
> > 
> > Any replacement provided by gtk?
> 
> It doesn't look like it
> 
> > I don't feel like adding new code depending on already deprecated
> > features ...
> > 
> > Also note that there is the "grab-on-hover" option in the view menu,
> > which will make qemu grab the keyboard if the mouse pointer is inside
> > the qemu window.  Which is pretty convinient for hotkeys, they go to the
> > guest if you work in the qemu window and to the host otherwise.
> 
> IMHO the right thing todo long term is to kill the menu bar from the
> GTK UI entirely, and replace with the GTK HeaderBar. This allows the
> menu items to be provided via popups directly from the title bar of
> the windows, which is more vertically space efficient. This would
> probably have to wait for us to ditch GTK2, so I think this fix is
> reasonable until that time.

Fair enough.  Patch queued.

cheers,
  Gerd

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

* Re: [Qemu-devel] [PATCH 2/2] gtk: disable the F10 menubar key
  2018-05-15  8:46       ` Gerd Hoffmann
@ 2018-05-15  8:55         ` Peter Wu
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Wu @ 2018-05-15  8:55 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Daniel P. Berrangé, qemu-devel

On Tue, May 15, 2018 at 10:46:54AM +0200, Gerd Hoffmann wrote:
> On Tue, May 15, 2018 at 09:39:12AM +0100, Daniel P. Berrangé wrote:
> > On Tue, May 15, 2018 at 10:30:09AM +0200, Gerd Hoffmann wrote:
> > > On Fri, May 11, 2018 at 01:07:39AM +0200, Peter Wu wrote:
> > > > The F10 key is used in various applications, disable it unconditionally
> > > > (do not limit it to grab mode). Note that this property is deprecated
> > > > and might be removed in the future (GTK+ commit b082fb598d).
> > > 
> > > Any replacement provided by gtk?
> > 
> > It doesn't look like it

Would it still be possible to change the commit message? I asked Timm
(the author of that commit) about it, and it appears that the feature
was restored at some point again because gnome-terminal relied on it.

The new message (if possible):

The F10 key is used in various applications, disable it unconditionally
(do not limit it to grab mode). This property will still work with GTK3,
but as it is deprecated it might be removed in GTK4.
-- 
Kind regards,
Peter Wu
https://lekensteyn.nl

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

end of thread, other threads:[~2018-05-15  8:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10 23:07 [Qemu-devel] [PATCH 1/2] gtk: make it possible to hide the menu bar Peter Wu
2018-05-10 23:07 ` [Qemu-devel] [PATCH 2/2] gtk: disable the F10 menubar key Peter Wu
2018-05-15  8:30   ` Gerd Hoffmann
2018-05-15  8:39     ` Daniel P. Berrangé
2018-05-15  8:46       ` Gerd Hoffmann
2018-05-15  8:55         ` Peter Wu
2018-05-15  8:32 ` [Qemu-devel] [PATCH 1/2] gtk: make it possible to hide the menu bar Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.