Remove support for zaphod mode

This makes awesome support only a single X11 protocol screen. If you are still
using zaphod mode, you can run multiple instances of awesome on the single
screens, e.g.:

DISPLAY=:1.0 awesome & DISPLAY=:1.1 awesome &

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-08-16 13:47:40 +02:00
parent 27f9c0177a
commit 32d9a5b2ab
25 changed files with 283 additions and 455 deletions

View File

@ -66,19 +66,11 @@ typedef struct
void void
awesome_atexit(void) awesome_atexit(void)
{ {
int screen_nbr, nscreens;
signal_object_emit(globalconf.L, &global_signals, "exit", 0); signal_object_emit(globalconf.L, &global_signals, "exit", 0);
a_dbus_cleanup(); a_dbus_cleanup();
/* do this only for real screen */ systray_cleanup();
const xcb_setup_t *setup = xcb_get_setup(globalconf.connection);
nscreens = setup ? xcb_setup_roots_length(setup) : -1;
for(screen_nbr = 0;
screen_nbr < nscreens;
screen_nbr++)
systray_cleanup(screen_nbr);
/* Close Lua */ /* Close Lua */
lua_close(globalconf.L); lua_close(globalconf.L);
@ -96,33 +88,27 @@ awesome_atexit(void)
static void static void
scan(void) scan(void)
{ {
int i, phys_screen, tree_c_len; int i, tree_c_len;
const int screen_max = xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); root_win_t root_win;
root_win_t root_wins[screen_max];
xcb_query_tree_reply_t *tree_r; xcb_query_tree_reply_t *tree_r;
xcb_window_t *wins = NULL; xcb_window_t *wins = NULL;
xcb_get_window_attributes_reply_t *attr_r; xcb_get_window_attributes_reply_t *attr_r;
xcb_get_geometry_reply_t *geom_r; xcb_get_geometry_reply_t *geom_r;
long state; long state;
for(phys_screen = 0; phys_screen < screen_max; phys_screen++)
{
/* Get the root window ID associated to this screen */ /* Get the root window ID associated to this screen */
root_wins[phys_screen].id = xutil_screen_get(globalconf.connection, phys_screen)->root; root_win.id = xutil_screen_get(globalconf.connection, globalconf.default_screen)->root;
/* Get the window tree associated to this screen */ /* Get the window tree associated to this screen */
root_wins[phys_screen].tree_cookie = xcb_query_tree_unchecked(globalconf.connection, root_win.tree_cookie = xcb_query_tree_unchecked(globalconf.connection,
root_wins[phys_screen].id); root_win.id);
}
for(phys_screen = 0; phys_screen < screen_max; phys_screen++)
{
tree_r = xcb_query_tree_reply(globalconf.connection, tree_r = xcb_query_tree_reply(globalconf.connection,
root_wins[phys_screen].tree_cookie, root_win.tree_cookie,
NULL); NULL);
if(!tree_r) if(!tree_r)
continue; return;
/* Get the tree of the children windows of the current root window */ /* Get the tree of the children windows of the current root window */
if(!(wins = xcb_query_tree_children(tree_r))) if(!(wins = xcb_query_tree_children(tree_r)))
@ -172,14 +158,13 @@ scan(void)
*(geom_wins[i]), NULL))) *(geom_wins[i]), NULL)))
continue; continue;
client_manage(wins[i], geom_r, phys_screen, true); client_manage(wins[i], geom_r, true);
p_delete(&geom_r); p_delete(&geom_r);
} }
p_delete(&tree_r); p_delete(&tree_r);
} }
}
static void static void
a_refresh_cb(EV_P_ ev_prepare *w, int revents) a_refresh_cb(EV_P_ ev_prepare *w, int revents)
@ -283,7 +268,7 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
char *confpath = NULL; char *confpath = NULL;
int xfd, i, screen_nbr, opt, colors_nbr; int xfd, i, opt, colors_nbr;
xcolor_init_request_t colors_reqs[2]; xcolor_init_request_t colors_reqs[2];
ssize_t cmdlen = 1; ssize_t cmdlen = 1;
xdgHandle xdg; xdgHandle xdg;
@ -408,15 +393,12 @@ main(int argc, char **argv)
ev_prepare_start(globalconf.loop, &a_refresh); ev_prepare_start(globalconf.loop, &a_refresh);
ev_unref(globalconf.loop); ev_unref(globalconf.loop);
for(screen_nbr = 0;
screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
screen_nbr++)
{ {
const uint32_t select_input_val = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT; const uint32_t select_input_val = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
/* This causes an error if some other window manager is running */ /* This causes an error if some other window manager is running */
xcb_change_window_attributes(globalconf.connection, xcb_change_window_attributes(globalconf.connection,
xutil_screen_get(globalconf.connection, screen_nbr)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
XCB_CW_EVENT_MASK, &select_input_val); XCB_CW_EVENT_MASK, &select_input_val);
} }
@ -465,13 +447,8 @@ main(int argc, char **argv)
&globalconf.modeswitchmask); &globalconf.modeswitchmask);
/* do this only for real screen */ /* do this only for real screen */
for(screen_nbr = 0; ewmh_init();
screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); systray_init();
screen_nbr++)
{
ewmh_init(screen_nbr);
systray_init(screen_nbr);
}
/* init spawn (sn) */ /* init spawn (sn) */
spawn_init(); spawn_init();
@ -487,10 +464,6 @@ main(int argc, char **argv)
/* scan existing windows */ /* scan existing windows */
scan(); scan();
/* do this only for real screen */
for(screen_nbr = 0;
screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
screen_nbr++)
{ {
/* select for events */ /* select for events */
const uint32_t change_win_vals[] = const uint32_t change_win_vals[] =
@ -505,7 +478,7 @@ main(int argc, char **argv)
}; };
xcb_change_window_attributes(globalconf.connection, xcb_change_window_attributes(globalconf.connection,
xutil_screen_get(globalconf.connection, screen_nbr)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
XCB_CW_EVENT_MASK, XCB_CW_EVENT_MASK,
change_win_vals); change_win_vals);
} }

View File

@ -42,7 +42,6 @@ typedef struct xembed_window xembed_window_t;
struct xembed_window struct xembed_window
{ {
xcb_window_t win; xcb_window_t win;
int phys_screen;
xembed_info_t info; xembed_info_t info;
}; };

View File

@ -136,21 +136,4 @@ xutil_key_mask_tostr(uint16_t mask, const char **name, size_t *len)
} }
} }
/** Convert a root window a physical screen ID.
* \param connection The connection to the X server.
* \param root Root window.
* \return A physical screen number.
*/
int
xutil_root2screen(xcb_connection_t *connection, xcb_window_t root)
{
xcb_screen_iterator_t iter;
int phys_screen = 0;
for(iter = xcb_setup_roots_iterator(xcb_get_setup(connection));
iter.rem && iter.data->root != root; xcb_screen_next(&iter), ++phys_screen);
return phys_screen;
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -80,7 +80,5 @@ xutil_screen_get(xcb_connection_t *c, int screen)
return s; return s;
} }
int xutil_root2screen(xcb_connection_t *, xcb_window_t);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

9
draw.c
View File

