diff options
Diffstat (limited to 'openbox/actions')
| -rw-r--r-- | openbox/actions/all.c | 1 | ||||
| -rw-r--r-- | openbox/actions/all.h | 1 | ||||
| -rw-r--r-- | openbox/actions/growtoedge.c | 3 | ||||
| -rw-r--r-- | openbox/actions/moverelative.c | 2 | ||||
| -rw-r--r-- | openbox/actions/moveresizeto.c | 6 | ||||
| -rw-r--r-- | openbox/actions/movetoedge.c | 10 | ||||
| -rw-r--r-- | openbox/actions/resizerelative.c | 2 | ||||
| -rw-r--r-- | openbox/actions/tiling.c | 134 |
8 files changed, 153 insertions, 6 deletions
diff --git a/openbox/actions/all.c b/openbox/actions/all.c index 332e79ca..002813dc 100644 --- a/openbox/actions/all.c +++ b/openbox/actions/all.c @@ -39,6 +39,7 @@ void action_all_startup(void) action_growtoedge_startup(); action_if_startup(); action_focustobottom_startup(); + action_tiling_startup(); /* 3.4-compatibility */ action_shadelowerraise_startup(); } diff --git a/openbox/actions/all.h b/openbox/actions/all.h index 54d63195..0e5c4730 100644 --- a/openbox/actions/all.h +++ b/openbox/actions/all.h @@ -40,6 +40,7 @@ void action_movetoedge_startup(void); void action_growtoedge_startup(void); void action_if_startup(void); void action_focustobottom_startup(void); +void action_tiling_startup(void); /* 3.4-compatibility */ void action_shadelowerraise_startup(void); diff --git a/openbox/actions/growtoedge.c b/openbox/actions/growtoedge.c index acfbcfab..02ac63ac 100644 --- a/openbox/actions/growtoedge.c +++ b/openbox/actions/growtoedge.c @@ -1,4 +1,5 @@ #include "openbox/actions.h" +#include "openbox/tiling.h" #include "openbox/misc.h" #include "openbox/client.h" #include "openbox/frame.h" @@ -117,6 +118,7 @@ static gboolean do_grow(ObActionsData *data, gint x, gint y, gint w, gint h) { actions_client_move(data, TRUE); client_move_resize(data->client, x, y, realw, realh); + tiling_action_moved(data->client); actions_client_move(data, FALSE); return TRUE; } @@ -171,6 +173,7 @@ static gboolean do_grow_all_edges(ObActionsData* data, actions_client_move(data, TRUE); client_move_resize(data->client, x, y, w, h); + tiling_action_moved(data->client); actions_client_move(data, FALSE); return TRUE; } diff --git a/openbox/actions/moverelative.c b/openbox/actions/moverelative.c index b67b5cf1..456bb19f 100644 --- a/openbox/actions/moverelative.c +++ b/openbox/actions/moverelative.c @@ -1,4 +1,5 @@ #include "openbox/actions.h" +#include "openbox/tiling.h" #include "openbox/client.h" #include "openbox/screen.h" #include "openbox/frame.h" @@ -77,6 +78,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) actions_client_move(data, TRUE); client_configure(c, x, y, w, h, TRUE, TRUE, FALSE); + tiling_action_moved(data->client); actions_client_move(data, FALSE); } diff --git a/openbox/actions/moveresizeto.c b/openbox/actions/moveresizeto.c index 95de0e98..73de6a0f 100644 --- a/openbox/actions/moveresizeto.c +++ b/openbox/actions/moveresizeto.c @@ -1,4 +1,5 @@ #include "openbox/actions.h" +#include "openbox/tiling.h" #include "openbox/client.h" #include "openbox/screen.h" #include "openbox/frame.h" @@ -118,7 +119,9 @@ static gboolean run_func(ObActionsData *data, gpointer options) case PREV_MONITOR: mon = (cmon == 0) ? (screen_num_monitors - 1) : (cmon - 1); break; default: - g_assert_not_reached(); + if (mon >= screen_num_monitors) + mon = cmon; + break; } area = screen_area(c->desktop, mon, NULL); @@ -193,6 +196,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) actions_client_move(data, TRUE); client_configure(c, x, y, w, h, TRUE, TRUE, FALSE); + tiling_action_moved(data->client); actions_client_move(data, FALSE); g_slice_free(Rect, area); diff --git a/openbox/actions/movetoedge.c b/openbox/actions/movetoedge.c index ef5b6920..d72f446b 100644 --- a/openbox/actions/movetoedge.c +++ b/openbox/actions/movetoedge.c @@ -1,4 +1,5 @@ #include "openbox/actions.h" +#include "openbox/tiling.h" #include "openbox/misc.h" #include "openbox/client.h" #include "openbox/frame.h" @@ -70,11 +71,11 @@ static gboolean run_func(ObActionsData *data, gpointer options) gint x, y; client_find_move_directional(data->client, o->dir, &x, &y); - if (x != data->client->area.x || y != data->client->area.y) { - actions_client_move(data, TRUE); + actions_client_move(data, TRUE); + if (x != data->client->area.x || y != data->client->area.y) client_move(data->client, x, y); - actions_client_move(data, FALSE); - } + tiling_action_moved(data->client); + actions_client_move(data, FALSE); } return FALSE; @@ -108,4 +109,3 @@ static gpointer setup_west_func(xmlNodePtr node) o->dir = OB_DIRECTION_WEST; return o; } - diff --git a/openbox/actions/resizerelative.c b/openbox/actions/resizerelative.c index 74a3bd74..2683a515 100644 --- a/openbox/actions/resizerelative.c +++ b/openbox/actions/resizerelative.c @@ -1,4 +1,5 @@ #include "openbox/actions.h" +#include "openbox/tiling.h" #include "openbox/client.h" #include "openbox/screen.h" #include "openbox/frame.h" @@ -107,6 +108,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) actions_client_move(data, TRUE); client_move_resize(c, x + xoff, y + yoff, nw, nh); + tiling_action_moved(data->client); actions_client_move(data, FALSE); } diff --git a/openbox/actions/tiling.c b/openbox/actions/tiling.c new file mode 100644 index 00000000..91aa7ded --- /dev/null +++ b/openbox/actions/tiling.c @@ -0,0 +1,134 @@ +#include "openbox/actions.h" +#include "openbox/client.h" +#include "openbox/screen.h" +#include "openbox/tiling.h" + +typedef struct { + gboolean main_stack; + gint delta; + guint key; +} Options; + +static gpointer setup(xmlNodePtr node) +{ + Options *options = g_new0(Options, 1); + xmlNodePtr child; + + options->main_stack = TRUE; + options->delta = 1; + if ((child = obt_xml_find_node(node, "stack"))) + options->main_stack = !obt_xml_node_contains(child, "side"); + if ((child = obt_xml_find_node(node, "delta"))) + options->delta = obt_xml_node_int(child); + if ((child = obt_xml_find_node(node, "key"))) + options->key = obt_xml_node_int(child); + return options; +} + +#define KEY_SETUP(number) \ + static gpointer setup_key_##number(xmlNodePtr node) \ + { \ + Options *options = g_new0(Options, 1); \ + options->key = number; \ + return options; \ + } + +KEY_SETUP(0) +KEY_SETUP(1) +KEY_SETUP(2) +KEY_SETUP(3) +KEY_SETUP(4) +KEY_SETUP(5) +KEY_SETUP(6) +KEY_SETUP(7) +KEY_SETUP(8) +KEY_SETUP(9) +KEY_SETUP(10) +KEY_SETUP(11) +KEY_SETUP(12) + +#undef KEY_SETUP + +static guint monitor(ObActionsData *data) +{ + return data->client ? client_monitor(data->client) : screen_monitor_pointer(); +} + +static gboolean toggle(ObActionsData *data, gpointer options) +{ + actions_client_move(data, TRUE); + tiling_toggle(monitor(data)); + actions_client_move(data, FALSE); + return FALSE; +} + +static gboolean flip(ObActionsData *data, gpointer options) +{ + actions_client_move(data, TRUE); + tiling_flip(monitor(data)); + actions_client_move(data, FALSE); + return FALSE; +} + +static gboolean count(ObActionsData *data, gpointer options) +{ + Options *o = options; + + actions_client_move(data, TRUE); + tiling_change_count(monitor(data), o->main_stack, o->delta); + actions_client_move(data, FALSE); + return FALSE; +} + +static gboolean promote(ObActionsData *data, gpointer options) +{ + actions_client_move(data, TRUE); + tiling_promote(data->client); + actions_client_move(data, FALSE); + return FALSE; +} + +static gboolean assign(ObActionsData *data, gpointer options) +{ + Options *o = options; + + tiling_assign(data->client, o->key); + return FALSE; +} + +static gboolean recall(ObActionsData *data, gpointer options) +{ + Options *o = options; + + actions_client_move(data, TRUE); + tiling_recall(o->key); + actions_client_move(data, FALSE); + return FALSE; +} + +void action_tiling_startup(void) +{ + static const ObActionsDataSetupFunc key_setups[] = { + setup_key_0, setup_key_1, setup_key_2, setup_key_3, setup_key_4, + setup_key_5, setup_key_6, setup_key_7, setup_key_8, setup_key_9, + setup_key_10, setup_key_11, setup_key_12 + }; + guint key; + + actions_register("ToggleTiling", NULL, NULL, toggle); + actions_register("FlipTiling", NULL, NULL, flip); + actions_register("ChangeTileCount", setup, g_free, count); + actions_register("MakeMainTile", NULL, NULL, promote); + actions_register("AssignWindowKey", setup, g_free, assign); + actions_register("RecallWindowKey", setup, g_free, recall); + actions_register("AssignWindow0", setup_key_0, g_free, assign); + for (key = 1; key < G_N_ELEMENTS(key_setups); ++key) { + gchar *name = g_strdup_printf("AssignWindow%u", key); + + actions_register(name, key_setups[key], g_free, assign); + g_free(name); + name = g_strdup_printf("RecallWindow%u", key); + actions_register(name, key_setups[key], g_free, recall); + g_free(name); + } +} |
