2006-03-23 12:36:51 +03:00
|
|
|
/*
|
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2006-06-08 12:54:19 +04:00
|
|
|
#include <stdio.h>
|
2006-03-23 12:36:51 +03:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "wm.h"
|
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
static char buf[256];
|
2006-04-03 00:53:56 +04:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
static void
|
|
|
|
assign_sel_view(View *v)
|
2006-04-13 18:52:33 +04:00
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
if(sel && sel != v) {
|
|
|
|
snprintf(buf, sizeof(buf), "UnfocusTag %s\n", sel->name);
|
|
|
|
write_event(buf);
|
|
|
|
}
|
|
|
|
sel = v;
|
|
|
|
snprintf(buf, sizeof(buf), "FocusTag %s\n", sel->name);
|
|
|
|
write_event(buf);
|
2006-04-13 18:52:33 +04:00
|
|
|
}
|
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
View *
|
2006-05-24 11:26:08 +04:00
|
|
|
create_view(const char *name)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
|
|
|
static unsigned short id = 1;
|
2006-06-08 12:54:19 +04:00
|
|
|
View **i, *v = cext_emallocz(sizeof(View));
|
2006-03-23 12:36:51 +03:00
|
|
|
|
|
|
|
v->id = id++;
|
2006-04-04 14:25:36 +04:00
|
|
|
cext_strlcpy(v->name, name, sizeof(v->name));
|
2006-06-08 12:54:19 +04:00
|
|
|
create_area(v, nil, 0);
|
|
|
|
create_area(v, v->area, 0);
|
2006-03-23 12:36:51 +03:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
for(i=&view; *i && (strcmp((*i)->name, name) < 0); i=&(*i)->next);
|
|
|
|
v->next = *i;
|
|
|
|
*i = v;
|
2006-06-07 21:19:16 +04:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
snprintf(buf, sizeof(buf), "CreateTag %s\n", v->name);
|
2006-06-07 21:20:41 +04:00
|
|
|
write_event(buf);
|
2006-06-08 12:54:19 +04:00
|
|
|
if(!sel)
|
|
|
|
assign_sel_view(v);
|
|
|
|
|
|
|
|
return v;
|
2006-06-07 21:19:16 +04:00
|
|
|
}
|
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
void
|
2006-03-23 12:43:57 +03:00
|
|
|
destroy_view(View *v)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
Area *a;
|
|
|
|
View **i;
|
|
|
|
|
|
|
|
for(a=v->area; a; a=a->next)
|
|
|
|
destroy_area(a);
|
|
|
|
|
|
|
|
for(i=&view; *i && *i != v; i=&(*i)->next);
|
|
|
|
*i = v->next;
|
|
|
|
|
|
|
|
if(sel == v)
|
|
|
|
for(sel=view; sel && sel->next != *i; sel=sel->next);
|
2006-03-23 12:36:51 +03:00
|
|
|
|
2006-06-06 23:10:30 +04:00
|
|
|
snprintf(buf, sizeof(buf), "DestroyTag %s\n", v->name);
|
|
|
|
write_event(buf);
|
2006-03-23 18:12:06 +03:00
|
|
|
free(v);
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_frame_selectors(View *v)
|
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
Client *c;
|
|
|
|
Frame *f;
|
2006-03-23 12:36:51 +03:00
|
|
|
|
|
|
|
/* select correct frames of clients */
|
2006-06-08 12:54:19 +04:00
|
|
|
for(c=client; c; c=c->next) {
|
|
|
|
for(f=c->frame; f && f->area->view != v; f=f->cnext);
|
|
|
|
if(f)
|
|
|
|
c->sel = f;
|
2006-04-26 13:09:16 +04:00
|
|
|
}
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-03-23 12:43:57 +03:00
|
|
|
focus_view(View *v)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
2006-03-29 11:45:54 +04:00
|
|
|
Client *c;
|
2006-06-08 12:54:19 +04:00
|
|
|
|
|
|
|
cext_assert(v);
|
2006-03-23 12:36:51 +03:00
|
|
|
|
|
|
|
XGrabServer(dpy);
|
2006-06-07 21:19:16 +04:00
|
|
|
assign_sel_view(v);
|
2006-03-23 12:36:51 +03:00
|
|
|
|
|
|
|
update_frame_selectors(v);
|
|
|
|
|
|
|
|
/* gives all(!) clients proper geometry (for use of different tags) */
|
2006-06-08 12:54:19 +04:00
|
|
|
for(c=client; c; c=c->next)
|
|
|
|
if(c->sel) {
|
|
|
|
Frame *f = c->sel;
|
|
|
|
if(f && f->area->view == v) {
|
|
|
|
XMoveWindow(dpy, c->framewin, f->rect.x, f->rect.y);
|
|
|
|
resize_client(c, &f->rect, False);
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
else
|
2006-06-08 12:54:19 +04:00
|
|
|
XMoveWindow(dpy, c->framewin,
|
2006-04-26 13:09:16 +04:00
|
|
|
2 * rect.width + f->rect.x, f->rect.y);
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
2006-06-08 12:54:19 +04:00
|
|
|
|
|
|
|
if((c = selected_client()))
|
2006-04-28 14:37:19 +04:00
|
|
|
focus_client(c, True);
|
2006-06-08 12:54:19 +04:00
|
|
|
|
2006-04-28 14:37:19 +04:00
|
|
|
draw_clients();
|
2006-03-23 12:36:51 +03:00
|
|
|
XSync(dpy, False);
|
|
|
|
XUngrabServer(dpy);
|
2006-05-01 23:15:24 +04:00
|
|
|
flush_masked_events(EnterWindowMask);
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
XRectangle *
|
2006-05-29 11:50:11 +04:00
|
|
|
rects_of_view(View *v, unsigned int *num)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
2006-03-23 17:01:32 +03:00
|
|
|
XRectangle *result = nil;
|
2006-06-08 12:54:19 +04:00
|
|
|
Frame *f;
|
2006-03-23 18:12:06 +03:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
*num = 2;
|
|
|
|
for(f=v->area->frame; f; f=f->anext, (*num)++);
|
2006-03-23 12:36:51 +03:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
result = cext_emallocz(*num * sizeof(XRectangle));
|
|
|
|
for(f=v->area->frame; f; f=f->anext)
|
|
|
|
*(result++) = f->rect;
|
|
|
|
*(result++) = rect;
|
|
|
|
*(result++) = brect;
|
|
|
|
return (result - *num);
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
View *
|
|
|
|
view_of_id(unsigned short id) {
|
|
|
|
View *v;
|
|
|
|
for(v = view; v && v->id != id; v=v->next);
|
|
|
|
return v;
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
View *
|
2006-05-24 11:26:08 +04:00
|
|
|
view_of_name(const char *name)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
View *v;
|
|
|
|
for(v = view; v && strcmp(v->name, name); v=v->next);
|
|
|
|
return v;
|
2006-03-24 15:36:35 +03:00
|
|
|
}
|
|
|
|
|
2006-04-12 12:44:07 +04:00
|
|
|
static View *
|
2006-05-24 11:26:08 +04:00
|
|
|
get_view(const char *name)
|
2006-03-24 15:36:35 +03:00
|
|
|
{
|
2006-04-12 12:44:07 +04:00
|
|
|
View *v = view_of_name(name);
|
|
|
|
return v ? v : create_view(name);
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-05-24 11:26:08 +04:00
|
|
|
select_view(const char *arg)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
2006-05-24 11:26:08 +04:00
|
|
|
char buf[256];
|
|
|
|
cext_strlcpy(buf, arg, sizeof(buf));
|
|
|
|
cext_trim(buf, " \t+");
|
|
|
|
if(!strlen(buf))
|
|
|
|
return;
|
2006-06-08 12:54:19 +04:00
|
|
|
assign_sel_view(get_view(arg));
|
2006-05-23 18:56:43 +04:00
|
|
|
update_views(); /* performs focus_view */
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
|
2006-04-11 11:20:19 +04:00
|
|
|
static Bool
|
2006-04-12 12:44:07 +04:00
|
|
|
is_of_view(View *v, Client *c)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
Area *a;
|
|
|
|
for(a=v->area; a; a=a->next)
|
|
|
|
if(is_of_area(a, c))
|
2006-03-23 12:36:51 +03:00
|
|
|
return True;
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-12 12:44:07 +04:00
|
|
|
detach_from_view(View *v, Client *c)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
2006-06-10 03:57:00 +04:00
|
|
|
Area *a, *next;
|
2006-04-10 19:43:13 +04:00
|
|
|
|
2006-06-10 03:57:00 +04:00
|
|
|
for(a=v->area; a; a=next) {
|
|
|
|
next=a->next;
|
2006-06-08 12:54:19 +04:00
|
|
|
if(is_of_area(a, c)) {
|
|
|
|
detach_from_area(a, c);
|
2006-03-23 12:36:51 +03:00
|
|
|
XMoveWindow(dpy, c->framewin, 2 * rect.width, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-12 12:44:07 +04:00
|
|
|
attach_to_view(View *v, Client *c)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
|
|
|
Area *a;
|
|
|
|
|
2006-04-26 18:00:47 +04:00
|
|
|
c->revert = nil;
|
|
|
|
|
2006-05-23 00:35:20 +04:00
|
|
|
if(c->trans || c->floating || c->fixedsize
|
2006-04-26 18:23:05 +04:00
|
|
|
|| (c->rect.width == rect.width && c->rect.height == rect.height))
|
2006-06-08 12:54:19 +04:00
|
|
|
a = v->area;
|
2006-03-23 12:36:51 +03:00
|
|
|
else
|
2006-06-08 12:54:19 +04:00
|
|
|
a = v->sel;
|
2006-05-31 18:34:48 +04:00
|
|
|
attach_to_area(a, c, False);
|
2006-06-08 12:54:19 +04:00
|
|
|
v->sel = a;
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-03-23 12:43:57 +03:00
|
|
|
restack_view(View *v)
|
2006-03-23 12:36:51 +03:00
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
Area *a;
|
|
|
|
Frame *f;
|
|
|
|
Client *c;
|
|
|
|
unsigned int n=0, i=0;
|
2006-03-23 12:36:51 +03:00
|
|
|
static Window *wins = nil;
|
2006-03-23 17:01:32 +03:00
|
|
|
static unsigned int winssz = 0;
|
2006-03-23 12:36:51 +03:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
for(c=client; c; c=c->next, i++);
|
|
|
|
if(i > winssz) {
|
|
|
|
winssz = 2 * i;
|
2006-04-10 17:48:27 +04:00
|
|
|
wins = realloc(wins, sizeof(Window) * winssz);
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
for(a=v->area; a; a=a->next) {
|
|
|
|
if(a->frame) {
|
|
|
|
wins[n++] = a->sel->client->framewin;
|
|
|
|
for(f=a->frame; f; f=f->anext, f != a->sel && n++);
|
|
|
|
i=n;
|
|
|
|
for(f=a->frame; f; f=f->anext) {
|
|
|
|
Client *c = f->client;
|
|
|
|
update_client_grab(c, (v->sel == a) && (a->sel == f));
|
|
|
|
if(f != a->sel)
|
|
|
|
wins[--i] = c->framewin;
|
2006-03-23 12:36:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(n)
|
|
|
|
XRestackWindows(dpy, wins, n);
|
|
|
|
}
|
2006-03-27 09:17:47 +04:00
|
|
|
|
2006-04-24 19:39:58 +04:00
|
|
|
void
|
|
|
|
scale_view(View *v, float w)
|
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
unsigned int xoff, i=0;
|
|
|
|
Area *a;
|
2006-04-24 19:39:58 +04:00
|
|
|
float scale, dx = 0;
|
2006-05-04 01:11:14 +04:00
|
|
|
int wdiff = 0;
|
2006-04-24 19:39:58 +04:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
if(!v->area->next)
|
2006-04-24 19:39:58 +04:00
|
|
|
return;
|
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
for(a=v->area->next; a; a=a->next, i++)
|
|
|
|
dx += a->rect.width;
|
2006-04-24 19:39:58 +04:00
|
|
|
scale = w / dx;
|
2006-05-04 00:25:33 +04:00
|
|
|
xoff = 0;
|
2006-06-08 12:54:19 +04:00
|
|
|
for(a=v->area->next; a; a=a->next) {
|
2006-04-24 19:39:58 +04:00
|
|
|
a->rect.width *= scale;
|
2006-06-08 12:54:19 +04:00
|
|
|
if(!a->next)
|
2006-05-04 01:26:21 +04:00
|
|
|
a->rect.width = w - xoff;
|
|
|
|
xoff += a->rect.width;
|
2006-04-24 19:39:58 +04:00
|
|
|
}
|
2006-05-04 01:11:14 +04:00
|
|
|
|
|
|
|
/* MIN_COLWIDTH can only be respected when there is enough space; the caller should guarantee this */
|
2006-06-08 12:54:19 +04:00
|
|
|
if(i * MIN_COLWIDTH > w)
|
2006-05-04 01:11:14 +04:00
|
|
|
return;
|
2006-05-04 01:26:21 +04:00
|
|
|
xoff = 0;
|
2006-06-08 12:54:19 +04:00
|
|
|
for(a=v->area->next; a; a=a->next, i--) {
|
2006-05-04 01:11:14 +04:00
|
|
|
if(a->rect.width < MIN_COLWIDTH)
|
|
|
|
a->rect.width = MIN_COLWIDTH;
|
2006-06-08 12:54:19 +04:00
|
|
|
else if((wdiff = xoff + a->rect.width - w + i * MIN_COLWIDTH) > 0)
|
2006-05-04 01:11:14 +04:00
|
|
|
a->rect.width -= wdiff;
|
2006-06-08 12:54:19 +04:00
|
|
|
if(!a->next)
|
2006-05-04 01:11:14 +04:00
|
|
|
a->rect.width = w - xoff;
|
|
|
|
xoff += a->rect.width;
|
|
|
|
}
|
2006-04-24 19:39:58 +04:00
|
|
|
}
|
|
|
|
|
2006-03-27 09:17:47 +04:00
|
|
|
void
|
2006-04-24 19:19:50 +04:00
|
|
|
arrange_view(View *v)
|
2006-03-27 09:17:47 +04:00
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
unsigned int xoff = 0;
|
|
|
|
Area *a;
|
2006-03-27 09:17:47 +04:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
if(!v->area->next)
|
2006-03-27 09:17:47 +04:00
|
|
|
return;
|
|
|
|
|
2006-04-24 19:39:58 +04:00
|
|
|
scale_view(v, rect.width);
|
2006-06-08 12:54:19 +04:00
|
|
|
for(a=v->area->next; a; a=a->next) {
|
2006-04-24 19:19:50 +04:00
|
|
|
a->rect.x = xoff;
|
|
|
|
a->rect.y = 0;
|
|
|
|
a->rect.height = rect.height - brect.height;
|
|
|
|
xoff += a->rect.width;
|
2006-04-06 19:03:12 +04:00
|
|
|
arrange_column(a, False);
|
2006-03-27 09:17:47 +04:00
|
|
|
}
|
|
|
|
}
|
2006-04-10 19:50:39 +04:00
|
|
|
|
2006-04-11 12:16:01 +04:00
|
|
|
static void
|
|
|
|
update_client_views(Client *c)
|
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
static ViewLink *free_view_links = nil;
|
|
|
|
ViewLink *v;
|
2006-04-11 12:16:01 +04:00
|
|
|
char buf[256];
|
|
|
|
char *toks[16];
|
|
|
|
unsigned int i, n;
|
|
|
|
|
|
|
|
cext_strlcpy(buf, c->tags, sizeof(buf));
|
|
|
|
n = cext_tokenize(toks, 16, buf, '+');
|
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
while((v = c->views)) {
|
|
|
|
c->views = v->next;
|
|
|
|
v->next = free_view_links;
|
|
|
|
free_view_links = v;
|
|
|
|
}
|
2006-04-11 12:16:01 +04:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
for(i = 0; i < n; i++) {
|
|
|
|
if(free_view_links) {
|
|
|
|
v = free_view_links;
|
|
|
|
free_view_links = v->next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
v = cext_emallocz(sizeof(ViewLink));
|
|
|
|
|
|
|
|
v->next = c->views;
|
|
|
|
c->views = v;
|
|
|
|
v->view = get_view(toks[i]);
|
|
|
|
}
|
2006-04-11 12:16:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2006-04-12 12:44:07 +04:00
|
|
|
is_view_of(Client *c, View *v)
|
2006-04-11 12:16:01 +04:00
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
ViewLink *l;
|
|
|
|
for(l=c->views; l; l=l->next)
|
|
|
|
if(l->view == v)
|
2006-04-11 12:16:01 +04:00
|
|
|
return True;
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2006-06-17 15:32:49 +04:00
|
|
|
/* XXX: This will need cleanup */
|
|
|
|
unsigned char *
|
|
|
|
view_index(View *v) {
|
|
|
|
enum { BUF_MAX = 8092 };
|
|
|
|
static unsigned char buf[BUF_MAX];
|
|
|
|
unsigned int a_i, buf_i, n;
|
|
|
|
int len;
|
|
|
|
Frame *f;
|
|
|
|
Area *a;
|
|
|
|
|
|
|
|
len = BUF_MAX;
|
|
|
|
buf_i = 0;
|
|
|
|
for((a = v->area), (a_i = 0); a; (a=a->next), (a_i++)) {
|
|
|
|
for(f=a->frame; f && len > 0; f=f->anext) {
|
|
|
|
XRectangle *r = &f->rect;
|
|
|
|
if(a_i == 0)
|
|
|
|
n = snprintf(&buf[buf_i], len, "~ %d %d %d %d %d %s\n",
|
|
|
|
idx_of_client(f->client),
|
|
|
|
r->x, r->y, r->width, r->height,
|
|
|
|
f->client->props);
|
|
|
|
else
|
|
|
|
n = snprintf(&buf[buf_i], len, "%d %d %d %s\n",
|
|
|
|
a_i, idx_of_client(f->client),
|
|
|
|
r->width, f->client->props);
|
|
|
|
buf_i += n;
|
|
|
|
len -= n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: This will need cleanup too */
|
2006-06-19 12:38:21 +04:00
|
|
|
char *
|
2006-06-19 00:58:10 +04:00
|
|
|
message_view(View *v, char *message) {
|
|
|
|
unsigned int i, n;
|
|
|
|
Frame *f;
|
2006-06-19 03:04:16 +04:00
|
|
|
Client *c;
|
2006-06-19 12:38:21 +04:00
|
|
|
static char Ebadvalue[] = "bad value";
|
|
|
|
|
2006-06-19 03:04:16 +04:00
|
|
|
if(!strncmp(message, "send ", 5)) {
|
2006-06-19 00:58:10 +04:00
|
|
|
message += 5;
|
2006-06-19 03:04:16 +04:00
|
|
|
if(1 != sscanf(message, "%d %n", &i, &n))
|
2006-06-19 12:38:21 +04:00
|
|
|
return Ebadvalue;
|
2006-06-19 03:04:16 +04:00
|
|
|
for(c=client; i && c; c=c->next, i--);
|
|
|
|
if(!c)
|
2006-06-19 12:38:21 +04:00
|
|
|
return Ebadvalue;
|
2006-06-19 03:04:16 +04:00
|
|
|
for(f=c->frame; f; f=f->cnext)
|
|
|
|
if(f->area->view == v)
|
|
|
|
break;
|
2006-06-19 00:58:10 +04:00
|
|
|
if(!f)
|
2006-06-19 12:38:21 +04:00
|
|
|
return Ebadvalue;
|
2006-06-19 03:04:16 +04:00
|
|
|
return send_client(f, &message[n]);
|
2006-06-19 00:58:10 +04:00
|
|
|
}
|
2006-06-19 12:38:21 +04:00
|
|
|
return nil;
|
2006-06-17 15:32:49 +04:00
|
|
|
}
|
|
|
|
|
2006-05-23 18:56:43 +04:00
|
|
|
static Bool
|
|
|
|
is_empty(View *v)
|
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
Area *a;
|
|
|
|
for(a=v->area; a; a=a->next)
|
|
|
|
if(a->frame)
|
2006-05-23 18:56:43 +04:00
|
|
|
return False;
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
2006-04-11 12:16:01 +04:00
|
|
|
void
|
|
|
|
update_views()
|
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
View **i, *v, *old = sel;
|
|
|
|
Client *c;
|
|
|
|
|
|
|
|
for(c=client; c; c=c->next)
|
|
|
|
update_client_views(c);
|
|
|
|
|
|
|
|
for(c=client; c; c=c->next) {
|
|
|
|
for(v=view; v; v=v->next) {
|
|
|
|
update_frame_selectors(v);
|
|
|
|
if(is_view_of(c, v)) {
|
|
|
|
if(!is_of_view(v, c))
|
|
|
|
attach_to_view(v, c);
|
2006-04-11 11:20:19 +04:00
|
|
|
}
|
2006-04-11 12:16:01 +04:00
|
|
|
else {
|
2006-06-08 12:54:19 +04:00
|
|
|
if(is_of_view(v, c))
|
|
|
|
detach_from_view(v, c);
|
2006-04-10 19:50:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 18:56:43 +04:00
|
|
|
if(old && !strncmp(old->name, "nil", 4))
|
2006-05-23 20:51:16 +04:00
|
|
|
old = nil;
|
2006-06-08 12:54:19 +04:00
|
|
|
|
|
|
|
for(i=&view; *i; *i && (i=&(*i)->next))
|
|
|
|
if((*i != old) && is_empty(*i))
|
|
|
|
destroy_view(*i);
|
2006-04-10 19:50:39 +04:00
|
|
|
|
2006-04-19 18:24:19 +04:00
|
|
|
if(old)
|
|
|
|
focus_view(old);
|
2006-06-08 12:54:19 +04:00
|
|
|
else if(sel)
|
|
|
|
focus_view(sel);
|
2006-04-10 19:50:39 +04:00
|
|
|
}
|
2006-05-31 11:51:40 +04:00
|
|
|
|
|
|
|
unsigned int
|
2006-05-31 21:48:44 +04:00
|
|
|
newcolw_of_view(View *v)
|
2006-05-31 11:51:40 +04:00
|
|
|
{
|
2006-06-08 12:54:19 +04:00
|
|
|
Rule *r;
|
|
|
|
Area *a;
|
2006-05-31 11:51:40 +04:00
|
|
|
unsigned int i, n;
|
|
|
|
regmatch_t tmpregm;
|
|
|
|
|
2006-06-17 15:32:49 +04:00
|
|
|
for(r=def.colrules.rule; r; r=r->next) {
|
2006-05-31 11:51:40 +04:00
|
|
|
if(!regexec(&r->regex, v->name, 1, &tmpregm, 0)) {
|
2006-05-31 21:13:21 +04:00
|
|
|
char buf[256];
|
|
|
|
char *toks[16];
|
|
|
|
cext_strlcpy(buf, r->value, sizeof(buf));
|
|
|
|
n = cext_tokenize(toks, 16, buf, '+');
|
2006-06-08 15:14:33 +04:00
|
|
|
for(a=v->area, i=0; a; a=a->next, i++);
|
2006-06-08 15:16:24 +04:00
|
|
|
if(n && n >= i) {
|
2006-06-08 12:54:19 +04:00
|
|
|
if(sscanf(toks[i - 1], "%u", &n) == 1)
|
2006-05-31 21:13:21 +04:00
|
|
|
return (rect.width * n) / 100;
|
2006-05-31 11:51:40 +04:00
|
|
|
}
|
2006-05-31 21:13:21 +04:00
|
|
|
break;
|
2006-05-31 11:51:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|