Cfactor/Client: Use macro to generate redundant uicb functions #2
This commit is contained in:
parent
9e932ec98a
commit
c054e529a3
@ -32,6 +32,20 @@
|
||||
|
||||
#include "wmfs.h"
|
||||
|
||||
#define CLIENT_RESIZE_DIR(d) \
|
||||
void \
|
||||
uicb_client_resize_##d(uicb_t cmd) \
|
||||
{ \
|
||||
CHECK(sel); \
|
||||
cfactor_set(sel, d, atoi(cmd)); \
|
||||
}
|
||||
|
||||
/* uicb_client_resize_dir() */
|
||||
CLIENT_RESIZE_DIR(Right);
|
||||
CLIENT_RESIZE_DIR(Left);
|
||||
CLIENT_RESIZE_DIR(Top);
|
||||
CLIENT_RESIZE_DIR(Bottom);
|
||||
|
||||
/** Clean client tile factors
|
||||
*\param c Client pointer
|
||||
*/
|
||||
@ -302,51 +316,4 @@ cfactor_multi_set(Client *c, int fac[4])
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
uicb_client_resize_right(uicb_t cmd)
|
||||
{
|
||||
int n = atoi(cmd);
|
||||
|
||||
CHECK(sel);
|
||||
|
||||
cfactor_set(sel, Right, n);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
uicb_client_resize_left(uicb_t cmd)
|
||||
{
|
||||
int n = atoi(cmd);
|
||||
|
||||
CHECK(sel);
|
||||
|
||||
cfactor_set(sel, Left, n);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
uicb_client_resize_top(uicb_t cmd)
|
||||
{
|
||||
int n = atoi(cmd);
|
||||
|
||||
CHECK(sel);
|
||||
|
||||
cfactor_set(sel, Top, n);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
uicb_client_resize_bottom(uicb_t cmd)
|
||||
{
|
||||
int n = atoi(cmd);
|
||||
|
||||
CHECK(sel);
|
||||
|
||||
cfactor_set(sel, Bottom, n);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
196
src/client.c
196
src/client.c
@ -32,6 +32,55 @@
|
||||
|
||||
#include "wmfs.h"
|
||||
|
||||
#define client_swapsel(c) \
|
||||
do \
|
||||
{ \
|
||||
client_swap(sel, c); \
|
||||
client_focus(c); \
|
||||
} while(/* CONSTCOND */ 0) \
|
||||
|
||||
#define CLIENT_ACTION_LIST(A, L) \
|
||||
void \
|
||||
uicb_client_##A##_##L(uicb_t cmd) \
|
||||
{ \
|
||||
Client *c; \
|
||||
(void)cmd; \
|
||||
\
|
||||
if((c = client_get_##L())) \
|
||||
client_##A(c); \
|
||||
}
|
||||
|
||||
#define CLIENT_ACTION_DIR(A, D) \
|
||||
void \
|
||||
uicb_client_##A##_##D(uicb_t cmd) \
|
||||
{ \
|
||||
Client *c; \
|
||||
(void)cmd; \
|
||||
\
|
||||
if((c = client_get_next_with_direction(sel, D))) \
|
||||
client_##A(c); \
|
||||
} \
|
||||
|
||||
/* uicb_client_focus_List() */
|
||||
CLIENT_ACTION_LIST(focus, next);
|
||||
CLIENT_ACTION_LIST(focus, prev);
|
||||
|
||||
/* uicb_client_swap_List() */
|
||||
CLIENT_ACTION_LIST(swapsel, next);
|
||||
CLIENT_ACTION_LIST(swapsel, prev);
|
||||
|
||||
/* uicb_client_focus_Dir() */
|
||||
CLIENT_ACTION_DIR(focus, Right);
|
||||
CLIENT_ACTION_DIR(focus, Left);
|
||||
CLIENT_ACTION_DIR(focus, Top);
|
||||
CLIENT_ACTION_DIR(focus, Bottom);
|
||||
|
||||
/* uicb_client_swap_Dir() */
|
||||
CLIENT_ACTION_DIR(swapsel, Right);
|
||||
CLIENT_ACTION_DIR(swapsel, Left);
|
||||
CLIENT_ACTION_DIR(swapsel, Top);
|
||||
CLIENT_ACTION_DIR(swapsel, Bottom);
|
||||
|
||||
/** Attach client in the client chain
|
||||
* \param c Client pointer
|
||||
*/
|
||||
@ -109,7 +158,7 @@ client_get_next(void)
|
||||
/** Get the previous client
|
||||
*\return The previous client or NULL
|
||||
*/
|
||||
static Client*
|
||||
Client*
|
||||
client_get_prev(void)
|
||||
{
|
||||
Client *c = NULL, *d;
|
||||
@ -162,151 +211,6 @@ client_get_next_with_direction(Client *bc, Position pos)
|
||||
return c;
|
||||
}
|
||||
|
||||
/** Switch to the previous client
|
||||
* \param cmd uicb_t type unused
|
||||
*/
|
||||
void
|
||||
uicb_client_prev(uicb_t cmd)
|
||||
{
|
||||
Client *c;
|
||||
(void)cmd;
|
||||
|
||||
if((c = client_get_prev()))
|
||||
{
|
||||
client_focus(c);
|
||||
client_raise(c);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Switch to the next client
|
||||
* \param cmd uicb_t type unused
|
||||
*/
|
||||
void
|
||||
uicb_client_next(uicb_t cmd)
|
||||
{
|
||||
Client *c;
|
||||
(void)cmd;
|
||||
|
||||
if((c = client_get_next()))
|
||||
{
|
||||
client_focus(c);
|
||||
client_raise(c);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Swap the current client with the next one
|
||||
*\param cmd uicb_t type unused
|
||||
*/
|
||||
void
|
||||
uicb_client_swap_next(uicb_t cmd)
|
||||
{
|
||||
Client *c;
|
||||
(void)cmd;
|
||||
|
||||
if((c = client_get_next()))
|
||||
{
|
||||
client_swap(sel, c);
|
||||
client_focus(c);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Swap the current client with the previous one
|
||||
*\param cmd uicb_t type unused
|
||||
*/
|
||||
void
|
||||
uicb_client_swap_prev(uicb_t cmd)
|
||||
{
|
||||
Client *c;
|
||||
(void)cmd;
|
||||
|
||||
if((c = client_get_prev()))
|
||||
{
|
||||
client_swap(sel, c);
|
||||
client_focus(c);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Select next client positioned to the right
|
||||
*\param cmd uicb_t type unused
|
||||
*/
|
||||
void
|
||||
uicb_client_focus_right(uicb_t cmd)
|
||||
{
|
||||
Client *c;
|
||||
(void)cmd;
|
||||
|
||||
if((c = client_get_next_with_direction(sel, Right)))
|
||||
{
|
||||
client_focus(c);
|
||||
client_raise(c);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Select next client positioned to the left
|
||||
*\param cmd uicb_t type unused
|
||||
*/
|
||||
void
|
||||
uicb_client_focus_left(uicb_t cmd)
|
||||
{
|
||||
Client *c;
|
||||
(void)cmd;
|
||||
|
||||
if((c = client_get_next_with_direction(sel, Left)))
|
||||
{
|
||||
client_focus(c);
|
||||
client_raise(c);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Select next client positioned to the top
|
||||
*\param cmd uicb_t type unused
|
||||
*/
|
||||
void
|
||||
uicb_client_focus_top(uicb_t cmd)
|
||||
{
|
||||
Client *c;
|
||||
(void)cmd;
|
||||
|
||||
if((c = client_get_next_with_direction(sel, Top)))
|
||||
{
|
||||
client_focus(c);
|
||||
client_raise(c);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Select next client positioned to the bottom
|
||||
*\param cmd uicb_t type unused
|
||||
*/
|
||||
void
|
||||
uicb_client_focus_bottom(uicb_t cmd)
|
||||
{
|
||||
Client *c;
|
||||
(void)cmd;
|
||||
|
||||
if((c = client_get_next_with_direction(sel, Bottom)))
|
||||
{
|
||||
client_focus(c);
|
||||
client_raise(c);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Set the client c above
|
||||
*\param c Client pointer
|
||||
*/
|
||||
|
||||
28
src/config.c
28
src/config.c
@ -36,25 +36,29 @@ const func_name_list_t func_list[] =
|
||||
{
|
||||
{"spawn", uicb_spawn },
|
||||
{"client_kill", uicb_client_kill },
|
||||
{"client_prev", uicb_client_prev },
|
||||
{"client_next", uicb_client_next },
|
||||
{"client_swap_next", uicb_client_swap_next },
|
||||
{"client_swap_prev", uicb_client_swap_prev },
|
||||
{"client_prev", uicb_client_focus_prev },
|
||||
{"client_next", uicb_client_focus_next },
|
||||
{"client_swap_next", uicb_client_swapsel_next },
|
||||
{"client_swap_prev", uicb_client_swapsel_prev },
|
||||
{"client_swap_right", uicb_client_swapsel_Right },
|
||||
{"client_swap_left", uicb_client_swapsel_Left },
|
||||
{"client_swap_top", uicb_client_swapsel_Top },
|
||||
{"client_swap_bottom", uicb_client_swapsel_Bottom },
|
||||
{"client_screen_next", uicb_client_screen_next },
|
||||
{"client_screen_prev", uicb_client_screen_prev },
|
||||
{"client_screen_set", uicb_client_screen_set },
|
||||
{"client_focus_right", uicb_client_focus_right },
|
||||
{"client_focus_left" , uicb_client_focus_left },
|
||||
{"client_focus_top", uicb_client_focus_top },
|
||||
{"client_focus_bottom", uicb_client_focus_bottom },
|
||||
{"client_focus_right", uicb_client_focus_Right },
|
||||
{"client_focus_left" , uicb_client_focus_Left },
|
||||
{"client_focus_top", uicb_client_focus_Top },
|
||||
{"client_focus_bottom", uicb_client_focus_Bottom },
|
||||
{"client_move", uicb_client_move },
|
||||
{"client_resize", uicb_client_resize },
|
||||
{"client_ignore_tag", uicb_client_ignore_tag },
|
||||
{"client_set_master", uicb_client_set_master },
|
||||
{"client_resize_right", uicb_client_resize_right },
|
||||
{"client_resize_left", uicb_client_resize_left },
|
||||
{"client_resize_top", uicb_client_resize_top },
|
||||
{"client_resize_bottom", uicb_client_resize_bottom },
|
||||
{"client_resize_right", uicb_client_resize_Right },
|
||||
{"client_resize_left", uicb_client_resize_Left },
|
||||
{"client_resize_top", uicb_client_resize_Top },
|
||||
{"client_resize_bottom", uicb_client_resize_Bottom },
|
||||
{"toggle_max", uicb_togglemax },
|
||||
{"layout_next", uicb_layout_next },
|
||||
{"layout_prev", uicb_layout_prev },
|
||||
|
||||
33
src/wmfs.h
33
src/wmfs.h
@ -162,10 +162,12 @@ Bool cfactor_check_2pc(XRectangle g1, XRectangle g2, Position p);
|
||||
Bool cfactor_parentrow(XRectangle cg, XRectangle ccg, Position p);
|
||||
void cfactor_set(Client *c, Position p, int fac);
|
||||
void cfactor_multi_set(Client *c, int fac[4]);
|
||||
void uicb_client_resize_right(uicb_t cmd);
|
||||
void uicb_client_resize_left(uicb_t cmd);
|
||||
void uicb_client_resize_top(uicb_t cmd);
|
||||
void uicb_client_resize_bottom(uicb_t cmd);
|
||||
/* Generated with macro {{{ */
|
||||
void uicb_client_resize_Right(uicb_t cmd);
|
||||
void uicb_client_resize_Left(uicb_t cmd);
|
||||
void uicb_client_resize_Top(uicb_t cmd);
|
||||
void uicb_client_resize_Bottom(uicb_t cmd);
|
||||
/* }}} */
|
||||
|
||||
/* client.c */
|
||||
void client_attach(Client *c);
|
||||
@ -173,6 +175,7 @@ void client_configure(Client *c);
|
||||
void client_detach(Client *c);
|
||||
void client_focus(Client *c);
|
||||
Client *client_get_next(void);
|
||||
Client *client_get_prev(void);
|
||||
/* client_gb_*() {{{ */
|
||||
Client* client_gb_win(Window w);
|
||||
Client* client_gb_frame(Window w);
|
||||
@ -201,14 +204,20 @@ void client_update_attributes(Client *c);
|
||||
void client_urgent(Client *c, Bool u);
|
||||
Client* client_get_next_with_direction(Client *bc, Position pos);
|
||||
void uicb_client_raise(uicb_t);
|
||||
void uicb_client_next(uicb_t);
|
||||
void uicb_client_prev(uicb_t);
|
||||
void uicb_client_swap_next(uicb_t);
|
||||
void uicb_client_swap_prev(uicb_t);
|
||||
void uicb_client_focus_right(uicb_t cmd);
|
||||
void uicb_client_focus_left(uicb_t cmd);
|
||||
void uicb_client_focus_top(uicb_t cmd);
|
||||
void uicb_client_focus_bottom(uicb_t cmd);
|
||||
/* Generated with macro {{{ */
|
||||
void uicb_client_focus_next(uicb_t);
|
||||
void uicb_client_focus_prev(uicb_t);
|
||||
void uicb_client_swapsel_next(uicb_t);
|
||||
void uicb_client_swapsel_prev(uicb_t);
|
||||
void uicb_client_swapsel_Right(uicb_t);
|
||||
void uicb_client_swapsel_Left(uicb_t);
|
||||
void uicb_client_swapsel_Top(uicb_t);
|
||||
void uicb_client_swapsel_Bottom(uicb_t);
|
||||
void uicb_client_focus_Right(uicb_t cmd);
|
||||
void uicb_client_focus_Left(uicb_t cmd);
|
||||
void uicb_client_focus_Top(uicb_t cmd);
|
||||
void uicb_client_focus_Bottom(uicb_t cmd);
|
||||
/* }}} */
|
||||
void uicb_client_kill(uicb_t);
|
||||
void uicb_client_screen_next(uicb_t);
|
||||
void uicb_client_screen_prev(uicb_t);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user