Commit graph

123 commits

Author SHA1 Message Date
Max Reitz 63c67b6d44 gtk: Replace gdk_cursor_new()
gdk_cursor_new() has been deprecated in GTK 3.16, it is recommended to
use gdk_cursor_new_for_display() instead, so do that.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-05-29 11:43:29 +02:00
Gerd Hoffmann 97edf3bd5e gtk: add opengl support, using egl
This adds opengl rendering support to the gtk ui, using egl.
It's off by default for now, use 'qemu -display gtk,gl=on'
to play with this.

Note that gtk got native opengl support with release 3.16.
There most likely will be a separate implementation for 3.16+,
using the native gtk opengl support.  This patch covers older
versions (and for the time being 3.16 too, hopefully without
rendering quirks).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-05-29 11:43:29 +02:00
Gerd Hoffmann 1271f7f7c6 gtk: update mouse position in mouse_set()
Without that the next mouse motion event uses the old position
as base for relative move calculation, giving wrong results and
making your mouse pointer jump around.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-05-06 08:38:05 +02:00
Gerd Hoffmann dc7ff34418 gtk: create gtk.h
Move various gtk bits (includes, data structures) to a header file.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-05-06 08:38:05 +02:00
Gerd Hoffmann 1301e515ef gtk: add ui_info support
Pass new display size to the guest after window resizes.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-05-06 08:38:05 +02:00
Jan Kiszka 1a01716a30 gtk: Avoid accel key leakage into guest on console switch
GTK2 sends the accel key to the guest when switching to the graphic
console via that shortcut. Resolve this by ignoring any keys until the
next key-release event. However, do not ignore keys when switching via
the menu or when on GTK3.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-04-27 11:00:43 +02:00
Jan Kiszka 9d677e1c2f gtk: Fix VTE focus grabbing
At least on GTK2, the VTE terminal has to be specified as target of
gtk_widget_grab_focus. Otherwise, switching from one VTE terminal to
another causes the focus to get lost.

CC: John Snow <jsnow@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

[ kraxel: fixed build with CONFIG_VTE=n ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-04-27 11:00:07 +02:00
Gerd Hoffmann 779ce88fbd console/gtk: add qemu_console_get_label
Add a new function to get a nice label for a given QemuConsole.
Drop the labeling code in gtk.c and use the new function instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-04-22 13:21:16 +02:00
Gerd Hoffmann f8c223f69a gtk: bind to text terminal consoles too
This way gtk has text terminal consoles even when building without vte.
Most notably you'll get a monitor tab on windows now.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-04-22 13:21:16 +02:00
Gerd Hoffmann f98f43eab0 gtk: handle switch_surface(NULL) properly
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-04-22 13:21:16 +02:00
Hervé Poussineau 4cdfc93526 gtk: do not call gtk_widget_get_window if drawing area is not initialized
This prevents gtk_widget_get_window to return a NULL pointer.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-03-26 17:58:12 +01:00
Benjamin Herrenschmidt fcf73af68e ui/gtk: Support shared surface for most pixman formats
At least all the ones I've tested. We make the assumption that
pixman is going to be better at conversion than we are.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

[ kraxel: just hook up qemu_pixman_check_format ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-01-19 13:33:26 +01:00
Fam Zheng b310a2a609 gtk: Don't crash if -nodefaults
This fixes a crash by just skipping the vte resize hack if cur is NULL.

Reproducer:

qemu-system-x86_64 -nodefaults

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-11-21 08:37:59 +01:00
zhanghailiang 8a0f9b5263 gtk: fix possible memory leak about local_err
local_err in gd_vc_gfx_init() is not freed, and we don't use it,
so remove it.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-11-21 08:37:59 +01:00
Gerd Hoffmann dc52017146 gtk: add GDK_KEY_pause #define
Add pause key to the list of compatibility defines.
Fixes the build with older gtk versions.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-11-04 14:40:20 +01:00
Cole Robinson b0f3182064 gtk: Hide the menubar when in fullscreen mode (lp 1294898)
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>
2014-11-04 08:15:21 +01:00
Cole Robinson 277836c82b gtk: Install vc accelerators on parent window
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>
2014-11-04 08:15:21 +01:00
Cole Robinson 9541491461 gtk: Install fullscreen accelerator on toplevel window
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>
2014-11-04 08:15:21 +01:00
Cole Robinson 400519d24a gtk: Grab accel_group from GtkDisplayState
Rather than needlessly pass it around

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-11-04 08:15:21 +01:00
Gerd Hoffmann 316cb068bd gtk: avoid gd_widget_reparent with gtk 3.14+
gtk_widget_reparent is depricated in gtk 3.14, stop using it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-10-28 11:25:14 +01:00
Gerd Hoffmann 987fec54e1 gtk: drop gtk_widget_set_double_buffered call
Dunno why it is here.  Removing it seems to have no ill side effects.
It is depricated in 3.14+.  In some cases it has no effect since 3.10
according to the docs:

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-set-double-buffered

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-10-28 11:25:14 +01:00
Martin Decky 5c960521b8 gtk: add support for the Pause key
Special handing of the Pause key. Implemented in a similar way as in
ui/sdl.c.

Signed-off-by: Martin Decky <martin@decky.cz>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-10-15 11:08:32 +02:00
Chen Fan 84961407a5 gtk.c: Fix memory leak in gd_set_keycode_type()
this memory leak is introduced by the original
 commit 3158a3482b

 valgrind out showing:
 ==14553== 21,459 (72 direct, 21,387 indirect) bytes in 1 blocks are definitely
 lost in loss record 8,055 of 8,082
 ==14553==    at 0x4A06BC3: calloc (vg_replace_malloc.c:618)
 ==14553==    by 0x80DBFBC: XkbGetKeyboardByName (in /usr/lib64/libX11.so.6.3.0)
 ==14553==    by 0x40C704: gtk_display_init (gtk.c:1798)
 ==14553==    by 0x1AEDC1: main (vl.c:4480)

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-10-15 11:08:32 +02:00
John Snow e72b59fa93 ui/gtk: Restore keyboard focus after Page change
(Resending for correct email addresses via MAINTAINERS ...)

In the GTK UI, after changing focus to the qemu monitor Notebook Page,
when restoring focus to the virtual machine page, the keyboard focus is lost
to a hidden GTK widget. Focus can only be restored to the virtual machine by
pressing "tab" or any of the four directional arrow keys.

Clicking in the window or grabbing/ungrabbing input does not restore keyboard
focus to the child widget.

This patch adjusts the Notebook page switching callback to automatically
steal keyboard focus on the Page switch event, so that keyboard input
does not appear to break or disappear after tabbing to the QEMU monitor.

Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-07-11 10:44:00 +02:00
Gerd Hoffmann fa7a1e5219 gtk: update window size after showing/hiding tabs
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-06-11 14:26:49 +02:00
Gerd Hoffmann f50def915e gtk: factor out gtk3 grab into the new gd_grab_devices function
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-06-11 14:26:49 +02:00
Gerd Hoffmann 0a337ed067 gtk: cleanup backend dependencies
Make configure detect gtk x11 backend and link libX11 then.  Make
gtk backend specific code properly #ifdef'ed on the GTK_WINDOWING_*
backends at runtime).  Our gtk ui code should build and run fine on
any platform now.

This also fixes the linker failute due to the new XkbGetKeyboard call
added by commit 3158a3482b.

Cc: Richard Henderson <rth@twiddle.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
2014-06-11 14:26:49 +02:00
Gerd Hoffmann 932f2d7e0f gtk: factor out keycode mapping
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-06-11 14:26:49 +02:00
Gerd Hoffmann 6fa2769751 gtk: workaround gtk2 vte resize issue
Hack isn't pretty, but gets the job done.
See source code comment for details.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:04 +02:00
Gerd Hoffmann 82fc18099a gtk: window sizing overhaul
Major overhaul for window size handling.  This basically switches qemu
over to use geometry hints for the window manager instead of trying to
get the job done with widget resize requests.  This allows to specify
better what we need and also avoids window resizes.

FIXME: on gtk2 someone overwrites the geometry hints :(

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:04 +02:00
Gerd Hoffmann 0f61a61df3 gtk: zap unused global_state
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:04 +02:00
Bruce Rogers 3158a3482b gtk: Add handling for the xfree86 keycodes
Currently only evdev keycodes are handled by the gtk-ui. SDL has
code to handle both. This patch adds similar processing so that
both keycode types will be handled via the gtk-ui.

Signed-off-by: Bruce Rogers <brogers@suse.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:04 +02:00
Gerd Hoffmann aa0a55d42d gtk: enable untabify for gfx
Now we have all grab fixes in place, so we can allow detaching
graphic display tabs too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:04 +02:00
Gerd Hoffmann 0c77a37f11 gtk: detached window pointer grabs
Make ungrab hotkey work with detached windows.
Enable pointer grabs for detached windows.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:04 +02:00
Gerd Hoffmann 99623c90d1 gtk: update all windows on mouse mode changes
We might have multiple graphic displays now which all need a cursor update.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann 2884cf5b93 gtk: fix grab checks
Make it handle multiple windows case correctly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann 4eeaa3a885 gtk: update gd_update_caption
Adapt to recent changes, handle multiple windows.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann 746b867030 gtk: skip keyboard grab when hover autograb is active
It's pointless.  With grab on hover enabled the keyboard grab
is already active when you press Ctrl-Alt-G ;)

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann 4c638e2e4b gtk: keep track of grab owner
Simplifies grab state tracking and makes ungrab more reliable.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann 1c856da57b gtk: add gd_grab trace event
Input grab code is tricky, add some debug & trouble shooting aid.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann 74444bc198 gtk: add tab to trace events
So you can see which of multiple displays (if present) was resized ;)

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann cdeb7090ee gtk: allow moving tabs to windows and back.
"View->Detach tab" will move to tab to a new window.
Simply closing the window will move it back into a notebook tab.
The label will be permamently stored in VirtualConsole->label,
so it can easily be reused to (re-)label tabs and windows.

Works for vte tabs only for now. pointer/kbd grab code needs
adaptions before we can enable it for gfx tabs too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann d3ef575080 gtk: simplify resize
Simply ask for a small window size.  When the widgets don't fit in gtk
will automatically make the window large enougth to make things fit, no
need to try (and fail) duplicate that logic in qemu.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann 6a24ced5ca gtk: use device type as label
IMO useful than showing VGA for any graphic device
even in case it is something completely different.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann ed1132e41a gtk: support multiple gfx displays
Each display gets its own tab.  Tab switching continues to work like it
did, just the hotkeys of the vte consoles changes in case a secondary
display is present as it will get ctrl-alt-2 assigned and the vtes are
shifted by one.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann e3500d1f5f gtk: move vga state into VirtualGfxConsole
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann 271a25c0b6 gtk: VirtualConsole restruction
Move all vte-related items into VirtualVteConsole substruct.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann 832189c9b1 gtk: remove page numbering assumtions from the code
Lookup page numbers using gtk_notebook_page_num() instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Cole Robinson 0fb20d1c39 gtk: Add a scrollbar for text consoles
Only show the scrollbar if the content doesn't fit on the visible space.

[ kraxel: fix box packing ]

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00
Gerd Hoffmann ee5f31e48b gtk: cleanup CONFIG_VTE ifdef a bit.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26 08:41:03 +02:00