summaryrefslogtreecommitdiff
path: root/ui/gtk.c
AgeCommit message (Collapse)AuthorFilesLines
2014-11-21gtk: Don't crash if -nodefaultsFam Zheng1-7/+9
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-21gtk: fix possible memory leak about local_errzhanghailiang1-2/+1
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-04gtk: add GDK_KEY_pause #defineGerd Hoffmann1-0/+1
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-04gtk: Hide the menubar when in fullscreen mode (lp 1294898)Cole Robinson1-2/+2
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-04gtk: Install vc accelerators on parent windowCole Robinson1-7/+15
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-04gtk: Install fullscreen accelerator on toplevel windowCole Robinson1-4/+14
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-04gtk: Grab accel_group from GtkDisplayStateCole Robinson1-12/+9
Rather than needlessly pass it around Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-10-28gtk: avoid gd_widget_reparent with gtk 3.14+Gerd Hoffmann1-2/+11
gtk_widget_reparent is depricated in gtk 3.14, stop using it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-10-28gtk: drop gtk_widget_set_double_buffered callGerd Hoffmann1-1/+0
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-15gtk: add support for the Pause keyMartin Decky1-0/+6
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-15gtk.c: Fix memory leak in gd_set_keycode_type()Chen Fan1-0/+7
this memory leak is introduced by the original commit 3158a3482b0093e41f2b2596fba50774ea31ae08 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-07-11ui/gtk: Restore keyboard focus after Page changeJohn Snow1-3/+6
(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-06-11gtk: update window size after showing/hiding tabsGerd Hoffmann1-0/+2
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-06-11gtk: factor out gtk3 grab into the new gd_grab_devices functionGerd Hoffmann1-64/+36
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-06-11gtk: cleanup backend dependenciesGerd Hoffmann1-28/+42
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 3158a3482b0093e41f2b2596fba50774ea31ae08. Cc: Richard Henderson <rth@twiddle.net> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
2014-06-11gtk: factor out keycode mappingGerd Hoffmann1-7/+16
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: workaround gtk2 vte resize issueGerd Hoffmann1-0/+40
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-26gtk: window sizing overhaulGerd Hoffmann1-30/+70
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-26gtk: zap unused global_stateGerd Hoffmann1-4/+0
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: Add handling for the xfree86 keycodesBruce Rogers1-1/+35
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-26gtk: enable untabify for gfxGerd Hoffmann1-3/+7
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-26gtk: detached window pointer grabsGerd Hoffmann1-3/+21
Make ungrab hotkey work with detached windows. Enable pointer grabs for detached windows. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: update all windows on mouse mode changesGerd Hoffmann1-1/+5
We might have multiple graphic displays now which all need a cursor update. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: fix grab checksGerd Hoffmann1-12/+23
Make it handle multiple windows case correctly. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: update gd_update_captionGerd Hoffmann1-17/+28
Adapt to recent changes, handle multiple windows. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: skip keyboard grab when hover autograb is activeGerd Hoffmann1-1/+3
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-26gtk: keep track of grab ownerGerd Hoffmann1-5/+23
Simplifies grab state tracking and makes ungrab more reliable. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: add gd_grab trace eventGerd Hoffmann1-0/+4
Input grab code is tricky, add some debug & trouble shooting aid. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: add tab to trace eventsGerd Hoffmann1-3/+3
So you can see which of multiple displays (if present) was resized ;) Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: allow moving tabs to windows and back.Gerd Hoffmann1-11/+63
"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-26gtk: simplify resizeGerd Hoffmann1-26/+14
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-26gtk: use device type as labelGerd Hoffmann1-2/+12
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-26gtk: support multiple gfx displaysGerd Hoffmann1-37/+43
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-26gtk: move vga state into VirtualGfxConsoleGerd Hoffmann1-278/+337
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: VirtualConsole restructionGerd Hoffmann1-46/+73
Move all vte-related items into VirtualVteConsole substruct. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: remove page numbering assumtions from the codeGerd Hoffmann1-10/+30
Lookup page numbers using gtk_notebook_page_num() instead. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: Add a scrollbar for text consolesCole Robinson1-2/+40
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-26gtk: cleanup CONFIG_VTE ifdef a bit.Gerd Hoffmann1-19/+26
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: zap vte size requestsGerd Hoffmann1-14/+0
The vte tabs simply get the size of the vga tab then, with whatever cols and lines are fitting in. I find this bahavior more useful than resizing the qemu window all day long. YMMV. Comments are welcome. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26gtk: zap scrolled_windowGerd Hoffmann1-17/+2
The vte widget implements the scrollable interface, placing it into a scrolled window is pointless and creates a bunch of strange effects. Zap it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29gtk: Fix accelerators being triggered twice with gtk3Cole Robinson1-22/+0
When keyboard focus is grabbed, current qemu wants to pass every keypress to the VM, unless the user is pressing a UI accelerator. That's exactly how things work without any of the fancy handling. Drop the special handling, which seems to trigger accelerators twice on gtk3. Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29gtk: Fix -serial vcCole Robinson1-32/+9
Try kicking off a rhel5 text install over serial, the text menu navigation is all messed up, and some of the kernel boot messages are randomly corrupted. Drop use of a pty and just use vte infrastructure for reading and writing. This fixes the above corruption, and is simpler to boot. (I don't know what was wrong with the original code though. FWIW this is what virt-manager has done for years). Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29gtk: Use ctrl+alt+q for quit acceleratorCole Robinson1-1/+2
Using the standard ctrl+q makes it too easy to kill the whole VM. Using ctrl+alt+FOO is consistent with our other accelerators. https://bugzilla.redhat.com/show_bug.cgi?id=1062393 Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29gtk: Remove use of deprecated stock itemsCole Robinson1-9/+7
Stock items are deprecated. As are ImageMenuItems. Convert everything to text only MenuItems, with the same text content as mentioned in the conversion guide: https://docs.google.com/spreadsheet/pub?key=0AsPAM3pPwxagdGF4THNMMUpjUW5xMXZfdUNzMXhEa2c&output=html gtk2 users lose their menu icons as well, but I don't think that's enough of a problem to warrant keeping around back compat code. Example error: ui/gtk.c:1328:5: error: ‘GtkStock’ is deprecated [-Werror=deprecated-declarations] ui/gtk.c:1335:5: error: ‘gtk_image_menu_item_new_from_stock’ is deprecated (declared at /usr/include/gtk-3.0/gtk/deprecated/gtkimagemenuitem.h:78): Use 'gtk_menu_item_new' instead [-Werror=deprecated-declarations] s->zoom_out_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL); Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29gtk: Don't use deprecated vte_terminal_get_adjustmentCole Robinson1-0/+4
Guard this with a VTE version check, since I'm not sure if this is backwards compatible. ui/gtk.c: In function ‘gd_vc_init’: ui/gtk.c:1176:5: error: ‘vte_terminal_get_adjustment’ is deprecated (declared at /usr/include/vte-2.90/vte/vtedeprecated.h:101) [-Werror=deprecated-declarations] Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29gtk: Don't use deprecated gtk_image_menu_item_new_with_mnemonicCole Robinson1-2/+2
In these cases we weren't using an image in the menu item anyways, so just do as the suggestion says. Should be fine for all qemu supported gtk versions. ui/gtk.c: In function ‘gd_create_menu_machine’: ui/gtk.c:1284:5: error: ‘gtk_image_menu_item_new_with_mnemonic’ is deprecated (declared at /usr/include/gtk-3.0/gtk/deprecated/gtkimagemenuitem.h:76): Use 'gtk_menu_item_new_with_mnemonic' instead [-Werror=deprecated-declarations] s->reset_item = gtk_image_menu_item_new_with_mnemonic(_("_Reset")); ^ ui/gtk.c:1287:5: error: ‘gtk_image_menu_item_new_with_mnemonic’ is deprecated (declared at /usr/include/gtk-3.0/gtk/deprecated/gtkimagemenuitem.h:76): Use 'gtk_menu_item_new_with_mnemonic' instead [-Werror=deprecated-declarations] s->powerdown_item = gtk_image_menu_item_new_with_mnemonic(_("Power _Down")); Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-08gtk: Implement grab-on-click behavior in relative modeTakashi Iwai1-2/+17
This patch changes the behavior in the relative mode to be compatible with other UIs, namely, grabbing the input at the first left click. It improves the usability a lot; otherwise you have to press ctl-alt-G or select from menu at each time you want to move the pointer. Also, the input grab is cleared when the current mode is switched to the absolute mode. The automatic reset of the implicit grabbing is needed since the switching to the absolute mode happens always after the click even on Gtk. That is, we cannot check whether the absolute mode is already available at the first click time even though it should have been switched in X11 input driver side. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-07gtk: Remember the last grabbed pointer positionTakashi Iwai1-2/+14
It's pretty annoying that the pointer reappears at a random place once after grabbing and ungrabbing the input. Better to restore to the original position where the pointer was grabbed. Reference: https://bugzilla.novell.com/show_bug.cgi?id=849587 Tested-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com> Tested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-07gtk: Fix the relative pointer tracking modeTakashi Iwai1-9/+9
The relative pointer tracking mode was still buggy even after the previous fix of the motion-notify-event since the events are filtered out when the pointer moves outside the drawing window due to the boundary check for the absolute mode. This patch fixes the issue by moving the unnecessary boundary check into the if block of absolute mode, and keep the coordinate in the relative mode even if it's outside the drawing area. But this makes the coordinate (last_x, last_y) possibly pointing to (-1,-1), introduce a new flag to indicate the last coordinate has been updated. Reference: https://bugzilla.novell.com/show_bug.cgi?id=849587 Tested-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com> Tested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-07gtk: Use gtk generic event signal instead of motion-notify-eventTakashi Iwai1-2/+10
The GDK motion-notify-event isn't generated when the pointer goes out of the target window even if the pointer is grabbed, which essentially means to lose the pointer tracking in gtk-ui. Meanwhile the generic "event" signal is sent when the pointer is grabbed, so we can use this and pick the motion notify events manually there instead. Reference: https://bugzilla.novell.com/show_bug.cgi?id=849587 Tested-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com> Tested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>