screen: remove index field

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-18 17:51:31 +02:00
parent 41eb19f76f
commit 4a34693bfb
8 changed files with 24 additions and 23 deletions

View File

@ -1907,7 +1907,7 @@ luaA_client_index(lua_State *L)
lua_pushstring(L, c->icon_name); lua_pushstring(L, c->icon_name);
break; break;
case A_TK_SCREEN: case A_TK_SCREEN:
lua_pushnumber(L, 1 + c->screen->index); lua_pushnumber(L, 1 + screen_array_indexof(&globalconf.screens, c->screen));
break; break;
case A_TK_HIDE: case A_TK_HIDE:
lua_pushboolean(L, c->ishidden); lua_pushboolean(L, c->ishidden);

View File

@ -77,7 +77,7 @@ arrange(screen_t *screen)
/* call hook */ /* call hook */
if(globalconf.hooks.arrange != LUA_REFNIL) if(globalconf.hooks.arrange != LUA_REFNIL)
{ {
lua_pushnumber(globalconf.L, screen->index + 1); lua_pushnumber(globalconf.L, screen_array_indexof(&globalconf.screens, screen) + 1);
luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0); luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0);
} }

View File

@ -340,7 +340,7 @@ luaA_mouse_index(lua_State *L)
screen = screen_getbycoord(screen, mouse_x, mouse_y); screen = screen_getbycoord(screen, mouse_x, mouse_y);
lua_pushnumber(L, screen->index + 1); lua_pushnumber(L, screen_array_indexof(&globalconf.screens, screen) + 1);
break; break;
default: default:
return 0; return 0;
@ -442,7 +442,8 @@ luaA_mouse_coords(lua_State *L)
x = luaA_getopt_number(L, 1, "x", mouse_x); x = luaA_getopt_number(L, 1, "x", mouse_x);
y = luaA_getopt_number(L, 1, "y", mouse_y); y = luaA_getopt_number(L, 1, "y", mouse_y);
root = xutil_screen_get(globalconf.connection, screen->index)->root; root = xutil_screen_get(globalconf.connection,
screen_array_indexof(&globalconf.screens, screen))->root;
mouse_warp_pointer(root, x, y); mouse_warp_pointer(root, x, y);
lua_pop(L, 1); lua_pop(L, 1);
} }

View File

@ -83,16 +83,16 @@ screen_scan(void)
/* we already have a screen for this area, just check if /* we already have a screen for this area, just check if
* it's not bigger and drop it */ * it's not bigger and drop it */
drop = true; drop = true;
int i = screen_array_indexof(&globalconf.screens, screen_to_test);
screen_to_test->geometry.width = screen_to_test->geometry.width =
MAX(xsi[screen].width, xsi[screen_to_test->index].width); MAX(xsi[screen].width, xsi[i].width);
screen_to_test->geometry.height = screen_to_test->geometry.height =
MAX(xsi[screen].height, xsi[screen_to_test->index].height); MAX(xsi[screen].height, xsi[i].height);
} }
if(!drop) if(!drop)
{ {
screen_t s; screen_t s;
p_clear(&s, 1); p_clear(&s, 1);
s.index = screen;
s.geometry = screen_xsitoarea(xsi[screen]); s.geometry = screen_xsitoarea(xsi[screen]);
screen_array_append(&globalconf.screens, s); screen_array_append(&globalconf.screens, s);
} }
@ -109,7 +109,6 @@ screen_scan(void)
xcb_screen_t *xcb_screen = xutil_screen_get(globalconf.connection, screen); xcb_screen_t *xcb_screen = xutil_screen_get(globalconf.connection, screen);
screen_t s; screen_t s;
p_clear(&s, 1); p_clear(&s, 1);
s.index = screen;
s.geometry.x = 0; s.geometry.x = 0;
s.geometry.y = 0; s.geometry.y = 0;
s.geometry.width = xcb_screen->width_in_pixels; s.geometry.width = xcb_screen->width_in_pixels;
@ -504,7 +503,7 @@ luaA_screen_padding(lua_State *L)
foreach(w, s->wiboxes) foreach(w, s->wiboxes)
wibox_position_update(*w); wibox_position_update(*w);
ewmh_update_workarea(screen_virttophys(s->index)); ewmh_update_workarea(screen_virttophys(screen_array_indexof(&globalconf.screens, s)));
} }
return luaA_pushpadding(L, &s->padding); return luaA_pushpadding(L, &s->padding);
} }

View File

