[client] Merge zoom with swap, change togglefloating to setfloating

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-02 16:11:21 +02:00
parent ed7865c37b
commit c88b0b15ff
3 changed files with 35 additions and 41 deletions

View File

@ -377,13 +377,14 @@ keys
{ {
modkey = {"Mod4", "Control"} modkey = {"Mod4", "Control"}
key = "Return" key = "Return"
command = "client_zoom" command = "client_swap"
arg = "0"
} }
key key
{ {
modkey = {"Mod4", "Control"} modkey = {"Mod4", "Control"}
key = "space" key = "space"
command = "client_togglefloating" command = "client_setfloating"
} }
key key
{ {

View File

@ -938,6 +938,8 @@ client_find_visible(client_t *sel, int nindex)
} }
/** Swap the currently focused client with another one. /** Swap the currently focused client with another one.
* The argument must be an integer 1 for next, 2 for next of next, -1 for
* previous, etc. 0 will swap with the visible master window.
* \param screen Virtual screen number. * \param screen Virtual screen number.
* \param arg Relative number in the client stack. * \param arg Relative number in the client stack.
* \ingroup ui_callback * \ingroup ui_callback
@ -945,12 +947,19 @@ client_find_visible(client_t *sel, int nindex)
void void
uicb_client_swap(int screen, char *arg) uicb_client_swap(int screen, char *arg)
{ {
client_t *next; client_t *swap = NULL;
int i = atoi(arg); int i = atoi(arg);
if((next = client_find_visible(globalconf.focus->client, i))) if(i)
swap = client_find_visible(globalconf.focus->client, i);
else if(globalconf.focus->client == globalconf.clients)
swap = client_find_visible(globalconf.focus->client, 1);
else
swap = globalconf.clients;
if(swap)
{ {
client_list_swap(&globalconf.clients, next, globalconf.focus->client); client_list_swap(&globalconf.clients, swap, globalconf.focus->client);
globalconf.screens[screen].need_arrange = true; globalconf.screens[screen].need_arrange = true;
widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS);
} }
@ -1116,13 +1125,13 @@ uicb_client_togglemax(int screen, char *arg)
area = screen_get_area(screen, area = screen_get_area(screen,
globalconf.screens[screen].statusbar, globalconf.screens[screen].statusbar,
&globalconf.screens[screen].padding); &globalconf.screens[screen].padding);
if(arg[0] == 'v') if(arg && arg[0] == 'v')
{ {
area.x = globalconf.focus->client->geometry.x; area.x = globalconf.focus->client->geometry.x;
area.width = globalconf.focus->client->geometry.width; area.width = globalconf.focus->client->geometry.width;
area.height -= 2 * globalconf.focus->client->border; area.height -= 2 * globalconf.focus->client->border;
} }
else if(arg[0] == 'h') else if(arg && arg[0] == 'h')
{ {
area.y = globalconf.focus->client->geometry.y; area.y = globalconf.focus->client->geometry.y;
area.height = globalconf.focus->client->geometry.height; area.height = globalconf.focus->client->geometry.height;
@ -1136,31 +1145,6 @@ uicb_client_togglemax(int screen, char *arg)
client_maximize(globalconf.focus->client, area); client_maximize(globalconf.focus->client, area);
} }
/** Move the client to the master area.
* \param screen Screen ID
* \param arg Unused
* \ingroup ui_callback
*/
void
uicb_client_zoom(int screen, char *arg __attribute__ ((unused)))
{
client_t *c, *sel = globalconf.focus->client;
if(!sel)
return;
for(c = globalconf.clients; !client_isvisible(c, screen); c = c->next);
if(c == sel)
for(sel = sel->next; sel && !client_isvisible(sel, screen); sel = sel->next);
if(sel)
{
client_list_detach(&globalconf.clients, sel);
client_list_push(&globalconf.clients, sel);
globalconf.screens[screen].need_arrange = true;
}
}
/** Give focus to the next or previous visible client in the stack. /** Give focus to the next or previous visible client in the stack.
* \param screen Virtual screen number. * \param screen Virtual screen number.
* \param arg Relative number in the client stack. * \param arg Relative number in the client stack.
@ -1176,17 +1160,27 @@ uicb_client_focus(int screen, char *arg)
client_focus(next, screen, true); client_focus(next, screen, true);
} }
/** Toggle the floating state of the focused client. /** Set or toggle the floating state of the focused client.
* \param screen Screen ID * Argument must be none to toggle, or a boolean value to set.
* \param arg unused * \param screen Virtual screen number.
* \param arg
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_togglefloating(int screen __attribute__ ((unused)), char *arg __attribute__ ((unused))) uicb_client_setfloating(int screen __attribute__ ((unused)), char *arg)
{ {
if(globalconf.focus->client) bool floating;
client_setfloating(globalconf.focus->client, !globalconf.focus->client->isfloating,
globalconf.focus->client->layer == LAYER_FLOAT ? LAYER_TILE : LAYER_FLOAT); if(!globalconf.focus->client)
return;
if(!arg)
floating = !globalconf.focus->client->isfloating;
else
floating = a_strtobool(arg);
client_setfloating(globalconf.focus->client, !globalconf.focus->client->isfloating,
globalconf.focus->client->layer == LAYER_FLOAT ? LAYER_TILE : LAYER_FLOAT);
} }
/** Toggle the scratch client attribute on the focused client. /** Toggle the scratch client attribute on the focused client.

View File

@ -50,9 +50,8 @@ uicb_t uicb_client_moveresize;
uicb_t uicb_client_settrans; uicb_t uicb_client_settrans;
uicb_t uicb_client_swap; uicb_t uicb_client_swap;
uicb_t uicb_client_togglemax; uicb_t uicb_client_togglemax;
uicb_t uicb_client_zoom;
uicb_t uicb_client_focus; uicb_t uicb_client_focus;
uicb_t uicb_client_togglefloating; uicb_t uicb_client_setfloating;
uicb_t uicb_client_togglescratch; uicb_t uicb_client_togglescratch;
uicb_t uicb_client_setscratch; uicb_t uicb_client_setscratch;