screen: Add an `id` field to the vireport.

This will help to delete screens.
This commit is contained in:
Emmanuel Lepage Vallee 2019-06-19 17:34:22 -04:00
parent 14c78ef19c
commit ae99e8d7bb
1 changed files with 8 additions and 0 deletions

View File

@ -378,6 +378,7 @@ typedef struct viewport_t
int y; int y;
int width; int width;
int height; int height;
int id;
struct viewport_t *next; struct viewport_t *next;
screen_t *screen; screen_t *screen;
screen_output_array_t outputs; screen_output_array_t outputs;
@ -385,6 +386,7 @@ typedef struct viewport_t
static viewport_t *first_screen_viewport = NULL; static viewport_t *first_screen_viewport = NULL;
static viewport_t *last_screen_viewport = NULL; static viewport_t *last_screen_viewport = NULL;
static int screen_area_gid = 1;
static void static void
luaA_viewport_get_outputs(lua_State *L, viewport_t *a) luaA_viewport_get_outputs(lua_State *L, viewport_t *a)
@ -458,6 +460,11 @@ luaA_viewports(lua_State *L)
luaA_viewport_get_outputs(L, a); luaA_viewport_get_outputs(L, a);
lua_settable(L, -3); lua_settable(L, -3);
/* Add an identifier to better detect when screens are removed */
lua_pushstring(L, "id");
lua_pushinteger(L, a->id);
lua_settable(L, -3);
lua_rawseti(L, -2, count++); lua_rawseti(L, -2, count++);
} while ((a = a->next)); } while ((a = a->next));
@ -499,6 +506,7 @@ viewport_add(lua_State *L, int x, int y, int w, int h)
node->y = y; node->y = y;
node->width = w; node->width = w;
node->height = h; node->height = h;
node->id = screen_area_gid++;
node->next = NULL; node->next = NULL;
node->screen = NULL; node->screen = NULL;
node->marked = true; node->marked = true;