author | Francesco Abbate <francesco.bbt@gmail.com> | 2010年08月08日 00:47:16 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2010年08月08日 00:47:16 +0200 |
commit | edd594b48a302145178679af1719d1a85454dee4 (patch) | |
tree | 325bc8f04f91b81c4cf10fb2731a5cddc8dd74a9 | |
parent | 7ca6cb456b8517b97c9a063f07799b3babda3b5e (diff) | |
download | gsl-shell-edd594b48a302145178679af1719d1a85454dee4.tar.gz |
-rw-r--r-- | agg-plot/agg_platform_support_x11.cpp | 8 | ||||
-rw-r--r-- | agg-plot/canvas-window.cpp | 13 | ||||
-rw-r--r-- | agg-plot/canvas-window.h | 7 | ||||
-rw-r--r-- | window-refs.c | 2 |
diff --git a/agg-plot/agg_platform_support_x11.cpp b/agg-plot/agg_platform_support_x11.cpp index 0d252726..88dc7b28 100644 --- a/agg-plot/agg_platform_support_x11.cpp +++ b/agg-plot/agg_platform_support_x11.cpp @@ -66,6 +66,7 @@ namespace agg XImage* m_ximg_window; XSetWindowAttributes m_window_attributes; Atom m_close_atom; + Atom m_wm_protocols_atom; unsigned char* m_buf_window; unsigned char* m_buf_img[platform_support::max_images]; unsigned m_keymap[256]; @@ -97,6 +98,7 @@ namespace agg m_gc(0), m_ximg_window(0), m_close_atom(0), + m_wm_protocols_atom(0), m_buf_window(0), @@ -217,7 +219,7 @@ namespace agg ev.xclient.type = ClientMessage; ev.xclient.window = m_window; - // ev.xclient.message_type = XInternAtom(m_display, "WM_PROTOCOLS", true); + ev.xclient.message_type = m_wm_protocols_atom; ev.xclient.format = 32; ev.xclient.data.l[0] = m_close_atom; ev.xclient.data.l[1] = CurrentTime; @@ -649,6 +651,10 @@ namespace agg "WM_DELETE_WINDOW", false); + m_specific->m_wm_protocols_atom = XInternAtom(m_specific->m_display, + "WM_PROTOCOLS", + true); + XSetWMProtocols(m_specific->m_display, m_specific->m_window, &m_specific->m_close_atom, diff --git a/agg-plot/canvas-window.cpp b/agg-plot/canvas-window.cpp index 9b73d5f1..9302b46e 100644 --- a/agg-plot/canvas-window.cpp +++ b/agg-plot/canvas-window.cpp @@ -47,9 +47,9 @@ static int canvas_window_stroke (lua_State *L); static int canvas_window_clear (lua_State *L); static int canvas_window_refresh (lua_State *L); static int canvas_window_set_box_trans (lua_State *L); +static int canvas_window_index_protected (lua_State *L); static void * canvas_thread_function (void *_win); -static int canvas_window_index_protected (lua_State *L); static int canvas_window_draw_gener (lua_State *L, bool as_line); static const struct luaL_Reg canvas_win_functions[] = { @@ -248,6 +248,17 @@ canvas_window_close (lua_State *L) } int +canvas_window_close_protected (lua_State *L) +{ + canvas_window *win = canvas_window::check (L, 1); + win->lock(); + if (win->status == canvas_window::running) + win->close(); + win->unlock(); + return 0; +} + +int canvas_window_index_protected (lua_State *L) { canvas_window *win = canvas_window::check(L, lua_upvalueindex(2)); diff --git a/agg-plot/canvas-window.h b/agg-plot/canvas-window.h index ef71a002..2d1b808b 100644 --- a/agg-plot/canvas-window.h +++ b/agg-plot/canvas-window.h @@ -7,9 +7,10 @@ __BEGIN_DECLS #include "lua.h" -extern void canvas_window_register (lua_State *L); -extern int canvas_window_index (lua_State *L); -extern int canvas_window_close (lua_State *L); +extern void canvas_window_register (lua_State *L); +extern int canvas_window_index (lua_State *L); +extern int canvas_window_close (lua_State *L); +extern int canvas_window_close_protected (lua_State *L); __END_DECLS diff --git a/window-refs.c b/window-refs.c index 873f9d52..dc694d2d 100644 --- a/window-refs.c +++ b/window-refs.c @@ -47,7 +47,7 @@ window_ref_close_all (lua_State *L) lua_pushnil (L); /* first key */ while (lua_next(L, -2) != 0) { - lua_pushcfunction (L, canvas_window_close); + lua_pushcfunction (L, canvas_window_close_protected); lua_insert (L, -2); lua_call (L, 1, 0); } |