introduce get_xinerama_screen_bycoord(...)

this allows to retrieve the xinerama screen of a client with its coordinates
This commit is contained in:
Julien Danjou 2007-09-27 15:07:07 +02:00
parent 486dd410ca
commit ca16334351
7 changed files with 50 additions and 18 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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))

View File

@ -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))

View File

@ -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,13 +56,14 @@ get_screen_info(Display *disp, int screen, Statusbar statusbar, int *screen_numb
fake_screen_number = screen + 1;
}
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;
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,

View File

@ -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);