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 402373dac8551c34bf48ceeba4aace19cee0eea9 (commit) via 9c639e42fa7d4c0254d00294bd7100ef24ca42a8 (commit) from 21e1fa797b0f25794c323793ebcff1c1762c755a (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/402373dac8551c34bf48ceeba4aace19cee0e...
commit 402373dac8551c34bf48ceeba4aace19cee0eea9 Author: Cyril Hrubis metan@ucw.cz Date: Fri Mar 1 23:36:26 2013 +0100
examples: add X11 multiple windows example.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile index 782eee2..bca6fa2 100644 --- a/demos/c_simple/Makefile +++ b/demos/c_simple/Makefile @@ -18,7 +18,7 @@ APPS=backend_example loaders_example loaders filters_symmetry gfx_koch virtual_backend_example meta_data meta_data_dump tmp_file showimage v4l2_show v4l2_grab convolution weighted_median shapetest koch input_example fileview linetest randomshapetest fonttest- loaders_register blittest textaligntest abort sin_AA + loaders_register blittest textaligntest abort sin_AA x11_windows
ifeq ($(HAVE_LIBSDL),yes) APPS+=SDL_glue diff --git a/demos/c_simple/x11_windows.c b/demos/c_simple/x11_windows.c new file mode 100644 index 0000000..2c77075 --- /dev/null +++ b/demos/c_simple/x11_windows.c @@ -0,0 +1,123 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + + /* + + Simple backend example. + + */ + +#include <GP.h> + +static void redraw(struct GP_Context *context) +{ + GP_Pixel white_pixel, black_pixel; + + black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); + white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); + + GP_Fill(context, black_pixel); + GP_Line(context, 0, 0, context->w - 1, context->h - 1, white_pixel); + GP_Line(context, 0, context->h - 1, context->w - 1, 0, white_pixel); +} + +static int ev_loop(struct GP_Backend *backend, const char *name) +{ + GP_Event ev; + + if (backend == NULL) + return 0; + + while (GP_BackendGetEvent(backend, &ev)) { + + printf("-------------------------- %sn", name); + + GP_EventDump(&ev); + + switch (ev.type) { + case GP_EV_KEY: + switch (ev.val.val) { + case GP_KEY_ESC: + case GP_KEY_Q: + GP_BackendExit(backend); + return 1; + break; + } + break; + case GP_EV_SYS: + switch (ev.code) { + case GP_EV_SYS_RESIZE: + GP_BackendResizeAck(backend); + break; + case GP_EV_SYS_QUIT: + GP_BackendExit(backend); + return 1; + break; + } + break; + } + + printf("-----------------------------n"); + } + + return 0; +} + +int main(void) +{ + GP_Backend *win_1, *win_2; + + win_1 = GP_BackendX11Init(NULL, 0, 0, 300, 300, "win 1", 0); + win_2 = GP_BackendX11Init(NULL, 0, 0, 300, 300, "win 2", 0); + + /* Update the backend screen */ + redraw(win_1->context); + redraw(win_2->context); + + GP_BackendFlip(win_1); + GP_BackendFlip(win_2); + + for (;;) { + /* + * Wait for backend event. + * + * Either window is fine as they share connection. + */ + GP_Backend *b = win_1 ? win_1 : win_2; + + if (b == NULL) + return 0; + + GP_BackendWait(b); + + if (ev_loop(win_1, "win 1")) + win_1 = NULL; + + if (ev_loop(win_2, "win 2")) + win_2 = NULL; + } + + GP_BackendExit(win_1); + GP_BackendExit(win_2); + + return 0; +}
http://repo.or.cz/w/gfxprim.git/commit/9c639e42fa7d4c0254d00294bd7100ef24ca4...
commit 9c639e42fa7d4c0254d00294bd7100ef24ca42a8 Author: Cyril Hrubis metan@ucw.cz Date: Fri Mar 1 23:35:26 2013 +0100
backends: X11: Fix double close on exit.
This fixes segfault for multiple window X11 backend.
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index 3a6e2ba..e3ee8eb 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -525,8 +525,6 @@ static void x11_exit(GP_Backend *self) { window_close(self);
- x11_close(); - free(self); }
diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h index 759ec73..11786a8 100644 --- a/libs/backends/GP_X11_Win.h +++ b/libs/backends/GP_X11_Win.h @@ -394,7 +394,8 @@ void x11_win_close(struct x11_win *win) else destroy_ximage(self); */ - + XUnmapWindow(win->dpy, win->win); + XDestroyWindow(win->dpy, win->win); XUnlockDisplay(win->dpy);
-----------------------------------------------------------------------
Summary of changes: demos/c_simple/Makefile | 2 +- .../c_simple/{backend_example.c => x11_windows.c} | 129 +++++++++++--------- libs/backends/GP_X11.c | 2 - libs/backends/GP_X11_Win.h | 3 +- 4 files changed, 74 insertions(+), 62 deletions(-) copy demos/c_simple/{backend_example.c => x11_windows.c} (63%)
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.