} XConf;
enum {
- F_WM_DELETE = (1 << 0)
+ F_WM_DELETE = (1 << 0),
+ F_DIALOG = (1 << 1),
};
typedef struct Client {
Client* client_add(Window win, XWindowAttributes* attr);
void client_draw(Client* c);
Client* client_get(Window w, Location* loc);
+void client_adjust(Client* c);
void client_move(Client* c, int xdiff, int ydiff);
void client_resize(Client* c, int xdiff, int ydiff);
void client_close(Client* c);
return c;
}
-void client_raise(Client* c)
+void client_adjust(Client* c)
{
- XRaiseWindow(X.disp, c->frame);
- XRaiseWindow(X.disp, c->win);
-}
-
-void client_lower(Client* c)
-{
- XLowerWindow(X.disp, c->win);
- XLowerWindow(X.disp, c->frame);
+ client_move(c, 0, 0);
+ client_resize(c, 0, 0);
}
void client_move(Client* c, int xdiff, int ydiff)
XMoveWindow(X.disp, c->frame,
c->x - BORDER_WIDTH,
c->y - TITLE_HEIGHT - BORDER_WIDTH);
- XSync(X.disp, False);
mons_place(c);
}
XResizeWindow(X.disp, c->frame,
c->w + 2*BORDER_WIDTH,
c->h + 2*BORDER_WIDTH + TITLE_HEIGHT);
- XSync(X.disp, False);
mons_place(c);
}
void client_readprops(Client* c)
{
- Atom *protos = NULL, actual_type;
+ Atom *protos = NULL, actual_type, *wintype;
int format, nprotos = 0;
unsigned long n, extra;
+
+ /* get window title */
xfree(c->name);
c->name = NULL;
XGetWindowProperty(
- X.disp, c->win, XA_WM_NAME, 0L, 100L, False, AnyPropertyType, &actual_type, &format, &n, &extra, (unsigned char **)&c->name);
+ X.disp, c->win, XA_WM_NAME, 0, -1, False, AnyPropertyType, &actual_type, &format, &n, &extra, (unsigned char **)&c->name);
+
+ /* check if the window is a dialog */
+ XGetWindowProperty(
+ 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;
+ }
+ xfree(wintype);
+
+ /* get the other hints and protocols */
XGetWMNormalHints(X.disp, c->win, &(c->hints), &(c->hint_flags));
XGetWMProtocols(X.disp, c->win, &protos, &nprotos);
for (int i = 0; i < nprotos; i++)
static void coldims(Monitor* mon, Column* col, int *x, int *y, int *w, int *h)
{
*x = mon->x, *y = mon->y, *w = col->width, *h = mon->h;
+// printf("bef: %d %d %d %d\n", mon->x, mon->y, col->width, mon->h);
+// printf("mon: %d %d %d %d\n", mon->x, mon->y, mon->w, mon->h);
for (Column* c = mon->cspace->columns; c != col; *x += c->width, c = c->next);
*x += BORDER_WIDTH;
*y += BORDER_WIDTH + TITLE_HEIGHT;
- *w -= 2*BORDER_WIDTH;
- *h -= 2*BORDER_WIDTH + TITLE_HEIGHT;
+ *w -= (2*BORDER_WIDTH) + 2;
+ *h -= (2*BORDER_WIDTH + TITLE_HEIGHT) + 2;
+// printf("%d %d %d %d\n", *x, *y, *w, *h);
}
void mons_layer(Monitor* mon)
static void tile_monocle(Monitor* mon, Column* col, Client* c)
{
coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h));
- client_move(c, 0, 0);
- client_resize(c, 0, 0);
+ client_adjust(c);
c->next = col->clients;
col->clients = c;
}
static void tile_expand(Monitor* mon, Column* col, Client* client)
{
+ /*
+ * stack all existing clients top to bottom only showing title bars
+ * move+resize new client to fill remaining space or place its title bar at bottom of screen
+ */
(void)mon, (void)col;
client->next = col->clients;
col->clients = client;
static void tile_stacked(Monitor* mon, Column* col, Client* client)
{
+ /*
+ * find biggest client in stack
+ * split that client in half
+ * move+resize new client to fill the gap
+ */
(void)mon, (void)col;
client->next = col->clients;
col->clients = client;
int ptrx = 0, ptry = 0, winx = 0, winy = 0, mask = 0;
XQueryPointer(X.disp, X.root, &root, &child, &ptrx, &ptry, &winx, &winy, (unsigned int*)&mask);
Monitor* mon = pickmon(ptrx, ptry);
- if (X.mode == M_INIT)
+ if (X.mode == M_INIT || c->flags & F_DIALOG)
{
c->next = mon->cspace->floating;
mon->cspace->floating = c;
/* otherwise, return the current column */
if (!col)
{
-// puts("searching for active col");
int left = 0, right = 0;
for (col = cols; col; col = col->next)
{
left = right, right += col->width;
-// printf("%d <= %d < %d\n", left, relx, right);
if (left <= relx && relx < right)
{
break; /* we found the column holding the mouse */