screen: replace screens pointer by a screen_t array

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-17 16:14:09 +02:00
parent 9a66456f90
commit 486ef71a7f
25 changed files with 279 additions and 311 deletions

View File

@ -96,21 +96,19 @@ client_seturgent(client_t *c, bool urgent)
/** Returns true if a client is tagged
* with one of the tags of the specified screen.
* \param c The client to check.
* \param screen Virtual screen number.
* \param screen Virtual screen.
* \return true if the client is visible, false otherwise.
*/
bool
client_maybevisible(client_t *c, int screen)
client_maybevisible(client_t *c, screen_t *screen)
{
if(c->screen == screen)
{
if(c->issticky || c->type == WINDOW_TYPE_DESKTOP)
return true;
tag_array_t *tags = &globalconf.screens[screen].tags;
for(int i = 0; i < tags->len; i++)
if(tags->tab[i]->selected && is_client_tagged(c, tags->tab[i]))
foreach(tag, screen->tags)
if((*tag)->selected && is_client_tagged(c, *tag))
return true;
}
return false;
@ -173,7 +171,7 @@ client_getbywin(xcb_window_t w)
void
client_unfocus_update(client_t *c)
{
globalconf.screens[c->phys_screen].client_focus = NULL;
globalconf.screens.tab[c->phys_screen].client_focus = NULL;
ewmh_update_net_active_window(c->phys_screen);
/* Call hook */
@ -192,7 +190,7 @@ void
client_unfocus(client_t *c)
{
xcb_window_t root_win = xutil_screen_get(globalconf.connection, c->phys_screen)->root;
globalconf.screens[c->phys_screen].client_focus = NULL;
globalconf.screens.tab[c->phys_screen].client_focus = NULL;
/* Set focus on root window, so no events leak to the current window. */
window_setfocus(root_win, true);
@ -222,7 +220,7 @@ client_ban(client_t *c)
wibox_update_positions();
/* Wait until the last moment to take away the focus from the window. */
if(globalconf.screens[c->phys_screen].client_focus == c)
if(globalconf.screens.tab[c->phys_screen].client_focus == c)
client_unfocus(c);
}
}
@ -243,7 +241,7 @@ client_focus_update(client_t *c)
/* unban the client before focusing for consistency */
client_unban(c);
globalconf.screen_focus = &globalconf.screens[c->phys_screen];
globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen];
globalconf.screen_focus->client_focus = c;
/* Some layouts use focused client differently, so call them back.
@ -277,7 +275,7 @@ client_focus(client_t *c)
if(!client_maybevisible(c, c->screen))
return;
globalconf.screen_focus = &globalconf.screens[c->phys_screen];
globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen];
globalconf.screen_focus->client_focus = c;
window_setfocus(c->win, !c->nofocus);
@ -380,7 +378,6 @@ client_real_stack(void)
uint32_t config_win_vals[2];
client_node_t *node, *last = *client_node_list_last(&globalconf.stack);
layer_t layer;
int screen;
config_win_vals[0] = XCB_NONE;
config_win_vals[1] = XCB_STACK_MODE_ABOVE;
@ -393,8 +390,8 @@ client_real_stack(void)
config_win_vals[0]);
/* first stack not ontop wibox window */
for(screen = 0; screen < globalconf.nscreen; screen++)
foreach(_sb, globalconf.screens[screen].wiboxes)
foreach(s, globalconf.screens)
foreach(_sb, s->wiboxes)
{
wibox_t *sb = *_sb;
if(!sb->ontop)
@ -415,8 +412,8 @@ client_real_stack(void)
config_win_vals[0]);
/* then stack ontop wibox window */
for(screen = 0; screen < globalconf.nscreen; screen++)
foreach(_sb, globalconf.screens[screen].wiboxes)
foreach(s, globalconf.screens)
foreach(_sb, s->wiboxes)
{
wibox_t *sb = *_sb;
if(sb->ontop)
@ -450,7 +447,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
{
xcb_get_property_cookie_t ewmh_icon_cookie;
client_t *c, *tc = NULL;
int screen;
screen_t *screen;
const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK };
if(systray_iskdedockapp(w))
@ -468,7 +465,8 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
client_array_push(&globalconf.clients, client_ref(globalconf.L));
screen = c->screen = screen_getbycoord(phys_screen, wgeom->x, wgeom->y);
screen = c->screen = screen_getbycoord(&globalconf.screens.tab[phys_screen],
wgeom->x, wgeom->y);
c->phys_screen = phys_screen;
@ -666,13 +664,12 @@ client_geometry_hints(client_t *c, area_t geometry)
bool
client_resize(client_t *c, area_t geometry, bool hints)
{
int new_screen;
area_t geometry_internal;
area_t area;
/* offscreen appearance fixes */
area = display_area_get(c->phys_screen, NULL,
&globalconf.screens[c->screen].padding);
&c->screen->padding);
if(geometry.x > area.width)
geometry.x = area.width - geometry.width;
@ -700,7 +697,8 @@ client_resize(client_t *c, area_t geometry, bool hints)
|| c->geometries.internal.width != geometry_internal.width
|| c->geometries.internal.height != geometry_internal.height)
{
new_screen = screen_getbycoord(c->screen, geometry_internal.x, geometry_internal.y);
screen_t *new_screen = screen_getbycoord(c->screen,
geometry_internal.x, geometry_internal.y);
/* Values to configure a window is an array where values are
* stored according to 'value_mask' */
@ -746,7 +744,7 @@ client_resize(client_t *c, area_t geometry, bool hints)
* \param screen The screen that should be processed.
*/
void
client_update_strut_positions(int screen)
client_update_strut_positions(screen_t *screen)
{
area_t allowed_area, geom;
@ -772,8 +770,8 @@ client_update_strut_positions(int screen)
/* Screen area, minus padding, wibox'es and already processed struts. */
allowed_area = screen_area_get(c->screen,
&globalconf.screens[c->screen].wiboxes,
&globalconf.screens[c->screen].padding,
&c->screen->wiboxes,
&c->screen->padding,
true);
geom = c->geometry;
@ -815,8 +813,8 @@ client_update_strut_positions(int screen)
/* Screen area, minus padding, wibox'es and already processed struts. */
allowed_area = screen_area_get(c->screen,
&globalconf.screens[c->screen].wiboxes,
&globalconf.screens[c->screen].padding,
&c->screen->wiboxes,
&c->screen->padding,
true);
geom = c->geometry;
@ -858,8 +856,8 @@ client_update_strut_positions(int screen)
/* Screen area, minus padding, wibox'es and already processed struts. */
allowed_area = screen_area_get(c->screen,
&globalconf.screens[c->screen].wiboxes,
&globalconf.screens[c->screen].padding,
&c->screen->wiboxes,
&c->screen->padding,
true);
geom = c->geometry;
@ -901,8 +899,8 @@ client_update_strut_positions(int screen)
/* Screen area, minus padding, wibox'es and already processed struts. */
allowed_area = screen_area_get(c->screen,
&globalconf.screens[c->screen].wiboxes,
&globalconf.screens[c->screen].padding,
&c->screen->wiboxes,
&c->screen->padding,
true);
geom = c->geometry;
@ -1033,8 +1031,8 @@ client_setmaxhoriz(client_t *c, bool s)
client_setfullscreen(c, false);
geometry = screen_area_get(c->screen,
&globalconf.screens[c->screen].wiboxes,
&globalconf.screens[c->screen].padding,
&c->screen->wiboxes,
&c->screen->padding,
true);
geometry.y = c->geometry.y;
geometry.height = c->geometry.height;
@ -1073,8 +1071,8 @@ client_setmaxvert(client_t *c, bool s)
client_setfullscreen(c, false);
geometry = screen_area_get(c->screen,
&globalconf.screens[c->screen].wiboxes,
&globalconf.screens[c->screen].padding,
&c->screen->wiboxes,
&c->screen->padding,
true);
geometry.x = c->geometry.x;
geometry.width = c->geometry.width;
@ -1220,7 +1218,7 @@ client_unban(client_t *c)
void
client_unmanage(client_t *c)
{
tag_array_t *tags = &globalconf.screens[c->screen].tags;
tag_array_t *tags = &c->screen->tags;
/* Reset transient_for attributes of widows that maybe refering to us */
foreach(_tc, globalconf.clients)
@ -1230,7 +1228,7 @@ client_unmanage(client_t *c)
tc->transient_for = NULL;
}
if(globalconf.screens[c->phys_screen].client_focus == c)
if(globalconf.screens.tab[c->phys_screen].client_focus == c)
client_unfocus(c);
/* remove client from global list and everywhere else */
@ -1323,7 +1321,7 @@ luaA_client_get(lua_State *L)
lua_newtable(L);
if(screen == SCREEN_UNDEF)
if(screen == -1)
foreach(c, globalconf.clients)
{
client_push(L, *c);
@ -1333,7 +1331,7 @@ luaA_client_get(lua_State *L)
{
luaA_checkscreen(screen);
foreach(c, globalconf.clients)
if((*c)->screen == screen)
if((*c)->screen == &globalconf.screens.tab[screen])
{
client_push(L, *c);
lua_rawseti(L, -2, i++);
@ -1458,7 +1456,7 @@ static int
luaA_client_tags(lua_State *L)
{
client_t *c = luaA_client_checkudata(L, 1);
tag_array_t *tags = &globalconf.screens[c->screen].tags;
tag_array_t *tags = &c->screen->tags;
int j = 0;
if(lua_gettop(L) == 2)
@ -1676,7 +1674,7 @@ luaA_client_newindex(lua_State *L)
{
i = luaL_checknumber(L, 3) - 1;
luaA_checkscreen(i);
screen_client_moveto(c, i, true, true);
screen_client_moveto(c, &globalconf.screens.tab[i], true, true);
}
break;
case A_TK_HIDE:
@ -1913,7 +1911,7 @@ luaA_client_index(lua_State *L)
lua_pushstring(L, c->icon_name);
break;
case A_TK_SCREEN:
lua_pushnumber(L, 1 + c->screen);
lua_pushnumber(L, 1 + c->screen->index);
break;
case A_TK_HIDE:
lua_pushboolean(L, c->ishidden);

View File

@ -39,19 +39,19 @@ LUA_OBJECT_FUNCS(client_t, client, "client")
#define client_need_arrange(c) \
do { \
if(!globalconf.screens[(c)->screen].need_arrange \
if(!c->screen->need_arrange \
&& client_isvisible(c, (c)->screen)) \
globalconf.screens[(c)->screen].need_arrange = true; \
c->screen->need_arrange = true; \
} while(0)
bool client_maybevisible(client_t *, int);
bool client_maybevisible(client_t *, screen_t *);
client_t * client_getbywin(xcb_window_t);
void client_ban(client_t *);
void client_unban(client_t *);
void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, int, bool);
area_t client_geometry_hints(client_t *, area_t);
bool client_resize(client_t *, area_t, bool);
void client_update_strut_positions(int);
void client_update_strut_positions(screen_t *);
void client_unmanage(client_t *);
void client_kill(client_t *);
void client_setsticky(client_t *, bool);
@ -141,7 +141,7 @@ client_isfixed(client_t *c)
* \return true if the client is visible, false otherwise.
*/
static inline bool
client_isvisible(client_t *c, int screen)
client_isvisible(client_t *c, screen_t *screen)
{
return (!c->ishidden && !c->isminimized && client_maybevisible(c, screen));
}

View File

@ -375,8 +375,8 @@ event_handle_destroynotify(void *data __attribute__ ((unused)),
if(globalconf.embedded.tab[i].win == ev->window)
{
xembed_window_array_take(&globalconf.embedded, i);
for(int j = 0; j < globalconf.nscreen; j++)
widget_invalidate_bytype(j, widget_systray);
foreach(screen, globalconf.screens)
widget_invalidate_bytype(screen, widget_systray);
}
return 0;
@ -771,8 +771,8 @@ event_handle_unmapnotify(void *data __attribute__ ((unused)),
if(globalconf.embedded.tab[i].win == ev->window)
{
xembed_window_array_take(&globalconf.embedded, i);
for(int j = 0; j < globalconf.nscreen; j++)
widget_invalidate_bytype(j, widget_systray);
foreach(screen, globalconf.screens)
widget_invalidate_bytype(screen, widget_systray);
}
return 0;

26
ewmh.c
View File

@ -45,7 +45,7 @@
static void
ewmh_update_desktop_geometry(int phys_screen)
{
area_t geom = screen_area_get(phys_screen,
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen],
NULL,
NULL,
false);
@ -186,7 +186,7 @@ ewmh_update_net_client_list_stacking(int phys_screen)
void
ewmh_update_net_numbers_of_desktop(int phys_screen)
{
uint32_t count = globalconf.screens[phys_screen].tags.len;
uint32_t count = globalconf.screens.tab[phys_screen].tags.len;
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root,
@ -196,9 +196,9 @@ ewmh_update_net_numbers_of_desktop(int phys_screen)
void
ewmh_update_net_current_desktop(int phys_screen)
{
tag_array_t *tags = &globalconf.screens[phys_screen].tags;
tag_array_t *tags = &globalconf.screens.tab[phys_screen].tags;
uint32_t count = 0;
tag_t **curtags = tags_get_current(phys_screen);
tag_t **curtags = tags_get_current( &globalconf.screens.tab[phys_screen]);
while(count < (uint32_t) tags->len && tags->tab[count] != curtags[0])
count++;
@ -213,7 +213,7 @@ ewmh_update_net_current_desktop(int phys_screen)
void
ewmh_update_net_desktop_names(int phys_screen)
{
tag_array_t *tags = &globalconf.screens[phys_screen].tags;
tag_array_t *tags = &globalconf.screens.tab[phys_screen].tags;
buffer_t buf;
buffer_inita(&buf, BUFSIZ);
@ -236,11 +236,11 @@ ewmh_update_net_desktop_names(int phys_screen)
void
ewmh_update_workarea(int phys_screen)
{
tag_array_t *tags = &globalconf.screens[phys_screen].tags;
tag_array_t *tags = &globalconf.screens.tab[phys_screen].tags;
uint32_t *area = p_alloca(uint32_t, tags->len * 4);
area_t geom = screen_area_get(phys_screen,
&globalconf.screens[phys_screen].wiboxes,
&globalconf.screens[phys_screen].padding,
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen],
&globalconf.screens.tab[phys_screen].wiboxes,
&globalconf.screens.tab[phys_screen].padding,
true);
@ -389,7 +389,7 @@ ewmh_process_client_message(xcb_client_message_event_t *ev)
screen++)
{
if(ev->window == xutil_screen_get(globalconf.connection, screen)->root)
tag_view_only_byindex(screen, ev->data.data32[0]);
tag_view_only_byindex(&globalconf.screens.tab[screen], ev->data.data32[0]);
}
else if(ev->type == _NET_CLOSE_WINDOW)
{
@ -400,7 +400,7 @@ ewmh_process_client_message(xcb_client_message_event_t *ev)
{
if((c = client_getbywin(ev->window)))
{
tag_array_t *tags = &globalconf.screens[c->screen].tags;
tag_array_t *tags = &c->screen->tags;
if(ev->data.data32[0] == 0xffffffff)
c->issticky = true;
@ -477,7 +477,7 @@ void
ewmh_client_update_desktop(client_t *c)
{
int i;
tag_array_t *tags = &globalconf.screens[c->screen].tags;
tag_array_t *tags = &c->screen->tags;
for(i = 0; i < tags->len; i++)
if(is_client_tagged(c, tags->tab[i]))
@ -536,7 +536,7 @@ ewmh_client_check_hints(client_t *c)
reply = xcb_get_property_reply(globalconf.connection, c0, NULL);
if(reply && reply->value_len && (data = xcb_get_property_value(reply)))
{
tag_array_t *tags = &globalconf.screens[c->screen].tags;
tag_array_t *tags = &c->screen->tags;
desktop = *(uint32_t *) data;
if(desktop == -1)

View File

@ -25,11 +25,11 @@
#include "screen.h"
#include "titlebar.h"
/** Arrange windows following current selected layout
* \param screen the screen to arrange
/** Arrange windows following current selected layout.
* \param screen The screen to arrange.
*/
static void
arrange(int screen)
arrange(screen_t *screen)
{
uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK & ~(XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW) };
@ -72,12 +72,12 @@ arrange(int screen)
* This is needed if you call a function that relies
* on need_arrange while arrange is in progress.
*/
globalconf.screens[screen].need_arrange = false;
screen->need_arrange = false;
/* call hook */
if(globalconf.hooks.arrange != LUA_REFNIL)
{
lua_pushnumber(globalconf.L, screen + 1);
lua_pushnumber(globalconf.L, screen->index + 1);
luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0);
}
@ -96,10 +96,8 @@ arrange(int screen)
void
layout_refresh(void)
{
int screen;
for(screen = 0; screen < globalconf.nscreen; screen++)
if(globalconf.screens[screen].need_arrange)
foreach(screen, globalconf.screens)
if(screen->need_arrange)
arrange(screen);
}

2
luaa.h
View File

@ -69,7 +69,7 @@
#define luaA_checkscreen(screen) \
do { \
if(screen < 0 || screen >= globalconf.nscreen) \
if(screen < 0 || screen >= globalconf.screens.len) \
luaL_error(L, "invalid screen number: %d", screen + 1); \
} while(0)

23
mouse.c
View File

@ -82,7 +82,7 @@ mouse_query_pointer(xcb_window_t window, int16_t *x, int16_t *y, xcb_window_t *c
}
/** Get the pointer position on the screen.
* \param screen This will be set to the screen number the mouse is on.
* \param screen This will be set to the screen the mouse is on.
* \param x This will be set to the Pointer-x-coordinate relative to window.
* \param y This will be set to the Pointer-y-coordinate relative to window.
* \param child This will be set to the window under the pointer.
@ -90,7 +90,7 @@ mouse_query_pointer(xcb_window_t window, int16_t *x, int16_t *y, xcb_window_t *c
* \return True on success, false if an error occured.
*/
static bool
mouse_query_pointer_root(int *s, int16_t *x, int16_t *y, xcb_window_t *child, uint16_t *mask)
mouse_query_pointer_root(screen_t **s, int16_t *x, int16_t *y, xcb_window_t *child, uint16_t *mask)
{
for(int screen = 0;
screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
@ -100,7 +100,7 @@ mouse_query_pointer_root(int *s, int16_t *x, int16_t *y, xcb_window_t *child, ui
if(mouse_query_pointer(root, x, y, child, mask))
{
*s = screen;
*s = &globalconf.screens.tab[screen];
return true;
}
}
@ -331,7 +331,7 @@ luaA_mouse_index(lua_State *L)
size_t len;
const char *attr = luaL_checklstring(L, 2, &len);
int16_t mouse_x, mouse_y;
int screen, i;
screen_t *screen;
switch(a_tokenize(attr, len))
{
@ -339,9 +339,9 @@ luaA_mouse_index(lua_State *L)
if(!mouse_query_pointer_root(&screen, &mouse_x, &mouse_y, NULL, NULL))
return 0;
i = screen_getbycoord(screen, mouse_x, mouse_y);
screen = screen_getbycoord(screen, mouse_x, mouse_y);
lua_pushnumber(L, i + 1);
lua_pushnumber(L, screen->index + 1);
break;
default:
return 0;
@ -373,8 +373,8 @@ luaA_mouse_newindex(lua_State *L)
phys_screen = screen_virttophys(screen);
root = xutil_screen_get(globalconf.connection, phys_screen)->root;
x = globalconf.screens[screen].geometry.x;
y = globalconf.screens[screen].geometry.y;
x = globalconf.screens.tab[screen].geometry.x;
y = globalconf.screens.tab[screen].geometry.y;
mouse_warp_pointer(root, x, y);
break;
@ -427,8 +427,9 @@ static int
luaA_mouse_coords(lua_State *L)
{
uint16_t mask;
int screen, x, y;
int x, y;
int16_t mouse_x, mouse_y;
screen_t *screen;
if(lua_gettop(L) == 1)
{
@ -442,7 +443,7 @@ luaA_mouse_coords(lua_State *L)
x = luaA_getopt_number(L, 1, "x", mouse_x);
y = luaA_getopt_number(L, 1, "y", mouse_y);
root = xutil_screen_get(globalconf.connection, screen)->root;
root = xutil_screen_get(globalconf.connection, screen->index)->root;
mouse_warp_pointer(root, x, y);
lua_pop(L, 1);
}
@ -462,7 +463,7 @@ luaA_mouse_coords(lua_State *L)
static int
luaA_mouse_object_under_pointer(lua_State *L)
{
int screen;
screen_t *screen;
int16_t mouse_x, mouse_y;
xcb_window_t child;

View File

@ -21,6 +21,7 @@
#include <xcb/xcb_atom.h>
#include "screen.h"
#include "property.h"
#include "client.h"
#include "widget.h"
@ -376,13 +377,13 @@ property_handle_xrootpmap_id(void *data __attribute__ ((unused)),
xcb_get_property_reply_t *reply)
{
if(globalconf.xinerama_is_active)
for(int screen = 0; screen < globalconf.nscreen; screen++)
foreach(w, globalconf.screens[screen].wiboxes)
foreach(screen, globalconf.screens)
foreach(w, screen->wiboxes)
(*w)->need_update = true;
else
{
int screen = xutil_root2screen(connection, window);
foreach(w, globalconf.screens[screen].wiboxes)
foreach(w, globalconf.screens.tab[screen].wiboxes)
(*w)->need_update = true;
}

100
screen.c
View File

@ -71,98 +71,87 @@ screen_scan(void)
xsi = xcb_xinerama_query_screens_screen_info(xsq);
xinerama_screen_number = xcb_xinerama_query_screens_screen_info_length(xsq);
globalconf.screens = p_new(screen_t, xinerama_screen_number);
/* now check if screens overlaps (same x,y): if so, we take only the biggest one */
for(int screen = 0; screen < xinerama_screen_number; screen++)
{
bool drop = false;
for(int screen_to_test = 0; screen_to_test < globalconf.nscreen; screen_to_test++)
if(xsi[screen].x_org == globalconf.screens[screen_to_test].geometry.x
&& xsi[screen].y_org == globalconf.screens[screen_to_test].geometry.y)
foreach(screen_to_test, globalconf.screens)
if(xsi[screen].x_org == screen_to_test->geometry.x
&& xsi[screen].y_org == screen_to_test->geometry.y)
{
/* we already have a screen for this area, just check if
* it's not bigger and drop it */
drop = true;
globalconf.screens[screen_to_test].geometry.width =
MAX(xsi[screen].width, xsi[screen_to_test].width);
globalconf.screens[screen_to_test].geometry.height =
MAX(xsi[screen].height, xsi[screen_to_test].height);
screen_to_test->geometry.width =
MAX(xsi[screen].width, xsi[screen_to_test->index].width);
screen_to_test->geometry.height =
MAX(xsi[screen].height, xsi[screen_to_test->index].height);
}
if(!drop)
{
globalconf.screens[globalconf.nscreen].index = screen;
globalconf.screens[globalconf.nscreen++].geometry = screen_xsitoarea(xsi[screen]);
screen_t s;
p_clear(&s, 1);
s.index = screen;
s.geometry = screen_xsitoarea(xsi[screen]);
screen_array_append(&globalconf.screens, s);
}
}
/* realloc smaller if xinerama_screen_number != screen registered */
if(xinerama_screen_number != globalconf.nscreen)
{
screen_t *new = p_new(screen_t, globalconf.nscreen);
memcpy(new, globalconf.screens, globalconf.nscreen * sizeof(screen_t));
p_delete(&globalconf.screens);
globalconf.screens = new;
}
p_delete(&xsq);
}
else
/* One screen only / Zaphod mode */
for(int screen = 0;
screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
screen++)
{
globalconf.nscreen = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
globalconf.screens = p_new(screen_t, globalconf.nscreen);
for(int screen = 0; screen < globalconf.nscreen; screen++)
{
xcb_screen_t *s = xutil_screen_get(globalconf.connection, screen);
globalconf.screens[screen].index = screen;
globalconf.screens[screen].geometry.x = 0;
globalconf.screens[screen].geometry.y = 0;
globalconf.screens[screen].geometry.width = s->width_in_pixels;
globalconf.screens[screen].geometry.height = s->height_in_pixels;
}
xcb_screen_t *xcb_screen = xutil_screen_get(globalconf.connection, screen);
screen_t s;
p_clear(&s, 1);
s.index = screen;
s.geometry.x = 0;
s.geometry.y = 0;
s.geometry.width = xcb_screen->width_in_pixels;
s.geometry.height = xcb_screen->height_in_pixels;
screen_array_append(&globalconf.screens, s);
}
globalconf.screen_focus = globalconf.screens;
globalconf.screen_focus = globalconf.screens.tab;
}
/** Return the Xinerama screen number where the coordinates belongs to.
* \param screen The logical screen number.
* \param x X coordinate
* \param y Y coordinate
* \return Screen number or screen param if no match or no multi-head.
* \return Screen pointer or screen param if no match or no multi-head.
*/
int
screen_getbycoord(int screen, int x, int y)
screen_t *
screen_getbycoord(screen_t *screen, int x, int y)
{
int i;
/* don't waste our time */
if(!globalconf.xinerama_is_active)
return screen;
for(i = 0; i < globalconf.nscreen; i++)
{
screen_t *s = &globalconf.screens[i];
foreach(s, globalconf.screens)
if((x < 0 || (x >= s->geometry.x && x < s->geometry.x + s->geometry.width))
&& (y < 0 || (y >= s->geometry.y && y < s->geometry.y + s->geometry.height)))
return i;
}
return s;
return screen;
}
/** Get screens info.
* \param screen Screen number.
* \param screen Screen.
* \param wiboxes Wiboxes list to remove.
* \param padding Padding.
* \param strut Honor windows strut.
* \return The screen area.
*/
area_t
screen_area_get(int screen, wibox_array_t *wiboxes,
screen_area_get(screen_t *screen, wibox_array_t *wiboxes,
padding_t *padding, bool strut)
{
area_t area = globalconf.screens[screen].geometry;
area_t area = screen->geometry;
uint16_t top = 0, bottom = 0, left = 0, right = 0;
/* make padding corrections */
@ -296,17 +285,18 @@ screen_virttophys(int screen)
/** Move a client to a virtual screen.
* \param c The client to move.
* \param new_screen The destinatiuon screen number.
* \param new_screen The destinatiuon screen.
* \param dotag Set to true if we also change tags.
* \param doresize Set to true if we also move the client to the new x and
* y of the new screen.
*/
void
screen_client_moveto(client_t *c, int new_screen, bool dotag, bool doresize)
screen_client_moveto(client_t *c, screen_t *new_screen, bool dotag, bool doresize)
{
int i, old_screen = c->screen;
tag_array_t *old_tags = &globalconf.screens[old_screen].tags,
*new_tags = &globalconf.screens[new_screen].tags;
int i;
screen_t *old_screen = c->screen;
tag_array_t *old_tags = &old_screen->tags,
*new_tags = &new_screen->tags;
area_t from, to;
bool wasvisible = client_isvisible(c, c->screen);
@ -334,7 +324,7 @@ screen_client_moveto(client_t *c, int new_screen, bool dotag, bool doresize)
}
if(wasvisible)
globalconf.screens[old_screen].need_arrange = true;
old_screen->need_arrange = true;
client_need_arrange(c);
if(!doresize)
@ -400,7 +390,7 @@ luaA_screen_module_index(lua_State *L)
int screen = luaL_checknumber(L, 2) - 1;
luaA_checkscreen(screen);
lua_pushlightuserdata(L, &globalconf.screens[screen]);
lua_pushlightuserdata(L, &globalconf.screens.tab[screen]);
return luaA_settype(L, "screen");
}
@ -427,7 +417,7 @@ luaA_screen_tags(lua_State *L)
/* remove current tags */
for(i = 0; i < s->tags.len; i++)
s->tags.tab[i]->screen = SCREEN_UNDEF;
s->tags.tab[i]->screen = NULL;
tag_array_wipe(&s->tags);
tag_array_init(&s->tags);
@ -478,7 +468,7 @@ luaA_screen_index(lua_State *L)
luaA_pusharea(L, s->geometry);
break;
case A_TK_WORKAREA:
luaA_pusharea(L, screen_area_get(s->index, &s->wiboxes, &s->padding, true));
luaA_pusharea(L, screen_area_get(s, &s->wiboxes, &s->padding, true));
break;
default:
return 0;
@ -528,7 +518,7 @@ luaA_screen_padding(lua_State *L)
static int
luaA_screen_count(lua_State *L)
{
lua_pushnumber(L, globalconf.nscreen);
lua_pushnumber(L, globalconf.screens.len);
return 1;
}

View File

@ -24,14 +24,40 @@
#include "structs.h"
#define SCREEN_UNDEF (-1)
struct a_screen
{
/** Screen index */
int index;
/** Screen geometry */
area_t geometry;
/** true if we need to arrange() */
bool need_arrange;
/** Tag list */
tag_array_t tags;
/** Wiboxes */
wibox_array_t wiboxes;
/** Padding */
padding_t padding;
/** Window that contains the systray */
struct
{
xcb_window_t window;
/** Systray window parent */
xcb_window_t parent;
} systray;
/** Focused client */
client_t *client_focus;
/** The monitor of startup notifications */
SnMonitorContext *snmonitor;
};
ARRAY_FUNCS(screen_t, screen, DO_NOTHING)
void screen_scan(void);
int screen_getbycoord(int, int, int);
area_t screen_area_get(int, wibox_array_t *, padding_t *, bool);
screen_t *screen_getbycoord(screen_t *, int, int);
area_t screen_area_get(screen_t *, wibox_array_t *, padding_t *, bool);
area_t display_area_get(int, wibox_array_t *, padding_t *);
int screen_virttophys(int);
void screen_client_moveto(client_t *, int, bool, bool);
void screen_client_moveto(client_t *, screen_t *, bool, bool);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -205,7 +205,7 @@ spawn_init(void)
const int screen_max = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
for(int screen = 0; screen < screen_max; screen++)
globalconf.screens[screen].snmonitor = sn_monitor_context_new(globalconf.sndisplay,
globalconf.screens.tab[screen].snmonitor = sn_monitor_context_new(globalconf.sndisplay,
screen,
spawn_monitor_event,
NULL, NULL);

View File

@ -66,6 +66,7 @@ typedef enum
WIBOX_TYPE_TITLEBAR
} wibox_type_t;
typedef struct a_screen screen_t;
typedef struct button_t button_t;
typedef struct widget_t widget_t;
typedef struct widget_node_t widget_node_t;
@ -79,6 +80,8 @@ typedef struct awesome_t awesome_t;
ARRAY_TYPE(widget_node_t, widget_node)
ARRAY_TYPE(button_t *, button)
ARRAY_TYPE(tag_t *, tag)
ARRAY_TYPE(screen_t, screen)
/** Wibox type */
typedef struct
@ -98,7 +101,7 @@ typedef struct
/** Alignment */
alignment_t align;
/** Screen */
int screen;
screen_t *screen;
/** Widget list */
widget_node_array_t widgets;
luaA_ref widgets_table;
@ -129,9 +132,9 @@ struct widget_t
/** Widget destructor */
widget_destructor_t *destructor;
/** Geometry function */
area_t (*geometry)(widget_t *, int, int, int);
area_t (*geometry)(widget_t *, screen_t *, int, int);
/** Draw function */
void (*draw)(widget_t *, draw_context_t *, area_t, int, wibox_t *);
void (*draw)(widget_t *, draw_context_t *, area_t, wibox_t *);
/** Index function */
int (*index)(lua_State *, awesome_token_t);
/** Newindex function */
@ -230,7 +233,7 @@ struct client_t
/** Window holding command needed to start it (session management related) */
xcb_window_t leader_win;
/** Client logical screen */
int screen;
screen_t *screen;
/** Client physical screen */
int phys_screen;
/** Titlebar */
@ -257,40 +260,12 @@ struct tag
/** Tag name */
char *name;
/** Screen */
int screen;
screen_t *screen;
/** true if selected */
bool selected;
/** clients in this tag */
client_array_t clients;
};
ARRAY_TYPE(tag_t *, tag)
typedef struct
{
/** Screen index */
int index;
/** Screen geometry */
area_t geometry;
/** true if we need to arrange() */
bool need_arrange;
/** Tag list */
tag_array_t tags;
/** Wiboxes */
wibox_array_t wiboxes;
/** Padding */
padding_t padding;
/** Window that contains the systray */
struct
{
xcb_window_t window;
/** Systray window parent */
xcb_window_t parent;
} systray;
/** Focused client */
client_t *client_focus;
/** The monitor of startup notifications */
SnMonitorContext *snmonitor;
} screen_t;
/** Main configuration structure */
struct awesome_t
@ -306,9 +281,7 @@ struct awesome_t
/** Keys symbol table */
xcb_key_symbols_t *keysyms;
/** Logical screens */
screen_t *screens;
/** Number of screens */
int nscreen;
screen_array_t screens;
/** True if xinerama is active */
bool xinerama_is_active;
/** Root window key bindings */

View File

@ -23,6 +23,7 @@
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_atom.h>
#include "screen.h"
#include "systray.h"
#include "window.h"
#include "widget.h"
@ -55,9 +56,9 @@ systray_init(int phys_screen)
p_delete(&atom_name);
globalconf.screens[phys_screen].systray.window = xcb_generate_id(globalconf.connection);
globalconf.screens.tab[phys_screen].systray.window = xcb_generate_id(globalconf.connection);
xcb_create_window(globalconf.connection, xscreen->root_depth,
globalconf.screens[phys_screen].systray.window,
globalconf.screens.tab[phys_screen].systray.window,
xscreen->root,
-1, -1, 1, 1, 0,
XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL);
@ -69,7 +70,7 @@ systray_init(int phys_screen)
ev.format = 32;
ev.type = MANAGER;
ev.data.data32[0] = XCB_CURRENT_TIME;
ev.data.data32[2] = globalconf.screens[phys_screen].systray.window;
ev.data.data32[2] = globalconf.screens.tab[phys_screen].systray.window;
ev.data.data32[3] = ev.data.data32[4] = 0;
if(!(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, atom_systray_q, NULL)))
@ -83,7 +84,7 @@ systray_init(int phys_screen)
p_delete(&atom_systray_r);
xcb_set_selection_owner(globalconf.connection,
globalconf.screens[phys_screen].systray.window,
globalconf.screens.tab[phys_screen].systray.window,
atom_systray,
XCB_CURRENT_TIME);
@ -130,7 +131,6 @@ systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *i
{
xembed_window_t em;
xcb_get_property_cookie_t em_cookie;
int i;
const uint32_t select_input_val[] =
{
XCB_EVENT_MASK_STRUCTURE_NOTIFY
@ -152,7 +152,7 @@ systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *i
window_state_set(embed_win, XCB_WM_STATE_WITHDRAWN);
xcb_reparent_window(globalconf.connection, embed_win,
globalconf.screens[phys_screen].systray.window,
globalconf.screens.tab[phys_screen].systray.window,
0, 0);
em.win = embed_win;
@ -164,13 +164,13 @@ systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *i
xembed_info_get_reply(globalconf.connection, em_cookie, &em.info);
xembed_embedded_notify(globalconf.connection, em.win,
globalconf.screens[phys_screen].systray.window,
globalconf.screens.tab[phys_screen].systray.window,
MIN(XEMBED_VERSION, em.info.version));
xembed_window_array_append(&globalconf.embedded, em);
for(i = 0; i < globalconf.nscreen; i++)
widget_invalidate_bytype(i, widget_systray);
foreach(screen, globalconf.screens)
widget_invalidate_bytype(screen, widget_systray);
return 0;
}

67
tag.c
View File

@ -54,8 +54,8 @@ static void
tag_view(tag_t *tag, bool view)
{
tag->selected = view;
ewmh_update_net_current_desktop(screen_virttophys(tag->screen));
globalconf.screens[tag->screen].need_arrange = true;
ewmh_update_net_current_desktop(screen_virttophys(tag->screen->index));
tag->screen->need_arrange = true;
}
/** Append a tag which on top of the stack to a screen.
@ -67,7 +67,7 @@ tag_append_to_screen(screen_t *s)
int phys_screen = screen_virttophys(s->index);
tag_t *tag = tag_ref(globalconf.L);
tag->screen = s->index;
tag->screen = s;
tag_array_append(&s->tags, tag);
ewmh_update_net_numbers_of_desktop(phys_screen);
ewmh_update_net_desktop_names(phys_screen);
@ -89,9 +89,8 @@ tag_append_to_screen(screen_t *s)
static void
tag_remove_from_screen(tag_t *tag)
{
int screen = tag->screen;
int phys_screen = screen_virttophys(tag->screen);
tag_array_t *tags = &globalconf.screens[tag->screen].tags;
int phys_screen = screen_virttophys(tag->screen->index);
tag_array_t *tags = &tag->screen->tags;
for(int i = 0; i < tags->len; i++)
if(tags->tab[i] == tag)
@ -102,12 +101,12 @@ tag_remove_from_screen(tag_t *tag)
ewmh_update_net_numbers_of_desktop(phys_screen);
ewmh_update_net_desktop_names(phys_screen);
ewmh_update_workarea(phys_screen);
tag->screen = SCREEN_UNDEF;
tag->screen = NULL;
/* call hook */
if(globalconf.hooks.tags != LUA_REFNIL)
{
lua_pushnumber(globalconf.L, screen + 1);
lua_pushnumber(globalconf.L, tag->screen->index + 1);
tag_push(globalconf.L, tag);
lua_pushliteral(globalconf.L, "remove");
luaA_dofunction(globalconf.L, globalconf.hooks.tags, 3, 0);
@ -182,19 +181,18 @@ is_client_tagged(client_t *c, tag_t *t)
/** Get the current tags for the specified screen.
* Returned pointer must be p_delete'd after.
* \param screen screen id
* \return a double pointer of tag list finished with a NULL element
* \param screen Screen.
* \return A double pointer of tag list finished with a NULL element.
*/
tag_t **
tags_get_current(int screen)
tags_get_current(screen_t *screen)
{
tag_array_t *tags = &globalconf.screens[screen].tags;
tag_t **out = p_new(tag_t *, tags->len + 1);
tag_t **out = p_new(tag_t *, screen->tags.len + 1);
int n = 0;
for(int i = 0; i < tags->len; i++)
if(tags->tab[i]->selected)
out[n++] = tags->tab[i];
foreach(tag, screen->tags)
if((*tag)->selected)
out[n++] = *tag;
return out;
}
@ -207,22 +205,18 @@ static void
tag_view_only(tag_t *target)
{
if(target)
{
tag_array_t *tags = &globalconf.screens[target->screen].tags;
for(int i = 0; i < tags->len; i++)
tag_view(tags->tab[i], tags->tab[i] == target);
}
foreach(tag, target->screen->tags)
tag_view(*tag, *tag == target);
}
/** View only a tag, selected by its index.
* \param screen screen id
* \param dindex the index
* \param screen Screen.
* \param dindex The index.
*/
void
tag_view_only_byindex(int screen, int dindex)
tag_view_only_byindex(screen_t *screen, int dindex)
{
tag_array_t *tags = &globalconf.screens[screen].tags;
tag_array_t *tags = &screen->tags;
if(dindex < 0 || dindex >= tags->len)
return;
@ -244,9 +238,6 @@ luaA_tag_new(lua_State *L)
a_iso2utf8(name, len, &tag->name, NULL);
/* to avoid error */
tag->screen = SCREEN_UNDEF;
return 1;
}
@ -317,9 +308,9 @@ luaA_tag_index(lua_State *L)
lua_pushstring(L, tag->name);
break;
case A_TK_SCREEN:
if(tag->screen == SCREEN_UNDEF)
if(!tag->screen)
return 0;
lua_pushnumber(L, tag->screen + 1);
lua_pushnumber(L, tag->screen->index + 1);
break;
case A_TK_SELECTED:
lua_pushboolean(L, tag->selected);
@ -360,28 +351,28 @@ luaA_tag_newindex(lua_State *L)
luaA_checkscreen(screen);
}
else
screen = SCREEN_UNDEF;
screen = -1;
if(tag->screen != SCREEN_UNDEF)
if(tag->screen)
tag_remove_from_screen(tag);
if(screen != SCREEN_UNDEF)
if(screen != -1)
{
/* push tag on top of the stack */
lua_pushvalue(L, 1);
tag_append_to_screen(&globalconf.screens[screen]);
tag_append_to_screen(&globalconf.screens.tab[screen]);
}
break;
case A_TK_SELECTED:
if(tag->screen != SCREEN_UNDEF)
if(tag->screen)
tag_view(tag, luaA_checkboolean(L, 3));
return 0;
default:
return 0;
}
if(tag->screen != SCREEN_UNDEF && tag->selected)
globalconf.screens[tag->screen].need_arrange = true;
if(tag->screen && tag->selected)
tag->screen->need_arrange = true;
return 0;
}

4
tag.h
View File

@ -25,11 +25,11 @@
#include "structs.h"
#include "client.h"
tag_t **tags_get_current(int);
tag_t **tags_get_current(screen_t *);
void tag_client(client_t *);
void untag_client(client_t *, tag_t *);
bool is_client_tagged(client_t *, tag_t *);
void tag_view_only_byindex(int, int);
void tag_view_only_byindex(screen_t *, int);
void tag_append_to_screen(screen_t *);
void tag_unref_simplified(tag_t **);

View File

@ -218,7 +218,7 @@ titlebar_client_detach(client_t *c)
c->geometry = titlebar_geometry_remove(c->titlebar, 0, c->geometry);
simplewindow_wipe(&c->titlebar->sw);
c->titlebar->type = WIBOX_TYPE_NORMAL;
c->titlebar->screen = SCREEN_UNDEF;
c->titlebar->screen = NULL;
wibox_unref(globalconf.L, c->titlebar);
c->titlebar = NULL;
@ -307,7 +307,7 @@ titlebar_set_visible(wibox_t *t, bool visible)
else
titlebar_ban(t);
globalconf.screens[t->screen].need_arrange = true;
t->screen->need_arrange = true;
client_stack();
}
}

View File

@ -39,7 +39,7 @@ void titlebar_unban(wibox_t *);
int luaA_titlebar_newindex(lua_State *, wibox_t *, awesome_token_t);
static inline bool
titlebar_isvisible(client_t *c, int screen)
titlebar_isvisible(client_t *c, screen_t *screen)
{
if(client_isvisible(c, screen))
{

78
wibox.c
View File

@ -127,10 +127,10 @@ wibox_setposition(wibox_t *wibox, position_t p)
wibox_position_update(wibox);
/* reset all wibox position */
foreach(w, globalconf.screens[wibox->screen].wiboxes)
foreach(w, wibox->screen->wiboxes)
wibox_position_update(*w);
ewmh_update_workarea(screen_virttophys(wibox->screen));
ewmh_update_workarea(screen_virttophys(wibox->screen->index));
wibox_need_update(wibox);
}
@ -144,23 +144,23 @@ wibox_systray_kickout(int phys_screen)
{
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
if(globalconf.screens[phys_screen].systray.parent != s->root)
if(globalconf.screens.tab[phys_screen].systray.parent != s->root)
{
/* Who! Check that we're not deleting a wibox with a systray, because it
* may be its parent. If so, we reparent to root before, otherwise it will
* hurt very much. */
xcb_reparent_window(globalconf.connection,
globalconf.screens[phys_screen].systray.window,
globalconf.screens.tab[phys_screen].systray.window,
s->root, -512, -512);
globalconf.screens[phys_screen].systray.parent = s->root;
globalconf.screens.tab[phys_screen].systray.parent = s->root;
}
}
static void
wibox_systray_refresh(wibox_t *wibox)
{
if(wibox->screen == SCREEN_UNDEF)
if(!wibox->screen)
return;
for(int i = 0; i < wibox->widgets.len; i++)
@ -180,10 +180,10 @@ wibox_systray_refresh(wibox_t *wibox)
{
/* Set background of the systray window. */
xcb_change_window_attributes(globalconf.connection,
globalconf.screens[phys_screen].systray.window,
globalconf.screens.tab[phys_screen].systray.window,
XCB_CW_BACK_PIXEL, config_back);
/* Map it. */
xcb_map_window(globalconf.connection, globalconf.screens[phys_screen].systray.window);
xcb_map_window(globalconf.connection, globalconf.screens.tab[phys_screen].systray.window);
/* Move it. */
switch(wibox->sw.orientation)
{
@ -207,16 +207,16 @@ wibox_systray_refresh(wibox_t *wibox)
break;
}
/* reparent */
if(globalconf.screens[phys_screen].systray.parent != wibox->sw.window)
if(globalconf.screens.tab[phys_screen].systray.parent != wibox->sw.window)
{
xcb_reparent_window(globalconf.connection,
globalconf.screens[phys_screen].systray.window,
globalconf.screens.tab[phys_screen].systray.window,
wibox->sw.window,
config_win_vals[0], config_win_vals[1]);
globalconf.screens[phys_screen].systray.parent = wibox->sw.window;
globalconf.screens.tab[phys_screen].systray.parent = wibox->sw.window;
}
xcb_configure_window(globalconf.connection,
globalconf.screens[phys_screen].systray.window,
globalconf.screens.tab[phys_screen].systray.window,
XCB_CONFIG_WINDOW_X
| XCB_CONFIG_WINDOW_Y
| XCB_CONFIG_WINDOW_WIDTH
@ -342,20 +342,20 @@ wibox_position_update_non_floating(wibox_t *wibox)
/* Everything we do below needs the wibox' screen.
* No screen, nothing to do.
*/
if (wibox->screen == SCREEN_UNDEF)
if (!wibox->screen)
return;
/* This wibox limits the space available to clients and thus clients
* need to be repositioned.
*/
globalconf.screens[wibox->screen].need_arrange = true;
wibox->screen->need_arrange = true;
/* Place wibox'es at the edge of the screen, struts come later. */
area = screen_area_get(wibox->screen, NULL,
&globalconf.screens[wibox->screen].padding, false);
&wibox->screen->padding, false);
/* Top and Bottom wibox_t have prio */
foreach(_w, globalconf.screens[wibox->screen].wiboxes)
foreach(_w, wibox->screen->wiboxes)
{
wibox_t *w = *_w;
/* Ignore every wibox after me that is in the same position */
@ -519,8 +519,8 @@ wibox_position_update(wibox_t *wibox)
wibox_t *
wibox_getbywin(xcb_window_t win)
{
for(int screen = 0; screen < globalconf.nscreen; screen++)
foreach(w, globalconf.screens[screen].wiboxes)
foreach(screen, globalconf.screens)
foreach(w, screen->wiboxes)
if((*w)->sw.window == win)
return *w;
@ -556,8 +556,8 @@ wibox_draw(wibox_t *wibox)
void
wibox_refresh(void)
{
for(int screen = 0; screen < globalconf.nscreen; screen++)
foreach(w, globalconf.screens[screen].wiboxes)
foreach(screen, globalconf.screens)
foreach(w, screen->wiboxes)
if((*w)->need_update)
wibox_draw(*w);
@ -574,8 +574,8 @@ wibox_refresh(void)
void
wibox_update_positions(void)
{
for(int screen = 0; screen < globalconf.nscreen; screen++)
foreach(w, globalconf.screens[screen].wiboxes)
foreach(screen, globalconf.screens)
foreach(w, screen->wiboxes)
wibox_position_update(*w);
}
@ -591,7 +591,7 @@ wibox_setvisible(wibox_t *wibox, bool v)
wibox->isvisible = v;
wibox->mouse_over = NULL;
if(wibox->screen != SCREEN_UNDEF)
if(wibox->screen != NULL)
{
if(wibox->isvisible)
wibox_map(wibox);
@ -602,7 +602,7 @@ wibox_setvisible(wibox_t *wibox, bool v)
wibox_systray_refresh(wibox);
/* All the other wibox and ourselves need to be repositioned */
foreach(w, globalconf.screens[wibox->screen].wiboxes)
foreach(w, wibox->screen->wiboxes)
wibox_position_update(*w);
}
}
@ -614,7 +614,7 @@ wibox_setvisible(wibox_t *wibox, bool v)
void
wibox_detach(wibox_t *wibox)
{
if(wibox->screen != SCREEN_UNDEF)
if(wibox->screen != NULL)
{
bool v;
@ -630,16 +630,16 @@ wibox_detach(wibox_t *wibox)
simplewindow_wipe(&wibox->sw);
globalconf.screens[wibox->screen].need_arrange = true;
wibox->screen->need_arrange = true;
foreach(item, globalconf.screens[wibox->screen].wiboxes)
foreach(item, wibox->screen->wiboxes)
if(*item == wibox)
{
wibox_array_remove(&globalconf.screens[wibox->screen].wiboxes, item);
wibox_array_remove(&wibox->screen->wiboxes, item);
break;
}
wibox->screen = SCREEN_UNDEF;
wibox->screen = NULL;
wibox_unref(globalconf.L, wibox);
}
}
@ -657,10 +657,11 @@ wibox_attach(screen_t *s)
wibox_detach(wibox);
/* Set the wibox screen */
wibox->screen = s->index;
wibox->screen = s;
/* Check that the wibox coordinates matches the screen. */
int cscreen = screen_getbycoord(wibox->screen, wibox->sw.geometry.x, wibox->sw.geometry.y);
screen_t *cscreen =
screen_getbycoord(wibox->screen, wibox->sw.geometry.x, wibox->sw.geometry.y);
/* If it does not match, move it to the screen coordinates */
if(cscreen != wibox->screen)
@ -757,7 +758,6 @@ luaA_wibox_new(lua_State *L)
w->sw.geometry.width = luaA_getopt_number(L, 2, "width", 0);
w->sw.geometry.height = luaA_getopt_number(L, 2, "height", 0);
w->screen = SCREEN_UNDEF;
w->isvisible = true;
w->cursor = a_strdup("left_ptr");
@ -806,8 +806,8 @@ luaA_wibox_hasitem(lua_State *L, wibox_t *wibox, const void *item)
void
luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
{
for(int screen = 0; screen < globalconf.nscreen; screen++)
foreach(w, globalconf.screens[screen].wiboxes)
foreach(screen, globalconf.screens)
foreach(w, screen->wiboxes)
{
wibox_t *wibox = *w;
if(luaA_wibox_hasitem(L, wibox, item))
@ -866,9 +866,9 @@ luaA_wibox_index(lua_State *L)
case A_TK_CLIENT:
return client_push(L, client_getbytitlebar(wibox));
case A_TK_SCREEN:
if(wibox->screen == SCREEN_UNDEF)
if(!wibox->screen)
return 0;
lua_pushnumber(L, wibox->screen + 1);
lua_pushnumber(L, wibox->screen->index + 1);
break;
case A_TK_BORDER_WIDTH:
lua_pushnumber(L, wibox->sw.border.width);
@ -968,7 +968,7 @@ luaA_wibox_geometry(lua_State *L)
|| wingeom.height != wibox->sw.geometry.height)
{
wibox_resize(wibox, wingeom.width, wingeom.height);
globalconf.screens[wibox->screen].need_arrange = true;
wibox->screen->need_arrange = true;
}
break;
}
@ -1066,11 +1066,11 @@ luaA_wibox_newindex(lua_State *L)
{
int screen = luaL_checknumber(L, 3) - 1;
luaA_checkscreen(screen);
if(screen != wibox->screen)
if(!wibox->screen || screen != wibox->screen->index)
{
titlebar_client_detach(client_getbytitlebar(wibox));
lua_pushvalue(L, 1);
wibox_attach(&globalconf.screens[screen]);
wibox_attach(&globalconf.screens.tab[screen]);
}
}
break;

View File

@ -24,6 +24,7 @@
#include <xcb/xcb.h>
#include <xcb/xcb_atom.h>
#include "screen.h"
#include "mouse.h"
#include "widget.h"
#include "wibox.h"
@ -270,8 +271,7 @@ widget_render(wibox_t *wibox)
{
widgets->tab[i].geometry.y = 0;
widgets->tab[i].widget->draw(widgets->tab[i].widget,
ctx, widgets->tab[i].geometry,
wibox->screen, wibox);
ctx, widgets->tab[i].geometry, wibox);
}
switch(wibox->sw.orientation)
@ -294,13 +294,13 @@ widget_render(wibox_t *wibox)
}
/** Invalidate widgets which should be refresh depending on their types.
* \param screen Virtual screen number.
* \param screen Virtual screen.
* \param type Widget type to invalidate.
*/
void
widget_invalidate_bytype(int screen, widget_constructor_t *type)
widget_invalidate_bytype(screen_t *screen, widget_constructor_t *type)
{
foreach(wibox, globalconf.screens[screen].wiboxes)
foreach(wibox, screen->wiboxes)
foreach(wnode, (*wibox)->widgets)
if(wnode->widget->type == type)
{
@ -316,18 +316,15 @@ widget_invalidate_bytype(int screen, widget_constructor_t *type)
void
widget_invalidate_bywidget(widget_t *widget)
{
for(int screen = 0; screen < globalconf.nscreen; screen++)
for(int i = 0; i < globalconf.screens[screen].wiboxes.len; i++)
foreach(screen, globalconf.screens)
foreach(wibox, screen->wiboxes)
if(!(*wibox)->need_update)
foreach(wnode, (*wibox)->widgets)
if(wnode->widget == widget)
{
wibox_t *wibox = globalconf.screens[screen].wiboxes.tab[i];
if(!wibox->need_update)
for(int j = 0; j < wibox->widgets.len; j++)
if(wibox->widgets.tab[j].widget == widget)
{
wibox->need_update = true;
(*wibox)->need_update = true;
break;
}
}
foreach(_c, globalconf.clients)
{

View File

@ -40,7 +40,7 @@ void widget_render(wibox_t *);
void luaA_table2widgets(lua_State *, widget_node_array_t *);
void widget_invalidate_bywidget(widget_t *);
void widget_invalidate_bytype(int, widget_constructor_t *);
void widget_invalidate_bytype(screen_t *, widget_constructor_t *);
widget_constructor_t widget_textbox;
widget_constructor_t widget_progressbar;

View File

@ -147,7 +147,7 @@ graph_plot_get(graph_data_t *d, const char *title)
}
static area_t
graph_geometry(widget_t *widget, int screen, int height, int width)
graph_geometry(widget_t *widget, screen_t *screen, int height, int width)
{
area_t geometry;
graph_data_t *d = widget->data;
@ -160,7 +160,6 @@ graph_geometry(widget_t *widget, int screen, int height, int width)
/** Draw a graph widget.
* \param ctx The draw context.
* \param screen The screen number.
* \param w The widget node we are called from.
* \param offset The offset to draw at.
* \param used The already used width.
@ -169,7 +168,7 @@ graph_geometry(widget_t *widget, int screen, int height, int width)
*/
static void
graph_draw(widget_t *widget, draw_context_t *ctx,
area_t geometry, int screen, wibox_t *p)
area_t geometry, wibox_t *p)
{
int margin_top, y;
graph_data_t *d = widget->data;

View File

@ -33,7 +33,7 @@ typedef struct
} imagebox_data_t;
static area_t
imagebox_geometry(widget_t *widget, int screen, int height, int width)
imagebox_geometry(widget_t *widget, screen_t *screen, int height, int width)
{
area_t geometry;
imagebox_data_t *d = widget->data;
@ -76,12 +76,10 @@ imagebox_geometry(widget_t *widget, int screen, int height, int width)
* \param widget The widget.
* \param ctx The draw context.
* \param geometry The geometry we draw in.
* \param screen The screen.
* \param p A pointer to the object we're draw onto.
*/
static void
imagebox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry,
int screen, wibox_t *p)
imagebox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t *p)
{
imagebox_data_t *d = widget->data;

View File

@ -132,7 +132,7 @@ progressbar_bar_get(bar_array_t *bars, const char *title)
}
static area_t
progressbar_geometry(widget_t *widget, int screen, int height, int width)
progressbar_geometry(widget_t *widget, screen_t *screen, int height, int width)
{
area_t geometry;
progressbar_data_t *d = widget->data;
@ -162,7 +162,6 @@ progressbar_geometry(widget_t *widget, int screen, int height, int width)
/** Draw a progressbar.
* \param ctx The draw context.
* \param screen The screen we're drawing for.
* \param w The widget node we're drawing for.
* \param offset Offset to draw at.
* \param used Space already used.
@ -170,8 +169,7 @@ progressbar_geometry(widget_t *widget, int screen, int height, int width)
* \return The width used.
*/
static void
progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry,
int screen, wibox_t *p)
progressbar_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t *p)
{
/* pb_.. values points to the widget inside a potential border */
int values_ticks, pb_x, pb_y, pb_height, pb_width, pb_progress, pb_offset;

View File

@ -31,10 +31,10 @@
#define _NET_SYSTEM_TRAY_ORIENTATION_VERT 1
static area_t
systray_geometry(widget_t *widget, int screen, int height, int width)
systray_geometry(widget_t *widget, screen_t *screen, int height, int width)
{
area_t geometry;
int phys_screen = screen_virttophys(screen), n = 0;
int phys_screen = screen_virttophys(screen->index), n = 0;
geometry.height = height;
@ -50,7 +50,7 @@ systray_geometry(widget_t *widget, int screen, int height, int width)
static void
systray_draw(widget_t *widget, draw_context_t *ctx,
area_t geometry, int screen, wibox_t *p)
area_t geometry, wibox_t *p)
{
uint32_t orient;
@ -68,7 +68,7 @@ systray_draw(widget_t *widget, draw_context_t *ctx,
/* set wibox orientation */
/** \todo stop setting that property on each redraw */
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
globalconf.screens[p->sw.ctx.phys_screen].systray.window,
globalconf.screens.tab[p->sw.ctx.phys_screen].systray.window,
_NET_SYSTEM_TRAY_ORIENTATION, CARDINAL, 32, 1, &orient);
}

View File

@ -53,7 +53,7 @@ typedef struct
} textbox_data_t;
static area_t
textbox_geometry(widget_t *widget, int screen, int height, int width)
textbox_geometry(widget_t *widget, screen_t *screen, int height, int width)
{
area_t geometry;
textbox_data_t *d = widget->data;
@ -78,12 +78,10 @@ textbox_geometry(widget_t *widget, int screen, int height, int width)
/** Draw a textbox widget.
* \param widget The widget.
* \param ctx The draw context.
* \param screen The screen.
* \param p A pointer to the object we're draw onto.
*/
static void
textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry,
int screen, wibox_t *p)
textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, wibox_t *p)
{
textbox_data_t *d = widget->data;