Store physical screen id in statusbar and client, change get_phys_s() to screen_virttophys()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-03-21 10:53:17 +01:00
parent 8d0e5b29a6
commit 0a6c6e017b
17 changed files with 76 additions and 67 deletions

View File

@ -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);

View File

@ -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);

10
event.c
View File

@ -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

2
ewmh.c
View File

@ -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),

View File

@ -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;

17
mouse.c
View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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 */

2
tag.c
View File

@ -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;
}

View File

@ -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,

View File

@ -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;

View File

@ -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];
}

View File

@ -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);

View File

@ -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);