summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-05-15 23:47:00 +0200
committerwm4 <wm4@nowhere>2014-05-15 23:56:14 +0200
commit9bfe3f394c14b3d5cdae5bfff565a1e6fae94315 (patch)
treeed3b0e01a5d08da0958b3067c6ab29d7151b8734
parent1eee4d779954974cd413be5e46f1ed877836ef31 (diff)
downloadmpv-9bfe3f394c14b3d5cdae5bfff565a1e6fae94315.tar.bz2
mpv-9bfe3f394c14b3d5cdae5bfff565a1e6fae94315.tar.xz
x11: wait until the window is mapped
This blocks everything, until the window is actually reported as mapped. This fixes the race condition between VO initialization and mapping the window, which resulted in possibly different window sizes, leading to an immediate redraw, visible as flashing. Note that if the map event never comes for some reason, we're out of luck and will block forever.
-rw-r--r--video/out/x11_common.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index c84409b03c..0779718967 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -1336,6 +1336,16 @@ static void vo_x11_highlevel_resize(struct vo *vo, int x, int y, int w, int h)
update_vo_size(vo);
}
+static void wait_until_mapped(struct vo *vo)
+{
+ struct vo_x11_state *x11 = vo->x11;
+ while (x11->window_hidden) {
+ XEvent unused;
+ XPeekEvent(x11->display, &unused);
+ vo_x11_check_events(vo);
+ }
+}
+
/* Create and setup a window suitable for display
* vis: Visual to use for creating the window (NULL for default)
* x, y: position of window (might be ignored)
@@ -1408,6 +1418,7 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int flags,
x11->win_width = width;
x11->win_height = height;
}
+ wait_until_mapped(vo);
update_vo_size(vo);
x11->pending_vo_events &= ~VO_EVENT_RESIZE; // implicitly done by the VO
}