summaryrefslogtreecommitdiffstats
path: root/qemu/ui/sdl2.c
diff options
context:
space:
mode:
authorDon Dugger <n0ano@n0ano.com>2016-06-03 03:33:22 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-06-03 03:33:23 +0000
commitda27230f80795d0028333713f036d44c53cb0e68 (patch)
treeb3d379eaf000adf72b36cb01cdf4d79c3e3f064c /qemu/ui/sdl2.c
parent0e68cb048bb8aadb14675f5d4286d8ab2fc35449 (diff)
parent437fd90c0250dee670290f9b714253671a990160 (diff)
Merge "These changes are the raw update to qemu-2.6."
Diffstat (limited to 'qemu/ui/sdl2.c')
-rw-r--r--qemu/ui/sdl2.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/qemu/ui/sdl2.c b/qemu/ui/sdl2.c
index 5cb75aa36..d0424421e 100644
--- a/qemu/ui/sdl2.c
+++ b/qemu/ui/sdl2.c
@@ -23,6 +23,7 @@
*/
/* Ported SDL 1.2 code to 2.0 by Dave Airlie. */
+#include "qemu/osdep.h"
#include "qemu-common.h"
#include "ui/console.h"
#include "ui/input.h"
@@ -49,6 +50,10 @@ static int guest_x, guest_y;
static SDL_Cursor *guest_sprite;
static Notifier mouse_mode_notifier;
+#define SDL2_REFRESH_INTERVAL_BUSY 10
+#define SDL2_MAX_IDLE_COUNT (2 * GUI_REFRESH_INTERVAL_DEFAULT \
+ / SDL2_REFRESH_INTERVAL_BUSY + 1)
+
static void sdl_update_caption(struct sdl2_console *scon);
static struct sdl2_console *get_scon_from_window(uint32_t window_id)
@@ -256,7 +261,7 @@ static void sdl_mouse_mode_change(Notifier *notify, void *data)
static void sdl_send_mouse_event(struct sdl2_console *scon, int dx, int dy,
int x, int y, int state)
{
- static uint32_t bmap[INPUT_BUTTON_MAX] = {
+ static uint32_t bmap[INPUT_BUTTON__MAX] = {
[INPUT_BUTTON_LEFT] = SDL_BUTTON(SDL_BUTTON_LEFT),
[INPUT_BUTTON_MIDDLE] = SDL_BUTTON(SDL_BUTTON_MIDDLE),
[INPUT_BUTTON_RIGHT] = SDL_BUTTON(SDL_BUTTON_RIGHT),
@@ -578,6 +583,7 @@ static void handle_windowevent(SDL_Event *ev)
void sdl2_poll_events(struct sdl2_console *scon)
{
SDL_Event ev1, *ev = &ev1;
+ int idle = 1;
if (scon->last_vm_running != runstate_is_running()) {
scon->last_vm_running = runstate_is_running();
@@ -587,12 +593,15 @@ void sdl2_poll_events(struct sdl2_console *scon)
while (SDL_PollEvent(ev)) {
switch (ev->type) {
case SDL_KEYDOWN:
+ idle = 0;
handle_keydown(ev);
break;
case SDL_KEYUP:
+ idle = 0;
handle_keyup(ev);
break;
case SDL_TEXTINPUT:
+ idle = 0;
handle_textinput(ev);
break;
case SDL_QUIT:
@@ -602,13 +611,16 @@ void sdl2_poll_events(struct sdl2_console *scon)
}
break;
case SDL_MOUSEMOTION:
+ idle = 0;
handle_mousemotion(ev);
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
+ idle = 0;
handle_mousebutton(ev);
break;
case SDL_MOUSEWHEEL:
+ idle = 0;
handle_mousewheel(ev);
break;
case SDL_WINDOWEVENT:
@@ -618,6 +630,18 @@ void sdl2_poll_events(struct sdl2_console *scon)
break;
}
}
+
+ if (idle) {
+ if (scon->idle_counter < SDL2_MAX_IDLE_COUNT) {
+ scon->idle_counter++;
+ if (scon->idle_counter >= SDL2_MAX_IDLE_COUNT) {
+ scon->dcl.update_interval = GUI_REFRESH_INTERVAL_DEFAULT;
+ }
+ }
+ } else {
+ scon->idle_counter = 0;
+ scon->dcl.update_interval = SDL2_REFRESH_INTERVAL_BUSY;
+ }
}
static void sdl_mouse_warp(DisplayChangeListener *dcl,
@@ -700,6 +724,13 @@ static const DisplayChangeListenerOps dcl_gl_ops = {
.dpy_refresh = sdl2_gl_refresh,
.dpy_mouse_set = sdl_mouse_warp,
.dpy_cursor_define = sdl_mouse_define,
+
+ .dpy_gl_ctx_create = sdl2_gl_create_context,
+ .dpy_gl_ctx_destroy = sdl2_gl_destroy_context,
+ .dpy_gl_ctx_make_current = sdl2_gl_make_context_current,
+ .dpy_gl_ctx_get_current = sdl2_gl_get_current_context,
+ .dpy_gl_scanout = sdl2_gl_scanout,
+ .dpy_gl_update = sdl2_gl_scanout_flush,
};
#endif