From 8c531e2a81c929deaee6e22b1f8e8c154dc27be2 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 1 Oct 2007 15:23:05 +0200 Subject: [PATCH] store phys_screen --- awesome.c | 10 +++++----- client.c | 21 ++++++++++----------- client.h | 4 +++- config.c | 15 ++++++++------- config.h | 4 +++- event.c | 22 +++++++++------------- screen.c | 2 +- screen.h | 2 +- statusbar.c | 14 +++++++------- 9 files changed, 47 insertions(+), 47 deletions(-) diff --git a/awesome.c b/awesome.c index c7162f9af..bd279d220 100644 --- a/awesome.c +++ b/awesome.c @@ -189,7 +189,7 @@ static void setup(Display *disp, int screen, DC *drawcontext, awesome_config *awesomeconf) { XSetWindowAttributes wa; - int real_screen = get_real_screen(disp, screen); + int phys_screen = get_phys_screen(disp, screen); /* init cursors */ 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; 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); /* bar */ drawcontext->h = awesomeconf->statusbar.height = drawcontext->font.height + 2; 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); if(!drawcontext->font.set) diff --git a/client.c b/client.c index 3ffcf004a..285e91ca7 100644 --- a/client.c +++ b/client.c @@ -67,8 +67,6 @@ detachstack(Client * c) static void 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); if(focused) @@ -100,28 +98,28 @@ grabbuttons(Client * c, Bool focused, KeySym modkey, unsigned int numlockmask) XGrabButton(c->display, Button3, modkey | numlockmask | LockMask, 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 { XGrabButton(c->display, AnyButton, AnyModifier, c->win, False, BUTTONMASK, 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); } @@ -413,6 +411,7 @@ manage(Display *disp, DC *drawcontext, Window w, XWindowAttributes *wa, awesome_ c->h = c->rh = wa->height; c->oldborder = wa->border_width; c->display = disp; + c->phys_screen = get_phys_screen(disp, c->screen); if(c->w == si->width && c->h == si->height) { c->x = 0; diff --git a/client.h b/client.h index 4037bcc64..679daeae8 100644 --- a/client.h +++ b/client.h @@ -54,8 +54,10 @@ struct Client Window win; /** Client display */ Display *display; - /** Client screen (Zaphod) */ + /** Client logical screen */ int screen; + /** Client physical screen */ + int phys_screen; /** First time viewed on new layout */ Bool ftview; }; diff --git a/config.c b/config.c index a74a9af3e..534c0b0b5 100644 --- a/config.c +++ b/config.c @@ -199,6 +199,7 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg, /* set screen */ awesomeconf->screen = scr; + awesomeconf->phys_screen = get_phys_screen(disp, scr); if(config_read_file(&awesomelibconf, confpath) == CONFIG_FALSE) 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 */ 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"); - 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"); - 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"); - 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"); - 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"); - drawcontext->sel[ColFG] = initcolor(disp, scr, tmp ? tmp : "#ffffff"); + drawcontext->sel[ColFG] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#ffffff"); config_destroy(&awesomelibconf); p_delete(&confpath); @@ -498,7 +499,7 @@ get_numlockmask(Display *disp) static unsigned long initcolor(Display *disp, int scr, const char *colstr) { - Colormap cmap = DefaultColormap(disp, get_real_screen(disp, scr)); + Colormap 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/config.h b/config.h index c568788de..b09af6275 100644 --- a/config.h +++ b/config.h @@ -109,8 +109,10 @@ typedef struct /** Main configuration structure */ struct awesome_config { - /** Config screen number */ + /** Config virtual screen number */ int screen; + /** Config physical screen */ + int phys_screen; /** Tag list */ Tag *tags; /** Number of tags in **tags */ diff --git a/event.c b/event.c index 3235d04c4..09a553359 100644 --- a/event.c +++ b/event.c @@ -54,22 +54,20 @@ getclient(Window w) static void 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; Window dummy; XEvent ev; ScreenInfo *si; - real_screen = get_real_screen(c->display, awesomeconf->screen); - - si = get_display_info(c->display, real_screen, NULL); + si = get_display_info(c->display, c->phys_screen, NULL); ocx = nx = c->x; 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) 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(;;) { XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); @@ -110,7 +108,7 @@ resizemouse(Client * c, awesome_config *awesomeconf) ocx = c->x; 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, None, dc[c->screen].cursor[CurResize], CurrentTime) != GrabSuccess) return; @@ -227,7 +225,6 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf) Client *c; XConfigureRequestEvent *ev = &e->xconfigurerequest; XWindowChanges wc; - int real_screen; if((c = getclient(ev->window))) { @@ -236,7 +233,6 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf) c->border = ev->border_width; if(c->isfixed || c->isfloating || IS_ARRANGE(layout_floating)) { - real_screen = get_real_screen(c->display, c->screen); if(ev->value_mask & CWX) c->x = ev->x; if(ev->value_mask & CWY) @@ -245,10 +241,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, 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((c->x + c->w) > DisplayWidth(c->display, c->phys_screen) && c->isfloating) + c->x = DisplayWidth(c->display, c->phys_screen) / 2 - c->w / 2; /* center in x direction */ + if((c->y + c->h) > DisplayHeight(c->display, c->phys_screen) && c->isfloating) + 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))) configure(c); if(isvisible(c, c->screen, awesomeconf[c->screen].tags, awesomeconf[c->screen].ntags)) diff --git a/screen.c b/screen.c index f4b13e6a8..cd5a37b23 100644 --- a/screen.c +++ b/screen.c @@ -145,7 +145,7 @@ get_screen_count(Display *disp) * \return the X screen */ int -get_real_screen(Display *disp, int screen) +get_phys_screen(Display *disp, int screen) { if(XineramaIsActive(disp)) return DefaultScreen(disp); diff --git a/screen.h b/screen.h index b45d58694..fe8ce7c12 100644 --- a/screen.h +++ b/screen.h @@ -32,7 +32,7 @@ ScreenInfo * get_screen_info(Display *, int, Statusbar *, int *); ScreenInfo * get_display_info(Display *, int, Statusbar *); int get_screen_bycoord(Display *, int, int); 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); UICB_PROTO(uicb_focusnextscreen); UICB_PROTO(uicb_focusprevscreen); diff --git a/statusbar.c b/statusbar.c index 4fa653ff9..25ce2d67e 100644 --- a/statusbar.c +++ b/statusbar.c @@ -108,10 +108,10 @@ void initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar) { XSetWindowAttributes wa; - int screen_number, real_screen; + int screen_number, phys_screen; ScreenInfo *si; - real_screen = get_real_screen(disp, screen); + phys_screen = get_phys_screen(disp, screen); statusbar->screen = screen; @@ -123,17 +123,17 @@ initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar) wa.override_redirect = 1; wa.background_pixmap = ParentRelative; wa.event_mask = ButtonPressMask | ExposureMask; - 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); + statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0, si[screen].width, + statusbar->height, 0, DefaultDepth(disp, phys_screen), CopyFromParent, + DefaultVisual(disp, phys_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, real_screen), + RootWindow(disp, phys_screen), si[screen].width, statusbar->height, - DefaultDepth(disp, real_screen)); + DefaultDepth(disp, phys_screen)); } void