summaryrefslogtreecommitdiffstats
path: root/video/out/vo_sdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/vo_sdl.c')
-rw-r--r--video/out/vo_sdl.c66
1 files changed, 19 insertions, 47 deletions
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c
index 9f6cadacc3..5ab62cb78e 100644
--- a/video/out/vo_sdl.c
+++ b/video/out/vo_sdl.c
@@ -32,7 +32,7 @@
#include "core/input/input.h"
#include "core/input/keycodes.h"
-#include "core/mp_fifo.h"
+#include "core/input/input.h"
#include "core/mp_msg.h"
#include "core/options.h"
@@ -190,7 +190,6 @@ struct priv {
int num_targets;
int targets_size;
} osd_surfaces[MAX_OSD_PARTS];
- unsigned int mouse_timer;
int mouse_hidden;
int brightness, contrast;
@@ -470,28 +469,8 @@ static void flip_page(struct vo *vo)
static void check_events(struct vo *vo)
{
- struct priv *vc = vo->priv;
- struct mp_vo_opts *opts = vo->opts;
SDL_Event ev;
- if (opts->cursor_autohide_delay >= 0) {
- if (!vc->mouse_hidden &&
- (GetTimerMS() - vc->mouse_timer >= opts->cursor_autohide_delay)) {
- SDL_ShowCursor(0);
- vc->mouse_hidden = 1;
- }
- } else if (opts->cursor_autohide_delay == -1) {
- if (vc->mouse_hidden) {
- SDL_ShowCursor(1);
- vc->mouse_hidden = 0;
- }
- } else if (opts->cursor_autohide_delay == -2) {
- if (!vc->mouse_hidden) {
- SDL_ShowCursor(0);
- vc->mouse_hidden = 1;
- }
- }
-
while (SDL_PollEvent(&ev)) {
switch (ev.type) {
case SDL_WINDOWEVENT:
@@ -505,7 +484,7 @@ static void check_events(struct vo *vo)
}
break;
case SDL_QUIT:
- mplayer_put_key(vo->key_fifo, MP_KEY_CLOSE_WIN);
+ mp_input_put_key(vo->input_ctx, MP_KEY_CLOSE_WIN);
break;
case SDL_TEXTINPUT: {
int sdl_mod = SDL_GetModState();
@@ -521,7 +500,7 @@ static void check_events(struct vo *vo)
struct bstr t = {
ev.text.text, strlen(ev.text.text)
};
- mplayer_put_key_utf8(vo->key_fifo, mpv_mod, t);
+ mp_input_put_key_utf8(vo->input_ctx, mpv_mod, t);
break;
}
case SDL_KEYDOWN: {
@@ -549,35 +528,20 @@ static void check_events(struct vo *vo)
keycode |= MP_KEY_MODIFIER_ALT;
if (ev.key.keysym.mod & (KMOD_LGUI | KMOD_RGUI))
keycode |= MP_KEY_MODIFIER_META;
- mplayer_put_key(vo->key_fifo, keycode);
+ mp_input_put_key(vo->input_ctx, keycode);
}
break;
}
case SDL_MOUSEMOTION:
- if (opts->cursor_autohide_delay >= 0) {
- SDL_ShowCursor(1);
- vc->mouse_hidden = 0;
- vc->mouse_timer = GetTimerMS();
- }
vo_mouse_movement(vo, ev.motion.x, ev.motion.y);
break;
case SDL_MOUSEBUTTONDOWN:
- if (opts->cursor_autohide_delay >= 0) {
- SDL_ShowCursor(1);
- vc->mouse_hidden = 0;
- vc->mouse_timer = GetTimerMS();
- }
- mplayer_put_key(vo->key_fifo,
+ mp_input_put_key(vo->input_ctx,
(MP_MOUSE_BTN0 + ev.button.button - 1) | MP_KEY_STATE_DOWN);
break;
case SDL_MOUSEBUTTONUP:
- if (opts->cursor_autohide_delay >= 0) {
- SDL_ShowCursor(1);
- vc->mouse_hidden = 0;
- vc->mouse_timer = GetTimerMS();
- }
- mplayer_put_key(vo->key_fifo,
- (MP_MOUSE_BTN0 + ev.button.button - 1));
+ mp_input_put_key(vo->input_ctx,
+ (MP_MOUSE_BTN0 + ev.button.button - 1) | MP_KEY_STATE_UP);
break;
case SDL_MOUSEWHEEL:
break;
@@ -793,9 +757,6 @@ static int preinit(struct vo *vo, const char *arg)
// we don't have proper event handling
vo->wakeup_period = 0.02;
- // initialize the autohide timer properly
- vc->mouse_timer = GetTimerMS();
-
return 0;
}
@@ -978,7 +939,12 @@ static int get_eq(struct vo *vo, const char *name, int *value)
static int control(struct vo *vo, uint32_t request, void *data)
{
+ struct priv *vc = vo->priv;
+
switch (request) {
+ case VOCTRL_CHECK_EVENTS:
+ check_events(vo);
+ return 1;
case VOCTRL_FULLSCREEN:
set_fullscreen(vo, !vo->opts->fs);
return 1;
@@ -1009,6 +975,13 @@ static int control(struct vo *vo, uint32_t request, void *data)
args->out_image = get_screenshot(vo);
return true;
}
+ case VOCTRL_SET_CURSOR_VISIBILITY:
+ SDL_ShowCursor(*(bool *)data);
+ return true;
+ case VOCTRL_UPDATE_WINDOW_TITLE:
+ if (vc->window)
+ SDL_SetWindowTitle(vc->window, vo_get_window_title(vo));
+ return true;
}
return VO_NOTIMPL;
}
@@ -1039,7 +1012,6 @@ const struct vo_driver video_out_sdl = {
.control = control,
.draw_image = draw_image,
.uninit = uninit,
- .check_events = check_events,
.draw_osd = draw_osd,
.flip_page = flip_page,
};