2006-03-08 15:00:10 +03:00
|
|
|
/*
|
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
2006-04-12 12:44:07 +04:00
|
|
|
#include <stdlib.h>
|
2006-06-19 20:26:06 +04:00
|
|
|
#include <string.h>
|
2006-04-12 12:44:07 +04:00
|
|
|
|
2006-03-08 15:00:10 +03:00
|
|
|
#include "wm.h"
|
|
|
|
|
2006-04-12 12:44:07 +04:00
|
|
|
Frame *
|
2006-06-25 17:16:03 +04:00
|
|
|
create_frame(Client *c, View *v)
|
2006-04-12 12:44:07 +04:00
|
|
|
{
|
|
|
|
static unsigned short id = 1;
|
|
|
|
Frame *f = cext_emallocz(sizeof(Frame));
|
|
|
|
|
|
|
|
f->id = id++;
|
|
|
|
f->client = c;
|
2006-06-25 17:16:03 +04:00
|
|
|
f->view = v;
|
2006-06-26 06:18:00 +04:00
|
|
|
|
|
|
|
if(c->frame) {
|
|
|
|
f->revert = c->sel->revert;
|
|
|
|
f->rect = c->sel->rect;
|
|
|
|
}else{
|
|
|
|
f->revert = f->rect = c->rect;
|
|
|
|
f->revert.width = f->rect.width += 2 * def.border;
|
|
|
|
f->revert.height = f->rect.height += def.border + height_of_bar();
|
|
|
|
}
|
2006-06-12 14:11:22 +04:00
|
|
|
f->collapsed = False;
|
2006-06-19 20:26:06 +04:00
|
|
|
|
2006-06-22 13:03:42 +04:00
|
|
|
f->tile.blitz = &blz;
|
2006-06-22 17:25:59 +04:00
|
|
|
f->tile.drawable = pmap;
|
2006-06-22 13:03:42 +04:00
|
|
|
f->tile.gc = c->gc;
|
|
|
|
f->tile.font = &def.font;
|
|
|
|
f->tile.color = def.normcolor;
|
2006-06-23 13:34:10 +04:00
|
|
|
f->tile.border = True;
|
2006-06-22 14:42:27 +04:00
|
|
|
f->titlebar = f->posbar = f->tile;
|
2006-06-22 13:03:42 +04:00
|
|
|
f->titlebar.align = WEST;
|
2006-06-22 14:42:27 +04:00
|
|
|
f->posbar.align = CENTER;
|
|
|
|
|
|
|
|
f->tagbar.blitz = &blz;
|
2006-06-22 17:25:59 +04:00
|
|
|
f->tagbar.drawable = pmap;
|
2006-07-03 14:14:26 +04:00
|
|
|
f->tagbar.window = c->framewin;
|
2006-06-22 14:42:27 +04:00
|
|
|
f->tagbar.gc = c->gc;
|
|
|
|
f->tagbar.font = &def.font;
|
2006-06-23 12:47:07 +04:00
|
|
|
f->tagbar.color = def.normcolor;
|
2006-07-03 14:14:26 +04:00
|
|
|
blitz_settext_input(&f->tagbar, c->tags);
|
2006-06-19 20:26:06 +04:00
|
|
|
|
2006-04-12 12:44:07 +04:00
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
void
|
|
|
|
remove_frame(Frame *f)
|
|
|
|
{
|
|
|
|
Area *a = f->area;
|
|
|
|
Frame **ft = &a->frame;
|
2006-06-10 03:57:00 +04:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
for(; *ft && *ft != f; ft=&(*ft)->anext);
|
|
|
|
cext_assert(*ft == f);
|
|
|
|
*ft = f->anext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
insert_frame(Frame *pos, Frame *f, Bool before)
|
|
|
|
{
|
|
|
|
Area *a = f->area;
|
|
|
|
if(before) {
|
|
|
|
Frame *ft;
|
|
|
|
for(ft=a->frame; ft && ft->anext != pos; ft=ft->anext);
|
|
|
|
pos=ft;
|
|
|
|
}
|
|
|
|
Frame **p = pos ? &pos->anext : &a->frame;
|
|
|
|
f->anext = *p;
|
|
|
|
*p = f;
|
|
|
|
}
|
|
|
|
|
2006-06-19 20:26:06 +04:00
|
|
|
void
|
|
|
|
update_frame_widget_colors(Frame *f)
|
|
|
|
{
|
|
|
|
if(sel_screen && (f->client == sel_client()))
|
2006-06-23 12:47:07 +04:00
|
|
|
f->tagbar.color = f->tile.color = f->titlebar.color = def.selcolor;
|
2006-06-19 20:26:06 +04:00
|
|
|
else
|
2006-06-23 12:47:07 +04:00
|
|
|
f->tagbar.color = f->tile.color = f->titlebar.color = def.normcolor;
|
2006-06-19 20:26:06 +04:00
|
|
|
|
|
|
|
if(f->area->sel == f)
|
2006-06-22 13:03:42 +04:00
|
|
|
f->posbar.color = def.selcolor;
|
2006-06-19 20:26:06 +04:00
|
|
|
else
|
2006-06-22 13:03:42 +04:00
|
|
|
f->posbar.color = def.normcolor;
|
2006-06-19 20:26:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-06-22 13:46:39 +04:00
|
|
|
draw_frame(Frame *f)
|
2006-06-19 20:26:06 +04:00
|
|
|
{
|
|
|
|
Frame *p;
|
|
|
|
unsigned int fidx, size, w;
|
|
|
|
|
2006-06-30 10:02:44 +04:00
|
|
|
fidx = 0;
|
|
|
|
for(p=f->area->frame; p != f; p=p->anext)
|
|
|
|
fidx++;
|
2006-06-19 20:26:06 +04:00
|
|
|
for(size=fidx; p; p=p->anext, size++);
|
|
|
|
|
|
|
|
if(def.border) {
|
2006-06-22 13:03:42 +04:00
|
|
|
f->tile.rect = f->rect;
|
|
|
|
f->tile.rect.x = f->tile.rect.y = 0;
|
2006-06-19 20:26:06 +04:00
|
|
|
}
|
|
|
|
|
2006-06-22 13:03:42 +04:00
|
|
|
f->posbar.rect = f->tile.rect;
|
|
|
|
f->posbar.rect.height = height_of_bar();
|
2006-06-19 20:26:06 +04:00
|
|
|
|
2006-06-25 17:16:03 +04:00
|
|
|
snprintf(buffer, BUFFER_SIZE, "%s%d/%d",
|
2006-06-24 05:22:04 +04:00
|
|
|
f->area->floating ? "~" : "", fidx + 1, size);
|
2006-06-19 20:26:06 +04:00
|
|
|
|
2006-06-22 13:03:42 +04:00
|
|
|
w = f->posbar.rect.width =
|
2006-06-25 17:16:03 +04:00
|
|
|
f->posbar.rect.height + blitz_textwidth(&def.font, buffer);
|
2006-06-19 20:26:06 +04:00
|
|
|
|
2006-06-22 13:03:42 +04:00
|
|
|
f->posbar.rect.x = f->rect.width - f->posbar.rect.width;
|
2006-06-19 20:26:06 +04:00
|
|
|
|
|
|
|
/* tag bar */
|
2006-06-22 13:03:42 +04:00
|
|
|
f->tagbar.rect = f->posbar.rect;
|
|
|
|
f->tagbar.rect.x = 0;
|
2006-07-03 14:14:26 +04:00
|
|
|
f->tagbar.rect.width =
|
|
|
|
f->tagbar.rect.height + blitz_textwidth(&def.font, f->tagbar.text);
|
2006-06-19 20:26:06 +04:00
|
|
|
|
2006-06-22 13:03:42 +04:00
|
|
|
if(f->tagbar.rect.width > f->rect.width / 3)
|
|
|
|
f->tagbar.rect.width = f->rect.width / 3;
|
2006-06-19 20:26:06 +04:00
|
|
|
|
2006-06-22 13:03:42 +04:00
|
|
|
f->titlebar.rect = f->tagbar.rect;
|
|
|
|
f->titlebar.rect.x = f->tagbar.rect.x + f->tagbar.rect.width;
|
|
|
|
f->titlebar.rect.width = f->rect.width - (f->tagbar.rect.width + f->posbar.rect.width);
|
2006-06-19 20:26:06 +04:00
|
|
|
|
2006-06-22 13:46:39 +04:00
|
|
|
blitz_draw_tile(&f->tile);
|
2006-06-22 14:42:27 +04:00
|
|
|
blitz_draw_input(&f->tagbar);
|
2006-06-22 14:00:18 +04:00
|
|
|
blitz_draw_label(&f->titlebar, f->client->name);
|
2006-06-25 17:16:03 +04:00
|
|
|
blitz_draw_label(&f->posbar, buffer);
|
2006-06-29 13:53:45 +04:00
|
|
|
XCopyArea(blz.display, pmap, f->client->framewin, f->client->gc,
|
|
|
|
0, 0, f->rect.width, f->rect.height, 0, 0);
|
|
|
|
XSync(blz.display, False);
|
2006-06-19 20:26:06 +04:00
|
|
|
}
|
2006-06-20 16:32:19 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
draw_frames()
|
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
for(c=client; c; c=c->next)
|
2006-06-30 10:02:44 +04:00
|
|
|
if(c->sel && c->sel->view == screen->sel) {
|
2006-06-20 16:32:19 +04:00
|
|
|
update_frame_widget_colors(c->sel);
|
|
|
|
draw_frame(c->sel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|