{
XDestroyWindowEvent* ev = &(e->xdestroywindow);
printf("DESTROY(w: 0x%lx)\n", ev->window);
- Client* c = client_get(ev->window, NULL);
- if (c)
+ Location loc = {0};
+ if (mons_find(ev->window, &loc))
{
- if (Focused == c)
+ if (Focused == loc.client)
{
Focused = NULL;
}
- mons_delclient(c);
+ mons_delclient(&loc);
}
}
enum {
F_WM_DELETE = (1 << 0),
F_DIALOG = (1 << 1),
- F_SHADED = (1 << 2),
+ F_FLOATING = (1 << 2),
+ F_SHADED = (1 << 3),
};
typedef struct Node {
void mons_init(void);
void mons_layer(Monitor* mon);
void mons_addclient(Client* c);
-void mons_delclient(Client* c);
+void mons_delclient(Location* loc);
+void mons_togglefloat(Location* loc);
int mons_find(Window win, Location* loc);
void mons_place(Client* c);
void mons_wspace(int i);
if (XGetWindowAttributes(X.disp, wins[i], &attr) && !attr.override_redirect)
{
Client* c = client_add(wins[i], &attr);
- c->flags |= F_DIALOG;
+ c->flags |= F_FLOATING;
}
}
xfree(wins);
X.disp, c->win, atom("_NET_WM_WINDOW_TYPE"), 0L, -1, False, XA_ATOM, &actual_type, &format, &n, &extra, (unsigned char **)&wintype);
if (wintype && *wintype == atom("_NET_WM_WINDOW_TYPE_DIALOG"))
{
- c->flags |= F_DIALOG;
+ c->flags |= F_DIALOG|F_FLOATING;
}
xfree(wintype);
client_warpmouse(c);
}
-void mons_delclient(Client* c)
+void mons_delclient(Location* loc)
{
- Location loc = {0};
- if (mons_find(c->win, &loc))
+ remove_client(loc, loc->client);
+ xfree(loc->client->name);
+ XDestroyWindow(X.disp, loc->client->frame);
+ free(loc->client);
+}
+
+void mons_togglefloat(Location* loc)
+{
+ remove_client(loc, loc->client);
+ if (loc->client->flags & (F_FLOATING))
+ {
+ loc->client->flags &= ~F_FLOATING;
+ }
+ else
{
- remove_client(&loc, c);
- xfree(c->name);
- XDestroyWindow(X.disp, c->frame);
- free(c);
+ loc->client->flags |= F_FLOATING;
}
+ mons_addclient(loc->client);
}
int mons_find(Window win, Location* loc)
static void add_client(Monitor* mon, Client* c, int ptrx)
{
- if (X.mode == M_INIT || c->flags & F_DIALOG)
+ if (X.mode == M_INIT || c->flags & (F_DIALOG|F_FLOATING))
{
c->next = mon->cspace->floating;
mon->cspace->floating = c;
}
else if (ev->state & (MODKEY|ShiftMask))
{
- puts("to tile mode");
+ mons_togglefloat(loc);
}
else
{
}
else if (ev->state & (MODKEY|ShiftMask))
{
- puts("to float mode");
+ mons_togglefloat(loc);
}
else
{
}
else if (ev->state & (MODKEY|ShiftMask))
{
- puts("to float mode");
+ mons_togglefloat(loc);
}
else
{
col->clients = c;
col->focused = c;
coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h));
+ client_setshade(c, 0);
client_adjust(c);
mons_layer(mon);
}