@ -126,16 +126,15 @@ draw_text_context_init(draw_text_context_t *data, const char *str, ssize_t slen)
* \param bg Background color. * \param bg Background color.
*/ */
void void
draw_context_init(draw_context_t *d, int phys_screen, draw_context_init(draw_context_t *d,
int width, int height, xcb_pixmap_t px, int width, int height, xcb_pixmap_t px,
const xcolor_t *fg, const xcolor_t *bg) const xcolor_t *fg, const xcolor_t *bg)
{ {
d->phys_screen = phys_screen;
d->width = width; d->width = width;
d->height = height; d->height = height;
d->pixmap = px; d->pixmap = px;
d->surface = cairo_xcb_surface_create(globalconf.connection, d->surface = cairo_xcb_surface_create(globalconf.connection,
px, globalconf.screens.tab[phys_screen].visual, px, globalconf.screens.tab[0].visual,
width, height); width, height);
d->cr = cairo_create(d->surface); d->cr = cairo_create(d->surface);
d->layout = pango_cairo_create_layout(d->cr); d->layout = pango_cairo_create_layout(d->cr);
@ -308,10 +307,10 @@ draw_rotate(draw_context_t *ctx,
cairo_t *cr; cairo_t *cr;
surface = cairo_xcb_surface_create(globalconf.connection, dest, surface = cairo_xcb_surface_create(globalconf.connection, dest,
globalconf.screens.tab[ctx->phys_screen].visual, globalconf.screens.tab[0].visual,
dest_w, dest_h); dest_w, dest_h);
source = cairo_xcb_surface_create(globalconf.connection, src, source = cairo_xcb_surface_create(globalconf.connection, src,
globalconf.screens.tab[ctx->phys_screen].visual, globalconf.screens.tab[0].visual,
src_w, src_h); src_w, src_h);
cr = cairo_create (surface); cr = cairo_create (surface);

3
draw.h
View File

@ -61,7 +61,6 @@ typedef struct
xcb_pixmap_t pixmap; xcb_pixmap_t pixmap;
uint16_t width; uint16_t width;
uint16_t height; uint16_t height;
int phys_screen;
cairo_t *cr; cairo_t *cr;
cairo_surface_t *surface; cairo_surface_t *surface;
PangoLayout *layout; PangoLayout *layout;
@ -69,7 +68,7 @@ typedef struct
xcolor_t bg; xcolor_t bg;
} draw_context_t; } draw_context_t;
void draw_context_init(draw_context_t *, int, int, int, void draw_context_init(draw_context_t *, int, int,
xcb_pixmap_t, const xcolor_t *, const xcolor_t *); xcb_pixmap_t, const xcolor_t *, const xcolor_t *);
/** Wipe a draw context. /** Wipe a draw context.

26
event.c
View File

@ -133,8 +133,6 @@ event_handle_mousegrabber(int x, int y, uint16_t mask)
static void static void
event_handle_button(xcb_button_press_event_t *ev) event_handle_button(xcb_button_press_event_t *ev)
{ {
int screen;
const int nb_screen = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
client_t *c; client_t *c;
wibox_t *wibox; wibox_t *wibox;
@ -194,8 +192,7 @@ event_handle_button(xcb_button_press_event_t *ev)
XCB_CURRENT_TIME); XCB_CURRENT_TIME);
} }
else if(ev->child == XCB_NONE) else if(ev->child == XCB_NONE)
for(screen = 0; screen < nb_screen; screen++) if(xutil_screen_get(globalconf.connection, globalconf.default_screen)->root == ev->event)
if(xutil_screen_get(globalconf.connection, screen)->root == ev->event)
{ {
event_button_callback(ev, &globalconf.buttons, 0, 0, NULL); event_button_callback(ev, &globalconf.buttons, 0, 0, NULL);
return; return;
@ -290,12 +287,9 @@ event_handle_configurerequest(xcb_configure_request_event_t *ev)
static void static void
event_handle_configurenotify(xcb_configure_notify_event_t *ev) event_handle_configurenotify(xcb_configure_notify_event_t *ev)
{ {
int screen_nbr; const xcb_screen_t *screen = xutil_screen_get(globalconf.connection, globalconf.default_screen);
const xcb_screen_t *screen;
for(screen_nbr = 0; screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); screen_nbr++) if(ev->window == screen->root
if((screen = xutil_screen_get(globalconf.connection, screen_nbr)) != NULL
&& ev->window == screen->root
&& (ev->width != screen->width_in_pixels && (ev->width != screen->width_in_pixels
|| ev->height != screen->height_in_pixels)) || ev->height != screen->height_in_pixels))
/* it's not that we panic, but restart */ /* it's not that we panic, but restart */
@ -578,7 +572,6 @@ event_handle_key(xcb_key_press_event_t *ev)
static void static void
event_handle_maprequest(xcb_map_request_event_t *ev) event_handle_maprequest(xcb_map_request_event_t *ev)
{ {
int phys_screen;
client_t *c; client_t *c;
xcb_get_window_attributes_cookie_t wa_c; xcb_get_window_attributes_cookie_t wa_c;
xcb_get_window_attributes_reply_t *wa_r; xcb_get_window_attributes_reply_t *wa_r;
@ -619,9 +612,7 @@ event_handle_maprequest(xcb_map_request_event_t *ev)
goto bailout; goto bailout;
} }
phys_screen = xutil_root2screen(globalconf.connection, geom_r->root); client_manage(ev->window, geom_r, false);
client_manage(ev->window, geom_r, phys_screen, false);
p_delete(&geom_r); p_delete(&geom_r);
} }
@ -729,16 +720,11 @@ event_handle_mappingnotify(xcb_mapping_notify_event_t *ev)
&globalconf.shiftlockmask, &globalconf.capslockmask, &globalconf.shiftlockmask, &globalconf.capslockmask,
&globalconf.modeswitchmask); &globalconf.modeswitchmask);
int nscreen = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
/* regrab everything */ /* regrab everything */
for(int phys_screen = 0; phys_screen < nscreen; phys_screen++) xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
{
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
/* yes XCB_BUTTON_MASK_ANY is also for grab_key even if it's look weird */ /* yes XCB_BUTTON_MASK_ANY is also for grab_key even if it's look weird */
xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, s->root, XCB_BUTTON_MASK_ANY); xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, s->root, XCB_BUTTON_MASK_ANY);
xwindow_grabkeys(s->root, &globalconf.keys); xwindow_grabkeys(s->root, &globalconf.keys);
}
foreach(_c, globalconf.clients) foreach(_c, globalconf.clients)
{ {
@ -758,7 +744,7 @@ event_handle_reparentnotify(xcb_reparent_notify_event_t *ev)
{ {
/* Ignore reparents to the root window, they *might* be caused by /* Ignore reparents to the root window, they *might* be caused by
* ourselves if a client quickly unmaps and maps itself again. */ * ourselves if a client quickly unmaps and maps itself again. */
xcb_screen_t *s = xutil_screen_get(globalconf.connection, c->phys_screen); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
if (ev->parent != s->root) if (ev->parent != s->root)
client_unmanage(c); client_unmanage(c);
} }

57
ewmh.c
View File

@ -98,43 +98,40 @@ ewmh_signal_on_client_new(lua_State *L)
} }
/** Update the desktop geometry. /** Update the desktop geometry.
* \param phys_screen The physical screen id.
*/ */
static void static void
ewmh_update_desktop_geometry(int phys_screen) ewmh_update_desktop_geometry(void)
{ {
area_t geom = screen_area_get(&globalconf.screens.tab[phys_screen], false); area_t geom = screen_area_get(&globalconf.screens.tab[0], false);
uint32_t sizes[] = { geom.width, geom.height }; uint32_t sizes[] = { geom.width, geom.height };
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
_NET_DESKTOP_GEOMETRY, XCB_ATOM_CARDINAL, 32, countof(sizes), sizes); _NET_DESKTOP_GEOMETRY, XCB_ATOM_CARDINAL, 32, countof(sizes), sizes);
} }
static int static int
ewmh_update_net_active_window(lua_State *L) ewmh_update_net_active_window(lua_State *L)
{ {
client_t *c = luaA_checkudata(L, 1, &client_class);
xcb_window_t win; xcb_window_t win;
if(globalconf.screen_focus->client_focus if(globalconf.screen_focus->client_focus)
&& globalconf.screen_focus->client_focus->phys_screen == c->phys_screen)
win = globalconf.screen_focus->client_focus->window; win = globalconf.screen_focus->client_focus->window;
else else
win = XCB_NONE; win = XCB_NONE;
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, c->phys_screen)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
_NET_ACTIVE_WINDOW, XCB_ATOM_WINDOW, 32, 1, &win); _NET_ACTIVE_WINDOW, XCB_ATOM_WINDOW, 32, 1, &win);
return 0; return 0;
} }
void void
ewmh_init(int phys_screen) ewmh_init(void)
{ {
xcb_window_t father; xcb_window_t father;
xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen); xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, globalconf.default_screen);
xcb_atom_t atom[] = xcb_atom_t atom[] =
{ {
_NET_SUPPORTED, _NET_SUPPORTED,
@ -211,7 +208,7 @@ ewmh_init(int phys_screen)
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
father, _NET_WM_PID, XCB_ATOM_CARDINAL, 32, 1, &i); father, _NET_WM_PID, XCB_ATOM_CARDINAL, 32, 1, &i);
ewmh_update_desktop_geometry(phys_screen); ewmh_update_desktop_geometry();
lua_pushcfunction(globalconf.L, ewmh_signal_on_client_new); lua_pushcfunction(globalconf.L, ewmh_signal_on_client_new);
luaA_class_add_signal(globalconf.L, &client_class, "new", -1); luaA_class_add_signal(globalconf.L, &client_class, "new", -1);
@ -222,7 +219,7 @@ ewmh_init(int phys_screen)
} }
void void
ewmh_update_net_client_list(int phys_screen) ewmh_update_net_client_list(void)
{ {
xcb_window_t *wins = p_alloca(xcb_window_t, globalconf.clients.len); xcb_window_t *wins = p_alloca(xcb_window_t, globalconf.clients.len);
@ -230,68 +227,65 @@ ewmh_update_net_client_list(int phys_screen)
foreach(_c, globalconf.clients) foreach(_c, globalconf.clients)
{ {
client_t *c = *_c; client_t *c = *_c;
if(c->phys_screen == phys_screen)
wins[n++] = c->window; wins[n++] = c->window;
} }
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
_NET_CLIENT_LIST, XCB_ATOM_WINDOW, 32, n, wins); _NET_CLIENT_LIST, XCB_ATOM_WINDOW, 32, n, wins);
} }
/** Set the client list in stacking order, bottom to top. /** Set the client list in stacking order, bottom to top.
* \param phys_screen The physical screen id.
*/ */
void void
ewmh_update_net_client_list_stacking(int phys_screen) ewmh_update_net_client_list_stacking(void)
{ {
int n = 0; int n = 0;
xcb_window_t *wins = p_alloca(xcb_window_t, globalconf.stack.len); xcb_window_t *wins = p_alloca(xcb_window_t, globalconf.stack.len);
foreach(client, globalconf.stack) foreach(client, globalconf.stack)
if((*client)->phys_screen == phys_screen)
wins[n++] = (*client)->window; wins[n++] = (*client)->window;
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
_NET_CLIENT_LIST_STACKING, XCB_ATOM_WINDOW, 32, n, wins); _NET_CLIENT_LIST_STACKING, XCB_ATOM_WINDOW, 32, n, wins);
} }
void void
ewmh_update_net_numbers_of_desktop(int phys_screen) ewmh_update_net_numbers_of_desktop(void)
{ {
uint32_t count = globalconf.screens.tab[phys_screen].tags.len; uint32_t count = globalconf.screens.tab[0].tags.len;
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
_NET_NUMBER_OF_DESKTOPS, XCB_ATOM_CARDINAL, 32, 1, &count); _NET_NUMBER_OF_DESKTOPS, XCB_ATOM_CARDINAL, 32, 1, &count);
} }
void void
ewmh_update_net_current_desktop(int phys_screen) ewmh_update_net_current_desktop(void)
{ {
uint32_t idx = tags_get_first_selected_index(&globalconf.screens.tab[phys_screen]); uint32_t idx = tags_get_first_selected_index(&globalconf.screens.tab[0]);
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
_NET_CURRENT_DESKTOP, XCB_ATOM_CARDINAL, 32, 1, &idx); _NET_CURRENT_DESKTOP, XCB_ATOM_CARDINAL, 32, 1, &idx);
} }
void void
ewmh_update_net_desktop_names(int phys_screen) ewmh_update_net_desktop_names(void)
{ {
buffer_t buf; buffer_t buf;
buffer_inita(&buf, BUFSIZ); buffer_inita(&buf, BUFSIZ);
foreach(tag, globalconf.screens.tab[phys_screen].tags) foreach(tag, globalconf.screens.tab[0].tags)
{ {
buffer_adds(&buf, tag_get_name(*tag)); buffer_adds(&buf, tag_get_name(*tag));
buffer_addc(&buf, '\0'); buffer_addc(&buf, '\0');
} }
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
xutil_screen_get(globalconf.connection, phys_screen)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
_NET_DESKTOP_NAMES, UTF8_STRING, 8, buf.len, buf.s); _NET_DESKTOP_NAMES, UTF8_STRING, 8, buf.len, buf.s);
buffer_wipe(&buf); buffer_wipe(&buf);
} }
@ -399,16 +393,9 @@ int
ewmh_process_client_message(xcb_client_message_event_t *ev) ewmh_process_client_message(xcb_client_message_event_t *ev)
{ {
client_t *c; client_t *c;
int screen;
if(ev->type == _NET_CURRENT_DESKTOP) if(ev->type == _NET_CURRENT_DESKTOP)
for(screen = 0; tag_view_only_byindex(&globalconf.screens.tab[0], ev->data.data32[0]);
screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
screen++)
{
if(ev->window == xutil_screen_get(globalconf.connection, screen)->root)
tag_view_only_byindex(&globalconf.screens.tab[screen], ev->data.data32[0]);
}
else if(ev->type == _NET_CLOSE_WINDOW) else if(ev->type == _NET_CLOSE_WINDOW)
{ {
if((c = client_getbywin(ev->window))) if((c = client_getbywin(ev->window)))

12
ewmh.h
View File

@ -25,13 +25,13 @@
#include "globalconf.h" #include "globalconf.h"
#include "strut.h" #include "strut.h"
void ewmh_init(int); void ewmh_init(void);
void ewmh_update_net_client_list(int); void ewmh_update_net_client_list(void);
void ewmh_update_net_numbers_of_desktop(int); void ewmh_update_net_numbers_of_desktop(void);
void ewmh_update_net_current_desktop(int); void ewmh_update_net_current_desktop(void);
void ewmh_update_net_desktop_names(int); void ewmh_update_net_desktop_names(void);
int ewmh_process_client_message(xcb_client_message_event_t *); int ewmh_process_client_message(xcb_client_message_event_t *);
void ewmh_update_net_client_list_stacking(int); void ewmh_update_net_client_list_stacking(void);
void ewmh_client_check_hints(client_t *); void ewmh_client_check_hints(client_t *);
void ewmh_client_update_desktop(client_t *); void ewmh_client_update_desktop(client_t *);
void ewmh_process_client_strut(client_t *); void ewmh_process_client_strut(client_t *);

15
mouse.c
View File

@ -71,18 +71,13 @@ mouse_query_pointer(xcb_window_t window, int16_t *x, int16_t *y, xcb_window_t *c
static bool static bool
mouse_query_pointer_root(screen_t **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; xcb_window_t root = xutil_screen_get(globalconf.connection, globalconf.default_screen)->root;
screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
screen++)
{
xcb_window_t root = xutil_screen_get(globalconf.connection, screen)->root;
if(mouse_query_pointer(root, x, y, child, mask)) if(mouse_query_pointer(root, x, y, child, mask))
{ {
*s = &globalconf.screens.tab[screen]; *s = &globalconf.screens.tab[0];
return true; return true;
} }
}
return false; return false;
} }
@ -141,7 +136,7 @@ luaA_mouse_newindex(lua_State *L)
const char *attr = luaL_checklstring(L, 2, &len); const char *attr = luaL_checklstring(L, 2, &len);
int x, y = 0; int x, y = 0;
xcb_window_t root; xcb_window_t root;
int screen, phys_screen; int screen;
switch(a_tokenize(attr, len)) switch(a_tokenize(attr, len))
{ {
@ -149,9 +144,7 @@ luaA_mouse_newindex(lua_State *L)
screen = luaL_checknumber(L, 3) - 1; screen = luaL_checknumber(L, 3) - 1;
luaA_checkscreen(screen); luaA_checkscreen(screen);
/* we need the physical one to get the root window */ root = xutil_screen_get(globalconf.connection, globalconf.default_screen)->root;
phys_screen = screen_virttophys(screen);
root = xutil_screen_get(globalconf.connection, phys_screen)->root;
x = globalconf.screens.tab[screen].geometry.x; x = globalconf.screens.tab[screen].geometry.x;
y = globalconf.screens.tab[screen].geometry.y; y = globalconf.screens.tab[screen].geometry.y;

View File

@ -35,19 +35,7 @@
static bool static bool
mousegrabber_grab(xcb_cursor_t cursor) mousegrabber_grab(xcb_cursor_t cursor)
{ {
xcb_window_t root = XCB_NONE; xcb_window_t root = xutil_screen_get(globalconf.connection, globalconf.default_screen)->root;
for(int screen = 0;
screen < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
screen++)
{
int16_t x, y;
uint16_t mask;
root = xutil_screen_get(globalconf.connection, screen)->root;
if(mouse_query_pointer(root, &x, &y, NULL, &mask))
break;
}
for(int i = 1000; i; i--) for(int i = 1000; i; i--)
{ {

View File

@ -253,7 +253,7 @@ client_getbyframewin(xcb_window_t w)
void void
client_unfocus_update(client_t *c) client_unfocus_update(client_t *c)
{ {
globalconf.screens.tab[c->phys_screen].client_focus = NULL; globalconf.screens.tab[0].client_focus = NULL;
luaA_object_push(globalconf.L, c); luaA_object_push(globalconf.L, c);
luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1); luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1);
@ -266,7 +266,7 @@ void
client_unfocus(client_t *c) client_unfocus(client_t *c)
{ {
xcb_window_t root_win = xutil_screen_get(globalconf.connection, c->phys_screen)->root; xcb_window_t root_win = xutil_screen_get(globalconf.connection, globalconf.default_screen)->root;
/* Set focus on root window, so no events leak to the current window. /* Set focus on root window, so no events leak to the current window.
* This kind of inlines client_set_focus(), but a root window will never have * This kind of inlines client_set_focus(), but a root window will never have
* the WM_TAKE_FOCUS protocol. * the WM_TAKE_FOCUS protocol.
@ -311,11 +311,11 @@ client_set_focus(client_t *c, bool set_input_focus)
*/ */
void client_ban_unfocus(client_t *c) void client_ban_unfocus(client_t *c)
{ {
if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c) if(globalconf.screens.tab[0].prev_client_focus == c)
globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL; globalconf.screens.tab[0].prev_client_focus = NULL;
/* Wait until the last moment to take away the focus from the window. */ /* Wait until the last moment to take away the focus from the window. */
if(globalconf.screens.tab[c->phys_screen].client_focus == c) if(globalconf.screens.tab[0].client_focus == c)
client_unfocus(c); client_unfocus(c);
} }
@ -393,7 +393,7 @@ client_focus_update(client_t *c)
return; return;
} }
globalconf.screen_focus = &globalconf.screens.tab[c->phys_screen]; globalconf.screen_focus = &globalconf.screens.tab[0];
globalconf.screen_focus->prev_client_focus = c; globalconf.screen_focus->prev_client_focus = c;
globalconf.screen_focus->client_focus = c; globalconf.screen_focus->client_focus = c;
@ -467,17 +467,16 @@ client_update_properties(client_t *c)
/** Manage a new client. /** Manage a new client.
* \param w The window. * \param w The window.
* \param wgeom Window geometry. * \param wgeom Window geometry.
* \param phys_screen Physical screen number.
* \param startup True if we are managing at startup time. * \param startup True if we are managing at startup time.
*/ */
void void
client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, bool startup) client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, bool startup)
{ {
const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK }; const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK };
if(systray_iskdedockapp(w)) if(systray_iskdedockapp(w))
{ {
systray_request_handle(w, phys_screen, NULL); systray_request_handle(w, NULL);
return; return;
} }
@ -492,10 +491,8 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
xcb_change_save_set(globalconf.connection, XCB_SET_MODE_INSERT, w); xcb_change_save_set(globalconf.connection, XCB_SET_MODE_INSERT, w);
client_t *c = client_new(globalconf.L); client_t *c = client_new(globalconf.L);
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
/* This cannot change, ever. */
c->phys_screen = phys_screen;
/* consider the window banned */ /* consider the window banned */
c->isbanned = true; c->isbanned = true;
/* Store window */ /* Store window */
@ -542,7 +539,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
client_array_push(&globalconf.clients, luaA_object_ref(globalconf.L, -1)); client_array_push(&globalconf.clients, luaA_object_ref(globalconf.L, -1));
/* Set the right screen */ /* Set the right screen */
screen_client_moveto(c, screen_getbycoord(&globalconf.screens.tab[phys_screen], wgeom->x, wgeom->y), false); screen_client_moveto(c, screen_getbycoord(&globalconf.screens.tab[0], wgeom->x, wgeom->y), false);
/* Store initial geometry and emits signals so we inform that geometry have /* Store initial geometry and emits signals so we inform that geometry have
* been set. */ * been set. */
@ -573,7 +570,7 @@ HANDLE_GEOM(height)
/* Push client in stack */ /* Push client in stack */
client_raise(c); client_raise(c);
ewmh_update_net_client_list(c->phys_screen); ewmh_update_net_client_list();
/* Always stay in NORMAL_STATE. Even though iconified seems more /* Always stay in NORMAL_STATE. Even though iconified seems more
* appropriate sometimes. The only possible loss is that clients not using * appropriate sometimes. The only possible loss is that clients not using
@ -730,7 +727,7 @@ client_resize(client_t *c, area_t geometry, bool hints)
area_t area; area_t area;
/* offscreen appearance fixes */ /* offscreen appearance fixes */
area = display_area_get(c->phys_screen); area = display_area_get();
if(geometry.x > area.width) if(geometry.x > area.width)
geometry.x = area.width - geometry.width; geometry.x = area.width - geometry.width;
@ -1041,10 +1038,10 @@ client_unmanage(client_t *c)
tc->transient_for = NULL; tc->transient_for = NULL;
} }
if(globalconf.screens.tab[c->phys_screen].prev_client_focus == c) if(globalconf.screens.tab[0].prev_client_focus == c)
globalconf.screens.tab[c->phys_screen].prev_client_focus = NULL; globalconf.screens.tab[0].prev_client_focus = NULL;
if(globalconf.screens.tab[c->phys_screen].client_focus == c) if(globalconf.screens.tab[0].client_focus == c)
client_unfocus(c); client_unfocus(c);
/* remove client from global list and everywhere else */ /* remove client from global list and everywhere else */
@ -1066,7 +1063,7 @@ client_unmanage(client_t *c)
if(strut_has_value(&c->strut)) if(strut_has_value(&c->strut))
screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0); screen_emit_signal(globalconf.L, c->screen, "property::workarea", 0);
ewmh_update_net_client_list(c->phys_screen); ewmh_update_net_client_list();
/* Clear our event mask so that we don't receive any events from now on, /* Clear our event mask so that we don't receive any events from now on,
* especially not for the following requests. */ * especially not for the following requests. */
@ -1079,7 +1076,7 @@ client_unmanage(client_t *c)
XCB_CW_EVENT_MASK, XCB_CW_EVENT_MASK,
(const uint32_t []) { 0 }); (const uint32_t []) { 0 });
xcb_screen_t *s = xutil_screen_get(globalconf.connection, c->phys_screen); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
xcb_unmap_window(globalconf.connection, c->window); xcb_unmap_window(globalconf.connection, c->window);
xcb_reparent_window(globalconf.connection, c->window, s->root, xcb_reparent_window(globalconf.connection, c->window, s->root,
c->geometry.x, c->geometry.y); c->geometry.x, c->geometry.y);

View File

@ -111,8 +111,6 @@ struct client_t
xcb_window_t leader_window; xcb_window_t leader_window;
/** Client's WM_PROTOCOLS property */ /** Client's WM_PROTOCOLS property */
xcb_get_wm_protocols_reply_t protocols; xcb_get_wm_protocols_reply_t protocols;
/** Client physical screen */
int phys_screen;
/** Key bindings */ /** Key bindings */
key_array_t keys; key_array_t keys;
/** Icon */ /** Icon */
@ -144,7 +142,7 @@ client_t * client_getbyframewin(xcb_window_t);
void client_ban(client_t *); void client_ban(client_t *);
void client_ban_unfocus(client_t *); void client_ban_unfocus(client_t *);
void client_unban(client_t *); void client_unban(client_t *);
void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, int, bool); void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, bool);
area_t client_geometry_hints(client_t *, area_t); area_t client_geometry_hints(client_t *, area_t);
bool client_resize(client_t *, area_t, bool); bool client_resize(client_t *, area_t, bool);
void client_unmanage(client_t *); void client_unmanage(client_t *);

