summaryrefslogtreecommitdiffstats
path: root/video/out/x11_common.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-03-17 23:01:33 +0100
committerwm4 <wm4@nowhere>2013-03-17 23:01:33 +0100
commitea03cc67122ad8b47e640c868d108d7531536a21 (patch)
tree8da662b25a7f98273237e3c2edefefafade7284f /video/out/x11_common.c
parent79d35b8f012a589207e2478394bd6f91928d1349 (diff)
downloadmpv-ea03cc67122ad8b47e640c868d108d7531536a21.tar.bz2
mpv-ea03cc67122ad8b47e640c868d108d7531536a21.tar.xz
x11_common: remove assumption that video is always centered
The vo_x11_clearwindow_part() function assumed that the video is always centered. Replace it with a new vo_x11_clear_background() function instead, which essentially does the same as the old function. It takes the video rectangle instead of just the video size, and doesn't have to make the assumption that the video rectangle is centered. Also make vo_x11 use it (seems advantageous).
Diffstat (limited to 'video/out/x11_common.c')
-rw-r--r--video/out/x11_common.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 13da2706fb..c6741f2662 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -1074,36 +1074,34 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
x11->pending_vo_events &= ~VO_EVENT_RESIZE; // implicitly done by the VO
}
-void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
- int img_width, int img_height)
+static void fill_rect(struct vo *vo, GC gc, int x0, int y0, int x1, int y1)
{
struct vo_x11_state *x11 = vo->x11;
- Display *mDisplay = vo->x11->display;
- int u_dheight, u_dwidth, left_ov, left_ov2;
- if (x11->f_gc == None)
- return;
+ x0 = FFMAX(x0, 0);
+ y0 = FFMAX(y0, 0);
+ x1 = FFMIN(x1, x11->win_width);
+ y1 = FFMIN(y1, x11->win_height);
- u_dheight = x11->win_height;
- u_dwidth = x11->win_width;
- if ((u_dheight <= img_height) && (u_dwidth <= img_width))
- return;
+ if (x11->window && x1 > x0 && y1 > y0)
+ XFillRectangle(x11->display, x11->window, gc, x0, y0, x1 - x0, y1 - y0);
+}
- left_ov = (u_dheight - img_height) / 2;
- left_ov2 = (u_dwidth - img_width) / 2;
+// Clear everything outside of rc with the background color
+void vo_x11_clear_background(struct vo *vo, const struct mp_rect *rc)
+{
+ struct vo_x11_state *x11 = vo->x11;
+ GC gc = x11->f_gc;
- XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, 0, u_dwidth, left_ov);
- XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, u_dheight - left_ov - 1,
- u_dwidth, left_ov + 1);
+ int w = x11->win_width;
+ int h = x11->win_height;
- if (u_dwidth > img_width) {
- XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, left_ov, left_ov2,
- img_height);
- XFillRectangle(mDisplay, vo_window, x11->f_gc, u_dwidth - left_ov2 - 1,
- left_ov, left_ov2 + 1, img_height);
- }
+ fill_rect(vo, gc, 0, 0, w, rc->y0); // top
+ fill_rect(vo, gc, 0, rc->y1, w, h); // bottom
+ fill_rect(vo, gc, 0, rc->y0, rc->x0, rc->y1); // left
+ fill_rect(vo, gc, rc->x1, rc->y0, w, rc->y1); // right
- XFlush(mDisplay);
+ XFlush(x11->display);
}
void vo_x11_clearwindow(struct vo *vo, Window vo_window)