aboutsummaryrefslogtreecommitdiff
path: root/ui/sdl2.c
AgeCommit message (Collapse)AuthorFilesLines
2017-06-23sdl2: add assert to make coverity happyGerd Hoffmann1-0/+1
There is a loop a few lines up counting consoles and setting sdl2_num_outputs accordingly, so con ptr can't be NULL there. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20170621122234.12751-1-kraxel@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2017-05-23shutdown: Add source information to SHUTDOWN and RESETEric Blake1-2/+2
Time to wire up all the call sites that request a shutdown or reset to use the enum added in the previous patch. It would have been less churn to keep the common case with no arguments as meaning guest-triggered, and only modified the host-triggered code paths, via a wrapper function, but then we'd still have to audit that I didn't miss any host-triggered spots; changing the signature forces us to double-check that I correctly categorized all callers. Since command line options can change whether a guest reset request causes an actual reset vs. a shutdown, it's easy to also add the information to reset requests. Signed-off-by: Eric Blake <eblake@redhat.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> [ppc parts] Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> [SPARC part] Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> [s390x parts] Message-Id: <20170515214114.15442-5-eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2017-05-11ui: Support non-zero minimum values for absolute input axesPhilippe Voinov1-2/+2
This patch refactors ui/input.c to support absolute axis minimum values other than 0. All dependent calls to qemu_input_queue_abs have been updated to explicitly supply 0 as the axis minimum value. Signed-off-by: Philippe Voinov <philippevoinov@gmail.com> Message-id: 20170505133952.29885-1-philippevoinov@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2017-02-27sdl2: add scanout_disable supportGerd Hoffmann1-0/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 1487669841-13668-6-git-send-email-kraxel@redhat.com
2017-02-27console: rename dpy_gl_scanout to dpy_gl_scanout_textureGerd Hoffmann1-1/+1
We'll add a variant which accepts dmabufs soon. Change the name so we can easily disturgish the two variants. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 1487669841-13668-2-git-send-email-kraxel@redhat.com
2017-01-13sdl2: fix build failure on windowsGerd Hoffmann1-0/+6
Cc: Stefan Weil <sw@weilnetz.de> Cc: Samuel Thibault <samuel.thibault@gnu.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Stefan Weil <sw@weilnetz.de> Message-id: 1484295285-8809-1-git-send-email-kraxel@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-01-10sdl2: set window IDSamuel Thibault1-0/+7
This uses the console API to record the window ID of the SDL2 windows. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Message-id: 20161221003806.22412-4-samuel.thibault@ens-lyon.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2016-06-03sdl2: skip init without outputsGerd Hoffmann1-0/+3
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Tested-by: Cole Robinson <crobinso@redhat.com> Message-id: 1464790116-32405-1-git-send-email-kraxel@redhat.com
2016-05-11ui: sdl2: Release grab before opening console windowCole Robinson1-0/+4
sdl 2.0.4 currently has a bug which causes our UI shortcuts to fire rapidly in succession: https://bugzilla.libsdl.org/show_bug.cgi?id=3287 It's a toss up whether ctrl+alt+f or ctrl+alt+2 will fire an odd or even number of times, thus determining whether the action succeeds or fails. Opening monitor/serial windows is doubly broken, since it will often lock the UI trying to grab the pointer: 0x00007fffef3720a5 in SDL_Delay_REAL () at /lib64/libSDL2-2.0.so.0 0x00007fffef3688ba in X11_SetWindowGrab () at /lib64/libSDL2-2.0.so.0 0x00007fffef2f2da7 in SDL_SendWindowEvent () at /lib64/libSDL2-2.0.so.0 0x00007fffef2f080b in SDL_SetKeyboardFocus () at /lib64/libSDL2-2.0.so.0 0x00007fffef35d784 in X11_DispatchFocusIn.isra.8 () at /lib64/libSDL2-2.0.so.0 0x00007fffef35dbce in X11_DispatchEvent () at /lib64/libSDL2-2.0.so.0 0x00007fffef35ee4a in X11_PumpEvents () at /lib64/libSDL2-2.0.so.0 0x00007fffef2eea6a in SDL_PumpEvents_REAL () at /lib64/libSDL2-2.0.so.0 0x00007fffef2eeab5 in SDL_WaitEventTimeout_REAL () at /lib64/libSDL2-2.0.so.0 0x000055555597eed0 in sdl2_poll_events (scon=0x55555876f928) at ui/sdl2.c:593 We can work around that hang by ungrabbing the pointer before launching a new window. This roughly matches what our sdl1 code does Signed-off-by: Cole Robinson <crobinso@redhat.com> Message-id: 31c9ab6540b031f7a614c59edcecea9877685612.1462557436.git.crobinso@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2016-03-01qapi: rename input buttonsGerd Hoffmann1-2/+2
All lowercase, use-dash instead of CamelCase. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2016-02-04ui: Clean up includesPeter Maydell1-0/+1
Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1454089805-5470-2-git-send-email-peter.maydell@linaro.org
2016-02-02sdl: shorten the GUI refresh interval when mouse or keyboard is activeJindřich Makovička1-0/+23
Signed-off-by: Jindřich Makovička <makovick@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2016-01-08sdl2/opengl: add opengl context and scanout supportGerd Hoffmann1-0/+7
This allows virtio-gpu to render in 3d mode. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2015-12-17qapi: Change munging of CamelCase enum valuesEric Blake1-2/+2
When munging enum values, the fact that we were passing the entire prefix + value through camel_to_upper() meant that enum values spelled with CamelCase could be turned into CAMEL_CASE. However, this provides a potential collision (both OneTwo and One-Two would munge into ONE_TWO) for enum types, when the same two names are valid side-by-side as QAPI member names. By changing the generation of enum constants to always be prefix + '_' + c_name(value, False).upper(), and ensuring that there are no case collisions (in the next patches), we no longer have to worry about names that would be distinct as QAPI members but collide as variant tag names, without having to think about what munging the heuristics in camel_to_upper() will actually perform on an enum value. Making the change will affect enums that did not follow coding conventions, using 'CamelCase' rather than desired 'lower-case'. Thankfully, there are only two culprits: InputButton and ErrorClass. We already tweaked ErrorClass to make it an alias of QapiErrorClass, where only the alias needs changing rather than the whole tree. So the bulk of this change is modifying INPUT_BUTTON_WHEEL_UP to the new INPUT_BUTTON_WHEELUP (and likewise for WHEELDOWN). That part of this commit may later need reverting if we rename the enum constants from 'WheelUp' to 'wheel-up' as part of moving x-input-send-event to a stable interface; but at least we have documentation bread crumbs in place to remind us (commit 513e7cd), and it matches the fact that SDL constants are also spelled SDL_BUTTON_WHEELUP. Suggested by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1447836791-369-27-git-send-email-eblake@redhat.com> [Commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-12-17qapi: Don't let implicit enum MAX member collideEric Blake1-1/+1
Now that we guarantee the user doesn't have any enum values beginning with a single underscore, we can use that for our own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious that the sentinel is generated. This patch was mostly generated by applying a temporary patch: |diff --git a/scripts/qapi.py b/scripts/qapi.py |index e6d014b..b862ec9 100644 |--- a/scripts/qapi.py |+++ b/scripts/qapi.py |@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = { | max_index = c_enum_const(name, 'MAX', prefix) | ret += mcgen(''' | [%(max_index)s] = NULL, |+// %(max_index)s | }; | ''', | max_index=max_index) then running: $ cat qapi-{types,event}.c tests/test-qapi-types.c | sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list $ git grep -l _MAX | xargs sed -i -f list The only things not generated are the changes in scripts/qapi.py. Rejecting enum members named 'MAX' is now useless, and will be dropped in the next patch. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> [Rebased to current master, commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-06-09sdl2: fix crash in handle_windowevent() when restoring the screen sizeAlberto Garcia1-0/+4
The Ctrl-Alt-u keyboard shortcut restores the screen to its original size. In the SDL2 UI this is done by destroying the window and creating a new one. The old window emits SDL_WINDOWEVENT_HIDDEN when it's destroyed, but trying to call SDL_GetWindowFromID() from that event's window ID returns a null pointer. handle_windowevent() assumes that the pointer is never null so it results in a crash. Cc: qemu-stable@nongnu.org Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-05-05sdl2: add support for display rendering using opengl.Gerd Hoffmann1-7/+58
Add new sdl2-gl.c file, with display rendering functions using opengl. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2015-05-05sdl2: move SDL_* includes to sdl2.hGerd Hoffmann1-6/+0
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2015-01-19ui/sdl2: Support shared surface for more pixman formatsGerd Hoffmann1-6/+7
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-12-17sdl2: Work around SDL2 SDL_ShowWindow() bugMax Reitz1-0/+10
Apparently it is possible for X to send an event to a hidden SDL2 window, leading to SDL2 believing it is now shown. SDL2 will pass the SDL_WINDOWEVENT_SHOWN message to the application without actually showing the window; the problem is that the next SDL_ShowWindow() will be a no-op because SDL2 assumes the window is already shown. The correct way to react to SDL_WINDOWEVENT_SHOWN would be to clear scon->hidden (analogous for SDL_WINDOWEVENT_HIDDEN). However, due to the window not actually being shown, this will somehow not be correct after all. Therefore, just hide the window on SDL_WINDOWEVENT_SHOWN if it is supposed to be hidden (and analogous for SDL_WINDOWEVENT_HIDDEN). Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-12-17sdl2: Use correct sdl2_console for window eventsMax Reitz1-2/+4
SDL_PollEvent() polls events for all windows; therefore, sdl2_poll_events() will poll the events for all windows and not only for the one identified by the given sdl2_console. This should be considered in handle_windowevent(): The window affected by the event is not necessarily the one identified by the sdl2_console object given to sdl2_poll_events(), but the one identified by ev->window.windowID. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-12-17sdl2: move sdl2_2d_refresh to sdl2-2d.cGerd Hoffmann1-9/+1
Now that common event handling code is split off, we can move over sdl_refresh to sdl2-2d.c, and rename it to sdl2_2d_refresh. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-12-17sdl2: factor out sdl2_poll_eventsGerd Hoffmann1-10/+13
Create a new function to poll and handle sdl2 events, which is then just called from the refresh timer. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-12-17sdl2: add+use sdl2_2d_redraw function.Gerd Hoffmann1-11/+6
Add a new sdl2_2d_redraw function for a complete screen refresh, so we can stop using graphic_hw_invalidate for that. There is no need to bother console / gfx emulation code if we are just going to re-blit the screen after window resizes. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-12-17sdl2: move sdl_switch to sdl2-2d.cGerd Hoffmann1-46/+4
Move sdl_switch to sdl2-2d.c file, rename to sdl2_2d_switch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-12-17sdl2: overhaul window size handlingGerd Hoffmann1-93/+79
Split do_sdl_resize function (which does alot more than just resizing) into three: sdl2_window_{create,destroy,resize}. Fix SDL_Renderer handling: must be guest display size not host window size, and SDL2 will magically handle all scaling for us. Make fullscreen actually enter fullscreen mode and simplify the code. There is no need to store the original window size, the window manager will do that for us. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-12-17sdl2: move sdl_update to new sdl2-2d.cGerd Hoffmann1-30/+5
Create new sdl2-2d file for 2d display rendering. Move over sdl_update code, and rename to sdl2_2d_update. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-12-17sdl2: turn on keyboard grabsGerd Hoffmann1-3/+4
Makes quite some keys actually go to the guest instead of being captured by the host window manager. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-12-17sdl2: move keyboard input code to new sdl2-input.cGerd Hoffmann1-72/+3
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-12-17sdl2: rename sdl2_state to sdl2_console, move to header fileGerd Hoffmann1-36/+27
Create sdl2.h header file, in preparation for sdl2 code splitup. Populate it with sdl2_console struct (renamed from sdl2_state). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-12-16sdl: move version logic from source code to makefileGerd Hoffmann1-3/+0
Compile sdl.c / sdl2.c depending on CONFIG_SDLABI instead of compiling both and have version #ifdefs in the source code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
2014-09-16sdl2: drop sdl_zoom.hGerd Hoffmann1-1/+0
It isn't used. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-06-02sdl2: textinput + terminalGerd Hoffmann1-1/+40
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-06-02sdl2: make Ctrl-Alt-<nr> hotkeys show and hide windowsGerd Hoffmann1-1/+26
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-05-26sdl: pass key event source to input layerGerd Hoffmann1-9/+12
So the input layer knows where the input is coming from and input routing works correctly. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29sdl2: Support mouse wheelCole Robinson1-18/+26
In SDL2, wheel movement is its own event, not a button event. Wire it up similar to gtk.c Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-29sdl2: add ui info setting.Dave Airlie1-0/+7
Allows you to resize the sdl2 window and have the guest notice. [ kraxel: zero-initialize QemuUIInfo ] Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-11input: sdl2: Fix relative mode to match SDL1 behaviorCole Robinson1-1/+2
Right now relative mode accelerates too fast, and has the 'invisible wall' problem. SDL2 added an explicit API to handle this use case, so let's use it. Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-04-11input: sdl2: Fix guest_cursor logicCole Robinson1-7/+11
Unbreaks relative mouse mode with sdl2, just like was done with sdl.c in c3aa84b6. Signed-off-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-03-05ui/sdl2 : initial port to SDL 2.0 (v2.0)Dave Airlie1-0/+829
I've ported the SDL1.2 code over, and rewritten it to use the SDL2 interface. The biggest changes were in the input handling, where SDL2 has done a major overhaul, and I've had to include a generated translation file to get from SDL2 codes back to qemu compatible ones. I'm still not sure how the keyboard layout code works in qemu, so there may be further work if someone can point me a test case that works with SDL1.2 and doesn't with SDL2. Some SDL env vars we used to set are no longer used by SDL2, Windows, OSX support is untested, I don't think we can link to SDL1.2 and SDL2 at the same time, so I felt using --with-sdlabi=2.0 to select the new code should be fine, like how gtk does it. v1.1: fix keys in text console v1.2: fix shutdown, cleanups a bit of code, support ARGB cursor v2.0: merge the SDL multihead patch into this, g_new the number of consoles needed, wrap DCL inside per-console structure. Signed-off-by: Dave Airlie <airlied@redhat.com> Fixes & improvements by kraxel: * baum build fix * remove text console logic * adapt to new input core * codestyle fixups Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>