store phys_screen

This commit is contained in:
Julien Danjou 2007-10-01 15:23:05 +02:00
parent bdeb1eaca4
commit 8c531e2a81
9 changed files with 47 additions and 47 deletions

View File

@ -189,7 +189,7 @@ 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 = get_real_screen(disp, screen); int phys_screen = get_phys_screen(disp, screen);
/* init cursors */ /* init cursors */
drawcontext->cursor[CurNormal] = XCreateFontCursor(disp, XC_left_ptr); drawcontext->cursor[CurNormal] = XCreateFontCursor(disp, XC_left_ptr);
@ -201,18 +201,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, real_screen), CWEventMask | CWCursor, &wa); XChangeWindowAttributes(disp, RootWindow(disp, phys_screen), CWEventMask | CWCursor, &wa);
XSelectInput(disp, RootWindow(disp, real_screen), wa.event_mask); XSelectInput(disp, RootWindow(disp, phys_screen), wa.event_mask);
grabkeys(disp, real_screen, awesomeconf); grabkeys(disp, phys_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, real_screen), 0, 0); drawcontext->gc = XCreateGC(disp, RootWindow(disp, phys_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

@ -67,8 +67,6 @@ detachstack(Client * c)
static void static void
grabbuttons(Client * c, Bool focused, KeySym modkey, unsigned int numlockmask) grabbuttons(Client * c, Bool focused, KeySym modkey, unsigned int numlockmask)
{ {
int real_screen = get_real_screen(c->display, c->screen);
XUngrabButton(c->display, AnyButton, AnyModifier, c->win); XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
if(focused) if(focused)
@ -100,28 +98,28 @@ grabbuttons(Client * c, Bool focused, KeySym modkey, unsigned int numlockmask)
XGrabButton(c->display, Button3, modkey | numlockmask | LockMask, XGrabButton(c->display, Button3, modkey | numlockmask | LockMask,
c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
XUngrabButton(c->display, AnyButton, AnyModifier, RootWindow(c->display, real_screen)); XUngrabButton(c->display, AnyButton, AnyModifier, RootWindow(c->display, c->phys_screen));
} }
else else
{ {
XGrabButton(c->display, AnyButton, AnyModifier, c->win, False, BUTTONMASK, XGrabButton(c->display, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(c->display, Button4, NoSymbol, RootWindow(c->display, real_screen), False, BUTTONMASK, XGrabButton(c->display, Button4, NoSymbol, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(c->display, Button4, LockMask, RootWindow(c->display, real_screen), False, BUTTONMASK, XGrabButton(c->display, Button4, LockMask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(c->display, Button4, numlockmask, RootWindow(c->display, real_screen), False, BUTTONMASK, XGrabButton(c->display, Button4, numlockmask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(c->display, Button4, numlockmask | LockMask, RootWindow(c->display, real_screen), False, BUTTONMASK, XGrabButton(c->display, Button4, numlockmask | LockMask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(c->display, Button5, NoSymbol, RootWindow(c->display, real_screen), False, BUTTONMASK, XGrabButton(c->display, Button5, NoSymbol, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(c->display, Button5, LockMask, RootWindow(c->display, real_screen), False, BUTTONMASK, XGrabButton(c->display, Button5, LockMask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(c->display, Button5, numlockmask, RootWindow(c->display, real_screen), False, BUTTONMASK, XGrabButton(c->display, Button5, numlockmask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(c->display, Button5, numlockmask | LockMask, RootWindow(c->display, real_screen), False, BUTTONMASK, XGrabButton(c->display, Button5, numlockmask | LockMask, RootWindow(c->display, c->phys_screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
} }
@ -413,6 +411,7 @@ manage(Display *disp, DC *drawcontext, Window w, XWindowAttributes *wa, awesome_
c->h = c->rh = wa->height; c->h = c->rh = wa->height;
c->oldborder = wa->border_width; c->oldborder = wa->border_width;
c->display = disp; c->display = disp;
c->phys_screen = get_phys_screen(disp, c->screen);
if(c->w == si->width && c->h == si->height) if(c->w == si->width && c->h == si->height)
{ {
c->x = 0; c->x = 0;

View File

@ -54,8 +54,10 @@ struct Client
Window win; Window win;
/** Client display */ /** Client display */
Display *display; Display *display;
/** Client screen (Zaphod) */ /** Client logical screen */
int screen; int screen;
/** Client physical screen */
int phys_screen;
/** First time viewed on new layout */ /** First time viewed on new layout */
Bool ftview; Bool ftview;
}; };

View File

@ -199,6 +199,7 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
/* set screen */ /* set screen */
awesomeconf->screen = scr; awesomeconf->screen = scr;
awesomeconf->phys_screen = get_phys_screen(disp, scr);
if(config_read_file(&awesomelibconf, confpath) == CONFIG_FALSE) if(config_read_file(&awesomelibconf, confpath) == CONFIG_FALSE)
fprintf(stderr, "awesome: error parsing configuration file at line %d: %s\n", fprintf(stderr, "awesome: error parsing configuration file at line %d: %s\n",
@ -395,22 +396,22 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
/* colors */ /* colors */
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_border_color"); tmp = config_lookup_string(&awesomelibconf, "awesome.normal_border_color");
drawcontext->norm[ColBorder] = initcolor(disp, scr, tmp ? tmp : "#dddddd"); drawcontext->norm[ColBorder] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#dddddd");
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_bg_color"); tmp = config_lookup_string(&awesomelibconf, "awesome.normal_bg_color");
drawcontext->norm[ColBG] = initcolor(disp, scr, tmp ? tmp : "#000000"); drawcontext->norm[ColBG] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#000000");
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_fg_color"); tmp = config_lookup_string(&awesomelibconf, "awesome.normal_fg_color");
drawcontext->norm[ColFG] = initcolor(disp, scr, tmp ? tmp : "#ffffff"); drawcontext->norm[ColFG] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#ffffff");
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_border_color"); tmp = config_lookup_string(&awesomelibconf, "awesome.focus_border_color");
drawcontext->sel[ColBorder] = initcolor(disp, scr, tmp ? tmp : "#008b8b"); drawcontext->sel[ColBorder] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#008b8b");
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_bg_color"); tmp = config_lookup_string(&awesomelibconf, "awesome.focus_bg_color");
drawcontext->sel[ColBG] = initcolor(disp, scr, tmp ? tmp : "#008b8b"); drawcontext->sel[ColBG] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#008b8b");
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_fg_color"); tmp = config_lookup_string(&awesomelibconf, "awesome.focus_fg_color");
drawcontext->sel[ColFG] = initcolor(disp, scr, tmp ? tmp : "#ffffff"); drawcontext->sel[ColFG] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#ffffff");
config_destroy(&awesomelibconf); config_destroy(&awesomelibconf);
p_delete(&confpath); p_delete(&confpath);
@ -498,7 +499,7 @@ 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, get_real_screen(disp, scr)); Colormap 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

@ -109,8 +109,10 @@ typedef struct
/** Main configuration structure */ /** Main configuration structure */
struct awesome_config struct awesome_config
{ {
/** Config screen number */ /** Config virtual screen number */
int screen; int screen;
/** Config physical screen */
int phys_screen;
/** Tag list */ /** Tag list */
Tag *tags; Tag *tags;
/** Number of tags in **tags */ /** Number of tags in **tags */

22
event.c
View File

@ -54,22 +54,20 @@ getclient(Window w)
static void static void
movemouse(Client * c, awesome_config *awesomeconf) movemouse(Client * c, awesome_config *awesomeconf)
{ {
int x1, y1, ocx, ocy, di, nx, ny, real_screen; int x1, y1, ocx, ocy, di, nx, ny;
unsigned int dui; unsigned int dui;
Window dummy; Window dummy;
XEvent ev; XEvent ev;
ScreenInfo *si; ScreenInfo *si;
real_screen = get_real_screen(c->display, awesomeconf->screen); si = get_display_info(c->display, c->phys_screen, NULL);
si = get_display_info(c->display, real_screen, NULL);
ocx = nx = c->x; ocx = nx = c->x;
ocy = ny = c->y; ocy = ny = c->y;
if(XGrabPointer(c->display, RootWindow(c->display, real_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync, if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, dc[c->screen].cursor[CurMove], CurrentTime) != GrabSuccess) None, dc[c->screen].cursor[CurMove], CurrentTime) != GrabSuccess)
return; return;
XQueryPointer(c->display, RootWindow(c->display, real_screen), &dummy, &dummy, &x1, &y1, &di, &di, &dui); XQueryPointer(c->display, RootWindow(c->display, c->phys_screen), &dummy, &dummy, &x1, &y1, &di, &di, &dui);
for(;;) for(;;)
{ {
XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
@ -110,7 +108,7 @@ resizemouse(Client * c, awesome_config *awesomeconf)
ocx = c->x; ocx = c->x;
ocy = c->y; ocy = c->y;
if(XGrabPointer(c->display, RootWindow(c->display, get_real_screen(c->display, awesomeconf->screen)), if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen),
False, MOUSEMASK, GrabModeAsync, GrabModeAsync, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, dc[c->screen].cursor[CurResize], CurrentTime) != GrabSuccess) None, dc[c->screen].cursor[CurResize], CurrentTime) != GrabSuccess)
return; return;
@ -227,7 +225,6 @@ 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)))
{ {
@ -236,7 +233,6 @@ 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))
{ {
real_screen = get_real_screen(c->display, 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)
@ -245,10 +241,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, real_screen) && c->isfloating) if((c->x + c->w) > DisplayWidth(c->display, c->phys_screen) && c->isfloating)
c->x = DisplayWidth(c->display, real_screen) / 2 - c->w / 2; /* center in x direction */ c->x = DisplayWidth(c->display, c->phys_screen) / 2 - c->w / 2; /* center in x direction */
if((c->y + c->h) > DisplayHeight(c->display, real_screen) && c->isfloating) if((c->y + c->h) > DisplayHeight(c->display, c->phys_screen) && c->isfloating)
c->y = DisplayHeight(c->display, real_screen) / 2 - c->h / 2; /* center in y direction */ c->y = DisplayHeight(c->display, c->phys_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))

View File

@ -145,7 +145,7 @@ get_screen_count(Display *disp)
* \return the X screen * \return the X screen
*/ */
int int
get_real_screen(Display *disp, int screen) get_phys_screen(Display *disp, int screen)
{ {
if(XineramaIsActive(disp)) if(XineramaIsActive(disp))
return DefaultScreen(disp); return DefaultScreen(disp);

View File

@ -32,7 +32,7 @@ ScreenInfo * get_screen_info(Display *, int, Statusbar *, int *);
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 *);
int get_real_screen(Display *, int); int get_phys_screen(Display *, int);
void move_client_to_screen(Client *, awesome_config *, Bool); void move_client_to_screen(Client *, awesome_config *, Bool);
UICB_PROTO(uicb_focusnextscreen); UICB_PROTO(uicb_focusnextscreen);
UICB_PROTO(uicb_focusprevscreen); UICB_PROTO(uicb_focusprevscreen);

View File

@ -108,10 +108,10 @@ 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, real_screen; int screen_number, phys_screen;
ScreenInfo *si; ScreenInfo *si;
real_screen = get_real_screen(disp, screen); phys_screen = get_phys_screen(disp, screen);
statusbar->screen = screen; statusbar->screen = screen;
@ -123,17 +123,17 @@ initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar)
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, real_screen), 0, 0, si[screen].width, statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0, si[screen].width,
statusbar->height, 0, DefaultDepth(disp, real_screen), CopyFromParent, statusbar->height, 0, DefaultDepth(disp, phys_screen), CopyFromParent,
DefaultVisual(disp, real_screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); DefaultVisual(disp, phys_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, real_screen), RootWindow(disp, phys_screen),
si[screen].width, si[screen].width,
statusbar->height, statusbar->height,
DefaultDepth(disp, real_screen)); DefaultDepth(disp, phys_screen));
} }
void void