* [Qemu-devel] [PULL 1/5] gtk: Grab accel_group from GtkDisplayState
2014-11-04 10:41 [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Gerd Hoffmann
@ 2014-11-04 10:41 ` Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 2/5] gtk: Install fullscreen accelerator on toplevel window Gerd Hoffmann
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2014-11-04 10:41 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori, Cole Robinson
From: Cole Robinson <crobinso@redhat.com>
Rather than needlessly pass it around
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/gtk.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index a5f6869..97ac4c9 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1605,13 +1605,13 @@ static void gd_connect_signals(GtkDisplayState *s)
G_CALLBACK(gd_change_page), s);
}
-static GtkWidget *gd_create_menu_machine(GtkDisplayState *s, GtkAccelGroup *accel_group)
+static GtkWidget *gd_create_menu_machine(GtkDisplayState *s)
{
GtkWidget *machine_menu;
GtkWidget *separator;
machine_menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(machine_menu), accel_group);
+ gtk_menu_set_accel_group(GTK_MENU(machine_menu), s->accel_group);
s->pause_item = gtk_check_menu_item_new_with_mnemonic(_("_Pause"));
gtk_menu_shell_append(GTK_MENU_SHELL(machine_menu), s->pause_item);
@@ -1692,7 +1692,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
return group;
}
-static GtkWidget *gd_create_menu_view(GtkDisplayState *s, GtkAccelGroup *accel_group)
+static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
{
GSList *group = NULL;
GtkWidget *view_menu;
@@ -1701,7 +1701,7 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, GtkAccelGroup *accel_g
int vc;
view_menu = gtk_menu_new();
- gtk_menu_set_accel_group(GTK_MENU(view_menu), accel_group);
+ gtk_menu_set_accel_group(GTK_MENU(view_menu), s->accel_group);
s->full_screen_item = gtk_menu_item_new_with_mnemonic(_("_Fullscreen"));
gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->full_screen_item),
@@ -1783,11 +1783,9 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, GtkAccelGroup *accel_g
static void gd_create_menus(GtkDisplayState *s)
{
- GtkAccelGroup *accel_group;
-
- accel_group = gtk_accel_group_new();
- s->machine_menu = gd_create_menu_machine(s, accel_group);
- s->view_menu = gd_create_menu_view(s, accel_group);
+ s->accel_group = gtk_accel_group_new();
+ s->machine_menu = gd_create_menu_machine(s);
+ s->view_menu = gd_create_menu_view(s);
s->machine_menu_item = gtk_menu_item_new_with_mnemonic(_("_Machine"));
gtk_menu_item_set_submenu(GTK_MENU_ITEM(s->machine_menu_item),
@@ -1798,9 +1796,8 @@ static void gd_create_menus(GtkDisplayState *s)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(s->view_menu_item), s->view_menu);
gtk_menu_shell_append(GTK_MENU_SHELL(s->menu_bar), s->view_menu_item);
- g_object_set_data(G_OBJECT(s->window), "accel_group", accel_group);
- gtk_window_add_accel_group(GTK_WINDOW(s->window), accel_group);
- s->accel_group = accel_group;
+ 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);
}
static void gd_set_keycode_type(GtkDisplayState *s)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PULL 2/5] gtk: Install fullscreen accelerator on toplevel window
2014-11-04 10:41 [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 1/5] gtk: Grab accel_group from GtkDisplayState Gerd Hoffmann
@ 2014-11-04 10:41 ` Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 3/5] gtk: Install vc accelerators on parent window Gerd Hoffmann
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2014-11-04 10:41 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori, Cole Robinson
From: Cole Robinson <crobinso@redhat.com>
Instead of installing it on the menu. This will be needed to keep the
fullscreen keyboard shortcut working when we hide the menu (in future
patches).
On gtk < 3.8, this has the unfortunate side effect of no longer listing
the key combo in the UI. We could manually change the label in that case,
but it will look visually out of place, and I'm not sure if anyone really
cares.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/gtk.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index 97ac4c9..af8b2d0 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1123,6 +1123,12 @@ static void gd_menu_full_screen(GtkMenuItem *item, void *opaque)
gd_update_cursor(vc);
}
+static void gd_accel_full_screen(void *opaque)
+{
+ GtkDisplayState *s = opaque;
+ gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
+}
+
static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)
{
GtkDisplayState *s = opaque;
@@ -1704,10 +1710,14 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
gtk_menu_set_accel_group(GTK_MENU(view_menu), s->accel_group);
s->full_screen_item = gtk_menu_item_new_with_mnemonic(_("_Fullscreen"));
- gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->full_screen_item),
- "<QEMU>/View/Full Screen");
- gtk_accel_map_add_entry("<QEMU>/View/Full Screen", GDK_KEY_f,
- HOTKEY_MODIFIERS);
+
+ gtk_accel_group_connect(s->accel_group, GDK_KEY_f, HOTKEY_MODIFIERS, 0,
+ g_cclosure_new_swap(G_CALLBACK(gd_accel_full_screen), s, NULL));
+#if GTK_CHECK_VERSION(3, 8, 0)
+ gtk_accel_label_set_accel(
+ GTK_ACCEL_LABEL(gtk_bin_get_child(GTK_BIN(s->full_screen_item))),
+ GDK_KEY_f, HOTKEY_MODIFIERS);
+#endif
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->full_screen_item);
separator = gtk_separator_menu_item_new();
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PULL 3/5] gtk: Install vc accelerators on parent window
2014-11-04 10:41 [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 1/5] gtk: Grab accel_group from GtkDisplayState Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 2/5] gtk: Install fullscreen accelerator on toplevel window Gerd Hoffmann
@ 2014-11-04 10:41 ` Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 4/5] gtk: Hide the menubar when in fullscreen mode (lp 1294898) Gerd Hoffmann
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2014-11-04 10:41 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori, Cole Robinson
From: Cole Robinson <crobinso@redhat.com>
So they are usable when we hide the menubar in upcoming patches. This
has the accelerator text caveat as the fullscreen bit in the previous
patch.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/gtk.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index af8b2d0..552a73b 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1020,6 +1020,12 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque)
}
}
+static void gd_accel_switch_vc(void *opaque)
+{
+ VirtualConsole *vc = opaque;
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE);
+}
+
static void gd_menu_show_tabs(GtkMenuItem *item, void *opaque)
{
GtkDisplayState *s = opaque;
@@ -1407,19 +1413,21 @@ static gboolean gd_focus_out_event(GtkWidget *widget,
static GSList *gd_vc_menu_init(GtkDisplayState *s, VirtualConsole *vc,
int idx, GSList *group, GtkWidget *view_menu)
{
- char path[32];
-
- snprintf(path, sizeof(path), "<QEMU>/View/VC%d", idx);
-
vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, vc->label);
- group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
- gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item), path);
- gtk_accel_map_add_entry(path, GDK_KEY_1 + idx, HOTKEY_MODIFIERS);
+ gtk_accel_group_connect(s->accel_group, GDK_KEY_1 + idx,
+ HOTKEY_MODIFIERS, 0,
+ g_cclosure_new_swap(G_CALLBACK(gd_accel_switch_vc), vc, NULL));
+#if GTK_CHECK_VERSION(3, 8, 0)
+ gtk_accel_label_set_accel(
+ GTK_ACCEL_LABEL(gtk_bin_get_child(GTK_BIN(vc->menu_item))),
+ GDK_KEY_1 + idx, HOTKEY_MODIFIERS);
+#endif
g_signal_connect(vc->menu_item, "activate",
G_CALLBACK(gd_menu_switch_vc), s);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item);
+ group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
return group;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PULL 4/5] gtk: Hide the menubar when in fullscreen mode (lp 1294898)
2014-11-04 10:41 [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Gerd Hoffmann
` (2 preceding siblings ...)
2014-11-04 10:41 ` [Qemu-devel] [PULL 3/5] gtk: Install vc accelerators on parent window Gerd Hoffmann
@ 2014-11-04 10:41 ` Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 5/5] gtk: add GDK_KEY_pause #define Gerd Hoffmann
2014-11-04 12:57 ` [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Peter Maydell
5 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2014-11-04 10:41 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori, Cole Robinson
From: Cole Robinson <crobinso@redhat.com>
In fullscreen mode, we attempt to shrink the menubar to 1 pixel in height,
so it takes up as little room as possible while still allowing us to use
the keyboard shortcuts for its various operations.
However this shrinking is disregarded on gtk3, so the entire menu bar is
visible, which isn't very pleasant. This patch hides the menu bar instead.
The side effect is that the only keyboard shortcuts that will work in this
mode are the ones that we explicitly register on the top level window and
not the menu bar. The previous patches changed the fullscreen and vc
shortcuts to work like that, which I think are the only ones that really
matter in for the fullscreen case.
https://bugs.launchpad.net/qemu/+bug/1294898
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/gtk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index 552a73b..de564cc 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1104,7 +1104,7 @@ static void gd_menu_full_screen(GtkMenuItem *item, void *opaque)
if (!s->full_screen) {
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
- gtk_widget_set_size_request(s->menu_bar, 0, 0);
+ gtk_widget_hide(s->menu_bar);
if (vc->type == GD_VC_GFX) {
gtk_widget_set_size_request(vc->gfx.drawing_area, -1, -1);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
@@ -1115,7 +1115,7 @@ 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_set_size_request(s->menu_bar, -1, -1);
+ gtk_widget_show(s->menu_bar);
s->full_screen = FALSE;
if (vc->type == GD_VC_GFX) {
vc->gfx.scale_x = 1.0;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PULL 5/5] gtk: add GDK_KEY_pause #define
2014-11-04 10:41 [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Gerd Hoffmann
` (3 preceding siblings ...)
2014-11-04 10:41 ` [Qemu-devel] [PULL 4/5] gtk: Hide the menubar when in fullscreen mode (lp 1294898) Gerd Hoffmann
@ 2014-11-04 10:41 ` Gerd Hoffmann
2014-11-04 11:51 ` Cornelia Huck
2014-11-04 12:57 ` [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Peter Maydell
5 siblings, 1 reply; 10+ messages in thread
From: Gerd Hoffmann @ 2014-11-04 10:41 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori
Add pause key to the list of compatibility defines.
Fixes the build with older gtk versions.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/gtk.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/ui/gtk.c b/ui/gtk.c
index de564cc..2f3e716 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -128,6 +128,7 @@ static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
#define GDK_KEY_q GDK_q
#define GDK_KEY_plus GDK_plus
#define GDK_KEY_minus GDK_minus
+#define GDK_KEY_pause GDK_pause
#endif
#define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PULL 5/5] gtk: add GDK_KEY_pause #define
2014-11-04 10:41 ` [Qemu-devel] [PULL 5/5] gtk: add GDK_KEY_pause #define Gerd Hoffmann
@ 2014-11-04 11:51 ` Cornelia Huck
2014-11-04 13:39 ` Alexander Graf
0 siblings, 1 reply; 10+ messages in thread
From: Cornelia Huck @ 2014-11-04 11:51 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel, Anthony Liguori
On Tue, 4 Nov 2014 11:41:11 +0100
Gerd Hoffmann <kraxel@redhat.com> wrote:
> Add pause key to the list of compatibility defines.
> Fixes the build with older gtk versions.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> ui/gtk.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/ui/gtk.c b/ui/gtk.c
> index de564cc..2f3e716 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -128,6 +128,7 @@ static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
> #define GDK_KEY_q GDK_q
> #define GDK_KEY_plus GDK_plus
> #define GDK_KEY_minus GDK_minus
> +#define GDK_KEY_pause GDK_pause
This needs to be _Pause with a capital 'P', otherwise the build still
fails.
> #endif
>
> #define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PULL 5/5] gtk: add GDK_KEY_pause #define
2014-11-04 11:51 ` Cornelia Huck
@ 2014-11-04 13:39 ` Alexander Graf
0 siblings, 0 replies; 10+ messages in thread
From: Alexander Graf @ 2014-11-04 13:39 UTC (permalink / raw)
To: Cornelia Huck, Gerd Hoffmann; +Cc: qemu-devel, Anthony Liguori
On 04.11.14 12:51, Cornelia Huck wrote:
> On Tue, 4 Nov 2014 11:41:11 +0100
> Gerd Hoffmann <kraxel@redhat.com> wrote:
>
>> Add pause key to the list of compatibility defines.
>> Fixes the build with older gtk versions.
>>
>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>> ---
>> ui/gtk.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/ui/gtk.c b/ui/gtk.c
>> index de564cc..2f3e716 100644
>> --- a/ui/gtk.c
>> +++ b/ui/gtk.c
>> @@ -128,6 +128,7 @@ static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
>> #define GDK_KEY_q GDK_q
>> #define GDK_KEY_plus GDK_plus
>> #define GDK_KEY_minus GDK_minus
>> +#define GDK_KEY_pause GDK_pause
>
> This needs to be _Pause with a capital 'P', otherwise the build still
> fails.
... and in case you do the same mistake as me, it needs to be an upper
case P on both pauses ;).
Alex
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions.
2014-11-04 10:41 [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Gerd Hoffmann
` (4 preceding siblings ...)
2014-11-04 10:41 ` [Qemu-devel] [PULL 5/5] gtk: add GDK_KEY_pause #define Gerd Hoffmann
@ 2014-11-04 12:57 ` Peter Maydell
2014-11-04 13:38 ` Gerd Hoffmann
5 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2014-11-04 12:57 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: QEMU Developers
On 4 November 2014 10:41, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Hi,
>
> Here comes the gtk patch queue, featuring a buildfix for older gtk2
> versions. And thanks to Cole we finally have the menu bar still being
> visible in fullscreen mode (fully in gtk3, thin line in gtk2) fixed.
> Yay!
>
> please pull,
> Gerd
I'm assuming you're going to respin this with the caps
fixed in the pause patch.
thanks
-- PMM
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions.
2014-11-04 12:57 ` [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Peter Maydell
@ 2014-11-04 13:38 ` Gerd Hoffmann
0 siblings, 0 replies; 10+ messages in thread
From: Gerd Hoffmann @ 2014-11-04 13:38 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers
On Di, 2014-11-04 at 12:57 +0000, Peter Maydell wrote:
> On 4 November 2014 10:41, Gerd Hoffmann <kraxel@redhat.com> wrote:
> > Hi,
> >
> > Here comes the gtk patch queue, featuring a buildfix for older gtk2
> > versions. And thanks to Cole we finally have the menu bar still being
> > visible in fullscreen mode (fully in gtk3, thin line in gtk2) fixed.
> > Yay!
> >
> > please pull,
> > Gerd
>
> I'm assuming you're going to respin this with the caps
> fixed in the pause patch.
Yes.
/me wonders why my build test on rhel6 didn't catch it. Ah, gtk2 got
rebased to 2.24.23, so it needs a older rhel6 install to trigger ...
sorry for the trouble,
Gerd
^ permalink raw reply [flat|nested] 10+ messages in thread