sdl2: bugfixes.

spice: cleanups.
 input: mem leak fix.
 gtk: deprecate 2.x support.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJaWMu3AAoJEEy22O7T6HE4fkQP/1IKT3nfaMrRjQFwNFF/lcX/
 qUCfAojVmq+5at+Im/x29gq0xVI3J3/xaq53iyjUMJhS0rF382fY0ZMJwHj6LbVA
 jB2JiPa6JbyO5GC8bNCs5yYB8qtT0c9iP+6EcR+HJIuDj+eMt1tstLzv58waGM5/
 v1ZOEd4S4uMj6/dY/l9HZ5/CGkX8tlT4++zM3+kYvTEvkVRCIlGIEJA/R/mQmM+d
 M6tKqN2Yxc0QxypnuzXtLRPoEx9BlOMuNVR7IGdDbcc8z7yD47wq7XW7lxdqrDVo
 YLMlEZPxeBow78K5qq1MK32QeHtQqdXcu1RZCHGszu/I3Opad1UAS3JduHEQb2vO
 yD2KW3zGD8pB9TDEV9RTF10jtRRxakoB+UXeNnDX0vuylbNGcPTwBvrCCnwk+Ahj
 6raKwZnheqJW/zmr71UoDrpfAUKnmt4Y4Zvs06nuNqAXwIEGdIiX+7mz1pE+rK3u
 IUXOLAPE+HdDjcssbr3iuXove0pTpM6QXKY8exGKgByTmzK6/kfvA7DgS4g1wvgv
 HPLToS4mC2kg0ItphLdketSt+6K5qNXGChQxRjczzpLtiwpngd502VOaQui9gpXl
 nXkU+DTHY8bQDGgA+BJ8T6IB3qvCuWzFfRXrqHZR+eMHbQK+7dR21L++P6sCMFXM
 DzHlatBVfRs341k3GuS/
 =JUSN
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180112-pull-request' into staging

sdl2: bugfixes.
spice: cleanups.
input: mem leak fix.
gtk: deprecate 2.x support.

# gpg: Signature made Fri 12 Jan 2018 14:52:39 GMT
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/ui-20180112-pull-request:
  sdl2: Ignore UI hotkeys after a focus change when GUI modifier is held
  sdl2 uses surface relative coordinates
  sdl2: Do not hide the cursor on auxilliary windows
  spice: remove unused timer list
  spice: remove only written event_mask field
  spice: remove unused watch list
  spice: remove QXLWorker interface field
  ui: deprecate use of GTK 2.x in favour of 3.x series
  input: fix memory leak

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-01-12 16:41:24 +00:00
commit c7947342d7
10 changed files with 70 additions and 50 deletions

6
configure vendored
View File

@ -5629,6 +5629,12 @@ if test "$sdl_too_old" = "yes"; then
echo "-> Your SDL version is too old - please upgrade to have SDL support"
fi
if test "$gtkabi" = "2.0"; then
echo
echo "WARNING: Use of GTK 2.0 is deprecated and will be removed in"
echo "WARNING: future releases. Please switch to using GTK 3.0"
fi
if test "$supported_cpu" = "no"; then
echo
echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"

View File

@ -518,7 +518,6 @@ static void interface_attach_worker(QXLInstance *sin, QXLWorker *qxl_worker)
PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
trace_qxl_interface_attach_worker(qxl->id);
qxl->ssd.worker = qxl_worker;
}
static void interface_set_compression_level(QXLInstance *sin, int level)

View File

@ -24,6 +24,7 @@ struct sdl2_console {
int opengl;
int updates;
int idle_counter;
int ignore_hotkeys;
SDL_GLContext winctx;
#ifdef CONFIG_OPENGL
QemuGLShader *gls;

View File

@ -86,7 +86,6 @@ struct SimpleSpiceDisplay {
DisplayChangeListener dcl;
void *buf;
int bufsize;
QXLWorker *worker;
QXLInstance qxl;
uint32_t unique;
pixman_image_t *surface;

View File

@ -2587,6 +2587,15 @@ they were first deprecated in the 2.10.0 release.
What follows is a list of all features currently marked as
deprecated.
@section Build options
@subsection GTK 2.x
Previously QEMU has supported building against both GTK 2.x
and 3.x series APIs. Support for the GTK 2.x builds will be
discontinued, so maintainers should switch to using GTK 3.x,
which is the default.
@section System emulator command line arguments
@subsection -tdf (since 1.3.0)

View File

@ -2248,6 +2248,11 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
exit(1);
}
#if !GTK_CHECK_VERSION(3, 0, 0)
g_printerr("Running QEMU with GTK 2.x is deprecated, and will be removed\n"
"in a future release. Please switch to GTK 3.x instead\n");
#endif
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

View File

@ -421,6 +421,8 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down)
} else if (queue_count < queue_limit) {
qemu_input_queue_event(&kbd_queue, src, evt);
qemu_input_queue_sync(&kbd_queue);
} else {
qapi_free_InputEvent(evt);
}
}