View File

@ -75,11 +75,9 @@ tag_view(lua_State *L, int udx, bool view)
if(tag->screen) if(tag->screen)
{ {
int screen_index = screen_array_indexof(&globalconf.screens, tag->screen);
banning_need_update(tag->screen); banning_need_update(tag->screen);
ewmh_update_net_current_desktop(screen_virttophys(screen_index)); ewmh_update_net_current_desktop();
} }
luaA_object_emit_signal(L, udx, "property::selected", 0); luaA_object_emit_signal(L, udx, "property::selected", 0);
@ -103,13 +101,10 @@ tag_append_to_screen(lua_State *L, int udx, screen_t *s)
return; return;
} }
int screen_index = screen_array_indexof(&globalconf.screens, s);
int phys_screen = screen_virttophys(screen_index);
tag->screen = s; tag->screen = s;
tag_array_append(&s->tags, luaA_object_ref_class(globalconf.L, udx, &tag_class)); tag_array_append(&s->tags, luaA_object_ref_class(globalconf.L, udx, &tag_class));
ewmh_update_net_numbers_of_desktop(phys_screen); ewmh_update_net_numbers_of_desktop();
ewmh_update_net_desktop_names(phys_screen); ewmh_update_net_desktop_names();
luaA_object_push(globalconf.L, tag); luaA_object_push(globalconf.L, tag);
luaA_object_emit_signal(L, -1, "property::screen", 0); luaA_object_emit_signal(L, -1, "property::screen", 0);
@ -128,8 +123,6 @@ tag_remove_from_screen(tag_t *tag)
if(!tag->screen) if(!tag->screen)
return; return;
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++)
@ -143,8 +136,8 @@ tag_remove_from_screen(tag_t *tag)
if(tag->selected) if(tag->selected)
banning_need_update(tag->screen); banning_need_update(tag->screen);
ewmh_update_net_numbers_of_desktop(phys_screen); ewmh_update_net_numbers_of_desktop();
ewmh_update_net_desktop_names(phys_screen); ewmh_update_net_desktop_names();
screen_t *s = tag->screen; screen_t *s = tag->screen;
tag->screen = NULL; tag->screen = NULL;

