use real_screen for X functions, not logical screen

This commit is contained in:
Julien Danjou 2007-09-27 17:12:51 +02:00
parent bdd408cd6c
commit ecf79693a2
3 changed files with 28 additions and 11 deletions

View File

@ -177,6 +177,12 @@ static void
setup(Display *disp, int screen, DC *drawcontext, awesome_config *awesomeconf) setup(Display *disp, int screen, DC *drawcontext, awesome_config *awesomeconf)
{ {
XSetWindowAttributes wa; XSetWindowAttributes wa;
int real_screen;
if(XineramaIsActive(disp))
real_screen = DefaultScreen(disp);
else
real_screen = screen;
/* init cursors */ /* init cursors */
drawcontext->cursor[CurNormal] = XCreateFontCursor(disp, XC_left_ptr); drawcontext->cursor[CurNormal] = XCreateFontCursor(disp, XC_left_ptr);
@ -188,18 +194,18 @@ setup(Display *disp, int screen, DC *drawcontext, awesome_config *awesomeconf)
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask; | EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
wa.cursor = drawcontext->cursor[CurNormal]; wa.cursor = drawcontext->cursor[CurNormal];
XChangeWindowAttributes(disp, RootWindow(disp, screen), CWEventMask | CWCursor, &wa); XChangeWindowAttributes(disp, RootWindow(disp, real_screen), CWEventMask | CWCursor, &wa);
XSelectInput(disp, RootWindow(disp, screen), wa.event_mask); XSelectInput(disp, RootWindow(disp, real_screen), wa.event_mask);
grabkeys(disp, screen, awesomeconf); grabkeys(disp, real_screen, awesomeconf);
compileregs(awesomeconf->rules, awesomeconf->nrules); compileregs(awesomeconf->rules, awesomeconf->nrules);
/* bar */ /* bar */
drawcontext->h = awesomeconf->statusbar.height = drawcontext->font.height + 2; drawcontext->h = awesomeconf->statusbar.height = drawcontext->font.height + 2;
initstatusbar(disp, screen, drawcontext, &awesomeconf->statusbar); initstatusbar(disp, screen, drawcontext, &awesomeconf->statusbar);
drawcontext->gc = XCreateGC(disp, RootWindow(disp, screen), 0, 0); drawcontext->gc = XCreateGC(disp, RootWindow(disp, real_screen), 0, 0);
XSetLineAttributes(disp, drawcontext->gc, 1, LineSolid, CapButt, JoinMiter); XSetLineAttributes(disp, drawcontext->gc, 1, LineSolid, CapButt, JoinMiter);
if(!drawcontext->font.set) if(!drawcontext->font.set)

View File

@ -496,7 +496,12 @@ get_numlockmask(Display *disp)
static unsigned long static unsigned long
initcolor(Display *disp, int scr, const char *colstr) initcolor(Display *disp, int scr, const char *colstr)
{ {
Colormap cmap = DefaultColormap(disp, scr); Colormap cmap;
/* bypass screen if scr is a Xinerama screen number */
if(XineramaIsActive(disp))
cmap = DefaultColormap(disp, DefaultScreen(disp));
else
cmap = DefaultColormap(disp, scr);
XColor color; XColor color;
if(!XAllocNamedColor(disp, cmap, colstr, &color, &color)) if(!XAllocNamedColor(disp, cmap, colstr, &color, &color))
die("awesome: error, cannot allocate color '%s'\n", colstr); die("awesome: error, cannot allocate color '%s'\n", colstr);

View File

@ -107,26 +107,32 @@ 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;
statusbar->screen = screen; statusbar->screen = screen;
if(XineramaIsActive(disp))
real_screen = DefaultScreen(disp);
else
real_screen = screen;
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, screen), statusbar->window = XCreateWindow(disp, RootWindow(disp, screen), 0, 0, DisplayWidth(disp, real_screen),
statusbar->height, 0, DefaultDepth(disp, screen), CopyFromParent, statusbar->height, 0, DefaultDepth(disp, real_screen), CopyFromParent,
DefaultVisual(disp, 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]);
updatebarpos(disp, *statusbar); updatebarpos(disp, *statusbar);
XMapRaised(disp, statusbar->window); XMapRaised(disp, statusbar->window);
statusbar->drawable = XCreatePixmap(disp, statusbar->drawable = XCreatePixmap(disp,
RootWindow(disp, screen), RootWindow(disp, real_screen),
DisplayWidth(disp, screen), DisplayWidth(disp, real_screen),
statusbar->height, statusbar->height,
DefaultDepth(disp, screen)); DefaultDepth(disp, real_screen));
} }
void void