View File

@ -276,32 +276,10 @@ static void sdl_send_mouse_event(struct sdl2_console *scon, int dx, int dy,
}
if (qemu_input_is_absolute()) {
int scr_w, scr_h;
int max_w = 0, max_h = 0;
int off_x = 0, off_y = 0;
int cur_off_x = 0, cur_off_y = 0;
int i;
for (i = 0; i < sdl2_num_outputs; i++) {
struct sdl2_console *thiscon = &sdl2_console[i];
if (thiscon->real_window && thiscon->surface) {
SDL_GetWindowSize(thiscon->real_window, &scr_w, &scr_h);
cur_off_x = thiscon->x;
cur_off_y = thiscon->y;
if (scr_w + cur_off_x > max_w) {
max_w = scr_w + cur_off_x;
}
if (scr_h + cur_off_y > max_h) {
max_h = scr_h + cur_off_y;
}
if (i == scon->idx) {
off_x = cur_off_x;
off_y = cur_off_y;
}
}
}
qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_X, off_x + x, 0, max_w);
qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_Y, off_y + y, 0, max_h);
qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_X,
x, 0, surface_width(scon->surface));
qemu_input_queue_abs(scon->dcl.con, INPUT_AXIS_Y,
y, 0, surface_height(scon->surface));
} else {
if (guest_cursor) {
x -= guest_x;
@ -334,22 +312,28 @@ static void toggle_full_screen(struct sdl2_console *scon)
sdl2_redraw(scon);
}
static void handle_keydown(SDL_Event *ev)
static int get_mod_state(void)
{
int mod_state, win;
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
SDL_Keymod mod = SDL_GetModState();
if (alt_grab) {
mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
return (mod & (gui_grab_code | KMOD_LSHIFT)) ==
(gui_grab_code | KMOD_LSHIFT);
} else if (ctrl_grab) {
mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL;
return (mod & KMOD_RCTRL) == KMOD_RCTRL;
} else {
mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
return (mod & gui_grab_code) == gui_grab_code;
}
gui_key_modifier_pressed = mod_state;
}
if (gui_key_modifier_pressed) {
static void handle_keydown(SDL_Event *ev)
{
int win;
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
gui_key_modifier_pressed = get_mod_state();
if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repeat) {
switch (ev->key.keysym.scancode) {
case SDL_SCANCODE_2:
case SDL_SCANCODE_3:
@ -423,6 +407,8 @@ static void handle_keyup(SDL_Event *ev)
int mod_state;
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
scon->ignore_hotkeys = false;
if (!alt_grab) {
mod_state = (ev->key.keysym.mod & gui_grab_code);
} else {
@ -466,6 +452,10 @@ static void handle_mousemotion(SDL_Event *ev)
int max_x, max_y;
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
if (!qemu_console_is_graphic(scon->dcl.con)) {
return;
}
if (qemu_input_is_absolute() || absolute_enabled) {
int scr_w, scr_h;
SDL_GetWindowSize(scon->real_window, &scr_w, &scr_h);
@ -494,6 +484,10 @@ static void handle_mousebutton(SDL_Event *ev)
SDL_MouseButtonEvent *bev;
struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
if (!qemu_console_is_graphic(scon->dcl.con)) {
return;
}
bev = &ev->button;
if (!gui_grab && !qemu_input_is_absolute()) {
if (ev->type == SDL_MOUSEBUTTONUP && bev->button == SDL_BUTTON_LEFT) {
@ -516,6 +510,10 @@ static void handle_mousewheel(SDL_Event *ev)
SDL_MouseWheelEvent *wev = &ev->wheel;
InputButton btn;
if (!qemu_console_is_graphic(scon->dcl.con)) {
return;
}
if (wev->y > 0) {
btn = INPUT_BUTTON_WHEEL_UP;
} else if (wev->y < 0) {
@ -557,6 +555,14 @@ static void handle_windowevent(SDL_Event *ev)
if (!gui_grab && (qemu_input_is_absolute() || absolute_enabled)) {
absolute_mouse_grab(scon);
}
/* If a new console window opened using a hotkey receives the
* focus, SDL sends another KEYDOWN event to the new window,
* closing the console window immediately after.
*
* Work around this by ignoring further hotkey events until a
* key is released.
*/
scon->ignore_hotkeys = get_mod_state();
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
if (gui_grab && !gui_fullscreen) {
@ -657,6 +663,11 @@ static void sdl_mouse_warp(DisplayChangeListener *dcl,
int x, int y, int on)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
if (!qemu_console_is_graphic(scon->dcl.con)) {
return;
}
if (on) {
if (!guest_cursor) {
sdl_show_cursor();

View File

@ -55,9 +55,7 @@ static QemuThread me;
struct SpiceTimer {
QEMUTimer *timer;
QTAILQ_ENTRY(SpiceTimer) next;
};
static QTAILQ_HEAD(, SpiceTimer) timers = QTAILQ_HEAD_INITIALIZER(timers);
static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque)
{
@ -65,7 +63,6 @@ static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque)
timer = g_malloc0(sizeof(*timer));
timer->timer = timer_new_ms(QEMU_CLOCK_REALTIME, func, opaque);
QTAILQ_INSERT_TAIL(&timers, timer, next);
return timer;
}
@ -83,18 +80,14 @@ static void timer_remove(SpiceTimer *timer)
{
timer_del(timer->timer);
timer_free(timer->timer);
QTAILQ_REMOVE(&timers, timer, next);
g_free(timer);
}
struct SpiceWatch {
int fd;
int event_mask;
SpiceWatchFunc func;
void *opaque;
QTAILQ_ENTRY(SpiceWatch) next;
};
static QTAILQ_HEAD(, SpiceWatch) watches = QTAILQ_HEAD_INITIALIZER(watches);
static void watch_read(void *opaque)
{
@ -113,11 +106,10 @@ static void watch_update_mask(SpiceWatch *watch, int event_mask)
IOHandler *on_read = NULL;
IOHandler *on_write = NULL;
watch->event_mask = event_mask;
if (watch->event_mask & SPICE_WATCH_EVENT_READ) {
if (event_mask & SPICE_WATCH_EVENT_READ) {
on_read = watch_read;
}
if (watch->event_mask & SPICE_WATCH_EVENT_WRITE) {
if (event_mask & SPICE_WATCH_EVENT_WRITE) {
on_write = watch_write;
}
qemu_set_fd_handler(watch->fd, on_read, on_write, watch);
@ -131,7 +123,6 @@ static SpiceWatch *watch_add(int fd, int event_mask, SpiceWatchFunc func, void *
watch->fd = fd;
watch->func = func;
watch->opaque = opaque;
QTAILQ_INSERT_TAIL(&watches, watch, next);
watch_update_mask(watch, event_mask);
return watch;
@ -140,7 +131,6 @@ static SpiceWatch *watch_add(int fd, int event_mask, SpiceWatchFunc func, void *
static void watch_remove(SpiceWatch *watch)
{
qemu_set_fd_handler(watch->fd, NULL, NULL, NULL);
QTAILQ_REMOVE(&watches, watch, next);
g_free(watch);
}

View File

@ -519,7 +519,6 @@ static void interface_attach_worker(QXLInstance *sin, QXLWorker *qxl_worker)
SimpleSpiceDisplay *ssd = container_of(sin, SimpleSpiceDisplay, qxl);
dprint(1, "%s/%d:\n", __func__, ssd->qxl.id);
ssd->worker = qxl_worker;
}
static void interface_set_compression_level(QXLInstance *sin, int level)
@ -1028,7 +1027,6 @@ static void qemu_spice_display_init_one(QemuConsole *con)
ssd->qxl.base.sif = &dpy_interface.base;
qemu_spice_add_display_interface(&ssd->qxl, con);
assert(ssd->worker);
qemu_spice_create_host_memslot(ssd);
register_displaychangelistener(&ssd->dcl);