openbox/actions/layer.c (raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
#include "openbox/actions.h" #include "openbox/client.h" typedef struct { gint layer; /*!< -1 for below, 0 for normal, and 1 for above */ gboolean toggle; } Options; static gpointer setup_func_top(xmlNodePtr node); static gpointer setup_func_bottom(xmlNodePtr node); static gpointer setup_func_send(xmlNodePtr node); static gboolean run_func(ObActionsData *data, gpointer options); void action_layer_startup(void) { actions_register("ToggleAlwaysOnTop", setup_func_top, g_free, run_func, NULL, NULL); actions_register("ToggleAlwaysOnBottom", setup_func_bottom, g_free, run_func, NULL, NULL); actions_register("SendToLayer", setup_func_send, g_free, run_func, NULL, NULL); } static gpointer setup_func_top(xmlNodePtr node) { Options *o = g_new0(Options, 1); o->layer = 1; o->toggle = TRUE; return o; } static gpointer setup_func_bottom(xmlNodePtr node) { Options *o = g_new0(Options, 1); o->layer = -1; o->toggle = TRUE; return o; } static gpointer setup_func_send(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_new0(Options, 1); if ((n = obt_parse_find_node(node, "layer"))) { gchar *s = obt_parse_node_string(n); if (!g_ascii_strcasecmp(s, "above") || !g_ascii_strcasecmp(s, "top")) o->layer = 1; else if (!g_ascii_strcasecmp(s, "below") || !g_ascii_strcasecmp(s, "bottom")) o->layer = -1; else if (!g_ascii_strcasecmp(s, "normal") || !g_ascii_strcasecmp(s, "middle")) o->layer = 0; g_free(s); } return o; } /* Always return FALSE because its not interactive */ static gboolean run_func(ObActionsData *data, gpointer options) { Options *o = options; if (data->client) { ObClient *c = data->client; actions_client_move(data, TRUE); if (o->layer < 0) { if (o->toggle || !c->below) client_set_layer(c, c->below ? 0 : -1); } else if (o->layer > 0) { if (o->toggle || !c->above) client_set_layer(c, c->above ? 0 : 1); } else if (c->above || c->below) client_set_layer(c, 0); actions_client_move(data, FALSE); } return FALSE; } |