diff --git a/client.c b/client.c index fdbbdef5..c74291be 100644 --- a/client.c +++ b/client.c @@ -182,8 +182,6 @@ client_ban(Client *c) void client_focus(Client *c, int screen, Bool raise) { - int phys_screen = get_phys_screen(screen); - /* if c is NULL or invisible, take next client in the focus history */ if(!c || (c && !client_isvisible(c, screen))) { @@ -263,15 +261,15 @@ client_focus(Client *c, int screen, Bool raise) } /* since we're dropping EnterWindow events and sometimes the window * will appear under the mouse, grabbuttons */ - window_grabbuttons(phys_screen, c->win); + window_grabbuttons(c->phys_screen, c->win); } else XSetInputFocus(globalconf.display, - RootWindow(globalconf.display, phys_screen), + RootWindow(globalconf.display, c->phys_screen), RevertToPointerRoot, CurrentTime); widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS); - ewmh_update_net_active_window(phys_screen); + ewmh_update_net_active_window(c->phys_screen); } /** Manage a new client @@ -289,13 +287,17 @@ client_manage(Window w, XWindowAttributes *wa, int screen) Tag *tag; Rule *rule; area_t screen_geom; - int phys_screen = get_phys_screen(screen); long flags; c = p_new(Client, 1); c->screen = screen_get_bycoord(globalconf.screens_info, screen, wa->x, wa->y); + if(globalconf.screens_info->xinerama_is_active) + c->phys_screen = DefaultScreen(globalconf.display); + else + c->phys_screen = c->screen; + screen_geom = screen_get_area(c->screen, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); @@ -400,7 +402,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) if(globalconf.have_shape) { XShapeSelectInput(globalconf.display, w, ShapeNotifyMask); - window_setshape(phys_screen, c->win); + window_setshape(c->phys_screen, c->win); } /* attach to the stack */ @@ -431,7 +433,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) c->geometry.width, c->geometry.height); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); - ewmh_update_net_client_list(phys_screen); + ewmh_update_net_client_list(c->phys_screen); } static area_t @@ -505,7 +507,7 @@ client_resize(Client *c, area_t geometry, Bool hints) return False; /* offscreen appearance fixes */ - area = get_display_area(get_phys_screen(c->screen), NULL, + area = get_display_area(c->phys_screen, NULL, &globalconf.screens[c->screen].padding); if(geometry.x > area.width) @@ -899,7 +901,7 @@ uicb_client_moveresize(int screen, char *arg) Bool xqp = XQueryPointer(globalconf.display, RootWindow(globalconf.display, - get_phys_screen(screen)), + sel->phys_screen), &dummy, &dummy, &mx, &my, &dx, &dy, &dui); if(globalconf.screens[sel->screen].resize_hints) geometry = client_geometry_hints(sel, geometry); diff --git a/config.c b/config.c index 14e6fdd6..3fe0fe0d 100644 --- a/config.c +++ b/config.c @@ -277,7 +277,7 @@ statusbar_widgets_create(cfg_t *cfg_statusbar, Statusbar *statusbar) static void config_section_titlebar_init(cfg_t *cfg_titlebar, Titlebar *tb, int screen) { - int phys_screen = get_phys_screen(screen); + int phys_screen = screen_virttophys(screen); cfg_t *cfg_styles = cfg_getsec(cfg_titlebar, "styles"); tb->position = tb->dposition = cfg_getposition(cfg_titlebar, "position"); @@ -309,7 +309,7 @@ config_parse_screen(cfg_t *cfg, int screen) *cfg_layouts, *cfg_padding, *cfgsectmp, *cfg_titlebar, *cfg_styles_normal, *cfg_styles_focus, *cfg_styles_urgent; VirtScreen *virtscreen = &globalconf.screens[screen]; - int i, phys_screen = get_phys_screen(screen); + int i, phys_screen = screen_virttophys(screen); snprintf(buf, sizeof(buf), "%d", screen); cfg_screen = cfg_gettsec(cfg, "screen", buf); diff --git a/event.c b/event.c index 48f3c8ba..cc1af69e 100644 --- a/event.c +++ b/event.c @@ -132,7 +132,7 @@ event_handle_buttonpress(XEvent *e) && ev->button == Button1) { XAllowEvents(globalconf.display, ReplayPointer, CurrentTime); - window_grabbuttons(get_phys_screen(c->screen), c->win); + window_grabbuttons(c->phys_screen, c->win); } else event_handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL); @@ -268,7 +268,7 @@ event_handle_enternotify(XEvent *e) if(c || (c = client_get_bywin(globalconf.clients, ev->window))) { - window_grabbuttons(get_phys_screen(c->screen), c->win); + window_grabbuttons(c->phys_screen, c->win); if(globalconf.screens[c->screen].sloppy_focus) client_focus(c, c->screen, (globalconf.screens[c->screen].sloppy_focus @@ -319,7 +319,7 @@ event_handle_expose(XEvent *e) for(c = globalconf.clients; c; c = c->next) if(c->titlebar.sw && c->titlebar.sw->window == ev->window) { - simplewindow_refresh_drawable(c->titlebar.sw, get_phys_screen(c->screen)); + simplewindow_refresh_drawable(c->titlebar.sw, c->phys_screen); return; } } @@ -457,7 +457,7 @@ event_handle_unmapnotify(XEvent * e) XUnmapEvent *ev = &e->xunmap; if((c = client_get_bywin(globalconf.clients, ev->window)) - && ev->event == RootWindow(e->xany.display, get_phys_screen(c->screen)) + && ev->event == RootWindow(e->xany.display, c->phys_screen) && ev->send_event && window_getstate(c->win) == NormalState) client_unmanage(c); } @@ -472,7 +472,7 @@ event_handle_shape(XEvent * e) Client *c = client_get_bywin(globalconf.clients, ev->window); if(c) - window_setshape(get_phys_screen(c->screen), c->win); + window_setshape(c->phys_screen, c->win); } /** Handle XRandR events diff --git a/ewmh.c b/ewmh.c index 5b396415..5cc1a0df 100644 --- a/ewmh.c +++ b/ewmh.c @@ -154,7 +154,7 @@ ewmh_update_net_client_list(int phys_screen) wins = p_new(Window, n); for(n = 0, c = globalconf.clients; c; c = c->next, n++) - if(get_phys_screen(c->screen) == phys_screen) + if(c->phys_screen == phys_screen) wins[n] = c->win; XChangeProperty(globalconf.display, RootWindow(globalconf.display, phys_screen), diff --git a/layout.c b/layout.c index f990972e..18519a32 100644 --- a/layout.c +++ b/layout.c @@ -46,7 +46,7 @@ arrange(int screen) Client *c; Layout *curlay = layout_get_current(screen); unsigned int dui; - int di, x, y; + int di, x, y, phys_screen = screen_virttophys(screen); Window rootwin, childwin; for(c = globalconf.clients; c; c = c->next) @@ -75,11 +75,11 @@ arrange(int screen) client_focus(c, screen, True); /* check that the mouse is on a window or not */ - if(XQueryPointer(globalconf.display, RootWindow(globalconf.display, - get_phys_screen(screen)), + if(XQueryPointer(globalconf.display, + RootWindow(globalconf.display, phys_screen), &rootwin, &childwin, &x, &y, &di, &di, &dui) && (rootwin == None || childwin == None || childwin == rootwin)) - window_root_grabbuttons(get_phys_screen(screen)); + window_root_grabbuttons(phys_screen); /* reset status */ globalconf.screens[screen].need_arrange = False; diff --git a/mouse.c b/mouse.c index 8cb831a8..ffc3b200 100644 --- a/mouse.c +++ b/mouse.c @@ -44,7 +44,7 @@ extern AwesomeConf globalconf; void uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) { - int x, y, ocx, ocy, di, phys_screen, newscreen; + int x, y, ocx, ocy, di, newscreen; unsigned int dui; Window dummy, child; XEvent ev; @@ -61,15 +61,14 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) ocx = geometry.x = c->geometry.x; ocy = geometry.y = c->geometry.y; - phys_screen = get_phys_screen(c->screen); if(XGrabPointer(globalconf.display, - RootWindow(globalconf.display, phys_screen), + RootWindow(globalconf.display, c->phys_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync, - RootWindow(globalconf.display, phys_screen), + RootWindow(globalconf.display, c->phys_screen), globalconf.cursor[CurMove], CurrentTime) != GrabSuccess) return; XQueryPointer(globalconf.display, - RootWindow(globalconf.display, phys_screen), + RootWindow(globalconf.display, c->phys_screen), &dummy, &dummy, &x, &y, &di, &di, &dui); c->ismax = False; for(;;) @@ -119,7 +118,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) else { XQueryPointer(globalconf.display, - RootWindow(globalconf.display, phys_screen), + RootWindow(globalconf.display, c->phys_screen), &dummy, &child, &x, &y, &di, &di, &dui); if((newscreen = screen_get_bycoord(globalconf.screens_info, c->screen, x, y)) != c->screen) { @@ -188,10 +187,10 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused))) else return; - if(XGrabPointer(globalconf.display, RootWindow(globalconf.display, - get_phys_screen(c->screen)), + if(XGrabPointer(globalconf.display, + RootWindow(globalconf.display, c->phys_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync, - RootWindow(globalconf.display,get_phys_screen(c->screen)), + RootWindow(globalconf.display, c->phys_screen), globalconf.cursor[CurResize], CurrentTime) != GrabSuccess) return; diff --git a/placement.c b/placement.c index ad881e98..dba2cb53 100644 --- a/placement.c +++ b/placement.c @@ -159,7 +159,7 @@ placement_under_mouse(Client *c) int x, y, d; area_t finalgeometry = c->f_geometry; - if(XQueryPointer(globalconf.display, RootWindow(globalconf.display, get_phys_screen(c->screen)), + if(XQueryPointer(globalconf.display, RootWindow(globalconf.display, c->phys_screen), &dummy, &dummy, &x, &y, &d, &d, &m)) { finalgeometry.x = x - c->f_geometry.width / 2; diff --git a/screen.c b/screen.c index 5e65e0fc..a8a3508f 100644 --- a/screen.c +++ b/screen.c @@ -106,7 +106,7 @@ get_display_area(int screen, Statusbar *statusbar, Padding *padding) * \return the X screen */ int -get_phys_screen(int screen) +screen_virttophys(int screen) { if(globalconf.screens_info->xinerama_is_active) return DefaultScreen(globalconf.display); diff --git a/screen.h b/screen.h index 6a79f930..3993de99 100644 --- a/screen.h +++ b/screen.h @@ -26,7 +26,7 @@ area_t screen_get_area(int, Statusbar *, Padding *); area_t get_display_area(int, Statusbar *, Padding *); -int get_phys_screen(int); +int screen_virttophys(int); void move_client_to_screen(Client *, int, Bool); Uicb uicb_screen_focus; diff --git a/statusbar.c b/statusbar.c index 954b84a7..998c76b2 100644 --- a/statusbar.c +++ b/statusbar.c @@ -164,7 +164,7 @@ statusbar_display(Statusbar *statusbar) { /* don't waste our time */ if(statusbar->position != Off) - simplewindow_refresh_drawable(statusbar->sw, get_phys_screen(statusbar->screen)); + simplewindow_refresh_drawable(statusbar->sw, statusbar->phys_screen); } void @@ -182,11 +182,12 @@ statusbar_init(Statusbar *statusbar) { Statusbar *sb; Drawable dw; - int phys_screen = get_phys_screen(statusbar->screen); + int phys_screen = screen_virttophys(statusbar->screen); area_t area = screen_get_area(statusbar->screen, globalconf.screens[statusbar->screen].statusbar, &globalconf.screens[statusbar->screen].padding); + statusbar->phys_screen = phys_screen; /* Top and Bottom Statusbar have prio */ for(sb = globalconf.screens[statusbar->screen].statusbar; sb; sb = sb->next) diff --git a/structs.h b/structs.h index 1e8c7e36..297a33bf 100644 --- a/structs.h +++ b/structs.h @@ -163,6 +163,8 @@ struct Statusbar Position position; /** Screen */ int screen; + /** Physical screen id */ + int phys_screen; /** Widget list */ Widget *widgets; /** Draw context */ @@ -208,6 +210,8 @@ struct Client Window win; /** Client logical screen */ int screen; + /** Client physical screen */ + int phys_screen; /** True if the client is a new one */ Bool newcomer; /** Titlebar */ diff --git a/tag.c b/tag.c index fc7ef142..7f9f9e94 100644 --- a/tag.c +++ b/tag.c @@ -328,7 +328,7 @@ tag_view(Tag *tag, Bool view) { tag->was_selected = tag->selected; tag->selected = view; - ewmh_update_net_current_desktop(get_phys_screen(tag->screen)); + ewmh_update_net_current_desktop(screen_virttophys(tag->screen)); widget_invalidate_cache(tag->screen, WIDGET_CACHE_TAGS); globalconf.screens[tag->screen].need_arrange = True; } diff --git a/titlebar.c b/titlebar.c index 58458cb7..2b55dfb8 100644 --- a/titlebar.c +++ b/titlebar.c @@ -30,7 +30,6 @@ void titlebar_init(Client *c) { int titlebar_height; - int phys_screen = get_phys_screen(c->screen); if(c->titlebar.position == Off || c->titlebar.position == Auto) @@ -47,7 +46,7 @@ titlebar_init(Client *c) { case Top: c->titlebar.sw = simplewindow_new(globalconf.display, - phys_screen, + c->phys_screen, c->geometry.x, c->geometry.y - titlebar_height, c->geometry.width + 2 * c->border, @@ -56,7 +55,7 @@ titlebar_init(Client *c) break; case Bottom: c->titlebar.sw = simplewindow_new(globalconf.display, - phys_screen, + c->phys_screen, c->geometry.x, c->geometry.y + c->geometry.height + 2 * c->border, c->geometry.width + 2 * c->border, @@ -65,7 +64,7 @@ titlebar_init(Client *c) break; case Left: c->titlebar.sw = simplewindow_new(globalconf.display, - phys_screen, + c->phys_screen, c->geometry.x - titlebar_height, c->geometry.y, titlebar_height, @@ -74,7 +73,7 @@ titlebar_init(Client *c) break; case Right: c->titlebar.sw = simplewindow_new(globalconf.display, - phys_screen, + c->phys_screen, c->geometry.x + c->geometry.width + 2 * c->border, c->geometry.y, titlebar_height, diff --git a/widgets/graph.c b/widgets/graph.c index c9d61b52..2a1a1a46 100644 --- a/widgets/graph.c +++ b/widgets/graph.c @@ -338,13 +338,15 @@ graph_tell(Widget *widget, char *property, char *command) d->height = atof(command); else if(!a_strcmp(property, "bg")) { - if(!draw_color_new(globalconf.display, get_phys_screen(widget->statusbar->screen), + if(!draw_color_new(globalconf.display, + widget->statusbar->phys_screen, command, &d->bg)) return WIDGET_ERROR_FORMAT_COLOR; } else if(!a_strcmp(property, "bordercolor")) { - if(!draw_color_new(globalconf.display, get_phys_screen(widget->statusbar->screen), + if(!draw_color_new(globalconf.display, + widget->statusbar->phys_screen, command, &d->bordercolor)) return WIDGET_ERROR_FORMAT_COLOR; } @@ -372,7 +374,6 @@ graph_new(Statusbar *statusbar, cfg_t *config) Data *d; cfg_t *cfg; char *color; - int phys_screen = get_phys_screen(statusbar->screen); int i; char *type; XColor tmp_color = { 0, 0, 0, 0, 0, 0 }; @@ -454,20 +455,20 @@ graph_new(Statusbar *statusbar, cfg_t *config) d->data_title[i] = a_strdup(cfg_title(cfg)); if((color = cfg_getstr(cfg, "fg"))) - draw_color_new(globalconf.display, phys_screen, color, &tmp_color); + draw_color_new(globalconf.display, statusbar->phys_screen, color, &tmp_color); else tmp_color = globalconf.screens[statusbar->screen].styles.normal.fg; if((color = cfg_getstr(cfg, "fg_center"))) { ptmp_color_center = p_new(XColor, 1); - draw_color_new(globalconf.display, phys_screen, color, ptmp_color_center); + draw_color_new(globalconf.display, statusbar->phys_screen, color, ptmp_color_center); } if((color = cfg_getstr(cfg, "fg_end"))) { ptmp_color_end = p_new(XColor, 1); - draw_color_new(globalconf.display, phys_screen, color, ptmp_color_end); + draw_color_new(globalconf.display, statusbar->phys_screen, color, ptmp_color_end); } if (cfg_getbool(cfg, "scale")) @@ -522,12 +523,12 @@ graph_new(Statusbar *statusbar, cfg_t *config) } if((color = cfg_getstr(config, "bg"))) - draw_color_new(globalconf.display, phys_screen, color, &d->bg); + draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->bg); else d->bg = globalconf.screens[statusbar->screen].styles.normal.bg; if((color = cfg_getstr(config, "bordercolor"))) - draw_color_new(globalconf.display, phys_screen, color, &d->bordercolor); + draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->bordercolor); else d->bordercolor = tmp_color; diff --git a/widgets/progressbar.c b/widgets/progressbar.c index 0a9bb379..1f9d5d07 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -276,7 +276,8 @@ progressbar_tell(Widget *widget, char *property, char *command) for(i = 0; i < d->data_items; i++) if(!a_strcmp(title, d->data_title[i])) { - if(draw_color_new(globalconf.display, get_phys_screen(widget->statusbar->screen), + if(draw_color_new(globalconf.display, + widget->statusbar->phys_screen, setting, &d->fg[i])) return WIDGET_NOERROR; else @@ -292,7 +293,8 @@ progressbar_tell(Widget *widget, char *property, char *command) for(i = 0; i < d->data_items; i++) if(!a_strcmp(title, d->data_title[i])) { - if(draw_color_new(globalconf.display, get_phys_screen(widget->statusbar->screen), + if(draw_color_new(globalconf.display, + widget->statusbar->phys_screen, setting, &d->bg[i])) return WIDGET_NOERROR; else @@ -314,7 +316,8 @@ progressbar_tell(Widget *widget, char *property, char *command) flag = True; /* p_delete && restore to NULL, if draw_color_new unsuccessful */ d->pfg_center[i] = p_new(XColor, 1); } - if(!(draw_color_new(globalconf.display, get_phys_screen(widget->statusbar->screen), + if(!(draw_color_new(globalconf.display, + widget->statusbar->phys_screen, setting, d->pfg_center[i]))) { if(flag) /* restore */ @@ -342,7 +345,8 @@ progressbar_tell(Widget *widget, char *property, char *command) flag = True; d->pfg_end[i] = p_new(XColor, 1); } - if(!(draw_color_new(globalconf.display, get_phys_screen(widget->statusbar->screen), + if(!(draw_color_new(globalconf.display, + widget->statusbar->phys_screen, setting, d->pfg_end[i]))) { if(flag) /* restore */ @@ -363,7 +367,8 @@ progressbar_tell(Widget *widget, char *property, char *command) for(i = 0; i < d->data_items; i++) if(!a_strcmp(title, d->data_title[i])) { - if(draw_color_new(globalconf.display, get_phys_screen(widget->statusbar->screen), + if(draw_color_new(globalconf.display, + widget->statusbar->phys_screen, setting, &d->bordercolor[i])) return WIDGET_NOERROR; else @@ -409,7 +414,7 @@ progressbar_new(Statusbar *statusbar, cfg_t *config) Widget *w; Data *d; char *color; - int i, phys_screen = get_phys_screen(statusbar->screen); + int i; cfg_t *cfg; w = p_new(Widget, 1); @@ -459,29 +464,29 @@ progressbar_new(Statusbar *statusbar, cfg_t *config) d->reverse[i] = False; if((color = cfg_getstr(cfg, "fg"))) - draw_color_new(globalconf.display, phys_screen, color, &d->fg[i]); + draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->fg[i]); else d->fg[i] = globalconf.screens[statusbar->screen].styles.normal.fg; if((color = cfg_getstr(cfg, "fg_center"))) { d->pfg_center[i] = p_new(XColor, 1); - draw_color_new(globalconf.display, phys_screen, color, d->pfg_center[i]); + draw_color_new(globalconf.display, statusbar->phys_screen, color, d->pfg_center[i]); } if((color = cfg_getstr(cfg, "fg_end"))) { d->pfg_end[i] = p_new(XColor, 1); - draw_color_new(globalconf.display, phys_screen, color, d->pfg_end[i]); + draw_color_new(globalconf.display, statusbar->phys_screen, color, d->pfg_end[i]); } if((color = cfg_getstr(cfg, "bg"))) - draw_color_new(globalconf.display, phys_screen, color, &d->bg[i]); + draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->bg[i]); else d->bg[i] = globalconf.screens[statusbar->screen].styles.normal.bg; if((color = cfg_getstr(cfg, "bordercolor"))) - draw_color_new(globalconf.display, phys_screen, color, &d->bordercolor[i]); + draw_color_new(globalconf.display, statusbar->phys_screen, color, &d->bordercolor[i]); else d->bordercolor[i] = d->fg[i]; } diff --git a/widgets/tasklist.c b/widgets/tasklist.c index 21800080..e7d51225 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -272,7 +272,6 @@ tasklist_new(Statusbar *statusbar, cfg_t *config) Data *d; char *buf; cfg_t *cfg_styles; - int phys_screen = get_phys_screen(statusbar->screen); w = p_new(Widget, 1); widget_common_new(w, statusbar, config); @@ -283,17 +282,17 @@ tasklist_new(Statusbar *statusbar, cfg_t *config) cfg_styles = cfg_getsec(config, "styles"); - draw_style_init(globalconf.display, phys_screen, + draw_style_init(globalconf.display, statusbar->phys_screen, cfg_getsec(cfg_styles, "normal"), &d->styles.normal, &globalconf.screens[statusbar->screen].styles.normal); - draw_style_init(globalconf.display, phys_screen, + draw_style_init(globalconf.display, statusbar->phys_screen, cfg_getsec(cfg_styles, "focus"), &d->styles.focus, &globalconf.screens[statusbar->screen].styles.focus); - draw_style_init(globalconf.display, phys_screen, + draw_style_init(globalconf.display, statusbar->phys_screen, cfg_getsec(cfg_styles, "urgent"), &d->styles.urgent, &globalconf.screens[statusbar->screen].styles.urgent); diff --git a/widgets/textbox.c b/widgets/textbox.c index 129bd12a..239d2736 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -113,7 +113,6 @@ textbox_new(Statusbar *statusbar, cfg_t *config) { Widget *w; Data *d; - int phys_screen = get_phys_screen(statusbar->screen); w = p_new(Widget, 1); widget_common_new(w, statusbar, config); @@ -123,7 +122,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config) w->data = d = p_new(Data, 1); - draw_style_init(globalconf.display, phys_screen, + draw_style_init(globalconf.display, statusbar->phys_screen, cfg_getsec(config, "style"), &d->style, &globalconf.screens[statusbar->screen].styles.normal);