diff --git a/client.h b/client.h index 586e57cf2..e0e0af7dd 100644 --- a/client.h +++ b/client.h @@ -54,7 +54,7 @@ struct Client Window win; /** Client display */ Display *display; - /** Client screen */ + /** Client screen (Zaphod) */ int screen; /** First time viewed on new layout */ Bool ftview; diff --git a/event.c b/event.c index e4465862c..77de84f1d 100644 --- a/event.c +++ b/event.c @@ -60,7 +60,7 @@ movemouse(Client * c, awesome_config *awesomeconf) XEvent ev; ScreenInfo *si; - si = get_screen_info(c->display, c->screen, awesomeconf->statusbar, &x1); + si = get_screen_info(c->display, c->screen, &awesomeconf->statusbar, &x1); ocx = nx = c->x; ocy = ny = c->y; diff --git a/layout.c b/layout.c index fa3c955cf..a4cbc7443 100644 --- a/layout.c +++ b/layout.c @@ -225,7 +225,7 @@ uicb_togglemax(Display *disp, const char *arg __attribute__ ((unused))) { int dummy; - ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, awesomeconf->statusbar, &dummy); + ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, &awesomeconf->statusbar, &dummy); maximize(si[awesomeconf->screen].x_org, si[awesomeconf->screen].y_org, si[awesomeconf->screen].width - 2 * awesomeconf->borderpx, @@ -241,7 +241,7 @@ uicb_toggleverticalmax(Display *disp, const char *arg __attribute__ ((unused))) { int dummy; - ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, awesomeconf->statusbar, &dummy); + ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, &awesomeconf->statusbar, &dummy); if(sel) maximize(sel->x, si[awesomeconf->screen].y_org, @@ -258,7 +258,7 @@ uicb_togglehorizontalmax(Display *disp, const char *arg __attribute__ ((unused))) { int dummy; - ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, awesomeconf->statusbar, &dummy); + ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, &awesomeconf->statusbar, &dummy); if(sel) maximize(si[awesomeconf->screen].x_org, sel->y, diff --git a/layouts/max.c b/layouts/max.c index 011d3b8c9..ac2bc0952 100644 --- a/layouts/max.c +++ b/layouts/max.c @@ -31,7 +31,7 @@ layout_max(Display *disp, awesome_config *awesomeconf) { Client *c; int screen_number = 0, use_screen = 0; - ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, awesomeconf->statusbar, &screen_number); + ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, &awesomeconf->statusbar, &screen_number); for(c = clients; c; c = c->next) if(IS_TILED(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags)) diff --git a/layouts/tile.c b/layouts/tile.c index b38f92d19..d75249d8d 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -93,7 +93,7 @@ _tile(Display *disp, awesome_config *awesomeconf, const Bool right) ScreenInfo *screens_info = NULL; Client *c; - screens_info = get_screen_info(disp, awesomeconf->screen, awesomeconf->statusbar, &screen_numbers); + screens_info = get_screen_info(disp, awesomeconf->screen, &awesomeconf->statusbar, &screen_numbers); for(n = 0, c = clients; c; c = c->next) if(IS_TILED(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags)) diff --git a/screen.c b/screen.c index a798c1092..7f210fadf 100644 --- a/screen.c +++ b/screen.c @@ -34,7 +34,7 @@ extern Client *sel, *clients; * \return ScreenInfo struct array with all screens info */ ScreenInfo * -get_screen_info(Display *disp, int screen, Statusbar statusbar, int *screen_number) +get_screen_info(Display *disp, int screen, Statusbar *statusbar, int *screen_number) { int i, fake_screen_number = 0; ScreenInfo *si; @@ -56,14 +56,15 @@ get_screen_info(Display *disp, int screen, Statusbar statusbar, int *screen_numb fake_screen_number = screen + 1; } - for(i = 0; i < fake_screen_number; i++) - { - if(statusbar.position == BarTop - || statusbar.position == BarBot) - si[i].height -= statusbar.height; - if(statusbar.position == BarTop) - si[i].y_org += statusbar.height; - } + if(statusbar) + for(i = 0; i < fake_screen_number; i++) + { + if(statusbar->position == BarTop + || statusbar->position == BarBot) + si[i].height -= statusbar->height; + if(statusbar->position == BarTop) + si[i].y_org += statusbar->height; + } return si; } @@ -90,6 +91,36 @@ get_display_info(Display *disp, int screen, Statusbar statusbar) return si; } +/** Return the Xinerama screen number where the window is placed + * \param disp Display ref + * \param x x coordinate of the window + * \param y y coordinate of the window + * \return screen number or -1 on no match + */ +int +get_screen_bycoord(Display *disp, int x, int y) +{ + ScreenInfo *si; + int screen_number, i; + + /* don't waste our time */ + if(!XineramaIsActive(disp)) + return 0; + + si = get_screen_info(disp, 0, NULL, &screen_number); + + for(i = 0; i < screen_number; i++) + if(x >= si[i].x_org && x <= si[i].x_org + si[i].width + && y >= si[i].y_org && y <= si[i].x_org + si[i].height) + { + XFree(si); + return i; + } + + XFree(si); + return -1; +} + void uicb_focusnextscreen(Display *disp, DC *drawcontext, diff --git a/screen.h b/screen.h index 574f7df99..994116e98 100644 --- a/screen.h +++ b/screen.h @@ -28,8 +28,9 @@ typedef XineramaScreenInfo ScreenInfo; -ScreenInfo * get_screen_info(Display *, int, Statusbar, int *); -ScreenInfo * get_display_info(Display *disp, int, Statusbar statusbar); +ScreenInfo * get_screen_info(Display *, int, Statusbar *, int *); +ScreenInfo * get_display_info(Display *, int, Statusbar); +int get_screen_bycoord(Display *, int, int); UICB_PROTO(uicb_focusnextscreen); UICB_PROTO(uicb_focusprevscreen);