...
 
Commits (3)
......@@ -11,7 +11,7 @@ list_append(struct list *l, void *e)
}
bool
list_contains(struct list *l, void *e, bool (*f)(void *le, void *e))
list_contains(struct list *l, void const *e, bool (*f)(void *le, void const *e))
{
int unsigned i;
......@@ -44,7 +44,7 @@ list_destroy(struct list *l)
}
void *
list_find(struct list *l, void *e, bool (*f)(void *le, void *e))
list_find(struct list *l, void const *e, bool (*f)(void *le, void const *e))
{
if (!f)
die("list_find(): f == NULL");
......@@ -52,7 +52,8 @@ list_find(struct list *l, void *e, bool (*f)(void *le, void *e))
}
int unsigned
list_find_index(struct list *l, void *e, bool (*f)(void *le, void *e))
list_find_index(struct list *l, void const *e,
bool (*f)(void *le, void const *e))
{
int unsigned i;
......@@ -117,7 +118,7 @@ list_push(struct list *l, void *e)
}
void
list_remove(struct list *l, void *e, bool (*f)(void *le, void *e))
list_remove(struct list *l, void const *e, bool (*f)(void *le, void const *e))
{
int unsigned i;
......
......@@ -8,7 +8,7 @@
for (I = 0; I < L->size; ++I) \
for (E = L->elements[I]; E != NULL; E = NULL)
typedef bool (*list_eqfunc)(void *le, void *e);
typedef bool (*list_eqfunc)(void *le, void const *e);
typedef int (*list_cmpfunc)(void *e1, void *e2);
struct list {
......@@ -17,16 +17,19 @@ struct list {
};
void list_append(struct list *l, void *e);
bool list_contains(struct list *l, void *e, bool (*f)(void *le, void *e));
bool list_contains(struct list *l, void const *e,
bool (*f)(void *le, void const *e));
struct list *list_create(void);
void list_destroy(struct list *l);
void *list_find(struct list *l, void *e, bool (*f)(void *le, void *e));
int unsigned list_find_index(struct list *l, void *e,
bool (*f)(void *le, void *e));
void *list_find(struct list *l, void const *e,
bool (*f)(void *le, void const *e));
int unsigned list_find_index(struct list *l, void const *e,
bool (*f)(void *le, void const *e));
void list_insert(struct list *l, void *e, int unsigned index);
void list_insert_sorted(struct list *l, void *e, int (*f)(void *e1, void *e2));
void list_prepend(struct list *l, void *e);
void list_push(struct list *l, void *e);
void list_remove(struct list *l, void *e, bool (*f)(void *le, void *e));
void list_remove(struct list *l, void const *e,
bool (*f)(void *le, void const *e));
#endif /* ndef _KWM_LIST_H */
......@@ -9,8 +9,7 @@
#include <string.h>
static void arrange(struct wsmap *wsm);
static void arrangebox(struct wsmap *wsm, struct wsmbox *box,
struct wsmbox *centre);
static void arrangebox(struct wsmap *wsm, struct wsmbox *box);
static void
arrange(struct wsmap *wsm)
......@@ -21,32 +20,32 @@ arrange(struct wsmap *wsm)
assert(wsm->mon);
LIST_FOR (wsm->boxes, i, box)
arrangebox(wsm, box, wsm->selbox);
arrangebox(wsm, box);
}
static void
arrangebox(struct wsmap *wsm, struct wsmbox *box, struct wsmbox *centre)
arrangebox(struct wsmap *wsm, struct wsmbox *box)
{
struct config const *config = config_get();
struct position pos;
struct size boxsize;
struct size size;
assert(wsm->mon);
/* box dimensions */
boxsize = config->wsmbox.size;
size = config->wsmbox.size;
/* start at centre of monitor */
pos.x = wsm->mon->dim.x + (int) (0.5 * (double) wsm->mon->dim.width);
pos.y = wsm->mon->dim.y + (int) (0.5 * (double) wsm->mon->dim.width);
/* shift based on offset to centre box */
pos.x += (box->pos.x - centre->pos.x) * (int signed) boxsize.width;
pos.y += (box->pos.y - centre->pos.y) * (int signed) boxsize.height;
pos.x += (box->pos.x - wsm->selbox->pos.x) * (int signed) size.width;
pos.y += (box->pos.y - wsm->selbox->pos.y) * (int signed) size.height;
/* shift box center to that position */
pos.x -= (int signed) boxsize.width / 2;
pos.y -= (int signed) boxsize.height / 2;
pos.x -= (int signed) size.width / 2;
pos.y -= (int signed) size.height / 2;
wsmbox_move(box, pos);
}
......
......@@ -139,6 +139,13 @@ wsmbox_destroy(struct wsmbox *wb)
free(wb);
}
bool
wsmbox_has_name(struct wsmbox *wb, char const *name)
{
return wb->workspace
&& strcmp(wb->workspace->name, name) == 0;
}
bool
wsmbox_manages_window(struct wsmbox *wb, Window *win)
{
......
......@@ -21,6 +21,7 @@ struct wsmbox {
struct wsmbox *wsmbox_create(struct workspace *ws, struct wsmap *map);
struct wsmbox *wsmbox_create_ng(void);
void wsmbox_destroy(struct wsmbox *wb);
bool wsmbox_has_name(struct wsmbox *wb, char const *name);
bool wsmbox_manages_window(struct wsmbox *wb, Window *win);
bool wsmbox_manages_workspace(struct wsmbox *wb, struct workspace *ws);
void wsmbox_move(struct wsmbox *wb, struct position pos);
......