From: Mikael Magnusson Date: Fri, 17 Sep 2010 01:34:34 +0000 (+0200) Subject: Add mostly working LowerOne and very buggy RaiseOne X-Git-Tag: mikabox-3.5-7~36^2 X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=f4534e435b5ddbc7adef3ddb2a6abb25ccb0c81b;p=mikachu%2Fopenbox.git Add mostly working LowerOne and very buggy RaiseOne --- diff --git a/Makefile.am b/Makefile.am index 62570bd0..b166897e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -204,6 +204,7 @@ openbox_openbox_SOURCES = \ openbox/actions/kill.c \ openbox/actions/layer.c \ openbox/actions/lower.c \ + openbox/actions/lowerraiseone.c \ openbox/actions/maximize.c \ openbox/actions/move.c \ openbox/actions/moverelative.c \ diff --git a/openbox/actions/all.c b/openbox/actions/all.c index 332e79ca..2dc3a70c 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_lowerraiseone_startup(); /* 3.4-compatibility */ action_shadelowerraise_startup(); } diff --git a/openbox/actions/all.h b/openbox/actions/all.h index 54d63195..aa4e8b05 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_lowerraiseone_startup(void); /* 3.4-compatibility */ void action_shadelowerraise_startup(void); diff --git a/openbox/actions/lowerraiseone.c b/openbox/actions/lowerraiseone.c new file mode 100644 index 00000000..b41a0ede --- /dev/null +++ b/openbox/actions/lowerraiseone.c @@ -0,0 +1,52 @@ +#include "openbox/actions.h" +#include "openbox/stacking.h" +#include "openbox/window.h" +#include "openbox/client.h" + +static gboolean run_func(ObActionsData *data, gpointer options); +static gpointer setup_raise(xmlNodePtr node); +static gpointer setup_lower(xmlNodePtr node); + +void action_lowerraiseone_startup(void) +{ + actions_register("RaiseOne", + setup_raise, NULL, + run_func); + actions_register("LowerOne", + setup_lower, NULL, + run_func); +} + +static gpointer setup_raise(xmlNodePtr node) +{ + return GINT_TO_POINTER(1); +} + +static gpointer setup_lower(xmlNodePtr node) +{ + return GINT_TO_POINTER(0); +} + +/* Always return FALSE because its not interactive */ +static gboolean run_func(ObActionsData *data, gpointer options) +{ + gint dir = GPOINTER_TO_INT(options) ? 1 : -1; + + if (data->client) { + ObClient *client = data->client; + ObClient *sibling; + actions_client_move(data, TRUE); + if (dir == 1) { + sibling = stacking_occluded(client, NULL); + if (sibling) + stacking_above(client, sibling); + } else { + sibling = stacking_occludes(client, NULL); + if (sibling) + stacking_below(client, sibling); + } + actions_client_move(data, FALSE); + } + + return FALSE; +} diff --git a/openbox/stacking.c b/openbox/stacking.c index 58551b5d..43eff853 100644 --- a/openbox/stacking.c +++ b/openbox/stacking.c @@ -423,6 +423,20 @@ void stacking_lower(ObWindow *window) stacking_list_tail = g_list_last(stacking_list); } +void stacking_above(ObWindow *window, ObWindow *above) +{ + GList *wins, *before; + + if (window_layer(window) != window_layer(above)) + return; + + wins = g_list_append(NULL, window); + stacking_list = g_list_remove(stacking_list, window); + before = g_list_previous(g_list_find(stacking_list, above)); + do_restack(wins, before); + g_list_free(wins); +} + void stacking_below(ObWindow *window, ObWindow *below) { GList *wins, *before; @@ -564,13 +578,10 @@ void stacking_add_nonintrusive(ObWindow *win) stacking_list_tail = g_list_last(stacking_list); } -/*! Returns TRUE if client is occluded by the sibling. If sibling is NULL it - tries against all other clients. -*/ -static gboolean stacking_occluded(ObClient *client, ObClient *sibling) +ObClient *stacking_occluded(ObClient *client, ObClient *sibling) { GList *it; - gboolean occluded = FALSE; + ObClient *occluded = NULL; /* no need for any looping in this case */ if (sibling && client->layer != sibling->layer) @@ -589,12 +600,12 @@ static gboolean stacking_occluded(ObClient *client, ObClient *sibling) { if (sibling != NULL) { if (c == sibling) { - occluded = TRUE; + occluded = sibling; break; } } else if (c->layer == client->layer) { - occluded = TRUE; + occluded = c; break; } else if (c->layer > client->layer) @@ -605,13 +616,10 @@ static gboolean stacking_occluded(ObClient *client, ObClient *sibling) return occluded; } -/*! Returns TRUE if client occludes the sibling. If sibling is NULL it tries - against all other clients. -*/ -static gboolean stacking_occludes(ObClient *client, ObClient *sibling) +ObClient *stacking_occludes(ObClient *client, ObClient *sibling) { GList *it; - gboolean occludes = FALSE; + ObClient *occludes = NULL; /* no need for any looping in this case */ if (sibling && client->layer != sibling->layer) @@ -630,12 +638,12 @@ static gboolean stacking_occludes(ObClient *client, ObClient *sibling) { if (sibling != NULL) { if (c == sibling) { - occludes = TRUE; + occludes = sibling; break; } } else if (c->layer == client->layer) { - occludes = TRUE; + occludes = c; break; } else if (c->layer < client->layer) diff --git a/openbox/stacking.h b/openbox/stacking.h index c14aa2ed..c5385766 100644 --- a/openbox/stacking.h +++ b/openbox/stacking.h @@ -68,6 +68,18 @@ void stacking_lower(struct _ObWindow *window); it should really ONLY be used to restore stacking orders from saved sessions */ void stacking_below(struct _ObWindow *window, struct _ObWindow *below); +/*! Ibid, above */ +void stacking_above(struct _ObWindow *window, struct _ObWindow *above); + +/*! Returns sibling if client is occluded by the sibling. If sibling is NULL it + tries against all other clients, then the nearest client occluding is returned. +*/ +struct _ObClient *stacking_occluded(struct _ObClient *client, struct _ObClient *sibling); + +/*! Returns sibling if client occludes the sibling. If sibling is NULL it tries + against all other clients, then the nearest client occluded is returned. +*/ +struct _ObClient *stacking_occludes(struct _ObClient *client, struct _ObClient *sibling); /*! Restack a window based upon a sibling (or all windows) in various ways. @param client The client to be restacked