A tiling window manager

screen: Use screen_primary() to find the bar, not xrandr_is_primary()

xrandr might not be available or we might not have a primary screen.
screen_primary() factors in xrandr_is_primary() in its calculation
but has better logic for determining an actual primary screen.

Fixes the issue of the bar drawing over the only frame which can be
seen in Xnest.

+9 -6
+4 -4
screen.c
··· 36 36 { 37 37 int ret = s->height - defaults.padding_bottom - defaults.padding_top; 38 38 39 - if (defaults.bar_sticky && xrandr_is_primary(s)) { 39 + if (defaults.bar_sticky && screen_primary() == s) { 40 40 ret -= sticky_bar_height(s); 41 41 42 42 if (!defaults.bar_in_padding) ··· 69 69 { 70 70 int ret = s->top + defaults.padding_top; 71 71 72 - if (defaults.bar_sticky && xrandr_is_primary(s)) { 72 + if (defaults.bar_sticky && screen_primary() == s) { 73 73 switch (defaults.bar_location) { 74 74 case NorthEastGravity: 75 75 case NorthGravity: ··· 89 89 { 90 90 int ret = s->top + s->height - defaults.padding_bottom; 91 91 92 - if (defaults.bar_sticky && xrandr_is_primary(s)) { 92 + if (defaults.bar_sticky && screen_primary() == s) { 93 93 switch (defaults.bar_location) { 94 94 case SouthEastGravity: 95 95 case SouthGravity: ··· 622 622 s->width = width; 623 623 s->height = height; 624 624 625 - if (defaults.bar_sticky && xrandr_is_primary(s)) 625 + if (defaults.bar_sticky && screen_primary() == s) 626 626 hide_bar(s, 0); 627 627 628 628 XMoveResizeWindow(dpy, s->help_window, s->left, s->top, s->width,
+5 -2
xrandr.c
··· 112 112 } 113 113 114 114 int 115 - xrandr_is_primary(rp_screen * screen) 115 + xrandr_is_primary(rp_screen *screen) 116 116 { 117 - return screen->xrandr.primary; 117 + if (rp_have_xrandr) 118 + return screen->xrandr.primary; 119 + 120 + return 0; 118 121 } 119 122 120 123 void