simplify get_screen_info()
This commit is contained in:
parent
2ea22c721c
commit
950605b1a0
2
client.c
2
client.c
|
@ -382,7 +382,7 @@ manage(Display *disp, DC *drawcontext, Window w, XWindowAttributes *wa, awesome_
|
||||||
c->oldborder = wa->border_width;
|
c->oldborder = wa->border_width;
|
||||||
c->display = disp;
|
c->display = disp;
|
||||||
c->phys_screen = get_phys_screen(c->display, c->screen);
|
c->phys_screen = get_phys_screen(c->display, c->screen);
|
||||||
screen_info = get_screen_info(c->display, c->screen, NULL, &i);
|
screen_info = get_screen_info(c->display, c->screen, NULL);
|
||||||
if(c->w == screen_info[c->screen].width && c->h == screen_info[c->screen].height)
|
if(c->w == screen_info[c->screen].width && c->h == screen_info[c->screen].height)
|
||||||
{
|
{
|
||||||
c->x = 0;
|
c->x = 0;
|
||||||
|
|
6
event.c
6
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, NULL, &x1);
|
si = get_screen_info(c->display, c->screen, NULL);
|
||||||
|
|
||||||
ocx = nx = c->x;
|
ocx = nx = c->x;
|
||||||
ocy = ny = c->y;
|
ocy = ny = c->y;
|
||||||
|
@ -271,7 +271,7 @@ void
|
||||||
handle_event_configurenotify(XEvent * e, awesome_config *awesomeconf)
|
handle_event_configurenotify(XEvent * e, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
XConfigureEvent *ev = &e->xconfigure;
|
XConfigureEvent *ev = &e->xconfigure;
|
||||||
int screen, dummy;
|
int screen;
|
||||||
ScreenInfo *si;
|
ScreenInfo *si;
|
||||||
|
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
||||||
|
@ -282,7 +282,7 @@ handle_event_configurenotify(XEvent * e, awesome_config *awesomeconf)
|
||||||
DisplayWidth(e->xany.display, screen) = ev->width;
|
DisplayWidth(e->xany.display, screen) = ev->width;
|
||||||
DisplayHeight(e->xany.display, screen) = ev->height;
|
DisplayHeight(e->xany.display, screen) = ev->height;
|
||||||
|
|
||||||
si = get_screen_info(e->xany.display, screen, NULL, &dummy);
|
si = get_screen_info(e->xany.display, screen, NULL);
|
||||||
XFreePixmap(e->xany.display, awesomeconf[screen].statusbar.drawable);
|
XFreePixmap(e->xany.display, awesomeconf[screen].statusbar.drawable);
|
||||||
awesomeconf[screen].statusbar.drawable = XCreatePixmap(e->xany.display, RootWindow(e->xany.display, screen),
|
awesomeconf[screen].statusbar.drawable = XCreatePixmap(e->xany.display, RootWindow(e->xany.display, screen),
|
||||||
si[screen].width,
|
si[screen].width,
|
||||||
|
|
9
layout.c
9
layout.c
|
@ -224,8 +224,7 @@ uicb_togglemax(Display *disp,
|
||||||
awesome_config *awesomeconf,
|
awesome_config *awesomeconf,
|
||||||
const char *arg __attribute__ ((unused)))
|
const char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int dummy;
|
ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, &awesomeconf->statusbar);
|
||||||
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,
|
||||||
|
@ -240,8 +239,7 @@ uicb_toggleverticalmax(Display *disp,
|
||||||
awesome_config *awesomeconf,
|
awesome_config *awesomeconf,
|
||||||
const char *arg __attribute__ ((unused)))
|
const char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int dummy;
|
ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, &awesomeconf->statusbar);
|
||||||
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,
|
||||||
|
@ -257,8 +255,7 @@ uicb_togglehorizontalmax(Display *disp,
|
||||||
awesome_config *awesomeconf,
|
awesome_config *awesomeconf,
|
||||||
const char *arg __attribute__ ((unused)))
|
const char *arg __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int dummy;
|
ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, &awesomeconf->statusbar);
|
||||||
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,
|
||||||
|
|
|
@ -30,8 +30,7 @@ void
|
||||||
layout_max(Display *disp, awesome_config *awesomeconf)
|
layout_max(Display *disp, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
int screen_number = 0;
|
ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, &awesomeconf->statusbar);
|
||||||
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))
|
||||||
|
|
|
@ -101,12 +101,11 @@ _tile(Display *disp, awesome_config *awesomeconf, const Bool right)
|
||||||
/* master size */
|
/* master size */
|
||||||
unsigned int mw = 0, mh = 0;
|
unsigned int mw = 0, mh = 0;
|
||||||
int n, i, masterwin = 0, otherwin = 0;
|
int n, i, masterwin = 0, otherwin = 0;
|
||||||
int screen_numbers = 1;
|
|
||||||
int real_ncols = 1, win_by_col = 1, current_col = 0;
|
int real_ncols = 1, win_by_col = 1, current_col = 0;
|
||||||
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);
|
||||||
|
|
||||||
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))
|
||||||
|
|
25
screen.c
25
screen.c
|
@ -34,30 +34,26 @@ 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 i, fake_screen_number = 0;
|
int i, screen_number = 0;
|
||||||
ScreenInfo *si;
|
ScreenInfo *si;
|
||||||
|
|
||||||
if(XineramaIsActive(disp))
|
if(XineramaIsActive(disp))
|
||||||
{
|
si = XineramaQueryScreens(disp, &screen_number);
|
||||||
si = XineramaQueryScreens(disp, screen_number);
|
|
||||||
fake_screen_number = *screen_number;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* emulate Xinerama info but only fill the screen we want */
|
/* emulate Xinerama info but only fill the screen we want */
|
||||||
*screen_number = 1;
|
|
||||||
si = p_new(ScreenInfo, screen + 1);
|
si = p_new(ScreenInfo, screen + 1);
|
||||||
si[screen].width = DisplayWidth(disp, screen);
|
si[screen].width = DisplayWidth(disp, screen);
|
||||||
si[screen].height = DisplayHeight(disp, screen);
|
si[screen].height = DisplayHeight(disp, screen);
|
||||||
si[screen].x_org = 0;
|
si[screen].x_org = 0;
|
||||||
si[screen].y_org = 0;
|
si[screen].y_org = 0;
|
||||||
fake_screen_number = screen + 1;
|
screen_number = screen + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(statusbar)
|
if(statusbar)
|
||||||
for(i = 0; i < fake_screen_number; i++)
|
for(i = 0; i < screen_number; i++)
|
||||||
{
|
{
|
||||||
if(statusbar->position == BarTop
|
if(statusbar->position == BarTop
|
||||||
|| statusbar->position == BarBot)
|
|| statusbar->position == BarBot)
|
||||||
|
@ -101,15 +97,15 @@ int
|
||||||
get_screen_bycoord(Display *disp, int x, int y)
|
get_screen_bycoord(Display *disp, int x, int y)
|
||||||
{
|
{
|
||||||
ScreenInfo *si;
|
ScreenInfo *si;
|
||||||
int screen_number, i;
|
int i;
|
||||||
|
|
||||||
/* don't waste our time */
|
/* don't waste our time */
|
||||||
if(!XineramaIsActive(disp))
|
if(!XineramaIsActive(disp))
|
||||||
return DefaultScreen(disp);
|
return DefaultScreen(disp);
|
||||||
|
|
||||||
si = get_screen_info(disp, 0, NULL, &screen_number);
|
si = get_screen_info(disp, 0, NULL);
|
||||||
|
|
||||||
for(i = 0; i < screen_number; i++)
|
for(i = 0; i < get_screen_count(disp); i++)
|
||||||
if(x >= si[i].x_org && x < si[i].x_org + si[i].width
|
if(x >= si[i].x_org && x < si[i].x_org + si[i].width
|
||||||
&& y >= si[i].y_org && y < si[i].y_org + si[i].height)
|
&& y >= si[i].y_org && y < si[i].y_org + si[i].height)
|
||||||
{
|
{
|
||||||
|
@ -163,7 +159,7 @@ move_client_to_screen(Client *c, awesome_config *acf_new, Bool doresize)
|
||||||
for(i = 0; i < acf_new->ntags; i++)
|
for(i = 0; i < acf_new->ntags; i++)
|
||||||
c->tags[i] = acf_new->tags[i].selected;
|
c->tags[i] = acf_new->tags[i].selected;
|
||||||
|
|
||||||
si = get_screen_info(c->display, c->screen, &acf_new->statusbar, &i);
|
si = get_screen_info(c->display, c->screen, &acf_new->statusbar);
|
||||||
c->rx = si[c->screen].x_org;
|
c->rx = si[c->screen].x_org;
|
||||||
c->ry = si[c->screen].y_org;
|
c->ry = si[c->screen].y_org;
|
||||||
if(doresize)
|
if(doresize)
|
||||||
|
@ -176,8 +172,7 @@ move_mouse_pointer_to_screen(Display *disp, int screen)
|
||||||
{
|
{
|
||||||
if(XineramaIsActive(disp))
|
if(XineramaIsActive(disp))
|
||||||
{
|
{
|
||||||
int dummy;
|
ScreenInfo *si = get_screen_info(disp, screen, NULL);
|
||||||
ScreenInfo *si = get_screen_info(disp, screen, NULL, &dummy);
|
|
||||||
XWarpPointer(disp, None, DefaultRootWindow(disp), 0, 0, 0, 0, si[screen].x_org, si[screen].y_org);
|
XWarpPointer(disp, None, DefaultRootWindow(disp), 0, 0, 0, 0, si[screen].x_org, si[screen].y_org);
|
||||||
XFree(si);
|
XFree(si);
|
||||||
}
|
}
|
||||||
|
|
2
screen.h
2
screen.h
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
typedef XineramaScreenInfo ScreenInfo;
|
typedef XineramaScreenInfo ScreenInfo;
|
||||||
|
|
||||||
ScreenInfo * get_screen_info(Display *, int, Statusbar *, int *);
|
ScreenInfo * get_screen_info(Display *, int, Statusbar *);
|
||||||
ScreenInfo * get_display_info(Display *, int, Statusbar *);
|
ScreenInfo * get_display_info(Display *, int, Statusbar *);
|
||||||
int get_screen_bycoord(Display *, int, int);
|
int get_screen_bycoord(Display *, int, int);
|
||||||
int get_screen_count(Display *);
|
int get_screen_count(Display *);
|
||||||
|
|
|
@ -51,7 +51,7 @@ void
|
||||||
drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
|
drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
|
||||||
{
|
{
|
||||||
int x, i;
|
int x, i;
|
||||||
ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, NULL, &i);
|
ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, NULL);
|
||||||
|
|
||||||
drawcontext->x = drawcontext->y = 0;
|
drawcontext->x = drawcontext->y = 0;
|
||||||
for(i = 0; i < awesomeconf->ntags; i++)
|
for(i = 0; i < awesomeconf->ntags; i++)
|
||||||
|
@ -108,14 +108,14 @@ void
|
||||||
initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
|
initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
|
||||||
{
|
{
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
int screen_number, phys_screen;
|
int phys_screen;
|
||||||
ScreenInfo *si;
|
ScreenInfo *si;
|
||||||
|
|
||||||
phys_screen = get_phys_screen(disp, screen);
|
phys_screen = get_phys_screen(disp, screen);
|
||||||
|
|
||||||
statusbar->screen = screen;
|
statusbar->screen = screen;
|
||||||
|
|
||||||
si = get_screen_info(disp, screen, NULL, &screen_number);
|
si = get_screen_info(disp, screen, NULL);
|
||||||
|
|
||||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
|
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
|
||||||
|
@ -140,8 +140,7 @@ void
|
||||||
updatebarpos(Display *disp, Statusbar statusbar)
|
updatebarpos(Display *disp, Statusbar statusbar)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
int dummy;
|
ScreenInfo *si = get_screen_info(disp, statusbar.screen, NULL);
|
||||||
ScreenInfo *si = get_screen_info(disp, statusbar.screen, NULL, &dummy);
|
|
||||||
|
|
||||||
switch (statusbar.position)
|
switch (statusbar.position)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue