diff mbox

[2/2] gtk: disable the F10 menubar key

Message ID 20180510230739.28459-2-peter@lekensteyn.nl (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Wu May 10, 2018, 11:07 p.m. UTC
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(+)

Comments

Gerd Hoffmann May 15, 2018, 8:30 a.m. UTC | #1
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
Daniel P. Berrangé May 15, 2018, 8:39 a.m. UTC | #2
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
Gerd Hoffmann May 15, 2018, 8:46 a.m. UTC | #3
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
Peter Wu May 15, 2018, 8:55 a.m. UTC | #4
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.
diff mbox

Patch

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);
 }