1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-03 13:32:16 +00:00

vo: improve fixed-vo behavior when video size changes in x11 VOs

Now the window is only resized when video size (or size specified by
-geometry) changes; reconfiguring the window with the same size no
longer changes back to default size from possibly user-modified one.

Also fix a bug in fullscreen handling that could cause incorrect
window size when turning fullscreen off.
This commit is contained in:
Uoti Urpala 2010-07-23 03:30:44 +03:00
parent 8362ad36ac
commit 7a669a6407
2 changed files with 26 additions and 0 deletions

View File

@ -757,6 +757,9 @@ void vo_x11_uninit(struct vo *vo)
} }
vo_fs = 0; vo_fs = 0;
x11->vo_old_width = x11->vo_old_height = 0; x11->vo_old_width = x11->vo_old_height = 0;
x11->last_video_width = 0;
x11->last_video_height = 0;
x11->size_changed_during_fs = false;
} }
} }
@ -882,6 +885,13 @@ static void vo_x11_nofs_sizepos(struct vo *vo, int x, int y,
int width, int height) int width, int height)
{ {
struct vo_x11_state *x11 = vo->x11; struct vo_x11_state *x11 = vo->x11;
if (width == x11->last_video_width && height == x11->last_video_height) {
if (!vo->opts->force_window_position && !x11->size_changed_during_fs)
return;
} else if (vo_fs)
x11->size_changed_during_fs = true;
x11->last_video_height = height;
x11->last_video_width = width;
vo_x11_sizehint(vo, x, y, width, height, 0); vo_x11_sizehint(vo, x, y, width, height, 0);
if (vo_fs) { if (vo_fs) {
x11->vo_old_x = x; x11->vo_old_x = x;
@ -1321,6 +1331,10 @@ void vo_x11_fullscreen(struct vo *vo)
{ {
vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH
vo_fs = VO_FALSE; vo_fs = VO_FALSE;
if (x11->size_changed_during_fs && (x11->fs_type & vo_wm_FULLSCREEN))
vo_x11_nofs_sizepos(vo, vo->dx, vo->dy, x11->last_video_width,
x11->last_video_height);
x11->size_changed_during_fs = false;
} else } else
{ {
// win->fs // win->fs

View File

@ -20,6 +20,7 @@
#define MPLAYER_X11_COMMON_H #define MPLAYER_X11_COMMON_H
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -61,6 +62,17 @@ struct vo_x11_state {
int vo_old_width; int vo_old_width;
int vo_old_height; int vo_old_height;
/* Keep track of original video width/height to determine when to
* resize window when reconfiguring. Resize window when video size
* changes, but don't force window size changes as long as video size
* stays the same (even if that size is different from the current
* window size after the user modified the latter). */
int last_video_width;
int last_video_height;
/* Video size changed during fullscreen when we couldn't tell the new
* size to the window manager. Must set window size when turning
* fullscreen off. */
bool size_changed_during_fs;
unsigned int olddecor; unsigned int olddecor;
unsigned int oldfuncs; unsigned int oldfuncs;