From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PATCH 02/10] sdl2: rename sdl2_state to sdl2_console, move to header file
Date: Thu, 11 Dec 2014 11:49:25 +0100 [thread overview]
Message-ID: <1418294973-21790-3-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1418294973-21790-1-git-send-email-kraxel@redhat.com>
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>
---
include/ui/sdl2.h | 11 ++++++++++
ui/sdl2.c | 63 ++++++++++++++++++++++++-------------------------------
2 files changed, 38 insertions(+), 36 deletions(-)
create mode 100644 include/ui/sdl2.h
diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
new file mode 100644
index 0000000..7f91a75
--- /dev/null
+++ b/include/ui/sdl2.h
@@ -0,0 +1,11 @@
+struct sdl2_console {
+ DisplayChangeListener dcl;
+ DisplaySurface *surface;
+ SDL_Texture *texture;
+ SDL_Window *real_window;
+ SDL_Renderer *real_renderer;
+ int idx;
+ int last_vm_running; /* per console for caption reasons */
+ int x, y;
+ int hidden;
+};
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 45f23b1..375e1a3 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -32,22 +32,13 @@
#include "qemu-common.h"
#include "ui/console.h"
#include "ui/input.h"
+#include "ui/sdl2.h"
#include "sysemu/sysemu.h"
#include "sdl2-keymap.h"
static int sdl2_num_outputs;
-static struct sdl2_state {
- DisplayChangeListener dcl;
- DisplaySurface *surface;
- SDL_Texture *texture;
- SDL_Window *real_window;
- SDL_Renderer *real_renderer;
- int idx;
- int last_vm_running; /* per console for caption reasons */
- int x, y;
- int hidden;
-} *sdl2_console;
+static struct sdl2_console *sdl2_console;
static SDL_Surface *guest_sprite_surface;
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
@@ -71,9 +62,9 @@ static SDL_Cursor *guest_sprite;
static int scaling_active;
static Notifier mouse_mode_notifier;
-static void sdl_update_caption(struct sdl2_state *scon);
+static void sdl_update_caption(struct sdl2_console *scon);
-static struct sdl2_state *get_scon_from_window(uint32_t window_id)
+static struct sdl2_console *get_scon_from_window(uint32_t window_id)
{
int i;
for (i = 0; i < sdl2_num_outputs; i++) {
@@ -87,7 +78,7 @@ static struct sdl2_state *get_scon_from_window(uint32_t window_id)
static void sdl_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
{
- struct sdl2_state *scon = container_of(dcl, struct sdl2_state, dcl);
+ struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
SDL_Rect rect;
DisplaySurface *surf = qemu_console_surface(dcl->con);
@@ -109,7 +100,7 @@ static void sdl_update(DisplayChangeListener *dcl,
SDL_RenderPresent(scon->real_renderer);
}
-static void do_sdl_resize(struct sdl2_state *scon, int width, int height,
+static void do_sdl_resize(struct sdl2_console *scon, int width, int height,
int bpp)
{
int flags;
@@ -149,7 +140,7 @@ static void do_sdl_resize(struct sdl2_state *scon, int width, int height,
static void sdl_switch(DisplayChangeListener *dcl,
DisplaySurface *new_surface)
{
- struct sdl2_state *scon = container_of(dcl, struct sdl2_state, dcl);
+ struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
int format = 0;
int idx = scon->idx;
DisplaySurface *old_surface = scon->surface;
@@ -191,7 +182,7 @@ static void sdl_switch(DisplayChangeListener *dcl,
}
}
-static void reset_keys(struct sdl2_state *scon)
+static void reset_keys(struct sdl2_console *scon)
{
QemuConsole *con = scon ? scon->dcl.con : NULL;
int i;
@@ -205,7 +196,7 @@ static void reset_keys(struct sdl2_state *scon)
}
}
-static void sdl_process_key(struct sdl2_state *scon,
+static void sdl_process_key(struct sdl2_console *scon,
SDL_KeyboardEvent *ev)
{
int qcode = sdl2_scancode_to_qcode[ev->keysym.scancode];
@@ -257,7 +248,7 @@ static void sdl_process_key(struct sdl2_state *scon,
}
}
-static void sdl_update_caption(struct sdl2_state *scon)
+static void sdl_update_caption(struct sdl2_console *scon)
{
char win_title[1024];
char icon_title[1024];
@@ -321,7 +312,7 @@ static void sdl_show_cursor(void)
}
}
-static void sdl_grab_start(struct sdl2_state *scon)
+static void sdl_grab_start(struct sdl2_console *scon)
{
QemuConsole *con = scon ? scon->dcl.con : NULL;
@@ -349,7 +340,7 @@ static void sdl_grab_start(struct sdl2_state *scon)
sdl_update_caption(scon);
}
-static void sdl_grab_end(struct sdl2_state *scon)
+static void sdl_grab_end(struct sdl2_console *scon)
{
SDL_SetWindowGrab(scon->real_window, SDL_FALSE);
gui_grab = 0;
@@ -357,7 +348,7 @@ static void sdl_grab_end(struct sdl2_state *scon)
sdl_update_caption(scon);
}
-static void absolute_mouse_grab(struct sdl2_state *scon)
+static void absolute_mouse_grab(struct sdl2_console *scon)
{
int mouse_x, mouse_y;
int scr_w, scr_h;
@@ -384,7 +375,7 @@ static void sdl_mouse_mode_change(Notifier *notify, void *data)
}
}
-static void sdl_send_mouse_event(struct sdl2_state *scon, int dx, int dy,
+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] = {
@@ -407,7 +398,7 @@ static void sdl_send_mouse_event(struct sdl2_state *scon, int dx, int dy,
int i;
for (i = 0; i < sdl2_num_outputs; i++) {
- struct sdl2_state *thiscon = &sdl2_console[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;
@@ -441,14 +432,14 @@ static void sdl_send_mouse_event(struct sdl2_state *scon, int dx, int dy,
qemu_input_event_sync();
}
-static void sdl_scale(struct sdl2_state *scon, int width, int height)
+static void sdl_scale(struct sdl2_console *scon, int width, int height)
{
int bpp = 0;
do_sdl_resize(scon, width, height, bpp);
scaling_active = 1;
}
-static void toggle_full_screen(struct sdl2_state *scon)
+static void toggle_full_screen(struct sdl2_console *scon)
{
int width = surface_width(scon->surface);
int height = surface_height(scon->surface);
@@ -482,7 +473,7 @@ static void toggle_full_screen(struct sdl2_state *scon)
static void handle_keydown(SDL_Event *ev)
{
int mod_state, win;
- struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
+ struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
if (alt_grab) {
mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
@@ -560,7 +551,7 @@ static void handle_keydown(SDL_Event *ev)
static void handle_keyup(SDL_Event *ev)
{
int mod_state;
- struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
+ struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
if (!alt_grab) {
mod_state = (ev->key.keysym.mod & gui_grab_code);
@@ -590,7 +581,7 @@ static void handle_keyup(SDL_Event *ev)
static void handle_textinput(SDL_Event *ev)
{
- struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
+ struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
QemuConsole *con = scon ? scon->dcl.con : NULL;
if (qemu_console_is_graphic(con)) {
@@ -602,7 +593,7 @@ static void handle_textinput(SDL_Event *ev)
static void handle_mousemotion(SDL_Event *ev)
{
int max_x, max_y;
- struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
+ struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
if (qemu_input_is_absolute() || absolute_enabled) {
int scr_w, scr_h;
@@ -629,7 +620,7 @@ static void handle_mousebutton(SDL_Event *ev)
{
int buttonstate = SDL_GetMouseState(NULL, NULL);
SDL_MouseButtonEvent *bev;
- struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
+ struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
bev = &ev->button;
if (!gui_grab && !qemu_input_is_absolute()) {
@@ -649,7 +640,7 @@ static void handle_mousebutton(SDL_Event *ev)
static void handle_mousewheel(SDL_Event *ev)
{
- struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
+ struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
SDL_MouseWheelEvent *wev = &ev->wheel;
InputButton btn;
@@ -670,7 +661,7 @@ static void handle_mousewheel(SDL_Event *ev)
static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)
{
int w, h;
- struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
+ struct sdl2_console *scon = get_scon_from_window(ev->key.windowID);
switch (ev->window.event) {
case SDL_WINDOWEVENT_RESIZED:
@@ -717,7 +708,7 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)
static void sdl_refresh(DisplayChangeListener *dcl)
{
- struct sdl2_state *scon = container_of(dcl, struct sdl2_state, dcl);
+ struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
SDL_Event ev1, *ev = &ev1;
if (scon->last_vm_running != runstate_is_running()) {
@@ -766,7 +757,7 @@ static void sdl_refresh(DisplayChangeListener *dcl)
static void sdl_mouse_warp(DisplayChangeListener *dcl,
int x, int y, int on)
{
- struct sdl2_state *scon = container_of(dcl, struct sdl2_state, dcl);
+ struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
if (on) {
if (!guest_cursor) {
sdl_show_cursor();
@@ -871,7 +862,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
}
}
sdl2_num_outputs = i;
- sdl2_console = g_new0(struct sdl2_state, sdl2_num_outputs);
+ sdl2_console = g_new0(struct sdl2_console, sdl2_num_outputs);
for (i = 0; i < sdl2_num_outputs; i++) {
QemuConsole *con = qemu_console_lookup_by_index(i);
if (!qemu_console_is_graphic(con)) {
--
1.8.3.1
next prev parent reply other threads:[~2014-12-11 10:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-11 10:49 [Qemu-devel] [PATCH 00/10] sdl2: fixes, cleanups and opengl preparation Gerd Hoffmann
2014-12-11 10:49 ` [Qemu-devel] [PATCH 01/10] sdl: move version logic from source code to makefile Gerd Hoffmann
2014-12-11 14:05 ` Max Reitz
2014-12-11 10:49 ` Gerd Hoffmann [this message]
2014-12-11 13:45 ` [Qemu-devel] [PATCH 02/10] sdl2: rename sdl2_state to sdl2_console, move to header file Max Reitz
2014-12-12 9:03 ` Gerd Hoffmann
2014-12-11 10:49 ` [Qemu-devel] [PATCH 03/10] sdl2: move keyboard input code to new sdl2-input.c Gerd Hoffmann
2014-12-11 14:00 ` Max Reitz
2014-12-12 10:38 ` Gerd Hoffmann
2014-12-11 10:49 ` [Qemu-devel] [PATCH 04/10] sdl2: turn on keyboard grabs Gerd Hoffmann
2014-12-11 14:05 ` Max Reitz
2014-12-11 10:49 ` [Qemu-devel] [PATCH 05/10] sdl2: move sdl_update to new sdl2-2d.c Gerd Hoffmann
2014-12-11 14:14 ` Max Reitz
2014-12-11 10:49 ` [Qemu-devel] [PATCH 06/10] sdl2: overhaul window size handling Gerd Hoffmann
2014-12-11 14:42 ` Max Reitz
2014-12-11 15:06 ` Max Reitz
2014-12-12 10:43 ` Gerd Hoffmann
2014-12-11 10:49 ` [Qemu-devel] [PATCH 07/10] sdl2: move sdl_switch to sdl2-2d.c Gerd Hoffmann
2014-12-11 15:00 ` Max Reitz
2014-12-11 10:49 ` [Qemu-devel] [PATCH 08/10] sdl2: add+use sdl2_2d_redraw function Gerd Hoffmann
2014-12-11 15:07 ` Max Reitz
2014-12-11 10:49 ` [Qemu-devel] [PATCH 09/10] sdl2: factor out sdl2_poll_events Gerd Hoffmann
2014-12-11 15:17 ` Max Reitz
2014-12-11 10:49 ` [Qemu-devel] [PATCH 10/10] sdl2: move sdl2_2d_refresh to sdl2-2d.c Gerd Hoffmann
2014-12-11 15:19 ` Max Reitz
2014-12-12 10:45 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1418294973-21790-3-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=aliguori@amazon.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).