From e9fb6419fee39416f16d09d4505bd6c8ebf05045 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 22 Mar 2013 17:56:55 +0000 Subject: works if you cause messages to be delivered to allow the input pump to run --- src/surface/wld.c | 169 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 101 insertions(+), 68 deletions(-) diff --git a/src/surface/wld.c b/src/surface/wld.c index ded996d..76067e7 100644 --- a/src/surface/wld.c +++ b/src/surface/wld.c @@ -40,6 +40,73 @@ #include "plot.h" #include "cursor.h" +/** structure for display, registry and other global objects that + * should be cached when connecting to a wayland instance + */ +struct wld_connection { + struct wl_display *display; /**< connection object */ + struct wl_registry *registry; /**< registry object */ + + /** compositor object, available once teh registry messages have + * been processed + */ + struct wl_compositor *compositor; + + /** shell object, available once the registry messages have been + * processed + */ + struct wl_shell *shell; + + /** shared memory object, available once the registry messages + * have been processed + */ + struct wl_shm *shm; + + /** shared memory formats available */ + uint32_t shm_formats; +}; + +/* wayland window encompasing the display and shell surfaces */ +struct wld_window { + struct wld_connection* connection; /**< connection to wayland server */ + + struct wl_surface *surface; + struct wl_shell_surface *shell_surface; + + int width, height; +}; + +struct wld_shm_buffer { + struct wl_buffer *buffer; /**< wayland buffer object */ + void *data; /**< mapped memory */ + int size; /**< size of mapped memory */ + bool inuse; /**< flag to indicate if the buffer has been released + * after commit to a surface. + */ +}; + +typedef struct wldstate_s { + struct wld_connection* connection; /**< connection to wayland server */ + struct wld_window *window; + struct wld_shm_buffer *shm_buffer; +#if 0 + xcb_connection_t *connection; /* The x server connection */ + xcb_screen_t *screen; /* The screen to put the window on */ + xcb_key_symbols_t *keysymbols; /* keysym mappings */ + + xcb_shm_segment_info_t shminfo; + + xcb_image_t *image; /* The X image buffer */ + + xcb_window_t window; /* The handle to the window */ + xcb_pixmap_t pmap; /* The handle to the backing pixmap */ + xcb_gcontext_t gc; /* The handle to the pixmap plotting graphics context */ + xcb_shm_seg_t segment; /* The handle to the image shared memory */ +#endif + +} wldstate_t; + + #if 0 #if defined(NSFB_NEED_HINTS_ALLOC) @@ -585,14 +652,9 @@ xcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox) #endif -static int -wld_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) -{ -} -#if 0 static int -x_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) +wld_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) { if (nsfb->surface_priv != NULL) return -1; /* if were already initialised fail */ @@ -604,11 +666,10 @@ x_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e format) /* select default sw plotters for format */ select_plotters(nsfb); - nsfb->plotter_fns->copy = xcopy; - - return 0; } +#if 0 + static xcb_format_t * find_format(xcb_connection_t * c, uint8_t depth, uint8_t bpp) @@ -780,32 +841,6 @@ create_blank_cursor(xcb_connection_t *conn, const xcb_screen_t *scr) } #endif -/** structure for display, registry and other global objects that - * should be cached when connecting to a wayland instance - */ -struct wld_connection { - struct wl_display *display; /**< connection object */ - struct wl_registry *registry; /**< registry object */ - - /** compositor object, available once teh registry messages have - * been processed - */ - struct wl_compositor *compositor; - - /** shell object, available once the registry messages have been - * processed - */ - struct wl_shell *shell; - - /** shared memory object, available once the registry messages - * have been processed - */ - struct wl_shm *shm; - - /** shared memory formats available */ - uint32_t shm_formats; -}; - /** shared memory interface format available callback * @@ -977,36 +1012,29 @@ new_connection(void) } -typedef struct wldstate_s { - struct wld_connection* connection; /**< connection to wayland server */ - struct wld_window *window; - struct wld_shm_buffer *shm_buffer; -#if 0 - xcb_connection_t *connection; /* The x server connection */ - xcb_screen_t *screen; /* The screen to put the window on */ - xcb_key_symbols_t *keysymbols; /* keysym mappings */ - - xcb_shm_segment_info_t shminfo; - - xcb_image_t *image; /* The X image buffer */ - xcb_window_t window; /* The handle to the window */ - xcb_pixmap_t pmap; /* The handle to the backing pixmap */ - xcb_gcontext_t gc; /* The handle to the pixmap plotting graphics context */ - xcb_shm_seg_t segment; /* The handle to the image shared memory */ -#endif +static int +update_and_redraw(struct wldstate_s *wldstate, + int x, + int y, + int width, + int height) +{ + wl_surface_attach(wldstate->window->surface, + wldstate->shm_buffer->buffer, + 0, + 0); -} wldstate_t; + wl_surface_damage(wldstate->window->surface, x, y, width, height); -/* wayland window encompasing the display and shell surfaces */ -struct wld_window { - struct wld_connection* connection; /**< connection to wayland server */ + wl_surface_commit(wldstate->window->surface); + wldstate->shm_buffer->inuse = true; - struct wl_surface *surface; - struct wl_shell_surface *shell_surface; + /** @todo should this be here? */ + wl_display_roundtrip(wldstate->connection->display); - int width, height; -}; + return 0; +} static void handle_ping(void *data, struct wl_shell_surface *shell_surface, @@ -1137,14 +1165,6 @@ os_create_anonymous_file(off_t size) return fd; } -struct wld_shm_buffer { - struct wl_buffer *buffer; /**< wayland buffer object */ - void *data; /**< mapped memory */ - int size; /**< size of mapped memory */ - bool inuse; /**< flag to indicate if the buffer has been released - * after commit to a surface. - */ -}; static void buffer_release(void *data, struct wl_buffer *buffer) @@ -1277,6 +1297,11 @@ static int wld_initialise(nsfb_t *nsfb) return -1; /* error */ } + nsfb->ptr = wldstate->shm_buffer->data; + nsfb->linelen = nsfb->width * 4; + + update_and_redraw(wldstate,0,0, nsfb->width, nsfb->height); + nsfb->surface_priv = wldstate; return 0; @@ -1447,6 +1472,8 @@ static bool wld_input(nsfb_t *nsfb, nsfb_event_t *event, int timeout) return true; } + event->type = NSFB_EVENT_NONE; + return false; } @@ -1659,6 +1686,12 @@ x_cursor(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) static int wld_update(nsfb_t *nsfb, nsfb_bbox_t *box) { + wldstate_t *wldstate = nsfb->surface_priv; + + if (wldstate != NULL) { + update_and_redraw(wldstate, box->x0, box->y0, box->x1 - box->x0, box->y1 - box->y0); + } + return 0; } #if 0 -- cgit v1.2.1