From 97cf53cc2ad7ecfdd495133bad31d0ec7d939326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Mon, 21 Oct 2013 16:58:54 -0400 Subject: [PATCH] ephyr: hostx_screen_init(): Fix bits_per_pixel and bytes_per_line When the depth of the Xephyr server matches that of the host X server, Xephyr simply uses the buffer associated with the XImage as its framebuffer. In this case, it is correct to get the bits_per_pixel and bytes_per_line values returned from hostx_screen_init() from the XImage. However, when the depth doesn't match the host, Xephyr uses a private framebuffer that is periodically copied to the XImage. In this case, the returned values of bits_per_pixel and bytes_per_line should be those of the private framebuffer, not those of the XImage. Reviewed-by: Eric Anholt Signed-off-by: Soren Sandmann Reviewed-by: Adam Jackson --- hw/kdrive/ephyr/hostx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 5fa33b9db..6020e8d63 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -695,9 +695,6 @@ hostx_screen_init(KdScreenInfo *screen, malloc(scrpriv->ximg->stride * buffer_height); } - *bytes_per_line = scrpriv->ximg->stride; - *bits_per_pixel = scrpriv->ximg->bpp; - if (scrpriv->win_pre_existing == None && !EphyrWantResize) { /* Ask the WM to keep our size static */ xcb_size_hints_t size_hints = {0}; @@ -717,10 +714,16 @@ hostx_screen_init(KdScreenInfo *screen, scrpriv->win_height = height; if (host_depth_matches_server(scrpriv)) { + *bytes_per_line = scrpriv->ximg->stride; + *bits_per_pixel = scrpriv->ximg->bpp; + EPHYR_DBG("Host matches server"); return scrpriv->ximg->data; } else { + *bytes_per_line = width * (scrpriv->server_depth >> 3); + *bits_per_pixel = scrpriv->server_depth; + EPHYR_DBG("server bpp %i", scrpriv->server_depth >> 3); scrpriv->fb_data = malloc(width * buffer_height * (scrpriv->server_depth >> 3));