diff options
author | wm4 <wm4@nowhere> | 2013-07-18 14:05:39 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-07-18 14:07:21 +0200 |
commit | c4b08a9a1149a83d7374eaea9863dd4c7cbd12d7 (patch) | |
tree | 46dbfc1850b7166948b4447332a20edefcedc779 /video/out/vo_sdl.c | |
parent | 05cf512dc56aab1aaf12884e44065cf2fc03c11e (diff) | |
download | mpv-c4b08a9a1149a83d7374eaea9863dd4c7cbd12d7.tar.bz2 mpv-c4b08a9a1149a83d7374eaea9863dd4c7cbd12d7.tar.xz |
video: remove fullscreen flags chaos
There was a MPOpts fullscreen field, a mp_vo_opts.fs field, and
VOFLAG_FULLSCREEN. Remove all these and introduce a
mp_vo_opts.fullscreen flag instead.
When VOs receive VOCTRL_FULLSCREEN, they are supposed to set the
current fullscreen mode to the state in mp_vo_opts.fullscreen. They
also should do this implicitly on config().
VOs which are capable of doing so can update the mp_vo_opts.fullscreen
if the actual fullscreen mode changes (e.g. if the user uses the
window manager controls). If fullscreen mode switching fails, they
can also set mp_vo_opts.fullscreen to the actual state.
Note that the X11 backend does almost none of this, and it has a
private fs flag to store the fullscreen flag, instead of getting it
from the WM. (Possibly because it has to deal with broken WMs.)
The fullscreen option has to be checked on config() to deal with
the -fs option, especially with something like:
mpv --fs file1.mkv --{ --no-fs file2.mkv --}
(It should start in fullscreen mode, but go to windowed mode when
playing file2.mkv.)
Wayland changes by: Alexander Preisinger <alexander.preisinger@gmail.com>
Cocoa changes by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
Diffstat (limited to 'video/out/vo_sdl.c')
-rw-r--r-- | video/out/vo_sdl.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 5ab62cb78e..35d3ab4962 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -367,19 +367,27 @@ static void check_resize(struct vo *vo) resize(vo, w, h); } -static void set_fullscreen(struct vo *vo, int fs) +static void set_fullscreen(struct vo *vo) { struct priv *vc = vo->priv; + int fs = vo->opts->fullscreen; - Uint32 fs_flags = 0; - if (fs) { - if (vc->switch_mode) - fs_flags |= SDL_WINDOW_FULLSCREEN; - else - fs_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; - } + Uint32 fs_flag; + if (vc->switch_mode) + fs_flag = SDL_WINDOW_FULLSCREEN; + else + fs_flag = SDL_WINDOW_FULLSCREEN_DESKTOP; + + Uint32 old_flags = SDL_GetWindowFlags(vc->window); + int prev_fs = !!(old_flags & fs_flag); + if (fs == prev_fs) + return; + + Uint32 flags = 0; + if (fs) + flags |= fs_flag; - if (SDL_SetWindowFullscreen(vc->window, fs_flags)) { + if (SDL_SetWindowFullscreen(vc->window, flags)) { mp_msg(MSGT_VO, MSGL_ERR, "[sdl] SDL_SetWindowFullscreen failed\n"); return; } @@ -387,7 +395,6 @@ static void set_fullscreen(struct vo *vo, int fs) // toggling fullscreen might recreate the window, so better guard for this SDL_DisableScreenSaver(); - vo->opts->fs = fs; force_resize(vo); } @@ -449,8 +456,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, SDL_DisableScreenSaver(); - if (flags & VOFLAG_FULLSCREEN) - set_fullscreen(vo, 1); + set_fullscreen(vo); SDL_SetWindowTitle(vc->window, vo_get_window_title(vo)); @@ -946,7 +952,7 @@ static int control(struct vo *vo, uint32_t request, void *data) check_events(vo); return 1; case VOCTRL_FULLSCREEN: - set_fullscreen(vo, !vo->opts->fs); + set_fullscreen(vo); return 1; case VOCTRL_REDRAW_FRAME: draw_image(vo, NULL); |