@ -26,8 +26,6 @@
struct a_screen struct a_screen
{ {
/** Screen index */
int index;
/** Screen geometry */ /** Screen geometry */
area_t geometry; area_t geometry;
/** true if we need to arrange() */ /** true if we need to arrange() */

15
tag.c
View File

@ -54,7 +54,8 @@ static void
tag_view(tag_t *tag, bool view) tag_view(tag_t *tag, bool view)
{ {
tag->selected = view; tag->selected = view;
ewmh_update_net_current_desktop(screen_virttophys(tag->screen->index)); ewmh_update_net_current_desktop(screen_virttophys(screen_array_indexof(&globalconf.screens,
tag->screen)));
tag->screen->need_arrange = true; tag->screen->need_arrange = true;
} }
@ -64,7 +65,8 @@ tag_view(tag_t *tag, bool view)
void void
tag_append_to_screen(screen_t *s) tag_append_to_screen(screen_t *s)
{ {
int phys_screen = screen_virttophys(s->index); int screen_index = screen_array_indexof(&globalconf.screens, s);
int phys_screen = screen_virttophys(screen_index);
tag_t *tag = tag_ref(globalconf.L); tag_t *tag = tag_ref(globalconf.L);
tag->screen = s; tag->screen = s;
@ -76,7 +78,7 @@ tag_append_to_screen(screen_t *s)
/* call hook */ /* call hook */
if(globalconf.hooks.tags != LUA_REFNIL) if(globalconf.hooks.tags != LUA_REFNIL)
{ {
lua_pushnumber(globalconf.L, s->index + 1); lua_pushnumber(globalconf.L, screen_index + 1);
tag_push(globalconf.L, tag); tag_push(globalconf.L, tag);
lua_pushliteral(globalconf.L, "add"); lua_pushliteral(globalconf.L, "add");
luaA_dofunction(globalconf.L, globalconf.hooks.tags, 3, 0); luaA_dofunction(globalconf.L, globalconf.hooks.tags, 3, 0);
@ -89,7 +91,8 @@ tag_append_to_screen(screen_t *s)
static void static void
tag_remove_from_screen(tag_t *tag) tag_remove_from_screen(tag_t *tag)
{ {
int phys_screen = screen_virttophys(tag->screen->index); int screen_index = screen_array_indexof(&globalconf.screens, tag->screen);
int phys_screen = screen_virttophys(screen_index);
tag_array_t *tags = &tag->screen->tags; tag_array_t *tags = &tag->screen->tags;
for(int i = 0; i < tags->len; i++) for(int i = 0; i < tags->len; i++)
@ -105,7 +108,7 @@ tag_remove_from_screen(tag_t *tag)
/* call hook */ /* call hook */
if(globalconf.hooks.tags != LUA_REFNIL) if(globalconf.hooks.tags != LUA_REFNIL)
{ {
lua_pushnumber(globalconf.L, tag->screen->index + 1); lua_pushnumber(globalconf.L, screen_index + 1);
tag_push(globalconf.L, tag); tag_push(globalconf.L, tag);
lua_pushliteral(globalconf.L, "remove"); lua_pushliteral(globalconf.L, "remove");
luaA_dofunction(globalconf.L, globalconf.hooks.tags, 3, 0); luaA_dofunction(globalconf.L, globalconf.hooks.tags, 3, 0);
@ -311,7 +314,7 @@ luaA_tag_index(lua_State *L)
case A_TK_SCREEN: case A_TK_SCREEN:
if(!tag->screen) if(!tag->screen)
return 0; return 0;
lua_pushnumber(L, tag->screen->index + 1); lua_pushnumber(L, screen_array_indexof(&globalconf.screens, tag->screen) + 1);
break; break;
case A_TK_SELECTED: case A_TK_SELECTED:
lua_pushboolean(L, tag->selected); lua_pushboolean(L, tag->selected);

10
wibox.c
View File

@ -131,7 +131,7 @@ wibox_setposition(wibox_t *wibox, position_t p)
foreach(w, wibox->screen->wiboxes) foreach(w, wibox->screen->wiboxes)
wibox_position_update(*w); wibox_position_update(*w);
ewmh_update_workarea(screen_virttophys(wibox->screen->index)); ewmh_update_workarea(screen_virttophys(screen_array_indexof(&globalconf.screens, wibox->screen)));
wibox_need_update(wibox); wibox_need_update(wibox);
} }
@ -651,7 +651,7 @@ wibox_detach(wibox_t *wibox)
static void static void
wibox_attach(screen_t *s) wibox_attach(screen_t *s)
{ {
int phys_screen = screen_virttophys(s->index); int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s));
wibox_t *wibox = wibox_ref(globalconf.L); wibox_t *wibox = wibox_ref(globalconf.L);
@ -688,7 +688,7 @@ wibox_attach(screen_t *s)
foreach(w, s->wiboxes) foreach(w, s->wiboxes)
wibox_position_update(*w); wibox_position_update(*w);
ewmh_update_workarea(screen_virttophys(s->index)); ewmh_update_workarea(phys_screen);
if(wibox->isvisible) if(wibox->isvisible)
wibox_map(wibox); wibox_map(wibox);
@ -869,7 +869,7 @@ luaA_wibox_index(lua_State *L)
case A_TK_SCREEN: case A_TK_SCREEN:
if(!wibox->screen) if(!wibox->screen)
return 0; return 0;
lua_pushnumber(L, wibox->screen->index + 1); lua_pushnumber(L, screen_array_indexof(&globalconf.screens, wibox->screen) + 1);
break; break;
case A_TK_BORDER_WIDTH: case A_TK_BORDER_WIDTH:
lua_pushnumber(L, wibox->sw.border.width); lua_pushnumber(L, wibox->sw.border.width);
@ -1067,7 +1067,7 @@ luaA_wibox_newindex(lua_State *L)
{ {
int screen = luaL_checknumber(L, 3) - 1; int screen = luaL_checknumber(L, 3) - 1;
luaA_checkscreen(screen); luaA_checkscreen(screen);
if(!wibox->screen || screen != wibox->screen->index) if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
{ {
titlebar_client_detach(client_getbytitlebar(wibox)); titlebar_client_detach(client_getbytitlebar(wibox));
lua_pushvalue(L, 1); lua_pushvalue(L, 1);

View File

@ -34,7 +34,7 @@ static area_t
systray_geometry(widget_t *widget, screen_t *screen, int height, int width) systray_geometry(widget_t *widget, screen_t *screen, int height, int width)
{ {
area_t geometry; area_t geometry;
int phys_screen = screen_virttophys(screen->index), n = 0; int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, screen)), n = 0;
geometry.height = height; geometry.height = height;