wmii/frame.c

103 lines
2.3 KiB
C
Raw Normal View History

2006-10-12 18:10:57 +04:00
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
2006-03-08 15:00:10 +03:00
* See LICENSE file for license details.
*/
2006-10-12 18:10:57 +04:00
#include "wm.h"
2006-04-12 12:44:07 +04:00
#include <stdlib.h>
#include <string.h>
2006-04-12 12:44:07 +04:00
Frame *
2006-10-12 18:10:57 +04:00
create_frame(Client *c, View *v) {
2006-04-12 12:44:07 +04:00
static unsigned short id = 1;
2006-10-12 18:10:57 +04:00
Frame *f = ixp_emallocz(sizeof(Frame));
2006-04-12 12:44:07 +04:00
f->id = id++;
f->client = c;
2006-06-25 17:16:03 +04:00
f->view = v;
if(c->frame) {
f->revert = c->sel->revert;
f->rect = c->sel->rect;
2006-07-03 20:41:14 +04:00
}
else{
f->revert = f->rect = c->rect;
f->revert.width = f->rect.width += 2 * def.border;
f->revert.height = f->rect.height += def.border + blitz_labelh(&def.font);
}
2006-06-12 14:11:22 +04:00
f->collapsed = False;
f->tile.blitz = &blz;
f->tile.drawable = pmap;
f->tile.gc = c->gc;
f->tile.font = &def.font;
f->tile.color = def.normcolor;
f->tile.border = True;
2006-07-10 11:13:09 +04:00
f->grabbox = f->titlebar = f->tile;
f->titlebar.align = WEST;
2006-04-12 12:44:07 +04:00
return f;
}
2006-06-08 12:54:19 +04:00
void
2006-10-12 18:10:57 +04:00
remove_frame(Frame *f) {
2006-06-08 12:54:19 +04:00
Area *a = f->area;
Frame **ft = &a->frame;
2006-06-08 12:54:19 +04:00
for(; *ft && *ft != f; ft=&(*ft)->anext);
*ft = f->anext;
}
void
2006-10-12 18:10:57 +04:00
insert_frame(Frame *pos, Frame *f, Bool before) {
2006-06-08 12:54:19 +04:00
Area *a = f->area;
2006-10-12 18:10:57 +04:00
2006-06-08 12:54:19 +04:00
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;
}
void
2006-10-12 18:10:57 +04:00
update_frame_widget_colors(Frame *f) {
if(sel_screen && (f->client == sel_client()))
2006-09-27 09:56:40 +04:00
f->tile.color = f->titlebar.color = def.selcolor;
else
2006-09-27 09:56:40 +04:00
f->tile.color = f->titlebar.color = def.normcolor;
if(f->area->sel == f)
2006-07-10 11:13:09 +04:00
f->grabbox.color = def.selcolor;
else
2006-07-10 11:13:09 +04:00
f->grabbox.color = def.normcolor;
}
void
2006-10-12 18:10:57 +04:00
draw_frame(Frame *f) {
if(def.border) {
f->tile.rect = f->rect;
f->tile.rect.x = f->tile.rect.y = 0;
}
2006-07-10 11:13:09 +04:00
f->grabbox.rect = f->tile.rect;
f->grabbox.rect.height = blitz_labelh(&def.font);
f->grabbox.rect.width = def.font.height;
2006-07-10 11:13:09 +04:00
f->titlebar.rect = f->grabbox.rect;
f->titlebar.rect.x = f->grabbox.rect.x + f->grabbox.rect.width;
2006-09-27 09:56:40 +04:00
f->titlebar.rect.width = f->rect.width - f->titlebar.rect.x;
2006-06-22 13:46:39 +04:00
blitz_draw_tile(&f->tile);
2006-07-10 11:13:09 +04:00
blitz_draw_tile(&f->grabbox);
blitz_draw_label(&f->titlebar, f->client->name);
2006-07-03 20:41:14 +04:00
XCopyArea(blz.dpy, pmap, f->client->framewin, f->client->gc,
0, 0, f->rect.width, f->rect.height, 0, 0);
2006-07-03 20:41:14 +04:00
XSync(blz.dpy, False);
}
void
2006-10-12 18:10:57 +04:00
draw_frames() {
Client *c;
2006-10-12 18:10:57 +04:00
for(c=client; c; c=c->next)
if(c->sel && c->sel->view == screen->sel) {
update_frame_widget_colors(c->sel);
draw_frame(c->sel);
}
}