Replace layout_toggle_free by client_toggle_free, fix re-integration in tiled layout

This commit is contained in:
Martin Duquesnoy 2012-01-26 20:47:46 +01:00
parent 6b349bb4e4
commit dc377e30bd
8 changed files with 45 additions and 22 deletions

View File

@ -581,7 +581,7 @@ client_focus(struct client *c)
client_tab_focus(c); client_tab_focus(c);
client_frame_update(c, CCOL(c)); client_frame_update(c, CCOL(c));
if(c->flags & CLIENT_FREE) if(c->flags & CLIENT_FREE && !(c->flags & CLIENT_FULLSCREEN))
XRaiseWindow(W->dpy, c->frame); XRaiseWindow(W->dpy, c->frame);
XSetInputFocus(W->dpy, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(W->dpy, c->win, RevertToPointerRoot, CurrentTime);
@ -950,7 +950,7 @@ client_update_props(struct client *c, Flags f)
} }
} }
static void void
client_geo_hints(struct geo *g, int *s) client_geo_hints(struct geo *g, int *s)
{ {
/* base */ /* base */
@ -1326,6 +1326,28 @@ client_remove(struct client *c)
free(c); free(c);
} }
void
uicb_client_toggle_free(Uicb cmd)
{
struct client *c;
(void)cmd;
if(!(W->client))
return;
W->client->flags ^= CLIENT_FREE;
/* Set tabbed client of toggled client as free */
if(W->client->flags & CLIENT_TABMASTER)
{
SLIST_FOREACH(c, &W->client->tag->clients, tnext)
if(c->tabmaster == W->client)
c->flags ^= CLIENT_FREE;
}
layout_client(W->client);
}
void void
client_free(void) client_free(void)
{ {

View File

@ -37,6 +37,7 @@ void client_get_name(struct client *c);
void client_close(struct client *c); void client_close(struct client *c);
void uicb_client_close(Uicb cmd); void uicb_client_close(Uicb cmd);
struct client *client_new(Window w, XWindowAttributes *wa, bool scan); struct client *client_new(Window w, XWindowAttributes *wa, bool scan);
void client_geo_hints(struct geo *g, int *s);
void client_get_sizeh(struct client *c); void client_get_sizeh(struct client *c);
bool client_winsize(struct client *c, struct geo *geo); bool client_winsize(struct client *c, struct geo *geo);
bool client_moveresize(struct client *c, struct geo *g); bool client_moveresize(struct client *c, struct geo *g);
@ -56,6 +57,7 @@ void client_update_props(struct client *c, Flags f);
inline void client_fac_hint(struct client *c); inline void client_fac_hint(struct client *c);
void uicb_client_untab(Uicb cmd); void uicb_client_untab(Uicb cmd);
void uicb_client_toggle_free(Uicb cmd);
/* Generated */ /* Generated */
void uicb_client_resize_Right(Uicb); void uicb_client_resize_Right(Uicb);

View File

@ -46,7 +46,6 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] =
{ "layout_rotate_right", uicb_layout_rotate_right }, { "layout_rotate_right", uicb_layout_rotate_right },
{ "layout_prev_set", uicb_layout_prev_set }, { "layout_prev_set", uicb_layout_prev_set },
{ "layout_next_set", uicb_layout_next_set }, { "layout_next_set", uicb_layout_next_set },
{ "layout_toggle_free", uicb_layout_toggle_free },
/* Client */ /* Client */
{ "client_close", uicb_client_close }, { "client_close", uicb_client_close },
@ -74,6 +73,7 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] =
{ "client_focus_next_tab", uicb_client_focus_next_tab }, { "client_focus_next_tab", uicb_client_focus_next_tab },
{ "client_focus_prev_tab", uicb_client_focus_prev_tab }, { "client_focus_prev_tab", uicb_client_focus_prev_tab },
{ "client_focus_click", uicb_client_focus_click }, { "client_focus_click", uicb_client_focus_click },
{ "client_toggle_free", uicb_client_toggle_free },
/* Status */ /* Status */
{ "status" , uicb_status }, { "status" , uicb_status },

View File

