add the layer action
This commit is contained in:
parent
ca28e08c2f
commit
7f50e04925
11 changed files with 99 additions and 17 deletions
|
@ -173,6 +173,7 @@ openbox_openbox_SOURCES = \
|
|||
openbox/actions/fullscreen.c \
|
||||
openbox/actions/iconify.c \
|
||||
openbox/actions/kill.c \
|
||||
openbox/actions/layer.c \
|
||||
openbox/actions/lower.c \
|
||||
openbox/actions/maximize.c \
|
||||
openbox/actions/maximizehorizontal.c \
|
||||
|
|
|
@ -381,17 +381,6 @@ void action_toggle_layer(union ActionData *data)
|
|||
ObClient *c = data->layer.any.c;
|
||||
|
||||
client_action_start(data);
|
||||
if (data->layer.layer < 0)
|
||||
client_set_layer(c, c->below ? 0 : -1);
|
||||
else if (data->layer.layer > 0)
|
||||
client_set_layer(c, c->above ? 0 : 1);
|
||||
client_action_end(data, config_focus_under_mouse);
|
||||
}
|
||||
|
||||
void action_toggle_dockautohide(union ActionData *data)
|
||||
{
|
||||
}
|
||||
|
||||
void action_remove_desktop(union ActionData *data)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,4 +37,5 @@ void action_all_startup()
|
|||
action_resizerelative_startup();
|
||||
action_addremovedesktop_startup();
|
||||
action_dockautohide_startup();
|
||||
action_layer_startup();
|
||||
}
|
||||
|
|
|
@ -38,5 +38,6 @@ void action_directionaldesktop_startup();
|
|||
void action_resizerelative_startup();
|
||||
void action_addremovedesktop_startup();
|
||||
void action_dockautohide_startup();
|
||||
void action_layer_startup();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
|
|||
o = g_new0(Options, 1);
|
||||
o->toggle = TRUE;
|
||||
|
||||
if ((n = parse_find_node("decorations", node))) {
|
||||
if ((n = parse_find_node("state", node))) {
|
||||
gchar *s = parse_string(doc, n);
|
||||
if (g_ascii_strcasecmp(s, "toggle")) {
|
||||
o->toggle = FALSE;
|
||||
|
|
90
openbox/actions/layer.c
Normal file
90
openbox/actions/layer.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
#include "openbox/actions.h"
|
||||
#include "openbox/client.h"
|
||||
|
||||
typedef struct {
|
||||
gint layer; /*!< -1 for below, 0 for normal, and 1 for above */
|
||||
gboolean toggle;
|
||||
gboolean on;
|
||||
} Options;
|
||||
|
||||
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
|
||||
static void free_func(gpointer options);
|
||||
static gboolean run_func(ObActionsData *data, gpointer options);
|
||||
|
||||
void action_layer_startup()
|
||||
{
|
||||
actions_register("Layer",
|
||||
setup_func,
|
||||
free_func,
|
||||
run_func,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
|
||||
{
|
||||
xmlNodePtr n;
|
||||
Options *o;
|
||||
|
||||
o = g_new0(Options, 1);
|
||||
o->toggle = TRUE;
|
||||
|
||||
if ((n = parse_find_node("layer", node))) {
|
||||
gchar *s = parse_string(doc, 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);
|
||||
}
|
||||
if ((n = parse_find_node("state", node))) {
|
||||
gchar *s = parse_string(doc, n);
|
||||
if (g_ascii_strcasecmp(s, "toggle")) {
|
||||
o->toggle = FALSE;
|
||||
o->on = parse_bool(doc, n);
|
||||
}
|
||||
g_free(s);
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static void free_func(gpointer options)
|
||||
{
|
||||
Options *o = options;
|
||||
|
||||
g_free(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 != o->on)
|
||||
client_set_layer(c, c->below ? 0 : -1);
|
||||
}
|
||||
else if (o->layer > 0) {
|
||||
if (o->toggle || c->above != o->on)
|
||||
client_set_layer(c, c->above ? 0 : 1);
|
||||
}
|
||||
else {
|
||||
if ((o->toggle || o->on) && (c->above || c->below))
|
||||
client_set_layer(c, 0);
|
||||
}
|
||||
|
||||
actions_client_move(data, FALSE);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
|
@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
|
|||
o = g_new0(Options, 1);
|
||||
o->toggle = TRUE;
|
||||
|
||||
if ((n = parse_find_node("maximize", node))) {
|
||||
if ((n = parse_find_node("state", node))) {
|
||||
gchar *s = parse_string(doc, n);
|
||||
if (g_ascii_strcasecmp(s, "toggle")) {
|
||||
o->toggle = FALSE;
|
||||
|
|
|
@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
|
|||
o = g_new0(Options, 1);
|
||||
o->toggle = TRUE;
|
||||
|
||||
if ((n = parse_find_node("maximize", node))) {
|
||||
if ((n = parse_find_node("state", node))) {
|
||||
gchar *s = parse_string(doc, n);
|
||||
if (g_ascii_strcasecmp(s, "toggle")) {
|
||||
o->toggle = FALSE;
|
||||
|
|
|
@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
|
|||
o = g_new0(Options, 1);
|
||||
o->toggle = TRUE;
|
||||
|
||||
if ((n = parse_find_node("maximize", node))) {
|
||||
if ((n = parse_find_node("state", node))) {
|
||||
gchar *s = parse_string(doc, n);
|
||||
if (g_ascii_strcasecmp(s, "toggle")) {
|
||||
o->toggle = FALSE;
|
||||
|
|
|
@ -28,7 +28,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
|
|||
o = g_new0(Options, 1);
|
||||
o->toggle = TRUE;
|
||||
|
||||
if ((n = parse_find_node("omnipresent", node))) {
|
||||
if ((n = parse_find_node("state", node))) {
|
||||
gchar *s = parse_string(doc, n);
|
||||
if (g_ascii_strcasecmp(s, "toggle")) {
|
||||
o->toggle = FALSE;
|
||||
|
|
|
@ -27,7 +27,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
|
|||
o = g_new0(Options, 1);
|
||||
o->toggle = TRUE;
|
||||
|
||||
if ((n = parse_find_node("shade", node))) {
|
||||
if ((n = parse_find_node("state", node))) {
|
||||
gchar *s = parse_string(doc, n);
|
||||
if (g_ascii_strcasecmp(s, "toggle")) {
|
||||
o->toggle = FALSE;
|
||||
|
|
Loading…
Reference in a new issue