From 2dd32c7adb7116f1ad9ab2632d9fcf57a31e9fa2 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 21 Nov 2011 08:44:10 +0000 Subject: Improve API to allow for RAM surfaces instead of direct blitting Improve and update tests Fix RAM surface Fix VNC surface svn path=/trunk/libnsfb/; revision=13158 --- src/surface/Makefile | 6 +- src/surface/able.c | 12 +- src/surface/linux.c | 14 +- src/surface/ram.c | 71 +++++-- src/surface/sdl.c | 201 ++++++++++--------- src/surface/surface.c | 139 +++++++------ src/surface/vnc.c | 536 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/surface/x.c | 45 +++-- 8 files changed, 814 insertions(+), 210 deletions(-) (limited to 'src/surface') diff --git a/src/surface/Makefile b/src/surface/Makefile index 6eddcb6..21547a5 100644 --- a/src/surface/Makefile +++ b/src/surface/Makefile @@ -1,5 +1,5 @@ # Sources -DIR_SOURCES := surface.c vnc.c able.c ram.c linux.c +DIR_SOURCES := surface.c able.c ram.c linux.c ifeq ($(NSFB_SDL_AVAILABLE),yes) DIR_SOURCES := $(DIR_SOURCES) sdl.c @@ -9,4 +9,8 @@ ifeq ($(NSFB_XCB_AVAILABLE),yes) DIR_SOURCES := $(DIR_SOURCES) x.c endif +ifeq ($(NSFB_VNC_AVAILABLE),yes) + DIR_SOURCES := $(DIR_SOURCES) vnc.c +endif + include build/makefiles/Makefile.subdir diff --git a/src/surface/able.c b/src/surface/able.c index d7b9226..dd4c340 100644 --- a/src/surface/able.c +++ b/src/surface/able.c @@ -13,18 +13,18 @@ #include "libnsfb_plot.h" #include "libnsfb_event.h" #include "nsfb.h" -#include "frontend.h" +#include "surface.h" #define UNUSED(x) ((x) = (x)) -static int able_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) +static int able_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) { - if (nsfb->frontend_priv != NULL) + if (nsfb->surface_priv != NULL) return -1; /* if were already initialised fail */ nsfb->width = width; nsfb->height = height; - nsfb->bpp = bpp; + nsfb->format = format; return 0; } @@ -49,11 +49,11 @@ static bool able_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout) return false; } -const nsfb_frontend_rtns_t able_rtns = { +const nsfb_surface_rtns_t able_rtns = { .initialise = able_initialise, .finalise = able_finalise, .input = able_input, .geometry = able_set_geometry, }; -NSFB_FRONTEND_DEF(able, NSFB_FRONTEND_ABLE, &able_rtns) +NSFB_SURFACE_DEF(able, NSFB_SURFACE_ABLE, &able_rtns) diff --git a/src/surface/linux.c b/src/surface/linux.c index 3394f85..8c9ffec 100644 --- a/src/surface/linux.c +++ b/src/surface/linux.c @@ -16,20 +16,20 @@ #include "nsfb.h" #include "plot.h" -#include "frontend.h" +#include "surface.h" #include "cursor.h" #define UNUSED(x) ((x) = (x)) -static int linux_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) +static int linux_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) { - if (nsfb->frontend_priv != NULL) + if (nsfb->surface_priv != NULL) return -1; /* if we are already initialised fail */ nsfb->width = width; nsfb->height = height; - nsfb->bpp = bpp; + nsfb->format = format; /* select default sw plotters for bpp */ select_plotters(nsfb); @@ -39,7 +39,7 @@ static int linux_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) static int linux_initialise(nsfb_t *nsfb) { - if (nsfb->frontend_priv != NULL) + if (nsfb->surface_priv != NULL) return -1; /* sanity checked depth. */ @@ -122,7 +122,7 @@ static int linux_update(nsfb_t *nsfb, nsfb_bbox_t *box) return 0; } -const nsfb_frontend_rtns_t linux_rtns = { +const nsfb_surface_rtns_t linux_rtns = { .initialise = linux_initialise, .finalise = linux_finalise, .input = linux_input, @@ -132,4 +132,4 @@ const nsfb_frontend_rtns_t linux_rtns = { .geometry = linux_set_geometry, }; -NSFB_FRONTEND_DEF(linux, NSFB_FRONTEND_LINUX, &linux_rtns) +NSFB_SURFACE_DEF(linux, NSFB_SURFACE_LINUX, &linux_rtns) diff --git a/src/surface/ram.c b/src/surface/ram.c index 0948a5d..4deabda 100644 --- a/src/surface/ram.c +++ b/src/surface/ram.c @@ -8,36 +8,77 @@ #include #include +#include #include "libnsfb.h" #include "libnsfb_plot.h" #include "libnsfb_event.h" + #include "nsfb.h" -#include "frontend.h" +#include "surface.h" +#include "plot.h" #define UNUSED(x) ((x) = (x)) -static int ram_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) +static int ram_defaults(nsfb_t *nsfb) { - if (nsfb->frontend_priv != NULL) - return -1; /* if were already initialised fail */ + nsfb->width = 0; + nsfb->height = 0; + nsfb->format = NSFB_FMT_ABGR8888; - nsfb->width = width; - nsfb->height = height; - nsfb->bpp = bpp; + /* select default sw plotters for bpp */ + select_plotters(nsfb); return 0; } + static int ram_initialise(nsfb_t *nsfb) { - UNUSED(nsfb); + size_t size = (nsfb->width * nsfb->height * nsfb->bpp) / 8; + + nsfb->ptr = realloc(nsfb->ptr, size); + nsfb->linelen = (nsfb->width * nsfb->bpp) / 8; + + return 0; +} + +static int ram_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) +{ + int startsize; + int endsize; + + startsize = (nsfb->width * nsfb->height * nsfb->bpp) / 8; + + if (width > 0) { + nsfb->width = width; + } + + if (height > 0) { + nsfb->height = height; + } + + if (format != NSFB_FMT_ANY) { + nsfb->format = format; + } + + /* select soft plotters appropriate for format */ + select_plotters(nsfb); + + endsize = (nsfb->width * nsfb->height * nsfb->bpp) / 8; + if ((nsfb->ptr != NULL) && (startsize != endsize)) { + nsfb->ptr = realloc(nsfb->ptr, endsize); + } + nsfb->linelen = (nsfb->width * nsfb->bpp) / 8; + return 0; } + static int ram_finalise(nsfb_t *nsfb) { - UNUSED(nsfb); + free(nsfb->ptr); + return 0; } @@ -49,11 +90,19 @@ static bool ram_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout) return false; } -const nsfb_frontend_rtns_t ram_rtns = { +const nsfb_surface_rtns_t ram_rtns = { + .defaults = ram_defaults, .initialise = ram_initialise, .finalise = ram_finalise, .input = ram_input, .geometry = ram_set_geometry, }; -NSFB_FRONTEND_DEF(ram, NSFB_FRONTEND_RAM, &ram_rtns) +NSFB_SURFACE_DEF(ram, NSFB_SURFACE_RAM, &ram_rtns) + +/* + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ diff --git a/src/surface/sdl.c b/src/surface/sdl.c index f0f48af..2a905f5 100644 --- a/src/surface/sdl.c +++ b/src/surface/sdl.c @@ -16,7 +16,7 @@ #include "libnsfb_plot_util.h" #include "nsfb.h" -#include "frontend.h" +#include "surface.h" #include "plot.h" #include "cursor.h" @@ -350,7 +350,7 @@ enum nsfb_key_code_e sdl_nsfb_map[] = { static void set_palette(nsfb_t *nsfb) { - SDL_Surface *sdl_screen = nsfb->frontend_priv; + SDL_Surface *sdl_screen = nsfb->surface_priv; SDL_Color palette[256]; int rloop, gloop, bloop; int loop = 0; @@ -363,8 +363,8 @@ set_palette(nsfb_t *nsfb) palette[loop].g = (gloop << 5) | (gloop << 2) | (gloop >> 1); palette[loop].b = (bloop << 6) | (bloop << 4) | (bloop << 2) | (bloop); nsfb->palette[loop] = palette[loop].r | - palette[loop].g << 8 | - palette[loop].b << 16; + palette[loop].g << 8 | + palette[loop].b << 16; loop++; } } @@ -380,7 +380,7 @@ sdlcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox) { SDL_Rect src; SDL_Rect dst; - SDL_Surface *sdl_screen = nsfb->frontend_priv; + SDL_Surface *sdl_screen = nsfb->surface_priv; nsfb_bbox_t allbox; struct nsfb_cursor_s *cursor = nsfb->cursor; @@ -416,16 +416,16 @@ sdlcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox) } -static int sdl_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) +static int sdl_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) { - if (nsfb->frontend_priv != NULL) - return -1; /* if were already initialised fail */ + if (nsfb->surface_priv != NULL) + return -1; /* fail if surface already initialised */ nsfb->width = width; nsfb->height = height; - nsfb->bpp = bpp; + nsfb->format = format; - /* select default sw plotters for bpp */ + /* select default sw plotters for format */ select_plotters(nsfb); nsfb->plotter_fns->copy = sdlcopy; @@ -437,7 +437,7 @@ static int sdl_initialise(nsfb_t *nsfb) { SDL_Surface *sdl_screen; - if (nsfb->frontend_priv != NULL) + if (nsfb->surface_priv != NULL) return -1; /* sanity checked depth. */ @@ -449,7 +449,6 @@ static int sdl_initialise(nsfb_t *nsfb) fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); return -1; } - atexit(SDL_Quit); sdl_screen = SDL_SetVideoMode(nsfb->width, nsfb->height, @@ -461,7 +460,7 @@ static int sdl_initialise(nsfb_t *nsfb) return -1; } - nsfb->frontend_priv = sdl_screen; + nsfb->surface_priv = sdl_screen; if (nsfb->bpp == 8) set_palette(nsfb); @@ -478,6 +477,7 @@ static int sdl_initialise(nsfb_t *nsfb) static int sdl_finalise(nsfb_t *nsfb) { nsfb=nsfb; + SDL_Quit(); return 0; } @@ -518,92 +518,98 @@ static bool sdl_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout) SDL_RemoveTimer(tid); } } else { - got_event = SDL_WaitEvent(&sdlevent); + got_event = SDL_WaitEvent(&sdlevent); } } /* Do nothing if there was no event */ - if (got_event == 0) + if (got_event == 0) { return false; + } event->type = NSFB_EVENT_NONE; switch (sdlevent.type) { - case SDL_KEYDOWN: - event->type = NSFB_EVENT_KEY_DOWN; - event->value.keycode = sdl_nsfb_map[sdlevent.key.keysym.sym]; - break; - - case SDL_KEYUP: - event->type = NSFB_EVENT_KEY_UP; - event->value.keycode = sdl_nsfb_map[sdlevent.key.keysym.sym]; - break; - - case SDL_MOUSEBUTTONDOWN: - event->type = NSFB_EVENT_KEY_DOWN; - - switch (sdlevent.button.button) { - - case SDL_BUTTON_LEFT: - event->value.keycode = NSFB_KEY_MOUSE_1; - break; - - case SDL_BUTTON_MIDDLE: - event->value.keycode = NSFB_KEY_MOUSE_2; - break; - - case SDL_BUTTON_RIGHT: - event->value.keycode = NSFB_KEY_MOUSE_3; - break; - - case SDL_BUTTON_WHEELUP: - event->value.keycode = NSFB_KEY_MOUSE_4; - break; - - case SDL_BUTTON_WHEELDOWN: - event->value.keycode = NSFB_KEY_MOUSE_5; - break; - } - break; - - case SDL_MOUSEBUTTONUP: - event->type = NSFB_EVENT_KEY_UP; - - switch (sdlevent.button.button) { - - case SDL_BUTTON_LEFT: - event->value.keycode = NSFB_KEY_MOUSE_1; - break; - - case SDL_BUTTON_MIDDLE: - event->value.keycode = NSFB_KEY_MOUSE_2; - break; - - case SDL_BUTTON_RIGHT: - event->value.keycode = NSFB_KEY_MOUSE_3; - break; - - case SDL_BUTTON_WHEELUP: - event->value.keycode = NSFB_KEY_MOUSE_4; - break; - - case SDL_BUTTON_WHEELDOWN: - event->value.keycode = NSFB_KEY_MOUSE_5; - break; - } - break; - - case SDL_MOUSEMOTION: - event->type = NSFB_EVENT_MOVE_ABSOLUTE; - event->value.vector.x = sdlevent.motion.x; - event->value.vector.y = sdlevent.motion.y; - event->value.vector.z = 0; - break; - - case SDL_QUIT: - event->type = NSFB_EVENT_CONTROL; - event->value.controlcode = NSFB_CONTROL_QUIT; - break; + case SDL_KEYDOWN: + event->type = NSFB_EVENT_KEY_DOWN; + event->value.keycode = sdl_nsfb_map[sdlevent.key.keysym.sym]; + break; + + case SDL_KEYUP: + event->type = NSFB_EVENT_KEY_UP; + event->value.keycode = sdl_nsfb_map[sdlevent.key.keysym.sym]; + break; + + case SDL_MOUSEBUTTONDOWN: + event->type = NSFB_EVENT_KEY_DOWN; + + switch (sdlevent.button.button) { + + case SDL_BUTTON_LEFT: + event->value.keycode = NSFB_KEY_MOUSE_1; + break; + + case SDL_BUTTON_MIDDLE: + event->value.keycode = NSFB_KEY_MOUSE_2; + break; + + case SDL_BUTTON_RIGHT: + event->value.keycode = NSFB_KEY_MOUSE_3; + break; + + case SDL_BUTTON_WHEELUP: + event->value.keycode = NSFB_KEY_MOUSE_4; + break; + + case SDL_BUTTON_WHEELDOWN: + event->value.keycode = NSFB_KEY_MOUSE_5; + break; + } + break; + + case SDL_MOUSEBUTTONUP: + event->type = NSFB_EVENT_KEY_UP; + + switch (sdlevent.button.button) { + + case SDL_BUTTON_LEFT: + event->value.keycode = NSFB_KEY_MOUSE_1; + break; + + case SDL_BUTTON_MIDDLE: + event->value.keycode = NSFB_KEY_MOUSE_2; + break; + + case SDL_BUTTON_RIGHT: + event->value.keycode = NSFB_KEY_MOUSE_3; + break; + + case SDL_BUTTON_WHEELUP: + event->value.keycode = NSFB_KEY_MOUSE_4; + break; + + case SDL_BUTTON_WHEELDOWN: + event->value.keycode = NSFB_KEY_MOUSE_5; + break; + } + break; + + case SDL_MOUSEMOTION: + event->type = NSFB_EVENT_MOVE_ABSOLUTE; + event->value.vector.x = sdlevent.motion.x; + event->value.vector.y = sdlevent.motion.y; + event->value.vector.z = 0; + break; + + case SDL_QUIT: + event->type = NSFB_EVENT_CONTROL; + event->value.controlcode = NSFB_CONTROL_QUIT; + break; + + case SDL_USEREVENT: + event->type = NSFB_EVENT_CONTROL; + event->value.controlcode = NSFB_CONTROL_TIMEOUT; + break; } @@ -625,7 +631,7 @@ static int sdl_claim(nsfb_t *nsfb, nsfb_bbox_t *box) static int sdl_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) { - SDL_Surface *sdl_screen = nsfb->frontend_priv; + SDL_Surface *sdl_screen = nsfb->surface_priv; nsfb_bbox_t redraw; nsfb_bbox_t fbarea; @@ -659,7 +665,7 @@ sdl_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) static int sdl_update(nsfb_t *nsfb, nsfb_bbox_t *box) { - SDL_Surface *sdl_screen = nsfb->frontend_priv; + SDL_Surface *sdl_screen = nsfb->surface_priv; struct nsfb_cursor_s *cursor = nsfb->cursor; if ((cursor != NULL) && @@ -676,7 +682,7 @@ static int sdl_update(nsfb_t *nsfb, nsfb_bbox_t *box) return 0; } -const nsfb_frontend_rtns_t sdl_rtns = { +const nsfb_surface_rtns_t sdl_rtns = { .initialise = sdl_initialise, .finalise = sdl_finalise, .input = sdl_input, @@ -686,4 +692,11 @@ const nsfb_frontend_rtns_t sdl_rtns = { .geometry = sdl_set_geometry, }; -NSFB_FRONTEND_DEF(sdl, NSFB_FRONTEND_SDL, &sdl_rtns) +NSFB_SURFACE_DEF(sdl, NSFB_SURFACE_SDL, &sdl_rtns) + +/* + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ diff --git a/src/surface/surface.c b/src/surface/surface.c index 6fa65a8..b2cf769 100644 --- a/src/surface/surface.c +++ b/src/surface/surface.c @@ -12,40 +12,41 @@ #include #include -#include "frontend.h" +#include "surface.h" #include "plot.h" -#define MAX_FRONTENDS 16 +#define MAX_SURFACES 16 -struct nsfb_frontend_s { - enum nsfb_frontend_e type; - const nsfb_frontend_rtns_t *rtns; +struct nsfb_surface_s { + enum nsfb_type_e type; + const nsfb_surface_rtns_t *rtns; const char *name; }; -static struct nsfb_frontend_s frontends[MAX_FRONTENDS]; -static int frontend_count = 0; +static struct nsfb_surface_s surfaces[MAX_SURFACES]; +static int surface_count = 0; -/* internal routine which lets frontends register their presence at runtime */ -void _nsfb_register_frontend(const enum nsfb_frontend_e type, - const nsfb_frontend_rtns_t *rtns, +/* internal routine which lets surfaces register their presence at runtime */ +void _nsfb_register_surface(const enum nsfb_type_e type, + const nsfb_surface_rtns_t *rtns, const char *name) { - if (frontend_count >= MAX_FRONTENDS) - return; /* no space for additional frontends */ + if (surface_count >= MAX_SURFACES) + return; /* no space for additional surfaces */ - frontends[frontend_count].type = type; - frontends[frontend_count].rtns = rtns; - frontends[frontend_count].name = name; - frontend_count++; + surfaces[surface_count].type = type; + surfaces[surface_count].rtns = rtns; + surfaces[surface_count].name = name; + surface_count++; } -/* default frontend implementations */ -static int frontend_defaults(nsfb_t *nsfb) +/* default surface implementations */ + +static int surface_defaults(nsfb_t *nsfb) { nsfb->width = 800; nsfb->height = 600; - nsfb->bpp = 32; + nsfb->format = NSFB_FMT_XRGB8888; /* select default sw plotters for bpp */ select_plotters(nsfb); @@ -53,75 +54,93 @@ static int frontend_defaults(nsfb_t *nsfb) return 0; } -static int frontend_claim(nsfb_t *nsfb, nsfb_bbox_t *box) +static int surface_claim(nsfb_t *nsfb, nsfb_bbox_t *box) { nsfb=nsfb; box=box; return 0; } -static int frontend_update(nsfb_t *nsfb, nsfb_bbox_t *box) +static int surface_update(nsfb_t *nsfb, nsfb_bbox_t *box) { nsfb=nsfb; box=box; return 0; } -static int frontend_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) +static int surface_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) { nsfb=nsfb; cursor=cursor; return 0; } -nsfb_frontend_rtns_t *nsfb_frontend_get_rtns(enum nsfb_frontend_e type) +/* exported interface documented in surface.h */ +nsfb_surface_rtns_t * +nsfb_surface_get_rtns(enum nsfb_type_e type) { int fend_loop; - nsfb_frontend_rtns_t *rtns = NULL; - - for (fend_loop = 0; fend_loop < frontend_count; fend_loop++) { - if (frontends[fend_loop].type == type) { - rtns = malloc(sizeof(nsfb_frontend_rtns_t)); - memcpy(rtns, - frontends[fend_loop].rtns, - sizeof(nsfb_frontend_rtns_t)); - - /* frontend must have an initialisor, finaliser and input method */ - if ((rtns->initialise == NULL) || - (rtns->finalise == NULL) || - (rtns->input == NULL) ) { - free(rtns); - rtns = NULL; - } else { - /* The rest may be empty but to avoid the null check every time - * provide default implementations. - */ - if (rtns->defaults == NULL) - rtns->defaults = frontend_defaults; - - if (rtns->claim == NULL) - rtns->claim = frontend_claim; - - if (rtns->update == NULL) - rtns->update = frontend_update; - - if (rtns->cursor == NULL) - rtns->cursor = frontend_cursor; - } - + nsfb_surface_rtns_t *rtns = NULL; + + for (fend_loop = 0; fend_loop < surface_count; fend_loop++) { + /* surface type must match and have a initialisor, finaliser + * and input method + */ + if ((surfaces[fend_loop].type == type) && + (surfaces[fend_loop].rtns->initialise != NULL) && + (surfaces[fend_loop].rtns->finalise != NULL) && + (surfaces[fend_loop].rtns->input != NULL) ) { + + rtns = malloc(sizeof(nsfb_surface_rtns_t)); + if (rtns == NULL) { + continue; + } + + memcpy(rtns, + surfaces[fend_loop].rtns, + sizeof(nsfb_surface_rtns_t)); + + /* The rest may be empty but to avoid the null check every time + * provide default implementations. + */ + if (rtns->defaults == NULL) { + rtns->defaults = surface_defaults; + } + + if (rtns->claim == NULL) { + rtns->claim = surface_claim; + } + + if (rtns->update == NULL) { + rtns->update = surface_update; + } + + if (rtns->cursor == NULL) { + rtns->cursor = surface_cursor; + } + break; } } return rtns; } -enum nsfb_frontend_e nsfb_frontend_from_name(const char *name) +/* exported interface defined in libnsfb.h */ +enum nsfb_type_e +nsfb_type_from_name(const char *name) { int fend_loop; - for (fend_loop = 0; fend_loop < frontend_count; fend_loop++) { - if (strcmp(frontends[fend_loop].name, name) == 0) - return frontends[fend_loop].type; + for (fend_loop = 0; fend_loop < surface_count; fend_loop++) { + if (strcmp(surfaces[fend_loop].name, name) == 0) + return surfaces[fend_loop].type; } - return NSFB_FRONTEND_NONE; + return NSFB_SURFACE_NONE; } + +/* + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ diff --git a/src/surface/vnc.c b/src/surface/vnc.c index eb6d6ff..eb32560 100644 --- a/src/surface/vnc.c +++ b/src/surface/vnc.c @@ -9,51 +9,559 @@ #include #include +#include +#include + #include "libnsfb.h" #include "libnsfb_event.h" #include "libnsfb_plot.h" + #include "nsfb.h" -#include "frontend.h" +#include "surface.h" +#include "plot.h" +#include "cursor.h" #define UNUSED(x) ((x) = (x)) -static int vnc_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) +static nsfb_event_t *gevent; + +/* vnc special set codes */ +static enum nsfb_key_code_e vnc_nsfb_map[256] = { + NSFB_KEY_UNKNOWN, /* 0x00 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_BACKSPACE, /* 0x08 */ + NSFB_KEY_TAB, + NSFB_KEY_LF, + NSFB_KEY_CLEAR, + NSFB_KEY_UNKNOWN, + NSFB_KEY_RETURN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x10 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_RETURN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x18 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_ESCAPE, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_COMPOSE, /* 0x20 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x28 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x30 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x38 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x40 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x48 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_HOME, /* 0x50 */ + NSFB_KEY_LEFT, + NSFB_KEY_UP, + NSFB_KEY_RIGHT, + NSFB_KEY_DOWN, + NSFB_KEY_PAGEUP, + NSFB_KEY_PAGEDOWN, + NSFB_KEY_END, + NSFB_KEY_HOME, /* 0x58 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x60 */ + NSFB_KEY_PRINT, + NSFB_KEY_HELP, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNDO, + NSFB_KEY_UNKNOWN, + NSFB_KEY_MENU, + NSFB_KEY_UNKNOWN, /* 0x68 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_BREAK, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x70 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x78 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_MODE, + NSFB_KEY_NUMLOCK, + NSFB_KEY_UNKNOWN, /* 0x80 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x88 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_KP_ENTER, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x90 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0x98 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0xA0 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0xA8 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_KP_MULTIPLY, + NSFB_KEY_KP_PLUS, + NSFB_KEY_UNKNOWN, + NSFB_KEY_KP_MINUS, + NSFB_KEY_KP_PERIOD, + NSFB_KEY_KP_DIVIDE, + NSFB_KEY_KP0, /* 0xB0 */ + NSFB_KEY_KP1, + NSFB_KEY_KP2, + NSFB_KEY_KP3, + NSFB_KEY_KP4, + NSFB_KEY_KP5, + NSFB_KEY_KP6, + NSFB_KEY_KP7, + NSFB_KEY_KP8, /* 0xB8 */ + NSFB_KEY_KP9, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_KP_EQUALS, + NSFB_KEY_F1, + NSFB_KEY_F2, + NSFB_KEY_F3, /* 0xC0 */ + NSFB_KEY_F4, + NSFB_KEY_F5, + NSFB_KEY_F6, + NSFB_KEY_F7, + NSFB_KEY_F8, + NSFB_KEY_F9, + NSFB_KEY_F10, + NSFB_KEY_F11, /* 0xC8 */ + NSFB_KEY_F12, + NSFB_KEY_F13, + NSFB_KEY_F14, + NSFB_KEY_F15, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0xD0 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0xD8 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0xE0 */ + NSFB_KEY_LSHIFT, + NSFB_KEY_RSHIFT, + NSFB_KEY_LCTRL, + NSFB_KEY_RCTRL, + NSFB_KEY_CAPSLOCK, + NSFB_KEY_SCROLLOCK, + NSFB_KEY_LMETA, + NSFB_KEY_RMETA, /* 0xE8 */ + NSFB_KEY_LALT, + NSFB_KEY_RALT, + NSFB_KEY_LSUPER, + NSFB_KEY_RSUPER, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0xF0 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, /* 0xF8 */ + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_UNKNOWN, + NSFB_KEY_DELETE, +}; + + +static void vnc_doptr(int buttonMask,int x,int y,rfbClientPtr cl) +{ + static int prevbuttonMask = 0; + + UNUSED(cl); + + if (prevbuttonMask != buttonMask) { + /* button click */ + if (((prevbuttonMask ^ buttonMask) & 0x01) == 0x01) { + if ((buttonMask & 0x01) == 0x01) { + gevent->type = NSFB_EVENT_KEY_DOWN; + } else { + gevent->type = NSFB_EVENT_KEY_UP; + } + gevent->value.keycode = NSFB_KEY_MOUSE_1; + } else if (((prevbuttonMask ^ buttonMask) & 0x02) == 0x02) { + if ((buttonMask & 0x01) == 0x01) { + gevent->type = NSFB_EVENT_KEY_DOWN; + } else { + gevent->type = NSFB_EVENT_KEY_UP; + } + gevent->value.keycode = NSFB_KEY_MOUSE_2; + } else if (((prevbuttonMask ^ buttonMask) & 0x04) == 0x04) { + if ((buttonMask & 0x01) == 0x01) { + gevent->type = NSFB_EVENT_KEY_DOWN; + } else { + gevent->type = NSFB_EVENT_KEY_UP; + } + gevent->value.keycode = NSFB_KEY_MOUSE_3; + } else if (((prevbuttonMask ^ buttonMask) & 0x08) == 0x08) { + if ((buttonMask & 0x01) == 0x01) { + gevent->type = NSFB_EVENT_KEY_DOWN; + } else { + gevent->type = NSFB_EVENT_KEY_UP; + } + gevent->value.keycode = NSFB_KEY_MOUSE_4; + } else if (((prevbuttonMask ^ buttonMask) & 0x10) == 0x10) { + if ((buttonMask & 0x01) == 0x01) { + gevent->type = NSFB_EVENT_KEY_DOWN; + } else { + gevent->type = NSFB_EVENT_KEY_UP; + } + gevent->value.keycode = NSFB_KEY_MOUSE_5; + } + prevbuttonMask = buttonMask; + } else { + gevent->type = NSFB_EVENT_MOVE_ABSOLUTE; + gevent->value.vector.x = x; + gevent->value.vector.y = y; + gevent->value.vector.z = 0; + } + +} + + +static void vnc_dokey(rfbBool down, rfbKeySym key, rfbClientPtr cl) +{ + enum nsfb_key_code_e keycode = NSFB_KEY_UNKNOWN; + + UNUSED(cl); + + if ((key >= XK_space) && (key <= XK_asciitilde)) { + /* ascii codes line up */ + keycode = key; + } else if ((key & 0xff00) == 0xff00) { + /* bottom 8bits of keysyms in this range map via table */ + keycode = vnc_nsfb_map[(key & 0xff)]; + } + + if (down == 0) { + /* key up */ + gevent->type = NSFB_EVENT_KEY_UP; + } else { + /* key down */ + gevent->type = NSFB_EVENT_KEY_DOWN; + } + gevent->value.keycode = keycode; + +} + + +static int vnc_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) { - if (nsfb->frontend_priv != NULL) - return -1; /* if were already initialised fail */ + if (nsfb->surface_priv != NULL) + return -1; /* fail if surface already initialised */ + + if (width > 0) { + nsfb->width = width; + } + + if (height > 0) { + nsfb->height = height; + } + + if (format != NSFB_FMT_ANY) { + nsfb->format = format; + } - nsfb->width = width; - nsfb->height = height; - nsfb->bpp = bpp; + /* select soft plotters appropriate for format */ + select_plotters(nsfb); return 0; } static int vnc_initialise(nsfb_t *nsfb) { - UNUSED(nsfb); + rfbScreenInfoPtr vncscreen; + int argc = 0; + char **argv = NULL; + + if (nsfb->surface_priv != NULL) + return -1; /* fail if surface already initialised */ + + /* sanity checked depth. */ + if (nsfb->bpp != 32) + return -1; + + /* create vnc screen with 8bits per sample, three samples per + * pixel and 4 bytes per pixel. */ + vncscreen = rfbGetScreen(&argc, argv, + nsfb->width, nsfb->height, + 8, 3, (nsfb->bpp / 8)); + + if (vncscreen == NULL) { + /* Note libvncserver does not check its own allocations/error + * paths so the faliure mode of the rfbGetScreen is to segfault. + */ + return -1; + } + + vncscreen->frameBuffer = malloc(nsfb->width * nsfb->height * (nsfb->bpp / 8)); + + if (vncscreen->frameBuffer == NULL) { + rfbScreenCleanup(vncscreen); + return -1; + } + + + switch (nsfb->bpp) { + case 8: + break; + + case 16: + vncscreen->serverFormat.trueColour=TRUE; + vncscreen->serverFormat.redShift = 11; + vncscreen->serverFormat.greenShift = 5; + vncscreen->serverFormat.blueShift = 0; + vncscreen->serverFormat.redMax = 31; + vncscreen->serverFormat.greenMax = 63; + vncscreen->serverFormat.blueMax = 31; + break; + + case 32: + vncscreen->serverFormat.trueColour=TRUE; + vncscreen->serverFormat.redShift = 16; + vncscreen->serverFormat.greenShift = 8; + vncscreen->serverFormat.blueShift = 0; + break; + } + + vncscreen->alwaysShared = TRUE; + vncscreen->autoPort = 1; + vncscreen->ptrAddEvent = vnc_doptr; + vncscreen->kbdAddEvent = vnc_dokey; + + rfbInitServer(vncscreen); + + /* keep parameters */ + nsfb->surface_priv = vncscreen; + nsfb->ptr = (uint8_t *)vncscreen->frameBuffer; + nsfb->linelen = (nsfb->width * nsfb->bpp) / 8; + return 0; } static int vnc_finalise(nsfb_t *nsfb) { - UNUSED(nsfb); + rfbScreenInfoPtr vncscreen = nsfb->surface_priv; + + if (vncscreen != NULL) { + rfbScreenCleanup(vncscreen); + } + + return 0; +} + + +static int vnc_update(nsfb_t *nsfb, nsfb_bbox_t *box) +{ + rfbScreenInfoPtr vncscreen = nsfb->surface_priv; + + rfbMarkRectAsModified(vncscreen, box->x0, box->y0, box->x1, box->y1); + return 0; } + static bool vnc_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout) { - UNUSED(nsfb); - UNUSED(event); - UNUSED(timeout); + rfbScreenInfoPtr vncscreen = nsfb->surface_priv; + int ret; + + if (vncscreen != NULL) { + + gevent = event; /* blergh - have to use global state to pass data */ + + /* set default to timeout */ + event->type = NSFB_EVENT_CONTROL; + event->value.controlcode = NSFB_CONTROL_TIMEOUT; + + ret = rfbProcessEvents(vncscreen, timeout * 1000); + return true; + } + return false; } -const nsfb_frontend_rtns_t vnc_rtns = { +static int +vnc_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) +{ + rfbScreenInfoPtr vncscreen = nsfb->surface_priv; + rfbCursorPtr vnccursor = calloc(1,sizeof(rfbCursor)); + int rwidth; /* rounded width */ + int row; + int col; + const nsfb_colour_t *pixel; + uint8_t bit; + + rwidth = (cursor->bmp_width + 7) / 8; + + vnccursor->cleanup = 1; /* rfb lib will free this allocation */ + vnccursor->width = cursor->bmp_width; + vnccursor->height = cursor->bmp_height; + vnccursor->foreRed = vnccursor->foreGreen = vnccursor->foreBlue = 0xffff; + + vnccursor->source = calloc(rwidth, vnccursor->height); + vnccursor->cleanupSource = 1; /* rfb lib will free this allocation */ + vnccursor->mask = calloc(rwidth, vnccursor->height); + vnccursor->cleanupMask = 1; /* rfb lib will free this allocation */ + + for (row = 0, pixel = cursor->pixel; row < vnccursor->height; row++) { + for (col = 0, bit = 0x80; + col < vnccursor->width; + col++, bit = (bit & 1)? 0x80 : bit>>1, pixel++) { + + /* pixel luminance more than 50% */ + if ((((((*pixel) & 0xff) * 77) + + ((((*pixel) & 0xff00) >> 8) * 151) + + ((((*pixel) & 0xff0000) >> 16) * 28)) / 256) > 128) { + + vnccursor->source[row * rwidth + col/8] |= bit; + } + if (((*pixel) & 0xff000000) != 0) { + vnccursor->mask[row * rwidth + col/8] |= bit; + } + } + } + + rfbSetCursor(vncscreen, vnccursor); + return true; +} + +const nsfb_surface_rtns_t vnc_rtns = { .initialise = vnc_initialise, .finalise = vnc_finalise, .input = vnc_input, + .update = vnc_update, + .cursor = vnc_cursor, .geometry = vnc_set_geometry, }; -NSFB_FRONTEND_DEF(vnc, NSFB_FRONTEND_VNC, &vnc_rtns) +NSFB_SURFACE_DEF(vnc, NSFB_SURFACE_VNC, &vnc_rtns) + +/* + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ diff --git a/src/surface/x.c b/src/surface/x.c index a8c06ee..ccefacf 100644 --- a/src/surface/x.c +++ b/src/surface/x.c @@ -29,7 +29,7 @@ #include "libnsfb_plot_util.h" #include "nsfb.h" -#include "frontend.h" +#include "surface.h" #include "plot.h" #include "cursor.h" @@ -390,7 +390,7 @@ xkeysym_to_nsfbkeycode(xcb_keysym_t ks) static void set_palette(nsfb_t *nsfb) { - X_Surface *x_screen = nsfb->frontend_priv; + X_Surface *x_screen = nsfb->surface_priv; X_Color palette[256]; int rloop, gloop, bloop; int loop = 0; @@ -469,7 +469,7 @@ update_and_redraw_pixmap(xstate_t *xstate, int x, int y, int width, int height) static bool xcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox) { - xstate_t *xstate = nsfb->frontend_priv; + xstate_t *xstate = nsfb->surface_priv; nsfb_bbox_t allbox; struct nsfb_cursor_s *cursor = nsfb->cursor; uint8_t *srcptr; @@ -564,16 +564,17 @@ xcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox) } -static int x_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) +static int +x_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) { - if (nsfb->frontend_priv != NULL) + if (nsfb->surface_priv != NULL) return -1; /* if were already initialised fail */ nsfb->width = width; nsfb->height = height; - nsfb->bpp = bpp; + nsfb->format = format; - /* select default sw plotters for bpp */ + /* select default sw plotters for format */ select_plotters(nsfb); nsfb->plotter_fns->copy = xcopy; @@ -588,6 +589,7 @@ find_format(xcb_connection_t * c, uint8_t depth, uint8_t bpp) const xcb_setup_t *setup = xcb_get_setup(c); xcb_format_t *fmt = xcb_setup_pixmap_formats(setup); xcb_format_t *fmtend = fmt + xcb_setup_pixmap_formats_length(setup); + for(; fmt != fmtend; ++fmt) { if((fmt->depth == depth) && (fmt->bits_per_pixel == bpp)) { return fmt; @@ -756,7 +758,7 @@ static int x_initialise(nsfb_t *nsfb) uint32_t mask; uint32_t values[3]; xcb_size_hints_t *hints; - xstate_t *xstate = nsfb->frontend_priv; + xstate_t *xstate = nsfb->surface_priv; xcb_cursor_t blank_cursor; if (xstate != NULL) @@ -801,7 +803,7 @@ static int x_initialise(nsfb_t *nsfb) } /* ensure plotting information is stored */ - nsfb->frontend_priv = xstate; + nsfb->surface_priv = xstate; nsfb->ptr = xstate->image->data; nsfb->linelen = xstate->image->stride; @@ -867,7 +869,7 @@ static int x_initialise(nsfb_t *nsfb) static int x_finalise(nsfb_t *nsfb) { - xstate_t *xstate = nsfb->frontend_priv; + xstate_t *xstate = nsfb->surface_priv; if (xstate == NULL) return 0; @@ -890,7 +892,7 @@ static bool x_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout) xcb_button_press_event_t *ebp; xcb_key_press_event_t *ekp; xcb_key_press_event_t *ekr; - xstate_t *xstate = nsfb->frontend_priv; + xstate_t *xstate = nsfb->surface_priv; if (xstate == NULL) return false; @@ -916,8 +918,10 @@ static bool x_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout) retval = select(confd + 1, &rfds, NULL, NULL, &tv); if (retval == 0) { - return false; /* timeout, nothing happened */ - + /* timeout, nothing happened */ + event->type = NSFB_EVENT_CONTROL; + event->value.controlcode = NSFB_CONTROL_TIMEOUT; + return true; } } e = xcb_wait_for_event(xstate->connection); @@ -1051,7 +1055,7 @@ static int x_claim(nsfb_t *nsfb, nsfb_bbox_t *box) static int x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) { - xstate_t *xstate = nsfb->frontend_priv; + xstate_t *xstate = nsfb->surface_priv; nsfb_bbox_t redraw; nsfb_bbox_t fbarea; @@ -1083,7 +1087,7 @@ x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box) { - xstate_t *xstate = nsfb->frontend_priv; + xstate_t *xstate = nsfb->surface_priv; struct nsfb_cursor_s *cursor = nsfb->cursor; if ((cursor != NULL) && @@ -1096,7 +1100,7 @@ static int x_update(nsfb_t *nsfb, nsfb_bbox_t *box) return 0; } -const nsfb_frontend_rtns_t x_rtns = { +const nsfb_surface_rtns_t x_rtns = { .initialise = x_initialise, .finalise = x_finalise, .input = x_input, @@ -1106,4 +1110,11 @@ const nsfb_frontend_rtns_t x_rtns = { .geometry = x_set_geometry, }; -NSFB_FRONTEND_DEF(x, NSFB_FRONTEND_X, &x_rtns) +NSFB_SURFACE_DEF(x, NSFB_SURFACE_X, &x_rtns) + +/* + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ -- cgit v1.2.1