diff --git a/awesome.c b/awesome.c index 046b08b4..7a7cdd2d 100644 --- a/awesome.c +++ b/awesome.c @@ -38,6 +38,7 @@ #include "dbus.h" #include "systray.h" #include "event.h" +#include "screen.h" #include "common/version.h" #include "common/atoms.h" #include "config.h" @@ -170,8 +171,7 @@ scan(void) *(geom_wins[i]), NULL))) continue; - screen = screen_get_bycoord(globalconf.screens_info, phys_screen, - geom_r->x, geom_r->y); + screen = screen_getbycoord(phys_screen, geom_r->x, geom_r->y); client_manage(wins[i], geom_r, phys_screen, screen); diff --git a/client.c b/client.c index e414e639..0ec69f89 100644 --- a/client.c +++ b/client.c @@ -420,7 +420,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, c = p_new(client_t, 1); - c->screen = screen_get_bycoord(globalconf.screens_info, screen, wgeom->x, wgeom->y); + c->screen = screen_getbycoord(screen, wgeom->x, wgeom->y); c->phys_screen = phys_screen; @@ -567,8 +567,7 @@ client_resize(client_t *c, area_t geometry, bool hints) || c->geometry.width != geometry.width || c->geometry.height != geometry.height))) { - new_screen = - screen_get_bycoord(globalconf.screens_info, c->screen, geometry.x, geometry.y); + new_screen = screen_getbycoord(c->screen, geometry.x, geometry.y); c->geometry.x = values[0] = geometry.x; c->geometry.width = values[2] = geometry.width; diff --git a/common/xscreen.c b/common/xscreen.c index 48a38ec2..5bb67dcf 100644 --- a/common/xscreen.c +++ b/common/xscreen.c @@ -25,30 +25,6 @@ #include "common/xscreen.h" #include "common/xutil.h" -/** Return the Xinerama screen number where the coordinates belongs to. - * \param si The screens infos structure. - * \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. - */ -int -screen_get_bycoord(screens_info_t *si, int screen, int x, int y) -{ - int i; - - /* don't waste our time */ - if(!si->xinerama_is_active) - return screen; - - for(i = 0; i < si->nscreen; i++) - if((x < 0 || (x >= si->geometry[i].x && x < si->geometry[i].x + si->geometry[i].width)) - && (y < 0 || (y >= si->geometry[i].y && y < si->geometry[i].y + si->geometry[i].height))) - return i; - - return screen; -} - static inline area_t screen_xsitoarea(xcb_xinerama_screen_info_t si) { diff --git a/common/xscreen.h b/common/xscreen.h index b5445773..2e6d83d1 100644 --- a/common/xscreen.h +++ b/common/xscreen.h @@ -31,7 +31,6 @@ typedef struct area_t *geometry; } screens_info_t; -int screen_get_bycoord(screens_info_t *, int, int, int); void screensinfo_delete(screens_info_t **); screens_info_t * screensinfo_new(xcb_connection_t *); diff --git a/event.c b/event.c index 107b7dd5..40c17929 100644 --- a/event.c +++ b/event.c @@ -38,6 +38,7 @@ #include "lua.h" #include "systray.h" #include "statusbar.h" +#include "screen.h" #include "layouts/floating.h" #include "common/atoms.h" @@ -610,8 +611,7 @@ event_handle_maprequest(void *data __attribute__ ((unused)), if(globalconf.screens_info->xinerama_is_active && (qp_r = xcb_query_pointer_reply(connection, qp_c, NULL))) - screen = screen_get_bycoord(globalconf.screens_info, screen, - qp_r->root_x, qp_r->root_y); + screen = screen_getbycoord(screen, qp_r->root_x, qp_r->root_y); else screen = phys_screen; diff --git a/mouse.c b/mouse.c index 8a279774..a556a590 100644 --- a/mouse.c +++ b/mouse.c @@ -540,8 +540,7 @@ mouse_client_move(client_t *c, int snap, bool infobox) client_t *target; /* client moved to another screen? */ - newscreen = screen_get_bycoord(globalconf.screens_info, c->screen, - mouse_x, mouse_y); + newscreen = screen_getbycoord(c->screen, mouse_x, mouse_y); if(newscreen != c->screen) { screen_client_moveto(c, newscreen, true); @@ -1188,7 +1187,7 @@ luaA_mouse_index(lua_State *L) if(!mouse_query_pointer_root(&screen, &mouse_x, &mouse_y, NULL)) return 0; - i = screen_get_bycoord(globalconf.screens_info, screen, mouse_x, mouse_y); + i = screen_getbycoord(screen, mouse_x, mouse_y); lua_pushnumber(L, i + 1); break; diff --git a/screen.c b/screen.c index 01a9e23d..53b4d2a4 100644 --- a/screen.c +++ b/screen.c @@ -32,6 +32,30 @@ extern awesome_t globalconf; +/** 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. + */ +int +screen_getbycoord(int screen, int x, int y) +{ + int i; + screens_info_t *si = globalconf.screens_info; + + /* don't waste our time */ + if(!si->xinerama_is_active) + return screen; + + for(i = 0; i < si->nscreen; i++) + if((x < 0 || (x >= si->geometry[i].x && x < si->geometry[i].x + si->geometry[i].width)) + && (y < 0 || (y >= si->geometry[i].y && y < si->geometry[i].y + si->geometry[i].height))) + return i; + + return screen; +} + /** Get screens info. * \param screen Screen number. * \param statusbar Statusbar list to remove. diff --git a/screen.h b/screen.h index 6c24aec8..6883f1af 100644 --- a/screen.h +++ b/screen.h @@ -26,6 +26,7 @@ #define SCREEN_UNDEF (-1) +int screen_getbycoord(int, int, int); area_t screen_area_get(int, statusbar_t *, padding_t *, bool); area_t display_area_get(int, statusbar_t *, padding_t *); int screen_virttophys(int);