2006-02-03 18:15:36 +03:00
|
|
|
/*
|
|
|
|
* (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()
|
|
|
|
{
|
2006-02-03 20:11:22 +03:00
|
|
|
static unsigned short id = 1;
|
2006-02-03 18:15:36 +03:00
|
|
|
Area *a = cext_emallocz(sizeof(Area));
|
|
|
|
|
|
|
|
a->id = id++;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
destroy_area(Area *a)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
while(a->nclient)
|
|
|
|
detach_client(client[i], False);
|
|
|
|
free(a->client);
|
|
|
|
free(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
index_of_area(Page *p, Area *a)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < p->narea; i++)
|
|
|
|
if(p->area[i] == a)
|
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
index_of_area_id(Page *p, unsigned short id)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if(id == NEW_OBJ)
|
|
|
|
return p->narea;
|
|
|
|
for(i = 0; i < p->narea; i++)
|
|
|
|
if(p->area[i]->id == id)
|
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|