introduce get_xinerama_screen_bycoord(...)
this allows to retrieve the xinerama screen of a client with its coordinates
This commit is contained in:
parent
486dd410ca
commit
ca16334351
2
client.h
2
client.h
|
@ -54,7 +54,7 @@ struct Client
|
||||||
Window win;
|
Window win;
|
||||||
/** Client display */
|
/** Client display */
|
||||||
Display *display;
|
Display *display;
|
||||||
/** Client screen */
|
/** Client screen (Zaphod) */
|
||||||
int screen;
|
int screen;
|
||||||
/** First time viewed on new layout */
|
/** First time viewed on new layout */
|
||||||
Bool ftview;
|
Bool ftview;
|
||||||
|
|
2
event.c
2
event.c
|
@ -60,7 +60,7 @@ movemouse(Client * c, awesome_config *awesomeconf)
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
ScreenInfo *si;
|
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;
|
ocx = nx = c->x;
|
||||||
ocy = ny = c->y;
|
ocy = ny = c->y;
|
||||||
|
|
6
layout.c
6
layout.c
|
@ -225,7 +225,7 @@ uicb_togglemax(Display *disp,
|
||||||
const char *arg __attribute__ ((unused)))
|
const char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int dummy;
|
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,
|
maximize(si[awesomeconf->screen].x_org, si[awesomeconf->screen].y_org,
|
||||||
si[awesomeconf->screen].width - 2 * awesomeconf->borderpx,
|
si[awesomeconf->screen].width - 2 * awesomeconf->borderpx,
|
||||||
|
@ -241,7 +241,7 @@ uicb_toggleverticalmax(Display *disp,
|
||||||
const char *arg __attribute__ ((unused)))
|
const char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int dummy;
|
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)
|
if(sel)
|
||||||
maximize(sel->x, si[awesomeconf->screen].y_org,
|
maximize(sel->x, si[awesomeconf->screen].y_org,
|
||||||
|
@ -258,7 +258,7 @@ uicb_togglehorizontalmax(Display *disp,
|
||||||
const char *arg __attribute__ ((unused)))
|
const char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int dummy;
|
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)
|
if(sel)
|
||||||
maximize(si[awesomeconf->screen].x_org, sel->y,
|
maximize(si[awesomeconf->screen].x_org, sel->y,
|
||||||
|
|
|
@ -31,7 +31,7 @@ layout_max(Display *disp, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
int screen_number = 0, use_screen = 0;
|
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)
|
for(c = clients; c; c = c->next)
|
||||||
if(IS_TILED(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags))
|
if(IS_TILED(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags))
|
||||||
|
|
|
@ -93,7 +93,7 @@ _tile(Display *disp, awesome_config *awesomeconf, const Bool right)
|
||||||
ScreenInfo *screens_info = NULL;
|
ScreenInfo *screens_info = NULL;
|
||||||
Client *c;
|
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)
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
if(IS_TILED(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags))
|
if(IS_TILED(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags))
|
||||||
|
|
43
screen.c
43
screen.c
|
@ -34,7 +34,7 @@ extern Client *sel, *clients;
|
||||||
* \return ScreenInfo struct array with all screens info
|
* \return ScreenInfo struct array with all screens info
|
||||||
*/
|
*/
|
||||||
ScreenInfo *
|
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;
|
int i, fake_screen_number = 0;
|
||||||
ScreenInfo *si;
|
ScreenInfo *si;
|
||||||
|
@ -56,13 +56,14 @@ get_screen_info(Display *disp, int screen, Statusbar statusbar, int *screen_numb
|
||||||
fake_screen_number = screen + 1;
|
fake_screen_number = screen + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(statusbar)
|
||||||
for(i = 0; i < fake_screen_number; i++)
|
for(i = 0; i < fake_screen_number; i++)
|
||||||
{
|
{
|
||||||
if(statusbar.position == BarTop
|
if(statusbar->position == BarTop
|
||||||
|| statusbar.position == BarBot)
|
|| statusbar->position == BarBot)
|
||||||
si[i].height -= statusbar.height;
|
si[i].height -= statusbar->height;
|
||||||
if(statusbar.position == BarTop)
|
if(statusbar->position == BarTop)
|
||||||
si[i].y_org += statusbar.height;
|
si[i].y_org += statusbar->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
return si;
|
return si;
|
||||||
|
@ -90,6 +91,36 @@ get_display_info(Display *disp, int screen, Statusbar statusbar)
|
||||||
return si;
|
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
|
void
|
||||||
uicb_focusnextscreen(Display *disp,
|
uicb_focusnextscreen(Display *disp,
|
||||||
DC *drawcontext,
|
DC *drawcontext,
|
||||||
|
|
5
screen.h
5
screen.h
|
@ -28,8 +28,9 @@
|
||||||
|
|
||||||
typedef XineramaScreenInfo ScreenInfo;
|
typedef XineramaScreenInfo ScreenInfo;
|
||||||
|
|
||||||
ScreenInfo * get_screen_info(Display *, int, Statusbar, int *);
|
ScreenInfo * get_screen_info(Display *, int, Statusbar *, int *);
|
||||||
ScreenInfo * get_display_info(Display *disp, int, Statusbar statusbar);
|
ScreenInfo * get_display_info(Display *, int, Statusbar);
|
||||||
|
int get_screen_bycoord(Display *, int, int);
|
||||||
UICB_PROTO(uicb_focusnextscreen);
|
UICB_PROTO(uicb_focusnextscreen);
|
||||||
UICB_PROTO(uicb_focusprevscreen);
|
UICB_PROTO(uicb_focusprevscreen);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue