wc.border_width = ev->border_width;
wc.sibling = ev->above;
wc.stack_mode = ev->detail;
- XConfigureWindow(X.disp, ev->window, ev->value_mask, &wc);
Client* c = client_get(ev->window, NULL);
if (c && c->win == ev->window)
{
c->w = wc.width;
c->h = wc.height;
- client_resize(c, 0, 0);
+ client_adjust(c);
if (X.mode == M_RESIZE && Focused == c)
{
warp_mouse(c);
}
}
+ else
+ {
+ XConfigureWindow(X.disp, ev->window, ev->value_mask, &wc);
+ }
}
static void xmaprequest(XEvent* e)
static void xclientmsg(XEvent* e)
{
- (void)e;
+ XClientMessageEvent* ev = &(e->xclient);
+ printf("CLIENT_MSG(w: 0x%lx a: '%s')\n", ev->window, XGetAtomName(X.disp, ev->message_type));
+ if (ev->message_type == atom("_NET_ACTIVE_WINDOW"))
+ {
+ printf("ACTIVATE(w: %lx)\n", ev->window);
+ mons_activate(ev->window);
+ }
}
static void xpropnotify(XEvent* e)
void mons_coljoin(void);
void mons_coladjust(Monitor* mon, Column* col, int wdiff);
void mons_tilemove(Location* loc, int hdiff);
+void mons_activate(Window win);
/* client.c */
extern Client* Focused;
/* tile.c */
void monocled_add(Monitor* mon, Column* col, Client* c);
void monocled_del(Monitor* mon, Column* col, Client* c);
+void monocled_raise(Monitor* mon, Column* col, Client* c);
void monocled_set(Monitor* mon, Column* col, Client* c);
void stacked_add(Monitor* mon, Column* col, Client* c);
void stacked_del(Monitor* mon, Column* col, Client* c);
void client_adjust(Client* c)
{
- if (c->w < MIN_HEIGHT) c->w = MIN_HEIGHT;
- if (c->h < MIN_HEIGHT) c->h = MIN_HEIGHT;
+ int shaded = (c->flags & F_SHADED);
+ int minheight = (shaded ? MIN_HEIGHT : 3*MIN_HEIGHT);
+ if (c->w < minheight) c->w = minheight;
+ if (c->h < minheight) c->h = minheight;
XMoveResizeWindow(X.disp, c->frame, c->x, c->y, c->w, c->h);
printf("CONFIG(c: %lx x: %d y: %d w: %d h: %d)\n", c->frame, c->x, c->y, c->w, c->h);
if ( !(c->flags & F_SHADED) )
{
- XResizeWindow(X.disp, c->win,
- c->w - 2*BORDER_WIDTH - 2,
- c->h - 2*BORDER_WIDTH - TITLE_HEIGHT - 2);
+ int child_w = c->w - 2*BORDER_WIDTH - 2;
+ int child_h = c->h - 2*BORDER_WIDTH - TITLE_HEIGHT - 2;
+ if (child_w < 1) c->w = 1;
+ if (child_h < 1) c->h = 1;
+ XResizeWindow(X.disp, c->win, child_w, child_h);
}
mons_place(c);
}
void client_warpmouse(Client* c)
{
(void)c;
- //XWarpPointer(X.disp, None, X.root, 0, 0, 0, 0, (c->x + c->w/2), c->y + (MIN_HEIGHT/2));
+// XWarpPointer(X.disp, None, X.root, 0, 0, 0, 0, (c->x + c->w/2), c->y + (MIN_HEIGHT/2));
}
static void add_client(Monitor* mon, Client* c, int ptrx);
static void remove_client(Location* loc, Client* c);
static void adjust_all(Column* col, int xoff);
+static void change_wspace(Monitor* mon, Workspace* wspace);
Monitor* Monitors = NULL;
void mons_wspace(int wsid)
{
Monitor* mon = pickmon();
- Workspace* wspace = pickws(mon, wsid);
- if (mon->cspace != wspace)
- {
- client_visibility(mon->cspace, 0);
- client_visibility(wspace, 1);
- mon->cspace = wspace;
- }
+ change_wspace(mon, pickws(mon, wsid));
}
void mons_towspace(Client* c, int wsid)
}
}
+void mons_activate(Window win)
+{
+ Location loc;
+ if (mons_find(win, &loc))
+ {
+ change_wspace(loc.monitor, loc.workspace);
+ if (loc.column && loc.column->focused)
+ {
+ monocled_raise(loc.monitor, loc.column, loc.client);
+ mons_layer(loc.monitor);
+ }
+ else
+ {
+ mons_raise(loc.monitor, loc.client);
+ }
+ }
+}
+
static Monitor* pickmon(void)
{
get_mouse(&PtrX, &PtrY);
client_adjust(c);
}
}
+
+static void change_wspace(Monitor* mon, Workspace* wspace)
+{
+ if (mon->cspace != wspace)
+ {
+ client_visibility(mon->cspace, 0);
+ client_visibility(wspace, 1);
+ mon->cspace = wspace;
+ }
+}
}
}
+void monocled_raise(Monitor* mon, Column* col, Client* c)
+{
+ col->clients = list_del(col->clients, c);
+ c->next = col->clients;
+ col->clients = c;
+ col->focused = c;
+ coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h));
+ client_adjust(c);
+}
+
void monocled_set(Monitor* mon, Column* col, Client* c)
{
col->clients = list_del(col->clients, c);