mirror of
https://github.com/qemu/qemu.git
synced 2024-12-03 08:43:38 +08:00
sdl2: mouse wheel support, ui config notify
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJTX3wdAAoJEEy22O7T6HE4PQoQALJY6k95iB9a/tuLH+kV226E ICERL0sQqAa9IKBtNmtbsIyDSt2LnsTNZQLOpihxZ1/En+xtt47e2Ojr8lGi4E9v JK3isfbiHrxANJdR3Fw0J1RPjvR+bx/xHV1s7TO+vmq9Ooy8xiAT1S9RrmxElq24 J23IV6OH0e4OtzGXf8gxyOcoelIAXNCLPFYDISzE/imxFtyZi71zVzLZ75VooE1m d5kg2qA+07Nk5uslzJx/dip+s1d1hODqS7oZoS20M4S/8OkeMwzE7R1VLawsi6Vh Bonc+XzRL19+fNgixXGZlPy94xFAgDqZOgIYyBpExluM44n1b7pi1CuxBibZ/GN5 2lKIIWPnH+Nw+r1pO45U7j6D5zk21HO1MiY52BaOif8achiWfPD+KnjbdYx66uPa SGwvD7hudXT5btp5GyKk2S/57b3PDO19bidKKE8ZjyNgWfOcRxT1kwZvOKUaYe6w Dgx2C8MmQ55YtcKhCwQWwcUBpGi4/UHWu8lMC2mP79rdERD0ALcTsWkfRCSsYla0 5WT9u6GkkRQhcRZ1bJZrUjMq0Hpr4KxCbLj4fcsKbNiFwk54oxSRYmWyrZKLq7BP FNO75UggvRvmu59Upbq+1lVokcTnoaiHKzjmc0Ypi5t+iJu6znTblJBMiqyQb1Em MA72SbqrWXyAJJeQos7M =ERvz -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kraxel/tags/pull-sdl-2' into staging sdl2: mouse wheel support, ui config notify # gpg: Signature made Tue 29 Apr 2014 11:17:01 BST using RSA key ID D3E87138 # 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>" * remotes/kraxel/tags/pull-sdl-2: sdl2: Support mouse wheel sdl2: add ui info setting. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
52b08670e2
51
ui/sdl2.c
51
ui/sdl2.c
@ -359,16 +359,12 @@ static void sdl_mouse_mode_change(Notifier *notify, void *data)
|
||||
}
|
||||
|
||||
static void sdl_send_mouse_event(struct sdl2_state *scon, int dx, int dy,
|
||||
int dz, int x, int y, int state)
|
||||
int x, int y, int state)
|
||||
{
|
||||
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),
|
||||
#if 0
|
||||
[INPUT_BUTTON_WHEEL_UP] = SDL_BUTTON(SDL_BUTTON_WHEELUP),
|
||||
[INPUT_BUTTON_WHEEL_DOWN] = SDL_BUTTON(SDL_BUTTON_WHEELDOWN),
|
||||
#endif
|
||||
};
|
||||
static uint32_t prev_state;
|
||||
|
||||
@ -566,7 +562,7 @@ static void handle_mousemotion(SDL_Event *ev)
|
||||
}
|
||||
}
|
||||
if (gui_grab || qemu_input_is_absolute() || absolute_enabled) {
|
||||
sdl_send_mouse_event(scon, ev->motion.xrel, ev->motion.yrel, 0,
|
||||
sdl_send_mouse_event(scon, ev->motion.xrel, ev->motion.yrel,
|
||||
ev->motion.x, ev->motion.y, ev->motion.state);
|
||||
}
|
||||
}
|
||||
@ -576,7 +572,6 @@ 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);
|
||||
int dz;
|
||||
|
||||
bev = &ev->button;
|
||||
if (!gui_grab && !qemu_input_is_absolute()) {
|
||||
@ -585,25 +580,35 @@ static void handle_mousebutton(SDL_Event *ev)
|
||||
sdl_grab_start(scon);
|
||||
}
|
||||
} else {
|
||||
dz = 0;
|
||||
if (ev->type == SDL_MOUSEBUTTONDOWN) {
|
||||
buttonstate |= SDL_BUTTON(bev->button);
|
||||
} else {
|
||||
buttonstate &= ~SDL_BUTTON(bev->button);
|
||||
}
|
||||
#ifdef SDL_BUTTON_WHEELUP
|
||||
if (bev->button == SDL_BUTTON_WHEELUP &&
|
||||
ev->type == SDL_MOUSEBUTTONDOWN) {
|
||||
dz = -1;
|
||||
} else if (bev->button == SDL_BUTTON_WHEELDOWN &&
|
||||
ev->type == SDL_MOUSEBUTTONDOWN) {
|
||||
dz = 1;
|
||||
}
|
||||
#endif
|
||||
sdl_send_mouse_event(scon, 0, 0, dz, bev->x, bev->y, buttonstate);
|
||||
sdl_send_mouse_event(scon, 0, 0, bev->x, bev->y, buttonstate);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_mousewheel(SDL_Event *ev)
|
||||
{
|
||||
struct sdl2_state *scon = get_scon_from_window(ev->key.windowID);
|
||||
SDL_MouseWheelEvent *wev = &ev->wheel;
|
||||
InputButton btn;
|
||||
|
||||
if (wev->y > 0) {
|
||||
btn = INPUT_BUTTON_WHEEL_UP;
|
||||
} else if (wev->y < 0) {
|
||||
btn = INPUT_BUTTON_WHEEL_DOWN;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
qemu_input_queue_btn(scon->dcl.con, btn, true);
|
||||
qemu_input_event_sync();
|
||||
qemu_input_queue_btn(scon->dcl.con, btn, false);
|
||||
qemu_input_event_sync();
|
||||
}
|
||||
|
||||
static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)
|
||||
{
|
||||
int w, h;
|
||||
@ -612,6 +617,13 @@ static void handle_windowevent(DisplayChangeListener *dcl, SDL_Event *ev)
|
||||
switch (ev->window.event) {
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
sdl_scale(scon, ev->window.data1, ev->window.data2);
|
||||
{
|
||||
QemuUIInfo info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.width = ev->window.data1;
|
||||
info.height = ev->window.data2;
|
||||
dpy_set_ui_info(scon->dcl.con, &info);
|
||||
}
|
||||
graphic_hw_invalidate(scon->dcl.con);
|
||||
graphic_hw_update(scon->dcl.con);
|
||||
break;
|
||||
@ -678,6 +690,9 @@ static void sdl_refresh(DisplayChangeListener *dcl)
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
handle_mousebutton(ev);
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
handle_mousewheel(ev);
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
handle_windowevent(dcl, ev);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user