drawable/drawin: Pass both lua_State and stack index around
A stack index without the corresponding lua_State pointer is useless, because it could reference another coroutine than the main thread and thus just assuming globalconf.L is wrong. Fix this by also passing around the corresponding lua_State pointer. This improves the result for the following test: coroutine.resume(coroutine.create(function() drawin({}).visible = true end)) Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
f0ab2aebeb
commit
f957764e52
|
@ -797,7 +797,7 @@ client_resize_do(client_t *c, area_t geometry, bool force_notice, bool honor_hin
|
|||
area.y += geometry.y;
|
||||
if (hide_titlebars)
|
||||
area.width = area.height = 0;
|
||||
drawable_set_geometry(drawable, -1, area);
|
||||
drawable_set_geometry(globalconf.L, -1, area);
|
||||
|
||||
/* Pop the client and the drawable */
|
||||
lua_pop(globalconf.L, 2);
|
||||
|
|
|
@ -61,8 +61,9 @@ drawable_wipe(drawable_t *d)
|
|||
}
|
||||
|
||||
void
|
||||
drawable_set_geometry(drawable_t *d, int didx, area_t geom)
|
||||
drawable_set_geometry(lua_State *L, int didx, area_t geom)
|
||||
{
|
||||
drawable_t *d = luaA_checkudata(L, didx, &drawable_class);
|
||||
area_t old = d->geometry;
|
||||
d->geometry = geom;
|
||||
|
||||
|
@ -77,17 +78,17 @@ drawable_set_geometry(drawable_t *d, int didx, area_t geom)
|
|||
d->surface = cairo_xcb_surface_create(globalconf.connection,
|
||||
d->pixmap, globalconf.visual,
|
||||
geom.width, geom.height);
|
||||
luaA_object_emit_signal(globalconf.L, didx, "property::surface", 0);
|
||||
luaA_object_emit_signal(L, didx, "property::surface", 0);
|
||||
}
|
||||
|
||||
if (old.x != geom.x)
|
||||
luaA_object_emit_signal(globalconf.L, didx, "property::x", 0);
|
||||
luaA_object_emit_signal(L, didx, "property::x", 0);
|
||||
if (old.y != geom.y)
|
||||
luaA_object_emit_signal(globalconf.L, didx, "property::y", 0);
|
||||
luaA_object_emit_signal(L, didx, "property::y", 0);
|
||||
if (old.width != geom.width)
|
||||
luaA_object_emit_signal(globalconf.L, didx, "property::width", 0);
|
||||
luaA_object_emit_signal(L, didx, "property::width", 0);
|
||||
if (old.height != geom.height)
|
||||
luaA_object_emit_signal(globalconf.L, didx, "property::height", 0);
|
||||
luaA_object_emit_signal(L, didx, "property::height", 0);
|
||||
}
|
||||
|
||||
/** Get a drawable's surface
|
||||
|
|
|
@ -48,7 +48,7 @@ struct drawable_t
|
|||
typedef struct drawable_t drawable_t;
|
||||
|
||||
drawable_t *drawable_allocator(lua_State *, drawable_refresh_callback *, void *);
|
||||
void drawable_set_geometry(drawable_t *, int, area_t);
|
||||
void drawable_set_geometry(lua_State *, int, area_t);
|
||||
void drawable_class_setup(lua_State *);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -72,11 +72,12 @@ drawin_wipe(drawin_t *w)
|
|||
}
|
||||
|
||||
static void
|
||||
drawin_update_drawing(drawin_t *w, int widx)
|
||||
drawin_update_drawing(lua_State *L, int widx)
|
||||
{
|
||||
luaA_object_push_item(globalconf.L, widx, w->drawable);
|
||||
drawable_set_geometry(w->drawable, -1, w->geometry);
|
||||
lua_pop(globalconf.L, 1);
|
||||
drawin_t *w = luaA_checkudata(L, widx, &drawin_class);
|
||||
luaA_object_push_item(L, widx, w->drawable);
|
||||
drawable_set_geometry(L, -1, w->geometry);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
/** Refresh the window content by copying its pixmap data to its window.
|
||||
|
@ -124,7 +125,7 @@ drawin_moveresize(lua_State *L, int udx, area_t geometry)
|
|||
mask_vals |= XCB_CONFIG_WINDOW_HEIGHT;
|
||||
}
|
||||
|
||||
drawin_update_drawing(w, udx);
|
||||
drawin_update_drawing(L, udx);
|
||||
|
||||
/* Activate BMA */
|
||||
client_ignore_enterleave_events();
|
||||
|
@ -168,8 +169,9 @@ drawin_refresh_pixmap_partial(drawin_t *drawin,
|
|||
}
|
||||
|
||||
static void
|
||||
drawin_map(drawin_t *drawin, int widx)
|
||||
drawin_map(lua_State *L, int widx)
|
||||
{
|
||||
drawin_t *drawin = luaA_checkudata(L, widx, &drawin_class);
|
||||
/* Activate BMA */
|
||||
client_ignore_enterleave_events();
|
||||
/* Map the drawin */
|
||||
|
@ -182,7 +184,7 @@ drawin_map(drawin_t *drawin, int widx)
|
|||
drawin_array_append(&globalconf.drawins, drawin);
|
||||
/* Make sure it has a surface */
|
||||
if(drawin->drawable->surface == NULL)
|
||||
drawin_update_drawing(drawin, widx);
|
||||
drawin_update_drawing(L, widx);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -225,7 +227,7 @@ drawin_set_visible(lua_State *L, int udx, bool v)
|
|||
|
||||
if(drawin->visible)
|
||||
{
|
||||
drawin_map(drawin, udx);
|
||||
drawin_map(L, udx);
|
||||
/* duplicate drawin */
|
||||
lua_pushvalue(L, udx);
|
||||
/* ref it */
|
||||
|
|
Loading…
Reference in New Issue