mirror of
https://github.com/0intro/wmii
synced 2024-12-14 23:52:48 +03:00
52 lines
805 B
C
52 lines
805 B
C
/*
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
* See LICENSE file for license details.
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "wm.h"
|
|
|
|
Area *
|
|
alloc_area(Page *p)
|
|
{
|
|
static unsigned short id = 1;
|
|
Area *a = cext_emallocz(sizeof(Area));
|
|
a->page = p;
|
|
a->id = id++;
|
|
p->area = (Area **)cext_array_attach((void **)p->area, a, sizeof(Area *), &p->areasz);
|
|
p->narea++;
|
|
return a;
|
|
}
|
|
|
|
void
|
|
destroy_area(Area *a)
|
|
{
|
|
size_t i;
|
|
while(a->nclient)
|
|
detach_client(client[i], False);
|
|
free(a->client);
|
|
free(a);
|
|
}
|
|
|
|
int
|
|
area_to_index(Area *a)
|
|
{
|
|
int i;
|
|
Page *p = a->page;
|
|
for(i = 0; i < p->narea; i++)
|
|
if(p->area[i] == a)
|
|
return i;
|
|
return -1;
|
|
}
|
|
|
|
int
|
|
aid_to_index(Page *p, unsigned short id)
|
|
{
|
|
int i;
|
|
for(i = 0; i < p->narea; i++)
|
|
if(p->area[i]->id == id)
|
|
return i;
|
|
return -1;
|
|
}
|