From d779aa6c40c92ada6e4be51fc5cfc0d8109aa9da Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 29 Dec 2008 12:26:01 +0100 Subject: [PATCH] client: client screen change at manage is done in Lua Signed-off-by: Julien Danjou --- awesome.c | 6 ++---- awesomerc.lua.in | 6 ++++++ client.c | 6 +++--- client.h | 2 +- event.c | 20 ++------------------ 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/awesome.c b/awesome.c index a984d12a..bd5881e3 100644 --- a/awesome.c +++ b/awesome.c @@ -95,7 +95,7 @@ awesome_atexit(void) static void scan(void) { - int i, screen, phys_screen, tree_c_len; + int i, phys_screen, tree_c_len; const int screen_max = xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); root_win_t root_wins[screen_max]; xcb_query_tree_reply_t *tree_r; @@ -176,9 +176,7 @@ scan(void) *(geom_wins[i]), NULL))) continue; - screen = screen_getbycoord(phys_screen, geom_r->x, geom_r->y); - - client_manage(wins[i], geom_r, phys_screen, screen, true); + client_manage(wins[i], geom_r, phys_screen, true); p_delete(&geom_r); } diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 796c863e..e01a9275 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -364,6 +364,12 @@ awful.hooks.manage.register(function (c, startup) awful.client.movetotag(tags[target.screen][target.tag], c) end + -- If we are not managing this applicatin at startup, + -- move it to the screen where the mouse is + if not startup then + c.screen = mouse.screen + end + -- Do this after tag mapping, so you don't see it on the wrong tag for a split second. client.focus = c diff --git a/client.c b/client.c index e1e5b9cf..5dde6c50 100644 --- a/client.c +++ b/client.c @@ -439,15 +439,15 @@ client_duplicate_tags(client_t *src_c, client_t *dst_c) * \param w The window. * \param wgeom Window geometry. * \param phys_screen Physical screen number. - * \param screen Virtual screen number where to manage client. * \param startup True if we are managing at startup time. */ void -client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, int screen, bool startup) +client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, bool startup) { xcb_get_property_cookie_t ewmh_icon_cookie; client_t *c, *tc = NULL, *group = NULL; image_t *icon; + int screen; const uint32_t select_input_val[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY @@ -468,7 +468,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val); c = p_new(client_t, 1); - c->screen = screen_getbycoord(screen, wgeom->x, wgeom->y); + screen = c->screen = screen_getbycoord(phys_screen, wgeom->x, wgeom->y); c->phys_screen = phys_screen; diff --git a/client.h b/client.h index fd6324fd..58eb08f2 100644 --- a/client.h +++ b/client.h @@ -50,7 +50,7 @@ client_t * client_getbywin(xcb_window_t); void client_stack(void); void client_ban(client_t *); void client_unban(client_t *); -void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, int, int, bool); +void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, int, bool); area_t client_geometry_hints(client_t *, area_t); void client_resize(client_t *, area_t, bool); void client_unmanage(client_t *); diff --git a/event.c b/event.c index 03c3185b..8e0e4cbf 100644 --- a/event.c +++ b/event.c @@ -587,12 +587,10 @@ static int event_handle_maprequest(void *data __attribute__ ((unused)), xcb_connection_t *connection, xcb_map_request_event_t *ev) { - int phys_screen, screen = 0, ret = 0; + int phys_screen, ret = 0; client_t *c; xcb_get_window_attributes_cookie_t wa_c; xcb_get_window_attributes_reply_t *wa_r; - xcb_query_pointer_cookie_t qp_c = { 0 }; - xcb_query_pointer_reply_t *qp_r = NULL; xcb_get_geometry_cookie_t geom_c; xcb_get_geometry_reply_t *geom_r; @@ -623,34 +621,20 @@ event_handle_maprequest(void *data __attribute__ ((unused)), { geom_c = xcb_get_geometry_unchecked(connection, ev->window); - if(globalconf.xinerama_is_active) - qp_c = xcb_query_pointer_unchecked(connection, - xutil_screen_get(globalconf.connection, - globalconf.default_screen)->root); - if(!(geom_r = xcb_get_geometry_reply(connection, geom_c, NULL))) { - if(globalconf.xinerama_is_active) - qp_r = xcb_query_pointer_reply(connection, qp_c, NULL); ret = -1; goto bailout; } - phys_screen = xutil_root2screen(connection, geom_r->root); - if(globalconf.xinerama_is_active - && (qp_r = xcb_query_pointer_reply(connection, qp_c, NULL))) - screen = screen_getbycoord(screen, qp_r->root_x, qp_r->root_y); - else - screen = phys_screen; + client_manage(ev->window, geom_r, phys_screen, false); - client_manage(ev->window, geom_r, phys_screen, screen, false); p_delete(&geom_r); } bailout: - p_delete(&qp_r); p_delete(&wa_r); return ret; }