This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via f48d899fd136b662a6a5bd7820089dff4c309c72 (commit) via b76587f53f5976a66cc44cdbb5e7ee2dae0807b0 (commit) via 61e0747c9dfcf12d7eb3a3315a559d63dcd176e7 (commit) via 943bd6a63a5c34460b95441da36313d35d0a877b (commit) via 5b6b8f9395af8ef7d017642a6e6ca37eaf5abf54 (commit) via 0211dcc91eef550bdb079f6a2f3410bf3bda985a (commit) from a2551d947cc9e247126f7f6576c9b74b726484cc (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/f48d899fd136b662a6a5bd7820089dff4c309...
commit f48d899fd136b662a6a5bd7820089dff4c309c72 Author: Cyril Hrubis metan@ucw.cz Date: Fri May 25 20:28:57 2012 +0200
X11: Add option to run X11 backend in root window.
diff --git a/include/backends/GP_X11.h b/include/backends/GP_X11.h index 16be681..e03baf4 100644 --- a/include/backends/GP_X11.h +++ b/include/backends/GP_X11.h @@ -25,6 +25,14 @@
#include "GP_Backend.h"
+enum GP_BackendX11Flags { + /* + * When set, w and h is ignored and root window is used + */ + GP_X11_USE_ROOT_WIN = 0x01, +}; + + /* * Initalize X11 backend. * @@ -37,6 +45,7 @@ */ GP_Backend *GP_BackendX11Init(const char *display, int x, int y, unsigned int w, unsigned int h, - const char *caption); + const char *caption, + enum GP_BackendX11Flags flags);
#endif /* BACKENDS_GP_X11_H */ diff --git a/libs/backends/GP_BackendInit.c b/libs/backends/GP_BackendInit.c index b00fd10..316b137 100644 --- a/libs/backends/GP_BackendInit.c +++ b/libs/backends/GP_BackendInit.c @@ -133,24 +133,66 @@ static void backend_x11_help(FILE *help, const char *err) fprintf(help, "ERROR: %sn", err);
fprintf(help, "X11 backendn" - "-----------n" - "X11:WxHn"); + "--------------n" + "X11:WxH:[ROOT_WIN]nn" + "ROOT_WIN - starts the backend in the root windown" + " (w and h, if set, are ignored)n"); +} + +static int x11_params_to_flags(const char *param, GP_Size *w, GP_Size *h, + enum GP_BackendX11Flags *flags, FILE *help) +{ + if (!strcasecmp(param, "ROOT_WIN")) { + *flags |= GP_X11_USE_ROOT_WIN; + return 0; + } + + /* + * Accepts only string with format "intxint" or "intXint" + */ + int sw, sh; + unsigned int n; + + if (sscanf(param, "%i%*[xX]%i%n", &sw, &sh, &n) == 2 && n == strlen(param)) { + *w = sw; + *h = sh; + return 0; + } + + backend_sdl_help(help, "X11: Invalid parameters"); + return 1; }
+ static GP_Backend *backend_x11_init(char *params, const char *caption, FILE *help) { - unsigned int n, w = 640, h = 480; - + GP_Size w = 640, h = 480; + enum GP_BackendX11Flags flags = 0; + if (params == NULL) - return GP_BackendX11Init(NULL, 0, 0, w, h, caption); + return GP_BackendX11Init(NULL, 0, 0, w, h, caption, 0);
- if (sscanf(params, "%u%*[xX]%u%n", &w, &h, &n) == 2 && - n == strlen(params)) - return GP_BackendX11Init(NULL, 0, 0, w, h, caption); + char *s = params;
- backend_x11_help(help, "X11: Invalid parameters"); - return NULL; + for (;;) { + switch (*s) { + case ':': + (*s) = '0'; + if (x11_params_to_flags(params, &w, &h, &flags, help)) + return NULL; + s++; + params = s; + break; + case '0': + if (x11_params_to_flags(params, &w, &h, &flags, help)) + return NULL; + + return GP_BackendX11Init(NULL, 0, 0, w, h, caption, flags); + break; + } + s++; + } }
static const char *backend_names[] = { diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index 657087f..a1d9733 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -254,9 +254,60 @@ static int resize_ximage(GP_Backend *self, int w, int h) return 0; }
+void create_window(struct x11_priv *x11, int x, int y, + unsigned int *w, unsigned int *h, + const char *caption, enum GP_BackendX11Flags flags) +{ + XSetWindowAttributes attrs; + unsigned long attr_mask = 0; + + /* Set event mask */ + attrs.event_mask = ExposureMask | StructureNotifyMask |KeyPressMask | + KeyReleaseMask | PointerMotionMask; + attr_mask |= CWEventMask; + + /* + * If root window was selected, resize w and h and set x11->win to root + * window. + */ + if (flags & GP_X11_USE_ROOT_WIN) { + x11->win = DefaultRootWindow(x11->dpy); + *w = DisplayWidth(x11->dpy, x11->scr); + *h = DisplayHeight(x11->dpy, x11->scr); + + GP_DEBUG(2, "Using root window, owerriding size to %ux%u", + *w, *h); + + XChangeWindowAttributes(x11->dpy, x11->win, attr_mask, &attrs); + + return; + } + + GP_DEBUG(2, "Opening window '%s' %ix%i-%ux%u", + caption, x, y, *w, *h); + + /* + * For some reason reading mouse button clicks on root win are not + * allowed... + */ + attrs.event_mask |= ButtonPressMask | ButtonReleaseMask ; + + x11->win = XCreateWindow(x11->dpy, DefaultRootWindow(x11->dpy), + x, y, *w, *h, 0, CopyFromParent, + InputOutput, CopyFromParent, attr_mask, &attrs); + + /* Set window caption */ + XmbSetWMProperties(x11->dpy, x11->win, caption, caption, + NULL, 0, NULL, NULL, NULL); + + /* Show window */ + XMapWindow(x11->dpy, x11->win); +} + GP_Backend *GP_BackendX11Init(const char *display, int x, int y, unsigned int w, unsigned int h, - const char *caption) + const char *caption, + enum GP_BackendX11Flags flags) { GP_Backend *backend; struct x11_priv *x11; @@ -288,39 +339,22 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
GP_DEBUG(2, "Have Visual id %i, depth %u", (int)x11->vis->visualid, x11->scr_depth);
- if (create_ximage(backend, w, h)) - goto err1; - - GP_DEBUG(2, "Opening window '%s' %ix%i-%ux%u", - caption, x, y, w, h); - - x11->win = XCreateWindow(x11->dpy, DefaultRootWindow(x11->dpy), - x, y, w, h, 0, CopyFromParent, - InputOutput, CopyFromParent, 0, NULL); - + create_window(x11, x, y, &w, &h, caption, flags); + if (x11->win == None) { //TODO: Error message? GP_DEBUG(1, "Failed to create window"); - goto err2; + goto err1; } - /* Select events */ - XSelectInput(x11->dpy, x11->win, ExposureMask | StructureNotifyMask | - KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask | - PointerMotionMask); + if (create_ximage(backend, w, h)) + goto err1; +
- /* Set window caption */ - XmbSetWMProperties(x11->dpy, x11->win, caption, caption, - NULL, 0, NULL, NULL, NULL); - - /* Show window */ - XMapWindow(x11->dpy, x11->win); XFlush(x11->dpy); x11->resized_flag = 0;
- backend->name = "X11"; backend->Flip = x11_flip; backend->UpdateRect = x11_update_rect; @@ -330,8 +364,6 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y, backend->SetAttributes = x11_set_attributes;
return backend; -err2: - destroy_ximage(backend); err1: XCloseDisplay(x11->dpy); err0:
http://repo.or.cz/w/gfxprim.git/commit/b76587f53f5976a66cc44cdbb5e7ee2dae080...
commit b76587f53f5976a66cc44cdbb5e7ee2dae0807b0 Author: Cyril Hrubis metan@ucw.cz Date: Fri May 25 20:20:49 2012 +0200
demos: Change particle demo default backend to X11.
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c index 82c8e74..4143ffe 100644 --- a/demos/particle/particle_demo.c +++ b/demos/particle/particle_demo.c @@ -61,7 +61,7 @@ static void init_backend(const char *backend_opts)
int main(int argc, char *argv[]) { - const char *backend_opts = "SDL"; + const char *backend_opts = "X11"; int opt; int pause_flag = 0;
@@ -75,7 +75,7 @@ int main(int argc, char *argv[]) } } - GP_SetDebugLevel(10); +// GP_SetDebugLevel(10);
signal(SIGINT, sighandler); signal(SIGSEGV, sighandler);
http://repo.or.cz/w/gfxprim.git/commit/61e0747c9dfcf12d7eb3a3315a559d63dcd17...
commit 61e0747c9dfcf12d7eb3a3315a559d63dcd176e7 Author: Cyril Hrubis metan@ucw.cz Date: Fri May 25 18:25:28 2012 +0200
X11: Remove temporarily XResizeWindow
To avoid to infinite resize loop.
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index aec3bce..657087f 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -159,7 +159,7 @@ static int x11_set_attributes(struct GP_Backend *self, return 1;
/* Resize X11 window */ - XResizeWindow(x11->dpy, x11->win, w, h); + // XResizeWindow(x11->dpy, x11->win, w, h); XFlush(x11->dpy);
x11->resized_flag = 1;
http://repo.or.cz/w/gfxprim.git/commit/943bd6a63a5c34460b95441da36313d35d0a8...
commit 943bd6a63a5c34460b95441da36313d35d0a877b Author: Cyril Hrubis metan@ucw.cz Date: Fri May 25 18:23:29 2012 +0200
build: Remove the useless -dPIC compilation switch.
diff --git a/lib.mk b/lib.mk index c801e07..d9a6f0b 100644 --- a/lib.mk +++ b/lib.mk @@ -25,12 +25,12 @@ $(LIBP)$(LIB).so: $(OBJS) ifdef VERBOSE rm -f $(LIBP)$(LIB).so.0 cd $(LIBP) && ln -s $(LIB).so $(LIB).so.0 - $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@ + $(CC) -fPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@ else @rm -f $(LIBP)$(LIB).so.0 @cd $(LIBP) && ln -s $(LIB).so $(LIB).so.0 @echo "LD $@" - @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@ + @$(CC) -fPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@ endif
$(LIBP)$(LIB).a: $(OBJS)
http://repo.or.cz/w/gfxprim.git/commit/5b6b8f9395af8ef7d017642a6e6ca37eaf5ab...
commit 5b6b8f9395af8ef7d017642a6e6ca37eaf5abf54 Author: Cyril Hrubis metan@ucw.cz Date: Fri May 25 18:20:56 2012 +0200
backends: Move the resize w, h check into general code.
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h index 1f8428e..63020db 100644 --- a/include/backends/GP_Backend.h +++ b/include/backends/GP_Backend.h @@ -93,6 +93,8 @@ typedef struct GP_Backend { * * If w and h are zero, only caption is changed. * + * If w is set and h is zero, only w is changed and vice versa. + * * If caption is NULL only w and h are changed. * * Use the inline wrappers instead. diff --git a/include/backends/GP_X11.h b/include/backends/GP_X11.h index 198e252..16be681 100644 --- a/include/backends/GP_X11.h +++ b/include/backends/GP_X11.h @@ -28,8 +28,10 @@ /* * Initalize X11 backend. * - * The display may be NULL default display. The coordinates are position and - * geometry for newly created window. + * The display may be NULL for default display ($DISPLAY shell variable will + * be used). + * + * The coordinates are position and geometry for newly created window. * * Upon failure NULL is returned. */ diff --git a/libs/backends/GP_Backend.c b/libs/backends/GP_Backend.c index fc37449..88b52a3 100644 --- a/libs/backends/GP_Backend.c +++ b/libs/backends/GP_Backend.c @@ -46,6 +46,12 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h) { if (backend->SetAttributes == NULL) return 1; + + if (w == 0) + w = backend->context->w; + + if (h == 0) + h = backend->context->h;
if (backend->context->w == w && backend->context->h == h) return 0; diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index 1c5dd91..aec3bce 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -152,13 +152,7 @@ static int x11_set_attributes(struct GP_Backend *self, NULL, 0, NULL, NULL, NULL); }
- if (w != 0 || h != 0) { - if (w == 0) - w = self->context->w; - - if (h == 0) - h = self->context->h; - + if (w != 0 && h != 0) { GP_DEBUG(3, "Setting window size to %ux%u", w, h); if (resize_ximage(self, w, h))
http://repo.or.cz/w/gfxprim.git/commit/0211dcc91eef550bdb079f6a2f3410bf3bda9...
commit 0211dcc91eef550bdb079f6a2f3410bf3bda985a Author: Cyril Hrubis metan@ucw.cz Date: Fri May 25 18:00:45 2012 +0200
core: Fix color conversion function parameters.
And thanks clang-3.1 for spotting this.
diff --git a/libs/core/GP_Color.c b/libs/core/GP_Color.c index e124577..2c42d4a 100644 --- a/libs/core/GP_Color.c +++ b/libs/core/GP_Color.c @@ -121,7 +121,7 @@ bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type, if (color == GP_COL_INVALID) return false;
- *pixel = GP_ColorToPixel(pixel_type, color); + *pixel = GP_ColorToPixel(color, pixel_type);
return true; }
-----------------------------------------------------------------------
Summary of changes: demos/particle/particle_demo.c | 4 +- include/backends/GP_Backend.h | 2 + include/backends/GP_X11.h | 17 ++++++- lib.mk | 4 +- libs/backends/GP_Backend.c | 6 +++ libs/backends/GP_BackendInit.c | 62 ++++++++++++++++++++++---- libs/backends/GP_X11.c | 94 +++++++++++++++++++++++++-------------- libs/core/GP_Color.c | 2 +- 8 files changed, 139 insertions(+), 52 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.