From 14b95897807d21d06e9b42403fb134f77b417360 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 14 Feb 2013 10:45:49 +0100 Subject: [PATCH] xvfb: Adaptation to timer and framebuffer changes --- os/src/app/xvfb/main.cc | 34 +++++++++++++++++----------------- os/src/app/xvfb/target.mk | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/os/src/app/xvfb/main.cc b/os/src/app/xvfb/main.cc index 10c7d7d4d..22bf60442 100644 --- a/os/src/app/xvfb/main.cc +++ b/os/src/app/xvfb/main.cc @@ -13,6 +13,7 @@ /* Linux includes */ #include +#include #include #include @@ -52,10 +53,9 @@ int config_force_top = 1; static int xvfb_width, xvfb_height; static Pixel *xvfb_addr; -static Framebuffer::Session *fb_session; -static int fb_width, fb_height; -static Framebuffer::Session::Mode fb_mode; -static Pixel *fb_addr; +static Framebuffer::Session *fb_session; +static Framebuffer::Mode fb_mode; +static Pixel *fb_addr; static Nitpicker::Session *nitpicker() @@ -101,10 +101,10 @@ static bool read_config() static inline long convert_from_big_endian(long x) { char v[4] = { - (x & 0xff000000) >> 24, - (x & 0x00ff0000) >> 16, - (x & 0x0000ff00) >> 8, - (x & 0x000000ff) >> 0, + (char)((x & 0xff000000) >> 24), + (char)((x & 0x00ff0000) >> 16), + (char)((x & 0x0000ff00) >> 8), + (char)((x & 0x000000ff) >> 0), }; return *(long *)v; } @@ -134,19 +134,19 @@ static void *mmap_file(const char *file_name) /** * Flush part of the Xvfb screen to the Nitpicker session */ -static void flush(int x, int y, int width, int height) +static void flush(int x, int y, int width, int height, Framebuffer::Mode const &mode) { /* clip arguments against framebuffer geometry */ if (x < 0) width += x, x = 0; if (y < 0) height += y, y = 0; - if (width > fb_width - x) width = fb_width - x; - if (height > fb_height - y) height = fb_height - y; + if (width > mode.width() - x) width = mode.width() - x; + if (height > mode.height() - y) height = mode.height() - y; if (width <= 0 || height <= 0) return; /* copy pixels from xvfb to the nitpicker buffer */ - blit(xvfb_addr + x + xvfb_width*y, xvfb_width*sizeof(Pixel), - fb_addr + x + fb_width*y, fb_width*sizeof(Pixel), + blit(xvfb_addr + x + xvfb_width*y, xvfb_width*sizeof(Pixel), + fb_addr + x + mode.width()*y, mode.width()*sizeof(Pixel), width*sizeof(Pixel), height); /* refresh nitpicker views */ @@ -265,7 +265,7 @@ int main(int, char **) static Input::Session_client input(nitpicker()->input_session()); fb_session = &fb; fb_addr = Genode::env()->rm_session()->attach(fb.dataspace()); - fb.info(&fb_width, &fb_height, &fb_mode); + fb_mode = fb.mode(); XWDFileHeader *xwd = (XWDFileHeader *)mmap_file(config_xvfb_file_name); if (!xwd) return -1; @@ -283,9 +283,9 @@ int main(int, char **) xvfb_addr = (Pixel *)((long)xwd + convert_from_big_endian(xwd->header_size) + convert_from_big_endian(xwd->ncolors)*sizeof(XWDColor)); - if (xvfb_width != fb_width || xvfb_height != fb_height) { + if (xvfb_width != fb_mode.width() || xvfb_height != fb_mode.height()) { Genode::printf("Error: Xvfb mode must equal the Nitpicker screen mode of %dx%d\n", - fb_width, fb_height); + fb_mode.width(), fb_mode.height()); return -3; } @@ -332,7 +332,7 @@ int main(int, char **) if (pending_redraw.valid()) flush(pending_redraw.x(), pending_redraw.y(), - pending_redraw.w(), pending_redraw.h()); + pending_redraw.w(), pending_redraw.h(), fb_mode); timer.msleep(5); } diff --git a/os/src/app/xvfb/target.mk b/os/src/app/xvfb/target.mk index ba509b652..2af89bc10 100644 --- a/os/src/app/xvfb/target.mk +++ b/os/src/app/xvfb/target.mk @@ -1,6 +1,6 @@ TARGET = xvfb REQUIRES = linux x11 xtest xdamage SRC_CC = main.cc inject_input.cc -LIBS = env syscall blit xev_track lx_hybrid +LIBS = env syscall blit xev_track lx_hybrid signal EXT_OBJECTS += -lX11 -lXdamage /usr/lib/libXtst.so.6