@ -371,17 +371,27 @@ layout_split_integrate(struct client *c, struct client *sc)
|| sc->flags & CLIENT_FREE) || sc->flags & CLIENT_FREE)
{ {
/* /*
* Not even a first client in list, then * check for the first tiled client or
* maximize the lonely client * maximize the lonely client
*/ */
if(!(sc = SLIST_NEXT(SLIST_FIRST(&c->tag->clients), tnext)) FOREACH_NFCLIENT(sc, &c->tag->clients, tnext)
|| sc->flags & CLIENT_FREE) {
if(!(sc->flags & CLIENT_TILED) || sc == c)
continue;
break;
}
/* Ok there is no client to integrate in */
if(!sc)
{ {
client_maximize(c); client_maximize(c);
c->flags |= CLIENT_TILED;
return; return;
} }
} }
c->flags |= CLIENT_TILED;
g = layout_split(sc, (sc->geo.h < sc->geo.w)); g = layout_split(sc, (sc->geo.h < sc->geo.w));
client_moveresize(c, &g); client_moveresize(c, &g);
@ -555,6 +565,7 @@ layout_client(struct client *c)
if(c->flags & CLIENT_FREE) if(c->flags & CLIENT_FREE)
{ {
c->flags &= ~CLIENT_TILED;
layout_split_arrange_closed(c); layout_split_arrange_closed(c);
client_moveresize(c, &c->fgeo); client_moveresize(c, &c->fgeo);
XRaiseWindow(W->dpy, c->frame); XRaiseWindow(W->dpy, c->frame);
@ -562,17 +573,3 @@ layout_client(struct client *c)
else if(!(c->flags & CLIENT_TABBED)) else if(!(c->flags & CLIENT_TABBED))
layout_split_integrate(c, c->tag->sel); layout_split_integrate(c, c->tag->sel);
} }
void
uicb_layout_toggle_free(Uicb cmd)
{
(void)cmd;
if(!(W->client))
return;
W->client->flags ^= CLIENT_FREE;
layout_client(W->client);
}

View File

@ -41,7 +41,6 @@ void uicb_layout_rotate_left(Uicb cmd);
void uicb_layout_rotate_right(Uicb cmd); void uicb_layout_rotate_right(Uicb cmd);
void uicb_layout_prev_set(Uicb cmd); void uicb_layout_prev_set(Uicb cmd);
void uicb_layout_next_set(Uicb cmd); void uicb_layout_next_set(Uicb cmd);
void uicb_layout_toggle_free(Uicb cmd);
#endif /* LAYOUT_H */ #endif /* LAYOUT_H */

View File

@ -9,7 +9,6 @@
#include "client.h" #include "client.h"
#include "draw.h" #include "draw.h"
#define _REV_SBORDER(c) draw_reversed_rect(W->root, c, false); #define _REV_SBORDER(c) draw_reversed_rect(W->root, c, false);
#define _REV_BORDER() \ #define _REV_BORDER() \

View File

@ -197,6 +197,7 @@ struct client
#define CLIENT_MAPPED 0x400 #define CLIENT_MAPPED 0x400
#define CLIENT_FULLSCREEN 0x800 #define CLIENT_FULLSCREEN 0x800
#define CLIENT_FREE 0x1000 #define CLIENT_FREE 0x1000
#define CLIENT_TILED 0x2000
Flags flags; Flags flags;
Window win, frame, tmp; Window win, frame, tmp;
SLIST_ENTRY(client) next; /* Global list */ SLIST_ENTRY(client) next; /* Global list */

3
wmfsrc
View File

@ -240,6 +240,9 @@
[key] mod = {"Super"} key = "o" func = "layout_prev_set" [/key] [key] mod = {"Super"} key = "o" func = "layout_prev_set" [/key]
[key] mod = {"Super", "Shift"} key = "o" func = "layout_next_set" [/key] [key] mod = {"Super", "Shift"} key = "o" func = "layout_next_set" [/key]
# Toggle client free/tile
[key] mod = {"Super"} key = "f" func = "client_toggle_free" [/key]
# Launcher # Launcher
[key] mod = {"Super"} key = "p" func = "launcher" cmd = "exec" [/key] [key] mod = {"Super"} key = "p" func = "launcher" cmd = "exec" [/key]