View File

@ -34,23 +34,22 @@
LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox) LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox)
/** Kick out systray windows. /** Kick out systray windows.
* \param phys_screen Physical screen number.
*/ */
static void static void
wibox_systray_kickout(int phys_screen) wibox_systray_kickout(void)
{ {
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
if(globalconf.screens.tab[phys_screen].systray.parent != s->root) if(globalconf.screens.tab[0].systray.parent != s->root)
{ {
/* Who! Check that we're not deleting a wibox with a systray, because it /* 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 * may be its parent. If so, we reparent to root before, otherwise it will
* hurt very much. */ * hurt very much. */
xcb_reparent_window(globalconf.connection, xcb_reparent_window(globalconf.connection,
globalconf.screens.tab[phys_screen].systray.window, globalconf.screens.tab[0].systray.window,
s->root, -512, -512); s->root, -512, -512);
globalconf.screens.tab[phys_screen].systray.parent = s->root; globalconf.screens.tab[0].systray.parent = s->root;
} }
} }
@ -62,13 +61,11 @@ wibox_wipe_resources(wibox_t *w)
{ {
if(w->window) if(w->window)
{ {
int phys_screen = w->ctx.phys_screen;
/* Activate BMA */ /* Activate BMA */
client_ignore_enterleave_events(); client_ignore_enterleave_events();
/* Make sure we don't accidentally kill the systray window */ /* Make sure we don't accidentally kill the systray window */
if(globalconf.screens.tab[phys_screen].systray.parent == w->window) if(globalconf.screens.tab[0].systray.parent == w->window)
wibox_systray_kickout(phys_screen); wibox_systray_kickout();
xcb_destroy_window(globalconf.connection, w->window); xcb_destroy_window(globalconf.connection, w->window);
/* Deactivate BMA */ /* Deactivate BMA */
client_restore_enterleave_events(); client_restore_enterleave_events();
@ -182,7 +179,6 @@ static void
wibox_draw_context_update(wibox_t *w, xcb_screen_t *s) wibox_draw_context_update(wibox_t *w, xcb_screen_t *s)
{ {
xcolor_t fg = w->ctx.fg, bg = w->ctx.bg; xcolor_t fg = w->ctx.fg, bg = w->ctx.bg;
int phys_screen = w->ctx.phys_screen;
draw_context_wipe(&w->ctx); draw_context_wipe(&w->ctx);
@ -198,13 +194,13 @@ wibox_draw_context_update(wibox_t *w, xcb_screen_t *s)
w->ctx.pixmap, s->root, w->ctx.pixmap, s->root,
w->geometry.height, w->geometry.height,
w->geometry.width); w->geometry.width);
draw_context_init(&w->ctx, phys_screen, draw_context_init(&w->ctx,
w->geometry.height, w->geometry.height,
w->geometry.width, w->geometry.width,
w->ctx.pixmap, &fg, &bg); w->ctx.pixmap, &fg, &bg);
break; break;
case East: case East:
draw_context_init(&w->ctx, phys_screen, draw_context_init(&w->ctx,
w->geometry.width, w->geometry.width,
w->geometry.height, w->geometry.height,
w->pixmap, &fg, &bg); w->pixmap, &fg, &bg);
@ -214,12 +210,11 @@ wibox_draw_context_update(wibox_t *w, xcb_screen_t *s)
/** Initialize a wibox. /** Initialize a wibox.
* \param w The wibox to initialize. * \param w The wibox to initialize.
* \param phys_screen Physical screen number.
*/ */
static void static void
wibox_init(wibox_t *w, int phys_screen) wibox_init(wibox_t *w)
{ {
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
w->window = xcb_generate_id(globalconf.connection); w->window = xcb_generate_id(globalconf.connection);
xcb_create_window(globalconf.connection, s->root_depth, w->window, s->root, xcb_create_window(globalconf.connection, s->root_depth, w->window, s->root,
@ -247,7 +242,6 @@ wibox_init(wibox_t *w, int phys_screen)
w->geometry.width, w->geometry.height); w->geometry.width, w->geometry.height);
/* Update draw context physical screen, important for Zaphod. */ /* Update draw context physical screen, important for Zaphod. */
w->ctx.phys_screen = phys_screen;
wibox_draw_context_update(w, s); wibox_draw_context_update(w, s);
/* The default GC is just a newly created associated to the root window */ /* The default GC is just a newly created associated to the root window */
@ -312,7 +306,7 @@ wibox_moveresize(lua_State *L, int udx, area_t geometry)
if(w->pixmap != w->ctx.pixmap) if(w->pixmap != w->ctx.pixmap)
xcb_free_pixmap(globalconf.connection, w->ctx.pixmap); xcb_free_pixmap(globalconf.connection, w->ctx.pixmap);
w->pixmap = xcb_generate_id(globalconf.connection); w->pixmap = xcb_generate_id(globalconf.connection);
xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root, xcb_create_pixmap(globalconf.connection, s->root_depth, w->pixmap, s->root,
w->geometry.width, w->geometry.height); w->geometry.width, w->geometry.height);
wibox_draw_context_update(w, s); wibox_draw_context_update(w, s);
@ -384,7 +378,7 @@ wibox_set_orientation(lua_State *L, int udx, orientation_t o)
wibox_t *w = luaA_checkudata(L, udx, &wibox_class); wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
if(o != w->orientation) if(o != w->orientation)
{ {
xcb_screen_t *s = xutil_screen_get(globalconf.connection, w->ctx.phys_screen); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
w->orientation = o; w->orientation = o;
/* orientation != East */ /* orientation != East */
if(w->pixmap != w->ctx.pixmap) if(w->pixmap != w->ctx.pixmap)
@ -426,7 +420,6 @@ wibox_systray_refresh(wibox_t *wibox)
uint32_t config_win_vals[4]; uint32_t config_win_vals[4];
uint32_t config_win_vals_off[2] = { -512, -512 }; uint32_t config_win_vals_off[2] = { -512, -512 };
xembed_window_t *em; xembed_window_t *em;
int phys_screen = wibox->ctx.phys_screen;
wibox->has_systray = true; wibox->has_systray = true;
@ -436,10 +429,10 @@ wibox_systray_refresh(wibox_t *wibox)
{ {
/* Set background of the systray window. */ /* Set background of the systray window. */
xcb_change_window_attributes(globalconf.connection, xcb_change_window_attributes(globalconf.connection,
globalconf.screens.tab[phys_screen].systray.window, globalconf.screens.tab[0].systray.window,
XCB_CW_BACK_PIXEL, config_back); XCB_CW_BACK_PIXEL, config_back);
/* Map it. */ /* Map it. */
xcb_map_window(globalconf.connection, globalconf.screens.tab[phys_screen].systray.window); xcb_map_window(globalconf.connection, globalconf.screens.tab[0].systray.window);
/* Move it. */ /* Move it. */
switch(wibox->orientation) switch(wibox->orientation)
{ {
@ -463,16 +456,16 @@ wibox_systray_refresh(wibox_t *wibox)
break; break;
} }
/* reparent */ /* reparent */
if(globalconf.screens.tab[phys_screen].systray.parent != wibox->window) if(globalconf.screens.tab[0].systray.parent != wibox->window)
{ {
xcb_reparent_window(globalconf.connection, xcb_reparent_window(globalconf.connection,
globalconf.screens.tab[phys_screen].systray.window, globalconf.screens.tab[0].systray.window,
wibox->window, wibox->window,
config_win_vals[0], config_win_vals[1]); config_win_vals[0], config_win_vals[1]);
globalconf.screens.tab[phys_screen].systray.parent = wibox->window; globalconf.screens.tab[0].systray.parent = wibox->window;
} }
xcb_configure_window(globalconf.connection, xcb_configure_window(globalconf.connection,
globalconf.screens.tab[phys_screen].systray.window, globalconf.screens.tab[0].systray.window,
XCB_CONFIG_WINDOW_X XCB_CONFIG_WINDOW_X
| XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_Y
| XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_WIDTH
@ -483,7 +476,7 @@ wibox_systray_refresh(wibox_t *wibox)
config_win_vals[0] = 0; config_win_vals[0] = 0;
} }
else else
return wibox_systray_kickout(phys_screen); return wibox_systray_kickout();
switch(wibox->orientation) switch(wibox->orientation)
{ {
@ -492,8 +485,6 @@ wibox_systray_refresh(wibox_t *wibox)
for(int j = 0; j < globalconf.embedded.len; j++) for(int j = 0; j < globalconf.embedded.len; j++)
{ {
em = &globalconf.embedded.tab[j]; em = &globalconf.embedded.tab[j];
if(em->phys_screen == phys_screen)
{
if(config_win_vals[1] - config_win_vals[2] >= (uint32_t) wibox->geometry.y) if(config_win_vals[1] - config_win_vals[2] >= (uint32_t) wibox->geometry.y)
{ {
xcb_map_window(globalconf.connection, em->win); xcb_map_window(globalconf.connection, em->win);
@ -511,15 +502,12 @@ wibox_systray_refresh(wibox_t *wibox)
| XCB_CONFIG_WINDOW_Y, | XCB_CONFIG_WINDOW_Y,
config_win_vals_off); config_win_vals_off);
} }
}
break; break;
case South: case South:
config_win_vals[1] = 0; config_win_vals[1] = 0;
for(int j = 0; j < globalconf.embedded.len; j++) for(int j = 0; j < globalconf.embedded.len; j++)
{ {
em = &globalconf.embedded.tab[j]; em = &globalconf.embedded.tab[j];
if(em->phys_screen == phys_screen)
{
/* if(y + width <= wibox.y + systray.right) */ /* if(y + width <= wibox.y + systray.right) */
if(config_win_vals[1] + config_win_vals[3] <= (uint32_t) wibox->geometry.y + AREA_RIGHT(systray->geometry)) if(config_win_vals[1] + config_win_vals[3] <= (uint32_t) wibox->geometry.y + AREA_RIGHT(systray->geometry))
{ {
@ -538,15 +526,12 @@ wibox_systray_refresh(wibox_t *wibox)
| XCB_CONFIG_WINDOW_Y, | XCB_CONFIG_WINDOW_Y,
config_win_vals_off); config_win_vals_off);
} }
}
break; break;
case East: case East:
config_win_vals[1] = 0; config_win_vals[1] = 0;
for(int j = 0; j < globalconf.embedded.len; j++) for(int j = 0; j < globalconf.embedded.len; j++)
{ {
em = &globalconf.embedded.tab[j]; em = &globalconf.embedded.tab[j];
if(em->phys_screen == phys_screen)
{
/* if(x + width < systray.x + systray.width) */ /* if(x + width < systray.x + systray.width) */
if(config_win_vals[0] + config_win_vals[2] <= (uint32_t) AREA_RIGHT(systray->geometry) + wibox->geometry.x) if(config_win_vals[0] + config_win_vals[2] <= (uint32_t) AREA_RIGHT(systray->geometry) + wibox->geometry.x)
{ {
@ -565,7 +550,6 @@ wibox_systray_refresh(wibox_t *wibox)
| XCB_CONFIG_WINDOW_Y, | XCB_CONFIG_WINDOW_Y,
config_win_vals_off); config_win_vals_off);
} }
}
break; break;
} }
break; break;
@ -714,8 +698,6 @@ wibox_detach(lua_State *L, int udx)
static void static void
wibox_attach(lua_State *L, int udx, screen_t *s) wibox_attach(lua_State *L, int udx, screen_t *s)
{ {
int phys_screen = screen_virttophys(screen_array_indexof(&globalconf.screens, s));
/* duplicate wibox */ /* duplicate wibox */
lua_pushvalue(L, udx); lua_pushvalue(L, udx);
/* ref it */ /* ref it */
@ -739,7 +721,7 @@ wibox_attach(lua_State *L, int udx, screen_t *s)
wibox_array_append(&globalconf.wiboxes, wibox); wibox_array_append(&globalconf.wiboxes, wibox);
wibox_init(wibox, phys_screen); wibox_init(wibox);
xwindow_set_cursor(wibox->window, xwindow_set_cursor(wibox->window,
xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor))); xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));

View File

@ -251,7 +251,7 @@ widget_render(wibox_t *wibox)
char *data; char *data;
xcb_pixmap_t rootpix; xcb_pixmap_t rootpix;
xcb_get_property_cookie_t prop_c; xcb_get_property_cookie_t prop_c;
xcb_screen_t *s = xutil_screen_get(globalconf.connection, ctx->phys_screen); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
prop_c = xcb_get_property_unchecked(globalconf.connection, false, s->root, _XROOTPMAP_ID, prop_c = xcb_get_property_unchecked(globalconf.connection, false, s->root, _XROOTPMAP_ID,
XCB_ATOM_PIXMAP, 0, 1); XCB_ATOM_PIXMAP, 0, 1);
if((prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL))) if((prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL)))

View File

@ -46,11 +46,10 @@ systray_extents(lua_State *L, widget_t *widget)
luaA_checkscreen(screen); luaA_checkscreen(screen);
area_t geometry; area_t geometry;
int phys_screen = screen_virttophys(screen), n = 0; int n = 0;
systray_data_t *d = widget->data; systray_data_t *d = widget->data;
for(int i = 0; i < globalconf.embedded.len; i++) for(int i = 0; i < globalconf.embedded.len; i++)
if(globalconf.embedded.tab[i].phys_screen == phys_screen)
n++; n++;
/** \todo use class hints */ /** \todo use class hints */
@ -73,7 +72,7 @@ systray_draw(widget_t *widget, draw_context_t *ctx,
/* set wibox orientation */ /* set wibox orientation */
/** \todo stop setting that property on each redraw */ /** \todo stop setting that property on each redraw */
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
globalconf.screens.tab[p->ctx.phys_screen].systray.window, globalconf.screens.tab[0].systray.window,
_NET_SYSTEM_TRAY_ORIENTATION, XCB_ATOM_CARDINAL, 32, 1, &orient); _NET_SYSTEM_TRAY_ORIENTATION, XCB_ATOM_CARDINAL, 32, 1, &orient);
} }

View File

@ -337,9 +337,7 @@ property_handle_xrootpmap_id(uint8_t state,
(*w)->need_update = true; (*w)->need_update = true;
else else
{ {
int screen = xutil_root2screen(globalconf.connection, window);
foreach(w, globalconf.wiboxes) foreach(w, globalconf.wiboxes)
if(screen == screen_array_indexof(&globalconf.screens, (*w)->screen))
(*w)->need_update = true; (*w)->need_update = true;
} }

12
root.c
View File

@ -128,14 +128,9 @@ luaA_root_keys(lua_State *L)
while(lua_next(L, 1)) while(lua_next(L, 1))
key_array_append(&globalconf.keys, luaA_object_ref_class(L, -1, &key_class)); key_array_append(&globalconf.keys, luaA_object_ref_class(L, -1, &key_class));
int nscreen = xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
for(int phys_screen = 0; phys_screen < nscreen; phys_screen++)
{
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, s->root, XCB_BUTTON_MASK_ANY); xcb_ungrab_key(globalconf.connection, XCB_GRAB_ANY, s->root, XCB_BUTTON_MASK_ANY);
xwindow_grabkeys(s->root, &globalconf.keys); xwindow_grabkeys(s->root, &globalconf.keys);
}
return 1; return 1;
} }
@ -204,11 +199,8 @@ luaA_root_cursor(lua_State *L)
{ {
uint32_t change_win_vals[] = { xcursor_new(globalconf.connection, cursor_font) }; uint32_t change_win_vals[] = { xcursor_new(globalconf.connection, cursor_font) };
for(int screen_nbr = 0;
screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
screen_nbr++)
xcb_change_window_attributes(globalconf.connection, xcb_change_window_attributes(globalconf.connection,
xutil_screen_get(globalconf.connection, screen_nbr)->root, xutil_screen_get(globalconf.connection, globalconf.default_screen)->root,
XCB_CW_CURSOR, XCB_CW_CURSOR,
change_win_vals); change_win_vals);
} }

View File

@ -225,11 +225,7 @@ screen_scan_xinerama(void)
static void screen_scan_x11(void) static void screen_scan_x11(void)
{ {
/* One screen only / Zaphod mode */ /* One screen only / Zaphod mode */
for(int screen = 0; xcb_screen_t *xcb_screen = xutil_screen_get(globalconf.connection, globalconf.default_screen);
screen < xcb_setup_roots_length(xcb_get_setup(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.geometry.x = 0; s.geometry.x = 0;
@ -239,7 +235,6 @@ static void screen_scan_x11(void)
s.visual = screen_default_visual(xcb_screen); s.visual = screen_default_visual(xcb_screen);
screen_array_append(&globalconf.screens, s); screen_array_append(&globalconf.screens, s);
} }
}
/** Get screens informations and fill global configuration. /** Get screens informations and fill global configuration.
*/ */
@ -339,13 +334,12 @@ screen_area_get(screen_t *screen, bool strut)
} }
/** Get display info. /** Get display info.
* \param phys_screen Physical screen number.
* \return The display area. * \return The display area.
*/ */
area_t area_t
display_area_get(int phys_screen) display_area_get(void)
{ {
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen); xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
area_t area = { .x = 0, area_t area = { .x = 0,
.y = 0, .y = 0,
.width = s->width_in_pixels, .width = s->width_in_pixels,
@ -353,19 +347,6 @@ display_area_get(int phys_screen)
return area; return area;
} }
/** This returns the real X screen number for a logical
* screen if Xinerama is active.
* \param screen The logical screen.
* \return The X screen.
*/
int
screen_virttophys(int screen)
{
if(globalconf.xinerama_is_active)
return globalconf.default_screen;
return screen;
}
/** Move a client to a virtual screen. /** Move a client to a virtual screen.
* \param c The client to move. * \param c The client to move.
* \param new_screen The destination screen. * \param new_screen The destination screen.

View File

@ -64,8 +64,7 @@ void screen_emit_signal(lua_State *, screen_t *, const char *, int);
void screen_scan(void); void screen_scan(void);
screen_t *screen_getbycoord(screen_t *, int, int); screen_t *screen_getbycoord(screen_t *, int, int);
area_t screen_area_get(screen_t *, bool); area_t screen_area_get(screen_t *, bool);
area_t display_area_get(int); area_t display_area_get(void);
int screen_virttophys(int);
void screen_client_moveto(client_t *, screen_t *, bool); void screen_client_moveto(client_t *, screen_t *, bool);
#endif #endif

View File

@ -236,11 +236,8 @@ spawn_init(void)
{ {
globalconf.sndisplay = sn_xcb_display_new(globalconf.connection, NULL, NULL); globalconf.sndisplay = sn_xcb_display_new(globalconf.connection, NULL, NULL);
const int screen_max = xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); globalconf.screens.tab[0].snmonitor = sn_monitor_context_new(globalconf.sndisplay,
globalconf.default_screen,
for(int screen = 0; screen < screen_max; screen++)
globalconf.screens.tab[screen].snmonitor = sn_monitor_context_new(globalconf.sndisplay,
screen,
spawn_monitor_event, spawn_monitor_event,
NULL, NULL); NULL, NULL);
} }
@ -330,7 +327,7 @@ luaA_spawn(lua_State *L)
else else
cmdname = a_strdup(cmd); cmdname = a_strdup(cmd);
context = sn_launcher_context_new(globalconf.sndisplay, screen_virttophys(screen)); context = sn_launcher_context_new(globalconf.sndisplay, globalconf.default_screen);
sn_launcher_context_set_name(context, "awesome"); sn_launcher_context_set_name(context, "awesome");
sn_launcher_context_set_description(context, "awesome spawn"); sn_launcher_context_set_description(context, "awesome spawn");
sn_launcher_context_set_binary_name(context, cmdname); sn_launcher_context_set_binary_name(context, cmdname);

View File

@ -34,7 +34,7 @@ stack_client_remove(client_t *c)
client_array_remove(&globalconf.stack, client); client_array_remove(&globalconf.stack, client);
break; break;
} }
ewmh_update_net_client_list_stacking(c->phys_screen); ewmh_update_net_client_list_stacking();
stack_windows(); stack_windows();
} }
@ -46,7 +46,7 @@ stack_client_push(client_t *c)
{ {
stack_client_remove(c); stack_client_remove(c);
client_array_push(&globalconf.stack, c); client_array_push(&globalconf.stack, c);
ewmh_update_net_client_list_stacking(c->phys_screen); ewmh_update_net_client_list_stacking();
stack_windows(); stack_windows();
} }
@ -58,7 +58,7 @@ stack_client_append(client_t *c)
{ {
stack_client_remove(c); stack_client_remove(c);
client_array_append(&globalconf.stack, c); client_array_append(&globalconf.stack, c);
ewmh_update_net_client_list_stacking(c->phys_screen); ewmh_update_net_client_list_stacking();
stack_windows(); stack_windows();
} }

View File

@ -35,16 +35,15 @@
#define SYSTEM_TRAY_REQUEST_DOCK 0 /* Begin icon docking */ #define SYSTEM_TRAY_REQUEST_DOCK 0 /* Begin icon docking */
/** Initialize systray information in X. /** Initialize systray information in X.
* \param phys_screen Physical screen.
*/ */
void void
systray_init(int phys_screen) systray_init(void)
{ {
xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen); xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, globalconf.default_screen);
globalconf.screens.tab[phys_screen].systray.window = xcb_generate_id(globalconf.connection); globalconf.screens.tab[0].systray.window = xcb_generate_id(globalconf.connection);
xcb_create_window(globalconf.connection, xscreen->root_depth, xcb_create_window(globalconf.connection, xscreen->root_depth,
globalconf.screens.tab[phys_screen].systray.window, globalconf.screens.tab[0].systray.window,
xscreen->root, xscreen->root,
-1, -1, 1, 1, 0, -1, -1, 1, 1, 0,
XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL); XCB_COPY_FROM_PARENT, xscreen->root_visual, 0, NULL);
@ -54,46 +53,40 @@ systray_init(int phys_screen)
/** Refresh all systrays registrations per physical screen /** Refresh all systrays registrations per physical screen
*/ */
void void
systray_refresh() systray_refresh(void)
{
int nscreen = xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
for(int phys_screen = 0; phys_screen < nscreen; phys_screen++)
{ {
bool has_systray = false; bool has_systray = false;
foreach(w, globalconf.wiboxes) foreach(w, globalconf.wiboxes)
if(phys_screen == (*w)->ctx.phys_screen && (*w)->has_systray) if((*w)->has_systray)
/* Can't use "break" with foreach() :( */ /* Can't use "break" with foreach() :( */
has_systray = true; has_systray = true;
if(has_systray) if(has_systray)
systray_register(phys_screen); systray_register();
else else
systray_cleanup(phys_screen); systray_cleanup();
}
} }
/** Register systray in X. /** Register systray in X.
* \param phys_screen Physical screen.
*/ */
void void
systray_register(int phys_screen) systray_register(void)
{ {
xcb_client_message_event_t ev; xcb_client_message_event_t ev;
xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, phys_screen); xcb_screen_t *xscreen = xutil_screen_get(globalconf.connection, globalconf.default_screen);
char *atom_name; char *atom_name;
xcb_intern_atom_cookie_t atom_systray_q; xcb_intern_atom_cookie_t atom_systray_q;
xcb_intern_atom_reply_t *atom_systray_r; xcb_intern_atom_reply_t *atom_systray_r;
xcb_atom_t atom_systray; xcb_atom_t atom_systray;
/* Set registered even if it fails to don't try again unless forced */ /* Set registered even if it fails to don't try again unless forced */
if(globalconf.screens.tab[phys_screen].systray.registered) if(globalconf.screens.tab[0].systray.registered)
return; return;
globalconf.screens.tab[phys_screen].systray.registered = true; globalconf.screens.tab[0].systray.registered = true;
/* Send requests */ /* Send requests */
if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", phys_screen))) if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", globalconf.default_screen)))
{ {
warn("error getting systray atom"); warn("error getting systray atom");
return; return;
@ -111,7 +104,7 @@ systray_register(int phys_screen)
ev.format = 32; ev.format = 32;
ev.type = MANAGER; ev.type = MANAGER;
ev.data.data32[0] = XCB_CURRENT_TIME; ev.data.data32[0] = XCB_CURRENT_TIME;
ev.data.data32[2] = globalconf.screens.tab[phys_screen].systray.window; ev.data.data32[2] = globalconf.screens.tab[0].systray.window;
ev.data.data32[3] = ev.data.data32[4] = 0; ev.data.data32[3] = ev.data.data32[4] = 0;
if(!(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, atom_systray_q, NULL))) if(!(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, atom_systray_q, NULL)))
@ -125,7 +118,7 @@ systray_register(int phys_screen)
p_delete(&atom_systray_r); p_delete(&atom_systray_r);
xcb_set_selection_owner(globalconf.connection, xcb_set_selection_owner(globalconf.connection,
globalconf.screens.tab[phys_screen].systray.window, globalconf.screens.tab[0].systray.window,
atom_systray, atom_systray,
XCB_CURRENT_TIME); XCB_CURRENT_TIME);
@ -133,19 +126,18 @@ systray_register(int phys_screen)
} }
/** Remove systray information in X. /** Remove systray information in X.
* \param phys_screen Physical screen.
*/ */
void void
systray_cleanup(int phys_screen) systray_cleanup(void)
{ {
xcb_intern_atom_reply_t *atom_systray_r; xcb_intern_atom_reply_t *atom_systray_r;
char *atom_name; char *atom_name;
if(!globalconf.screens.tab[phys_screen].systray.registered) if(!globalconf.screens.tab[0].systray.registered)
return; return;
globalconf.screens.tab[phys_screen].systray.registered = false; globalconf.screens.tab[0].systray.registered = false;
if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", phys_screen)) if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", globalconf.default_screen))
|| !(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, || !(atom_systray_r = xcb_intern_atom_reply(globalconf.connection,
xcb_intern_atom_unchecked(globalconf.connection, xcb_intern_atom_unchecked(globalconf.connection,
false, false,
@ -170,12 +162,11 @@ systray_cleanup(int phys_screen)
/** Handle a systray request. /** Handle a systray request.
* \param embed_win The window to embed. * \param embed_win The window to embed.
* \param phys_screen The physical monitor to display on.
* \param info The embedding info * \param info The embedding info
* \return 0 on no error. * \return 0 on no error.
*/ */
int int
systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *info) systray_request_handle(xcb_window_t embed_win, xembed_info_t *info)
{ {
xembed_window_t em; xembed_window_t em;
xcb_get_property_cookie_t em_cookie; xcb_get_property_cookie_t em_cookie;
@ -204,11 +195,10 @@ systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *i
*/ */
xcb_change_save_set(globalconf.connection, XCB_SET_MODE_INSERT, embed_win); xcb_change_save_set(globalconf.connection, XCB_SET_MODE_INSERT, embed_win);
xcb_reparent_window(globalconf.connection, embed_win, xcb_reparent_window(globalconf.connection, embed_win,
globalconf.screens.tab[phys_screen].systray.window, globalconf.screens.tab[0].systray.window,
0, 0); 0, 0);
em.win = embed_win; em.win = embed_win;
em.phys_screen = phys_screen;
if(info) if(info)
em.info = *info; em.info = *info;
@ -216,7 +206,7 @@ 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_info_get_reply(globalconf.connection, em_cookie, &em.info);
xembed_embedded_notify(globalconf.connection, em.win, xembed_embedded_notify(globalconf.connection, em.win,
globalconf.screens.tab[phys_screen].systray.window, globalconf.screens.tab[0].systray.window,
MIN(XEMBED_VERSION, em.info.version)); MIN(XEMBED_VERSION, em.info.version));
xembed_window_array_append(&globalconf.embedded, em); xembed_window_array_append(&globalconf.embedded, em);
@ -233,10 +223,9 @@ systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *i
int int
systray_process_client_message(xcb_client_message_event_t *ev) systray_process_client_message(xcb_client_message_event_t *ev)
{ {
int screen_nbr = 0, ret = 0; int ret = 0;
xcb_get_geometry_cookie_t geom_c; xcb_get_geometry_cookie_t geom_c;
xcb_get_geometry_reply_t *geom_r; xcb_get_geometry_reply_t *geom_r;
xcb_screen_iterator_t iter;
switch(ev->data.data32[1]) switch(ev->data.data32[1])
{ {
@ -246,12 +235,10 @@ systray_process_client_message(xcb_client_message_event_t *ev)
if(!(geom_r = xcb_get_geometry_reply(globalconf.connection, geom_c, NULL))) if(!(geom_r = xcb_get_geometry_reply(globalconf.connection, geom_c, NULL)))
return -1; return -1;
for(iter = xcb_setup_roots_iterator(xcb_get_setup(globalconf.connection)), screen_nbr = 0; if(xutil_screen_get(globalconf.connection, globalconf.default_screen)->root == geom_r->root)
iter.rem && iter.data->root != geom_r->root; xcb_screen_next (&iter), ++screen_nbr); ret = systray_request_handle(ev->data.data32[2], NULL);
p_delete(&geom_r); p_delete(&geom_r);
ret = systray_request_handle(ev->data.data32[2], screen_nbr, NULL);
break; break;
} }

View File

@ -25,11 +25,11 @@
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include "common/xembed.h" #include "common/xembed.h"
void systray_init(int); void systray_init(void);
void systray_refresh(void); void systray_refresh(void);
void systray_register(int); void systray_register(void);
void systray_cleanup(int); void systray_cleanup(void);
int systray_request_handle(xcb_window_t, int, xembed_info_t *); int systray_request_handle(xcb_window_t, xembed_info_t *);
bool systray_iskdedockapp(xcb_window_t); bool systray_iskdedockapp(xcb_window_t);
int systray_process_client_message(xcb_client_message_event_t *); int systray_process_client_message(xcb_client_message_event_t *);
int xembed_process_client_message(xcb_client_message_event_t *); int xembed_process_client_message(xcb_client_message_event_t *);