make a lot of function in event and statusbar creation/handling Xinerama aware

This commit is contained in:
Julien Danjou 2007-09-27 21:22:35 +02:00
parent 2680d34a64
commit 11cbd79c62
2 changed files with 32 additions and 19 deletions

23
event.c
View File

@ -230,6 +230,7 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf)
Client *c;
XConfigureRequestEvent *ev = &e->xconfigurerequest;
XWindowChanges wc;
int real_screen;
if((c = getclient(ev->window)))
{
@ -238,6 +239,10 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf)
c->border = ev->border_width;
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)
c->x = ev->x;
if(ev->value_mask & CWY)
@ -246,10 +251,10 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf)
c->w = ev->width;
if(ev->value_mask & CWHeight)
c->h = ev->height;
if((c->x + c->w) > DisplayWidth(c->display, c->screen) && c->isfloating)
c->x = DisplayWidth(c->display, c->screen) / 2 - c->w / 2; /* center in x direction */
if((c->y + c->h) > DisplayHeight(c->display, c->screen) && c->isfloating)
c->y = DisplayHeight(c->display, c->screen) / 2 - c->h / 2; /* center in y direction */
if((c->x + c->w) > DisplayWidth(c->display, real_screen) && c->isfloating)
c->x = DisplayWidth(c->display, real_screen) / 2 - c->w / 2; /* center in x direction */
if((c->y + c->h) > DisplayHeight(c->display, real_screen) && c->isfloating)
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)))
configure(c);
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)
{
XConfigureEvent *ev = &e->xconfigure;
int screen;
int screen, dummy;
ScreenInfo *si;
for(screen = 0; screen < ScreenCount(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;
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);
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,
DefaultDepth(e->xany.display, screen));
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);
arrange(e->xany.display, &dc[screen], &awesomeconf[screen]);
}

View File

@ -51,6 +51,7 @@ void
drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
{
int x, i;
ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, NULL, &i);
drawcontext->x = drawcontext->y = 0;
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);
x = drawcontext->x + drawcontext->w;
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)
{
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);
if((drawcontext->w = drawcontext->x - x) > awesomeconf->statusbar.height)
@ -99,7 +100,7 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
else
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);
}
@ -107,7 +108,8 @@ void
initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
{
XSetWindowAttributes wa;
int real_screen;
int screen_number, real_screen;
ScreenInfo *si;
statusbar->screen = screen;
@ -116,13 +118,15 @@ initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
else
real_screen = screen;
si = get_screen_info(disp, screen, NULL, &screen_number);
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
wa.cursor = drawcontext->cursor[CurNormal];
wa.override_redirect = 1;
wa.background_pixmap = ParentRelative;
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,
DefaultVisual(disp, real_screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(disp, statusbar->window, drawcontext->cursor[CurNormal]);
@ -130,7 +134,7 @@ initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
XMapRaised(disp, statusbar->window);
statusbar->drawable = XCreatePixmap(disp,
RootWindow(disp, real_screen),
DisplayWidth(disp, real_screen),
si[screen].width,
statusbar->height,
DefaultDepth(disp, real_screen));
}
@ -139,22 +143,22 @@ void
updatebarpos(Display *disp, Statusbar statusbar)
{
XEvent ev;
ScreenInfo *si;
int dummy;
ScreenInfo *si = get_screen_info(disp, statusbar.screen, NULL, &dummy);
switch (statusbar.position)
{
default:
XMoveWindow(disp, statusbar.window, 0, 0);
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].y_org);
break;
case BarBot:
si = get_display_info(disp, statusbar.screen, &statusbar);
XMoveWindow(disp, statusbar.window, 0, si->height);
XFree(si);
XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].height - statusbar.height);
break;
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;
}
XFree(si);
XSync(disp, False);
while(XCheckMaskEvent(disp, EnterWindowMask, &ev));
}