From ecf79693a2189f5d823df483325b30a79a67d278 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 27 Sep 2007 17:12:51 +0200 Subject: [PATCH] use real_screen for X functions, not logical screen --- awesome.c | 14 ++++++++++---- config.c | 7 ++++++- statusbar.c | 18 ++++++++++++------ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/awesome.c b/awesome.c index 9766c793..a6b0c746 100644 --- a/awesome.c +++ b/awesome.c @@ -177,6 +177,12 @@ static void setup(Display *disp, int screen, DC *drawcontext, awesome_config *awesomeconf) { XSetWindowAttributes wa; + int real_screen; + + if(XineramaIsActive(disp)) + real_screen = DefaultScreen(disp); + else + real_screen = screen; /* init cursors */ 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; 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); /* bar */ drawcontext->h = awesomeconf->statusbar.height = drawcontext->font.height + 2; 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); if(!drawcontext->font.set) diff --git a/config.c b/config.c index 439b2697..49117ae1 100644 --- a/config.c +++ b/config.c @@ -496,7 +496,12 @@ get_numlockmask(Display *disp) static unsigned long 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; if(!XAllocNamedColor(disp, cmap, colstr, &color, &color)) die("awesome: error, cannot allocate color '%s'\n", colstr); diff --git a/statusbar.c b/statusbar.c index 6ab6296e..d5be960d 100644 --- a/statusbar.c +++ b/statusbar.c @@ -107,26 +107,32 @@ void initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar) { XSetWindowAttributes wa; + int real_screen; statusbar->screen = screen; + if(XineramaIsActive(disp)) + real_screen = DefaultScreen(disp); + else + real_screen = screen; + 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, screen), - statusbar->height, 0, DefaultDepth(disp, screen), CopyFromParent, - DefaultVisual(disp, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); + statusbar->window = XCreateWindow(disp, RootWindow(disp, screen), 0, 0, DisplayWidth(disp, real_screen), + statusbar->height, 0, DefaultDepth(disp, real_screen), CopyFromParent, + DefaultVisual(disp, real_screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); XDefineCursor(disp, statusbar->window, drawcontext->cursor[CurNormal]); updatebarpos(disp, *statusbar); XMapRaised(disp, statusbar->window); statusbar->drawable = XCreatePixmap(disp, - RootWindow(disp, screen), - DisplayWidth(disp, screen), + RootWindow(disp, real_screen), + DisplayWidth(disp, real_screen), statusbar->height, - DefaultDepth(disp, screen)); + DefaultDepth(disp, real_screen)); } void