tweak transient handling

This commit is contained in:
seanpringle
2012-08-31 02:32:23 +10:00
parent dba0314d87
commit 7e6b09d29f
2 changed files with 22 additions and 29 deletions

View File

@@ -323,13 +323,28 @@ void spot_xywh(int spot, int *x, int *y, int *w, int *h)
} }
// move a window to a screen "spot" // move a window to a screen "spot"
void client_spot(client *c, int spot) void client_spot(client *c, int spot, int force)
{ {
if (!c) return; if (!c) return;
int x, y, w, h; int x, y, w, h;
spot = MAX(SPOT1, MIN(SPOT3, spot)); spot = MAX(SPOT1, MIN(SPOT3, spot));
if (c->trans && !force)
{
client *t = window_client(c->transient_for);
spot = t->spot;
client_free(t);
}
spot_xywh(spot, &x, &y, &w, &h); spot_xywh(spot, &x, &y, &w, &h);
if (c->type == atoms[_NET_WM_WINDOW_TYPE_DIALOG])
{
x += (w - c->attr.width)/2;
y += (h - c->attr.height)/2;
w = c->attr.width + BORDER*2;
h = c->attr.height + BORDER*2;
}
c->spot = spot; c->spot = spot;
client_position(c, x, y, w, h); client_position(c, x, y, w, h);
} }
@@ -496,7 +511,7 @@ void configure_request(XConfigureRequestEvent *e)
if (c->manage && c->visible && !c->trans) if (c->manage && c->visible && !c->trans)
{ {
client_review(c); client_review(c);
client_spot(c, c->spot); client_spot(c, c->spot, 0);
} }
else else
{ {
@@ -521,30 +536,8 @@ void map_request(XMapEvent *e)
{ {
client_review(c); client_review(c);
int x, w, y, h;
int spot = SPOT_START == SPOT_CURRENT ? current_spot: SPOT_START; int spot = SPOT_START == SPOT_CURRENT ? current_spot: SPOT_START;
spot_xywh(spot, &x, &y, &w, &h); client_spot(c, spot, 0);
if (c->trans)
{
// locate a transient's parent's spot
client *t = window_client(c->transient_for);
spot = t->spot;
client_free(t);
}
if (!c->trans && c->type != atoms[_NET_WM_WINDOW_TYPE_DIALOG])
{
// fill a spot
client_spot(c, spot);
}
else
{
// center in spot at requested size
client_position(c,
x + (w - c->attr.width)/2, y + (h - c->attr.height)/2,
c->attr.width + BORDER*2, c->attr.height + BORDER*2);
c->spot = spot;
}
} }
client_free(c); client_free(c);
XMapWindow(display, e->window); XMapWindow(display, e->window);
@@ -614,15 +607,15 @@ void key_press(XKeyEvent *e)
{ {
case ACTION_MOVE_SPOT1: case ACTION_MOVE_SPOT1:
client_raise(c); client_raise(c);
client_spot(c, SPOT1); client_spot(c, SPOT1, 1);
break; break;
case ACTION_MOVE_SPOT2: case ACTION_MOVE_SPOT2:
client_raise(c); client_raise(c);
client_spot(c, SPOT2); client_spot(c, SPOT2, 1);
break; break;
case ACTION_MOVE_SPOT3: case ACTION_MOVE_SPOT3:
client_raise(c); client_raise(c);
client_spot(c, SPOT3); client_spot(c, SPOT3, 1);
break; break;
case ACTION_CYCLE: case ACTION_CYCLE:
client_cycle(c); client_cycle(c);

View File

@@ -15,7 +15,7 @@ int client_protocol(client *c, Atom protocol);
void client_close(client *c); void client_close(client *c);
void client_position(client *c, int x, int y, int w, int h); void client_position(client *c, int x, int y, int w, int h);
void spot_xywh(int spot, int *x, int *y, int *w, int *h); void spot_xywh(int spot, int *x, int *y, int *w, int *h);
void client_spot(client *c, int spot); void client_spot(client *c, int spot, int force);
void client_cycle(client *c); void client_cycle(client *c);
Window spot_active(int spot, Window except); Window spot_active(int spot, Window except);
void client_stack(client *c, stack *all, stack *raise); void client_stack(client *c, stack *all, stack *raise);