New titlebar style for tabbed client: the selected titlebar is not only the first anymore

This commit is contained in:
Martin Duquesnoy 2012-01-21 15:56:17 +01:00
parent 9ce29181e7
commit 9953f1b4b8
2 changed files with 54 additions and 41 deletions

View File

@ -23,4 +23,4 @@
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.5~ SUCH DAMAGE.

View File

@ -345,29 +345,35 @@ client_grabbuttons(struct client *c, bool focused)
void void
client_frame_update(struct client *c, struct colpair *cp) client_frame_update(struct client *c, struct colpair *cp)
{ {
struct client *cc;
int y, f, xt, w, n = 1;
if(c->flags & CLIENT_TABBED) if(c->flags & CLIENT_TABBED)
c = c->tabmaster; c = c->tabmaster;
XSetWindowBackground(W->dpy, c->frame, cp->bg); XSetWindowBackground(W->dpy, c->frame, cp->bg);
XClearWindow(W->dpy, c->frame); XClearWindow(W->dpy, c->frame);
if(c->titlebar && c->title) if(!c->titlebar || !c->title)
{ return;
struct client *cc;
int y, f, n = 1, xt, w = draw_textw(c->theme, c->title);
c->titlebar->fg = cp->fg; c->titlebar->fg = cp->fg;
c->titlebar->bg = cp->bg; c->titlebar->bg = cp->bg;
/* Get number of tabbed client if c is tabmaster */ /* Get number of tabbed client if c is tabmaster */
if(c->flags & CLIENT_TABMASTER) if(c->flags & CLIENT_TABMASTER)
{
SLIST_FOREACH(cc, &c->tag->clients, tnext) SLIST_FOREACH(cc, &c->tag->clients, tnext)
if(c == cc->tabmaster) if(c == cc->tabmaster)
++n; ++n;
}
f = (c->geo.w - (c->border * (n - 1))) / n; f = c->geo.w / n;
y = TEXTY(c->theme, c->tbarw); y = TEXTY(c->theme, c->tbarw);
if(n == 1)
{
w = draw_textw(c->theme, c->title);
_XTEXT(); _XTEXT();
barwin_reparent(c->titlebar, c->frame); barwin_reparent(c->titlebar, c->frame);
@ -376,39 +382,46 @@ client_frame_update(struct client *c, struct colpair *cp)
barwin_refresh_color(c->titlebar); barwin_refresh_color(c->titlebar);
draw_text(c->titlebar->dr, c->theme, xt, y, cp->fg, c->title); draw_text(c->titlebar->dr, c->theme, xt, y, cp->fg, c->title);
barwin_refresh(c->titlebar); barwin_refresh(c->titlebar);
}
/* Tabbing case, multiple titlebar in frame */ /* Tabbing case, multiple titlebar in frame */
if(c->flags & CLIENT_TABMASTER && n > 1) else
{ {
int x = f;
struct geo g = { 0, 0, 1, c->titlebar->geo.h }; struct geo g = { 0, 0, 1, c->titlebar->geo.h };
int x = 0;
SLIST_FOREACH(cc, &c->tag->clients, tnext) SLIST_FOREACH(cc, &c->tag->clients, tnext)
if(c == cc->tabmaster && cc->titlebar)
{ {
cc->titlebar->bg = c->ncol.bg; w = (cc->title ? draw_textw(c->theme, cc->title) : 0);
w = draw_textw(c->theme, cc->title);
_XTEXT(); _XTEXT();
if(cc == c)
{
barwin_reparent(c->titlebar, c->frame);
barwin_move(c->titlebar, x, 0);
barwin_resize(c->titlebar, f, c->tbarw);
barwin_refresh_color(c->titlebar);
draw_text(c->titlebar->dr, c->theme, xt, y, cp->fg, c->title);
barwin_refresh(c->titlebar);
barwin_refresh(cc->titlebar);
x += f;
}
if(cc->tabmaster == c)
{
barwin_reparent(cc->titlebar, c->frame); barwin_reparent(cc->titlebar, c->frame);
barwin_map(cc->titlebar) barwin_map(cc->titlebar);
barwin_move(cc->titlebar, x, 1); barwin_move(cc->titlebar, x, 1);
barwin_resize(cc->titlebar, f, c->tbarw - 2); barwin_resize(cc->titlebar, f, c->tbarw - 2);
barwin_refresh_color(cc->titlebar); barwin_refresh_color(cc->titlebar);
draw_rect(cc->titlebar->dr, g, c->scol.bg); draw_rect(cc->titlebar->dr, g, c->scol.bg);
draw_text(cc->titlebar->dr, c->theme, xt, y - 1, draw_text(cc->titlebar->dr, c->theme, xt, y - 1, c->ncol.fg, cc->title);
c->ncol.fg, cc->title);
barwin_refresh(cc->titlebar); barwin_refresh(cc->titlebar);
x += f; x += f;
} }
} }
} }
} }
void void
client_tab_focus(struct client *c) client_tab_focus(struct client *c)
{ {