make a lot of function in event and statusbar creation/handling Xinerama aware
This commit is contained in:
parent
2680d34a64
commit
11cbd79c62
23
event.c
23
event.c
|
@ -230,6 +230,7 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf)
|
||||||
Client *c;
|
Client *c;
|
||||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
int real_screen;
|
||||||
|
|
||||||
if((c = getclient(ev->window)))
|
if((c = getclient(ev->window)))
|
||||||
{
|
{
|
||||||
|
@ -238,6 +239,10 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf)
|
||||||
c->border = ev->border_width;
|
c->border = ev->border_width;
|
||||||
if(c->isfixed || c->isfloating || IS_ARRANGE(layout_floating))
|
if(c->isfixed || c->isfloating || IS_ARRANGE(layout_floating))
|
||||||
{
|
{
|
||||||
|
if(XineramaIsActive(c->display))
|
||||||
|
real_screen = DefaultScreen(c->display);
|
||||||
|
else
|
||||||
|
real_screen = c->screen;
|
||||||
if(ev->value_mask & CWX)
|
if(ev->value_mask & CWX)
|
||||||
c->x = ev->x;
|
c->x = ev->x;
|
||||||
if(ev->value_mask & CWY)
|
if(ev->value_mask & CWY)
|
||||||
|
@ -246,10 +251,10 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf)
|
||||||
c->w = ev->width;
|
c->w = ev->width;
|
||||||
if(ev->value_mask & CWHeight)
|
if(ev->value_mask & CWHeight)
|
||||||
c->h = ev->height;
|
c->h = ev->height;
|
||||||
if((c->x + c->w) > DisplayWidth(c->display, c->screen) && c->isfloating)
|
if((c->x + c->w) > DisplayWidth(c->display, real_screen) && c->isfloating)
|
||||||
c->x = DisplayWidth(c->display, c->screen) / 2 - c->w / 2; /* center in x direction */
|
c->x = DisplayWidth(c->display, real_screen) / 2 - c->w / 2; /* center in x direction */
|
||||||
if((c->y + c->h) > DisplayHeight(c->display, c->screen) && c->isfloating)
|
if((c->y + c->h) > DisplayHeight(c->display, real_screen) && c->isfloating)
|
||||||
c->y = DisplayHeight(c->display, c->screen) / 2 - c->h / 2; /* center in y direction */
|
c->y = DisplayHeight(c->display, real_screen) / 2 - c->h / 2; /* center in y direction */
|
||||||
if((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight)))
|
if((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight)))
|
||||||
configure(c);
|
configure(c);
|
||||||
if(isvisible(c, c->screen, awesomeconf[c->screen].tags, awesomeconf[c->screen].ntags))
|
if(isvisible(c, c->screen, awesomeconf[c->screen].tags, awesomeconf[c->screen].ntags))
|
||||||
|
@ -276,7 +281,8 @@ 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;
|
int screen, dummy;
|
||||||
|
ScreenInfo *si;
|
||||||
|
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
||||||
if(ev->window == RootWindow(e->xany.display, screen)
|
if(ev->window == RootWindow(e->xany.display, screen)
|
||||||
|
@ -285,13 +291,16 @@ 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);
|
||||||
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),
|
||||||
DisplayWidth(e->xany.display, screen),
|
si[screen].width,
|
||||||
awesomeconf[screen].statusbar.height,
|
awesomeconf[screen].statusbar.height,
|
||||||
DefaultDepth(e->xany.display, screen));
|
DefaultDepth(e->xany.display, screen));
|
||||||
XResizeWindow(e->xany.display, awesomeconf[screen].statusbar.window,
|
XResizeWindow(e->xany.display, awesomeconf[screen].statusbar.window,
|
||||||
DisplayWidth(e->xany.display, screen), awesomeconf[screen].statusbar.height);
|
si[screen].width, awesomeconf[screen].statusbar.height);
|
||||||
|
XFree(si);
|
||||||
updatebarpos(e->xany.display, awesomeconf[screen].statusbar);
|
updatebarpos(e->xany.display, awesomeconf[screen].statusbar);
|
||||||
arrange(e->xany.display, &dc[screen], &awesomeconf[screen]);
|
arrange(e->xany.display, &dc[screen], &awesomeconf[screen]);
|
||||||
}
|
}
|
||||||
|
|
28
statusbar.c
28
statusbar.c
|
@ -51,6 +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);
|
||||||
|
|
||||||
drawcontext->x = drawcontext->y = 0;
|
drawcontext->x = drawcontext->y = 0;
|
||||||
for(i = 0; i < awesomeconf->ntags; i++)
|
for(i = 0; i < awesomeconf->ntags; i++)
|
||||||
|
@ -74,11 +75,11 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, awesomeconf->current_layout->symbol, drawcontext->norm);
|
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, awesomeconf->current_layout->symbol, drawcontext->norm);
|
||||||
x = drawcontext->x + drawcontext->w;
|
x = drawcontext->x + drawcontext->w;
|
||||||
drawcontext->w = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->statustext, drawcontext->font.height);
|
drawcontext->w = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->statustext, drawcontext->font.height);
|
||||||
drawcontext->x = DisplayWidth(disp, awesomeconf->screen) - drawcontext->w;
|
drawcontext->x = si[awesomeconf->screen].width - drawcontext->w;
|
||||||
if(drawcontext->x < x)
|
if(drawcontext->x < x)
|
||||||
{
|
{
|
||||||
drawcontext->x = x;
|
drawcontext->x = x;
|
||||||
drawcontext->w = DisplayWidth(disp, awesomeconf->screen) - x;
|
drawcontext->w = si[awesomeconf->screen].width - x;
|
||||||
}
|
}
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, awesomeconf->statustext, drawcontext->norm);
|
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, awesomeconf->statustext, drawcontext->norm);
|
||||||
if((drawcontext->w = drawcontext->x - x) > awesomeconf->statusbar.height)
|
if((drawcontext->w = drawcontext->x - x) > awesomeconf->statusbar.height)
|
||||||
|
@ -99,7 +100,7 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
|
||||||
else
|
else
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, NULL, drawcontext->norm);
|
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, NULL, drawcontext->norm);
|
||||||
}
|
}
|
||||||
XCopyArea(disp, awesomeconf->statusbar.drawable, awesomeconf->statusbar.window, drawcontext->gc, 0, 0, DisplayWidth(disp, awesomeconf->screen), awesomeconf->statusbar.height, 0, 0);
|
XCopyArea(disp, awesomeconf->statusbar.drawable, awesomeconf->statusbar.window, drawcontext->gc, 0, 0, si[awesomeconf->screen].width, awesomeconf->statusbar.height, 0, 0);
|
||||||
XSync(disp, False);
|
XSync(disp, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +108,8 @@ void
|
||||||
initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
|
initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
|
||||||
{
|
{
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
int real_screen;
|
int screen_number, real_screen;
|
||||||
|
ScreenInfo *si;
|
||||||
|
|
||||||
statusbar->screen = screen;
|
statusbar->screen = screen;
|
||||||
|
|
||||||
|
@ -116,13 +118,15 @@ initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
|
||||||
else
|
else
|
||||||
real_screen = screen;
|
real_screen = screen;
|
||||||
|
|
||||||
|
si = get_screen_info(disp, screen, NULL, &screen_number);
|
||||||
|
|
||||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
|
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
|
||||||
wa.cursor = drawcontext->cursor[CurNormal];
|
wa.cursor = drawcontext->cursor[CurNormal];
|
||||||
wa.override_redirect = 1;
|
wa.override_redirect = 1;
|
||||||
wa.background_pixmap = ParentRelative;
|
wa.background_pixmap = ParentRelative;
|
||||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||||
statusbar->window = XCreateWindow(disp, RootWindow(disp, screen), 0, 0, DisplayWidth(disp, real_screen),
|
statusbar->window = XCreateWindow(disp, RootWindow(disp, real_screen), 0, 0, si[screen].width,
|
||||||
statusbar->height, 0, DefaultDepth(disp, real_screen), CopyFromParent,
|
statusbar->height, 0, DefaultDepth(disp, real_screen), CopyFromParent,
|
||||||
DefaultVisual(disp, real_screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
DefaultVisual(disp, real_screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||||
XDefineCursor(disp, statusbar->window, drawcontext->cursor[CurNormal]);
|
XDefineCursor(disp, statusbar->window, drawcontext->cursor[CurNormal]);
|
||||||
|
@ -130,7 +134,7 @@ initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
|
||||||
XMapRaised(disp, statusbar->window);
|
XMapRaised(disp, statusbar->window);
|
||||||
statusbar->drawable = XCreatePixmap(disp,
|
statusbar->drawable = XCreatePixmap(disp,
|
||||||
RootWindow(disp, real_screen),
|
RootWindow(disp, real_screen),
|
||||||
DisplayWidth(disp, real_screen),
|
si[screen].width,
|
||||||
statusbar->height,
|
statusbar->height,
|
||||||
DefaultDepth(disp, real_screen));
|
DefaultDepth(disp, real_screen));
|
||||||
}
|
}
|
||||||
|
@ -139,22 +143,22 @@ void
|
||||||
updatebarpos(Display *disp, Statusbar statusbar)
|
updatebarpos(Display *disp, Statusbar statusbar)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
ScreenInfo *si;
|
int dummy;
|
||||||
|
ScreenInfo *si = get_screen_info(disp, statusbar.screen, NULL, &dummy);
|
||||||
|
|
||||||
switch (statusbar.position)
|
switch (statusbar.position)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
XMoveWindow(disp, statusbar.window, 0, 0);
|
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].y_org);
|
||||||
break;
|
break;
|
||||||
case BarBot:
|
case BarBot:
|
||||||
si = get_display_info(disp, statusbar.screen, &statusbar);
|
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].height - statusbar.height);
|
||||||
XMoveWindow(disp, statusbar.window, 0, si->height);
|
|
||||||
XFree(si);
|
|
||||||
break;
|
break;
|
||||||
case BarOff:
|
case BarOff:
|
||||||
XMoveWindow(disp, statusbar.window, 0, 0 - statusbar.height);
|
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].y_org - statusbar.height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
XFree(si);
|
||||||
XSync(disp, False);
|
XSync(disp, False);
|
||||||
while(XCheckMaskEvent(disp, EnterWindowMask, &ev));
|
while(XCheckMaskEvent(disp, EnterWindowMask, &ev));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue