summaryrefslogtreecommitdiff
path: root/openbox/actions
diff options
context:
space:
mode:
Diffstat (limited to 'openbox/actions')
-rw-r--r--openbox/actions/addremovedesktop.c85
-rw-r--r--openbox/actions/all.c2
-rw-r--r--openbox/actions/all.h76
-rw-r--r--openbox/actions/breakchroot.c3
-rw-r--r--openbox/actions/close.c3
-rw-r--r--openbox/actions/cyclewindows.c143
-rw-r--r--openbox/actions/debug.c21
-rw-r--r--openbox/actions/decorations.c7
-rw-r--r--openbox/actions/desktop.c440
-rw-r--r--openbox/actions/directionalwindows.c297
-rw-r--r--openbox/actions/dockautohide.c3
-rw-r--r--openbox/actions/execute.c127
-rw-r--r--openbox/actions/exit.c12
-rw-r--r--openbox/actions/focus.c26
-rw-r--r--openbox/actions/focustobottom.c2
-rw-r--r--openbox/actions/fullscreen.c3
-rw-r--r--openbox/actions/growtoedge.c85
-rw-r--r--openbox/actions/iconify.c3
-rw-r--r--openbox/actions/if.c59
-rw-r--r--openbox/actions/kill.c3
-rw-r--r--openbox/actions/layer.c63
-rw-r--r--openbox/actions/lower.c3
-rw-r--r--openbox/actions/maximize.c63
-rw-r--r--openbox/actions/move.c9
-rw-r--r--openbox/actions/moverelative.c40
-rw-r--r--openbox/actions/moveresizeto.c68
-rw-r--r--openbox/actions/movetoedge.c62
-rw-r--r--openbox/actions/omnipresent.c3
-rw-r--r--openbox/actions/raise.c5
-rw-r--r--openbox/actions/raiselower.c5
-rw-r--r--openbox/actions/reconfigure.c5
-rw-r--r--openbox/actions/resize.c66
-rw-r--r--openbox/actions/resizerelative.c38
-rw-r--r--openbox/actions/restart.c26
-rw-r--r--openbox/actions/session.c78
-rw-r--r--openbox/actions/shade.c6
-rw-r--r--openbox/actions/shadelowerraise.c40
-rw-r--r--openbox/actions/showdesktop.c5
-rw-r--r--openbox/actions/showmenu.c11
-rw-r--r--openbox/actions/unfocus.c2
40 files changed, 1478 insertions, 520 deletions
diff --git a/openbox/actions/addremovedesktop.c b/openbox/actions/addremovedesktop.c
index 8125b9bb..e21e9e66 100644
--- a/openbox/actions/addremovedesktop.c
+++ b/openbox/actions/addremovedesktop.c
@@ -7,36 +7,40 @@ typedef struct {
gboolean add;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_add_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_remove_func(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_add_func(xmlNodePtr node);
+static gpointer setup_remove_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
+/* 3.4-compatibility */
+static gpointer setup_addcurrent_func(xmlNodePtr node);
+static gpointer setup_addlast_func(xmlNodePtr node);
+static gpointer setup_removecurrent_func(xmlNodePtr node);
+static gpointer setup_removelast_func(xmlNodePtr node);
void action_addremovedesktop_startup(void)
{
- actions_register("AddDesktop",
- setup_add_func,
- free_func,
- run_func,
- NULL, NULL);
- actions_register("RemoveDesktop",
- setup_remove_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("AddDesktop", setup_add_func, g_free, run_func);
+ actions_register("RemoveDesktop", setup_remove_func, g_free, run_func);
+
+ /* 3.4-compatibility */
+ actions_register("AddDesktopLast", setup_addlast_func, g_free, run_func);
+ actions_register("RemoveDesktopLast", setup_removelast_func,
+ g_free, run_func);
+ actions_register("AddDesktopCurrent", setup_addcurrent_func,
+ g_free, run_func);
+ actions_register("RemoveDesktopCurrent", setup_removecurrent_func,
+ g_free, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("where", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "where"))) {
+ gchar *s = obt_xml_node_string(n);
if (!g_ascii_strcasecmp(s, "last"))
o->current = FALSE;
else if (!g_ascii_strcasecmp(s, "current"))
@@ -47,28 +51,20 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o;
}
-static gpointer setup_add_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_add_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->add = TRUE;
return o;
}
-static gpointer setup_remove_func(ObParseInst *i,
- xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_remove_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->add = FALSE;
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)
{
@@ -85,3 +81,32 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE;
}
+
+/* 3.4-compatibility */
+static gpointer setup_addcurrent_func(xmlNodePtr node)
+{
+ Options *o = setup_add_func(node);
+ o->current = TRUE;
+ return o;
+}
+
+static gpointer setup_addlast_func(xmlNodePtr node)
+{
+ Options *o = setup_add_func(node);
+ o->current = FALSE;
+ return o;
+}
+
+static gpointer setup_removecurrent_func(xmlNodePtr node)
+{
+ Options *o = setup_remove_func(node);
+ o->current = TRUE;
+ return o;
+}
+
+static gpointer setup_removelast_func(xmlNodePtr node)
+{
+ Options *o = setup_remove_func(node);
+ o->current = FALSE;
+ return o;
+}
diff --git a/openbox/actions/all.c b/openbox/actions/all.c
index 47141ac6..4563e65f 100644
--- a/openbox/actions/all.c
+++ b/openbox/actions/all.c
@@ -38,4 +38,6 @@ void action_all_startup(void)
action_growtoedge_startup();
action_if_startup();
action_focustobottom_startup();
+ /* 3.4-compatibility */
+ action_shadelowerraise_startup();
}
diff --git a/openbox/actions/all.h b/openbox/actions/all.h
index 5f3f573f..6acbc9ca 100644
--- a/openbox/actions/all.h
+++ b/openbox/actions/all.h
@@ -1,43 +1,45 @@
#ifndef __actions_all_h
#define __actions_all_h
-void action_all_startup();
+void action_all_startup(void);
-void action_execute_startup();
-void action_debug_startup();
-void action_showmenu_startup();
-void action_showdesktop_startup();
-void action_reconfigure_startup();
-void action_exit_startup();
-void action_restart_startup();
-void action_cyclewindows_startup();
-void action_breakchroot_startup();
-void action_close_startup();
-void action_move_startup();
-void action_focus_startup();
-void action_raise_startup();
-void action_lower_startup();
-void action_raiselower_startup();
-void action_unfocus_startup();
-void action_iconify_startup();
-void action_fullscreen_startup();
-void action_maximize_startup();
-void action_moveresizeto_startup();
-void action_moverelative_startup();
-void action_shade_startup();
-void action_kill_startup();
-void action_omnipresent_startup();
-void action_directionalwindows_startup();
-void action_resize_startup();
-void action_decorations_startup();
-void action_desktop_startup();
-void action_resizerelative_startup();
-void action_addremovedesktop_startup();
-void action_dockautohide_startup();
-void action_layer_startup();
-void action_movetoedge_startup();
-void action_growtoedge_startup();
-void action_if_startup();
-void action_focustobottom_startup();
+void action_execute_startup(void);
+void action_debug_startup(void);
+void action_showmenu_startup(void);
+void action_showdesktop_startup(void);
+void action_reconfigure_startup(void);
+void action_exit_startup(void);
+void action_restart_startup(void);
+void action_cyclewindows_startup(void);
+void action_breakchroot_startup(void);
+void action_close_startup(void);
+void action_move_startup(void);
+void action_focus_startup(void);
+void action_raise_startup(void);
+void action_lower_startup(void);
+void action_raiselower_startup(void);
+void action_unfocus_startup(void);
+void action_iconify_startup(void);
+void action_fullscreen_startup(void);
+void action_maximize_startup(void);
+void action_moveresizeto_startup(void);
+void action_moverelative_startup(void);
+void action_shade_startup(void);
+void action_kill_startup(void);
+void action_omnipresent_startup(void);
+void action_directionalwindows_startup(void);
+void action_resize_startup(void);
+void action_decorations_startup(void);
+void action_desktop_startup(void);
+void action_resizerelative_startup(void);
+void action_addremovedesktop_startup(void);
+void action_dockautohide_startup(void);
+void action_layer_startup(void);
+void action_movetoedge_startup(void);
+void action_growtoedge_startup(void);
+void action_if_startup(void);
+void action_focustobottom_startup(void);
+/* 3.4-compatibility */
+void action_shadelowerraise_startup(void);
#endif
diff --git a/openbox/actions/breakchroot.c b/openbox/actions/breakchroot.c
index 9804091b..8c004582 100644
--- a/openbox/actions/breakchroot.c
+++ b/openbox/actions/breakchroot.c
@@ -7,8 +7,7 @@ void action_breakchroot_startup(void)
{
actions_register("BreakChroot",
NULL, NULL,
- run_func,
- NULL, NULL);
+ run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/close.c b/openbox/actions/close.c
index ab75e05d..d2bc96c2 100644
--- a/openbox/actions/close.c
+++ b/openbox/actions/close.c
@@ -7,8 +7,7 @@ void action_close_startup(void)
{
actions_register("Close",
NULL, NULL,
- run_func,
- NULL, NULL);
+ run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/cyclewindows.c b/openbox/actions/cyclewindows.c
index 32d6a453..d1112242 100644
--- a/openbox/actions/cyclewindows.c
+++ b/openbox/actions/cyclewindows.c
@@ -8,23 +8,36 @@
typedef struct {
gboolean linear;
- gboolean dialog;
gboolean dock_windows;
gboolean desktop_windows;
gboolean all_desktops;
gboolean forward;
gboolean bar;
gboolean raise;
+ ObFocusCyclePopupMode dialog_mode;
GSList *actions;
-} Options;
-static gboolean cycling = FALSE;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+ /* options for after we're done */
+ gboolean cancel; /* did the user cancel or not */
+ guint state; /* keyboard state when finished */
+} Options;
+
+static gpointer setup_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_forward_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_backward_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
static gboolean i_input_func(guint initial_state,
@@ -32,49 +45,55 @@ static gboolean i_input_func(guint initial_state,
gpointer options,
gboolean *used);
static void i_cancel_func(gpointer options);
-
-static void end_cycle(gboolean cancel, guint state, Options *o);
+static void i_post_func(gpointer options);
void action_cyclewindows_startup(void)
{
- actions_register("NextWindow", setup_forward_func, free_func,
- run_func, i_input_func, i_cancel_func);
- actions_register("PreviousWindow", setup_backward_func, free_func,
- run_func, i_input_func, i_cancel_func);
+ actions_register_i("NextWindow", setup_forward_func, free_func, run_func);
+ actions_register_i("PreviousWindow", setup_backward_func, free_func,
+ run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- o->dialog = TRUE;
o->bar = TRUE;
-
- if ((n = parse_find_node("linear", node)))
- o->linear = parse_bool(doc, n);
- if ((n = parse_find_node("dialog", node)))
- o->dialog = parse_bool(doc, n);
- if ((n = parse_find_node("bar", node)))
- o->bar = parse_bool(doc, n);
- if ((n = parse_find_node("raise", node)))
- o->raise = parse_bool(doc, n);
- if ((n = parse_find_node("panels", node)))
- o->dock_windows = parse_bool(doc, n);
- if ((n = parse_find_node("desktop", node)))
- o->desktop_windows = parse_bool(doc, n);
- if ((n = parse_find_node("allDesktops", node)))
- o->all_desktops = parse_bool(doc, n);
-
- if ((n = parse_find_node("finalactions", node))) {
+ o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_LIST;
+
+ if ((n = obt_xml_find_node(node, "linear")))
+ o->linear = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "dialog"))) {
+ if (obt_xml_node_contains(n, "none"))
+ o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_NONE;
+ else if (obt_xml_node_contains(n, "icons"))
+ o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_ICONS;
+ }
+ if ((n = obt_xml_find_node(node, "bar")))
+ o->bar = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "raise")))
+ o->raise = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "panels")))
+ o->dock_windows = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "desktop")))
+ o->desktop_windows = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "allDesktops")))
+ o->all_desktops = obt_xml_node_bool(n);
+
+ if ((n = obt_xml_find_node(node, "finalactions"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_xml_find_node(n->children, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->actions = g_slist_append(o->actions, action);
- m = parse_find_node("action", m->next);
+ m = obt_xml_find_node(m->next, "action");
}
}
else {
@@ -86,21 +105,30 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
actions_parse_string("Unshade"));
}
+ *input = i_input_func;
+ *cancel = i_cancel_func;
+ *post = i_post_func;
return o;
}
-static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_forward_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node, pre, input, cancel, post);
o->forward = TRUE;
return o;
}
-static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_backward_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node, pre, input, cancel, post);
o->forward = FALSE;
return o;
}
@@ -129,9 +157,8 @@ static gboolean run_func(ObActionsData *data, gpointer options)
o->linear,
TRUE,
o->bar,
- o->dialog,
+ o->dialog_mode,
FALSE, FALSE);
- cycling = TRUE;
stacking_restore();
if (o->raise && ft) stacking_temp_raise(CLIENT_AS_WINDOW(ft));
@@ -144,10 +171,13 @@ static gboolean i_input_func(guint initial_state,
gpointer options,
gboolean *used)
{
+ Options *o = options;
+
if (e->type == KeyPress) {
/* Escape cancels no matter what */
if (ob_keycode_match(e->xkey.keycode, OB_KEY_ESCAPE)) {
- end_cycle(TRUE, e->xkey.state, options);
+ o->cancel = TRUE;
+ o->state = e->xkey.state;
return FALSE;
}
@@ -155,7 +185,8 @@ static gboolean i_input_func(guint initial_state,
else if (ob_keycode_match(e->xkey.keycode, OB_KEY_RETURN) &&
!initial_state)
{
- end_cycle(FALSE, e->xkey.state, options);
+ o->cancel = FALSE;
+ o->state = e->xkey.state;
return FALSE;
}
}
@@ -163,7 +194,8 @@ static gboolean i_input_func(guint initial_state,
else if (e->type == KeyRelease && initial_state &&
(e->xkey.state & initial_state) == 0)
{
- end_cycle(FALSE, e->xkey.state, options);
+ o->cancel = FALSE;
+ o->state = e->xkey.state;
return FALSE;
}
@@ -172,14 +204,14 @@ static gboolean i_input_func(guint initial_state,
static void i_cancel_func(gpointer options)
{
- /* we get cancelled when we move focus, but we're not cycling anymore, so
- just ignore that */
- if (cycling)
- end_cycle(TRUE, 0, options);
+ Options *o = options;
+ o->cancel = TRUE;
+ o->state = 0;
}
-static void end_cycle(gboolean cancel, guint state, Options *o)
+static void i_post_func(gpointer options)
{
+ Options *o = options;
struct _ObClient *ft;
ft = focus_cycle(o->forward,
@@ -189,13 +221,12 @@ static void end_cycle(gboolean cancel, guint state, Options *o)
o->linear,
TRUE,
o->bar,
- o->dialog,
- TRUE, cancel);
- cycling = FALSE;
+ o->dialog_mode,
+ TRUE, o->cancel);
if (ft)
actions_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY,
- state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, ft);
+ o->state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, ft);
stacking_restore();
}
diff --git a/openbox/actions/debug.c b/openbox/actions/debug.c
index f71b685d..9ba7b1b0 100644
--- a/openbox/actions/debug.c
+++ b/openbox/actions/debug.c
@@ -5,39 +5,32 @@ typedef struct {
gchar *str;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_debug_startup(void)
{
- actions_register("Debug",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Debug", setup_func, free_func, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("string", node)))
- o->str = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "string")))
+ o->str = obt_xml_node_string(n);
return o;
}
static void free_func(gpointer options)
{
Options *o = options;
-
- if (o) {
- g_free(o->str);
- g_free(o);
- }
+ g_free(o->str);
+ g_free(o);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/decorations.c b/openbox/actions/decorations.c
index e85fb8ef..f6fd2cbe 100644
--- a/openbox/actions/decorations.c
+++ b/openbox/actions/decorations.c
@@ -7,10 +7,9 @@ static gboolean run_func_toggle(ObActionsData *data, gpointer options);
void action_decorations_startup(void)
{
- actions_register("Decorate", NULL, NULL, run_func_on, NULL, NULL);
- actions_register("Undecorate", NULL, NULL, run_func_off, NULL, NULL);
- actions_register("ToggleDecorations", NULL, NULL, run_func_toggle,
- NULL, NULL);
+ actions_register("Decorate", NULL, NULL, run_func_on);
+ actions_register("Undecorate", NULL, NULL, run_func_off);
+ actions_register("ToggleDecorations", NULL, NULL, run_func_toggle);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/desktop.c b/openbox/actions/desktop.c
index 07416151..5b0282cc 100644
--- a/openbox/actions/desktop.c
+++ b/openbox/actions/desktop.c
@@ -1,6 +1,7 @@
#include "openbox/actions.h"
#include "openbox/screen.h"
#include "openbox/client.h"
+#include "openbox/openbox.h"
#include <glib.h>
typedef enum {
@@ -24,37 +25,143 @@ typedef struct {
} u;
gboolean send;
gboolean follow;
+ gboolean interactive;
} Options;
-static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_send_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_go_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_send_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
static gboolean run_func(ObActionsData *data, gpointer options);
+static gboolean i_pre_func(guint state, gpointer options);
+static gboolean i_input_func(guint initial_state,
+ XEvent *e,
+ gpointer options,
+ gboolean *used);
+static void i_post_func(gpointer options);
+
+/* 3.4-compatibility */
+static gpointer setup_go_last_func(xmlNodePtr node);
+static gpointer setup_send_last_func(xmlNodePtr node);
+static gpointer setup_go_abs_func(xmlNodePtr node);
+static gpointer setup_send_abs_func(xmlNodePtr node);
+static gpointer setup_go_next_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_send_next_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_go_prev_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_send_prev_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_go_left_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_send_left_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_go_right_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_send_right_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_go_up_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_send_up_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_go_down_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_send_down_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+
void action_desktop_startup(void)
{
- actions_register("GoToDesktop", setup_go_func, g_free, run_func,
- NULL, NULL);
- actions_register("SendToDesktop", setup_send_func, g_free, run_func,
- NULL, NULL);
+ actions_register_i("GoToDesktop", setup_go_func, g_free, run_func);
+ actions_register_i("SendToDesktop", setup_send_func, g_free, run_func);
+ /* 3.4-compatibility */
+ actions_register("DesktopLast", setup_go_last_func, g_free, run_func);
+ actions_register("SendToDesktopLast", setup_send_last_func,
+ g_free, run_func);
+ actions_register("Desktop", setup_go_abs_func, g_free, run_func);
+ actions_register("SendToDesktop", setup_send_abs_func, g_free, run_func);
+ actions_register_i("DesktopNext", setup_go_next_func, g_free, run_func);
+ actions_register_i("SendToDesktopNext", setup_send_next_func,
+ g_free, run_func);
+ actions_register_i("DesktopPrevious", setup_go_prev_func,
+ g_free, run_func);
+ actions_register_i("SendToDesktopPrevious", setup_send_prev_func,
+ g_free, run_func);
+ actions_register_i("DesktopLeft", setup_go_left_func, g_free, run_func);
+ actions_register_i("SendToDesktopLeft", setup_send_left_func,
+ g_free, run_func);
+ actions_register_i("DesktopRight", setup_go_right_func, g_free, run_func);
+ actions_register_i("SendToDesktopRight", setup_send_right_func,
+ g_free, run_func);
+ actions_register_i("DesktopUp", setup_go_up_func, g_free, run_func);
+ actions_register_i("SendToDesktopUp", setup_send_up_func,
+ g_free, run_func);
+ actions_register_i("DesktopDown", setup_go_down_func, g_free, run_func);
+ actions_register_i("SendToDesktopDown", setup_send_down_func,
+ g_free, run_func);
}
-static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- /* don't go anywhere if theres no options given */
+ /* don't go anywhere if there are no options given */
o->type = ABSOLUTE;
o->u.abs.desktop = screen_desktop;
/* wrap by default - it's handy! */
o->u.rel.wrap = TRUE;
- if ((n = parse_find_node("to", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "to"))) {
+ gchar *s = obt_xml_node_string(n);
if (!g_ascii_strcasecmp(s, "last"))
o->type = LAST;
else if (!g_ascii_strcasecmp(s, "next")) {
@@ -94,24 +201,54 @@ static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc,
g_free(s);
}
- if ((n = parse_find_node("wrap", node)))
- o->u.rel.wrap = parse_bool(doc, n);
+ if ((n = obt_xml_find_node(node, "wrap")))
+ o->u.rel.wrap = obt_xml_node_bool(n);
return o;
}
-static gpointer setup_send_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+
+static gpointer setup_go_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o;
+
+ o = setup_func(node, pre, input, cancel, post);
+ if (o->type == RELATIVE) {
+ o->interactive = TRUE;
+ *pre = i_pre_func;
+ *input = i_input_func;
+ *post = i_post_func;
+ }
+
+ return o;
+}
+
+static gpointer setup_send_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
{
xmlNodePtr n;
Options *o;
- o = setup_go_func(i, doc, node);
+ o = setup_func(node, pre, input, cancel, post);
o->send = TRUE;
o->follow = TRUE;
- if ((n = parse_find_node("follow", node)))
- o->follow = parse_bool(doc, n);
+ if ((n = obt_xml_find_node(node, "follow")))
+ o->follow = obt_xml_node_bool(n);
+
+ if (o->type == RELATIVE && o->follow) {
+ o->interactive = TRUE;
+ *pre = i_pre_func;
+ *input = i_input_func;
+ *post = i_post_func;
+ }
return o;
}
@@ -133,6 +270,8 @@ static gboolean run_func(ObActionsData *data, gpointer options)
d = screen_find_desktop(screen_desktop,
o->u.rel.dir, o->u.rel.wrap, o->u.rel.linear);
break;
+ default:
+ g_assert_not_reached();
}
if (d < screen_num_desktops && d != screen_desktop) {
@@ -152,5 +291,264 @@ static gboolean run_func(ObActionsData *data, gpointer options)
actions_client_move(data, FALSE);
}
- return FALSE;
+
+ return o->interactive;
+}
+
+static gboolean i_input_func(guint initial_state,
+ XEvent *e,
+ gpointer options,
+ gboolean *used)
+{
+ if (e->type == KeyPress) {
+ /* Escape cancels no matter what */
+ if (ob_keycode_match(e->xkey.keycode, OB_KEY_ESCAPE)) {
+ return FALSE;
+ }
+
+ /* There were no modifiers and they pressed enter */
+ else if (ob_keycode_match(e->xkey.keycode, OB_KEY_RETURN) &&
+ !initial_state)
+ {
+ return FALSE;
+ }
+ }
+ /* They released the modifiers */
+ else if (e->type == KeyRelease && initial_state &&
+ (e->xkey.state & initial_state) == 0)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean i_pre_func(guint initial_state, gpointer options)
+{
+ if (!initial_state) {
+ Options *o = options;
+ o->interactive = FALSE;
+ return FALSE;
+ }
+ else {
+ screen_show_desktop_popup(screen_desktop, TRUE);
+ return TRUE;
+ }
+}
+
+static void i_post_func(gpointer options)
+{
+ screen_hide_desktop_popup();
+}
+
+/* 3.4-compatilibity */
+static gpointer setup_follow(xmlNodePtr node)
+{
+ xmlNodePtr n;
+ Options *o = g_new0(Options, 1);
+ o->send = TRUE;
+ o->follow = TRUE;
+ if ((n = obt_xml_find_node(node, "follow")))
+ o->follow = obt_xml_node_bool(n);
+ return o;
+}
+
+static gpointer setup_go_last_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->type = LAST;
+ return o;
+}
+
+static gpointer setup_send_last_func(xmlNodePtr node)
+{
+ Options *o = setup_follow(node);
+ o->type = LAST;
+ return o;
+}
+
+static gpointer setup_go_abs_func(xmlNodePtr node)
+{
+ xmlNodePtr n;
+ Options *o = g_new0(Options, 1);
+ o->type = ABSOLUTE;
+ if ((n = obt_xml_find_node(node, "desktop")))
+ o->u.abs.desktop = obt_xml_node_int(n) - 1;
+ else
+ o->u.abs.desktop = screen_desktop;
+ return o;
+}
+
+static gpointer setup_send_abs_func(xmlNodePtr node)
+{
+ xmlNodePtr n;
+ Options *o = setup_follow(node);
+ o->type = ABSOLUTE;
+ if ((n = obt_xml_find_node(node, "desktop")))
+ o->u.abs.desktop = obt_xml_node_int(n) - 1;
+ else
+ o->u.abs.desktop = screen_desktop;
+ return o;
+}
+
+static void setup_rel(Options *o, xmlNodePtr node, gboolean lin,
+ ObDirection dir,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsIPostFunc *post)
+{
+ xmlNodePtr n;
+
+ o->type = RELATIVE;
+ o->u.rel.linear = lin;
+ o->u.rel.dir = dir;
+ o->u.rel.wrap = TRUE;
+
+ if ((n = obt_xml_find_node(node, "wrap")))
+ o->u.rel.wrap = obt_xml_node_bool(n);
+
+ if (input) {
+ o->interactive = TRUE;
+ *pre = i_pre_func;
+ *input = i_input_func;
+ *post = i_post_func;
+ }
+}
+
+static gpointer setup_go_next_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = g_new0(Options, 1);
+ setup_rel(o, node, TRUE, OB_DIRECTION_EAST, pre, input, post);
+ return o;
+}
+
+static gpointer setup_send_next_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_follow(node);
+ setup_rel(o, node, TRUE, OB_DIRECTION_EAST,
+ pre, (o->follow ? input : NULL), post);
+ return o;
+}
+
+static gpointer setup_go_prev_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = g_new0(Options, 1);
+ setup_rel(o, node, TRUE, OB_DIRECTION_WEST, pre, input, post);
+ return o;
+}
+
+static gpointer setup_send_prev_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_follow(node);
+ setup_rel(o, node, TRUE, OB_DIRECTION_WEST,
+ pre, (o->follow ? input : NULL), post);
+ return o;
+}
+
+static gpointer setup_go_left_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = g_new0(Options, 1);
+ setup_rel(o, node, FALSE, OB_DIRECTION_WEST, pre, input, post);
+ return o;
+}
+
+static gpointer setup_send_left_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_follow(node);
+ setup_rel(o, node, FALSE, OB_DIRECTION_WEST,
+ pre, (o->follow ? input : NULL), post);
+ return o;
+}
+
+static gpointer setup_go_right_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = g_new0(Options, 1);
+ setup_rel(o, node, FALSE, OB_DIRECTION_EAST, pre, input, post);
+ return o;
+}
+
+static gpointer setup_send_right_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_follow(node);
+ setup_rel(o, node, FALSE, OB_DIRECTION_EAST,
+ pre, (o->follow ? input : NULL), post);
+ return o;
+}
+
+static gpointer setup_go_up_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = g_new0(Options, 1);
+ setup_rel(o, node, FALSE, OB_DIRECTION_NORTH, pre, input, post);
+ return o;
+}
+
+static gpointer setup_send_up_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_follow(node);
+ setup_rel(o, node, FALSE, OB_DIRECTION_NORTH,
+ pre, (o->follow ? input : NULL), post);
+ return o;
+}
+
+static gpointer setup_go_down_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = g_new0(Options, 1);
+ setup_rel(o, node, FALSE, OB_DIRECTION_SOUTH, pre, input, post);
+ return o;
+}
+
+static gpointer setup_send_down_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_follow(node);
+ setup_rel(o, node, FALSE, OB_DIRECTION_SOUTH,
+ pre, (o->follow ? input : NULL), post);
+ return o;
}
diff --git a/openbox/actions/directionalwindows.c b/openbox/actions/directionalwindows.c
index 6559e44c..2cca450c 100644
--- a/openbox/actions/directionalwindows.c
+++ b/openbox/actions/directionalwindows.c
@@ -20,11 +20,13 @@ typedef struct {
static gboolean cycling = FALSE;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_cycle_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_target_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post);
+static gpointer setup_target_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
static gboolean i_input_func(guint initial_state,
@@ -35,15 +37,98 @@ static void i_cancel_func(gpointer options);
static void end_cycle(gboolean cancel, guint state, Options *o);
+/* 3.4-compatibility */
+static gpointer setup_north_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_south_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_east_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_west_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_northwest_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_northeast_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_southwest_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_southeast_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *in,
+ ObActionsICancelFunc *c,
+ ObActionsIPostFunc *post);
+static gpointer setup_north_target_func(xmlNodePtr node);
+static gpointer setup_south_target_func(xmlNodePtr node);
+static gpointer setup_east_target_func(xmlNodePtr node);
+static gpointer setup_west_target_func(xmlNodePtr node);
+static gpointer setup_northwest_target_func(xmlNodePtr node);
+static gpointer setup_northeast_target_func(xmlNodePtr node);
+static gpointer setup_southwest_target_func(xmlNodePtr node);
+static gpointer setup_southeast_target_func(xmlNodePtr node);
+
void action_directionalwindows_startup(void)
{
- actions_register("DirectionalCycleWindows", setup_cycle_func, free_func,
- run_func, i_input_func, i_cancel_func);
+ actions_register_i("DirectionalCycleWindows", setup_cycle_func, free_func,
+ run_func);
actions_register("DirectionalTargetWindow", setup_target_func, free_func,
- run_func, NULL, NULL);
+ run_func);
+ /* 3.4-compatibility */
+ actions_register_i("DirectionalFocusNorth", setup_north_cycle_func,
+ free_func, run_func);
+ actions_register_i("DirectionalFocusSouth", setup_south_cycle_func,
+ free_func, run_func);
+ actions_register_i("DirectionalFocusWest", setup_west_cycle_func,
+ free_func, run_func);
+ actions_register_i("DirectionalFocusEast", setup_east_cycle_func,
+ free_func, run_func);
+ actions_register_i("DirectionalFocusNorthWest", setup_northwest_cycle_func,
+ free_func, run_func);
+ actions_register_i("DirectionalFocusNorthEast", setup_northeast_cycle_func,
+ free_func, run_func);
+ actions_register_i("DirectionalFocusSouthWest", setup_southwest_cycle_func,
+ free_func, run_func);
+ actions_register_i("DirectionalFocusSouthEast", setup_southeast_cycle_func,
+ free_func, run_func);
+ actions_register("DirectionalTargetNorth", setup_north_target_func,
+ free_func, run_func);
+ actions_register("DirectionalTargetSouth", setup_south_target_func,
+ free_func, run_func);
+ actions_register("DirectionalTargetWest", setup_west_target_func,
+ free_func, run_func);
+ actions_register("DirectionalTargetEast", setup_east_target_func,
+ free_func, run_func);
+ actions_register("DirectionalTargetNorthWest", setup_northwest_target_func,
+ free_func, run_func);
+ actions_register("DirectionalTargetNorthEast", setup_northeast_target_func,
+ free_func, run_func);
+ actions_register("DirectionalTargetSouthWest", setup_southwest_target_func,
+ free_func, run_func);
+ actions_register("DirectionalTargetSouthEast", setup_southeast_target_func,
+ free_func, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
@@ -52,18 +137,18 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o->dialog = TRUE;
o->bar = TRUE;
- if ((n = parse_find_node("dialog", node)))
- o->dialog = parse_bool(doc, n);
- if ((n = parse_find_node("bar", node)))
- o->bar = parse_bool(doc, n);
- if ((n = parse_find_node("raise", node)))
- o->raise = parse_bool(doc, n);
- if ((n = parse_find_node("panels", node)))
- o->dock_windows = parse_bool(doc, n);
- if ((n = parse_find_node("desktop", node)))
- o->desktop_windows = parse_bool(doc, n);
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "dialog")))
+ o->dialog = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "bar")))
+ o->bar = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "raise")))
+ o->raise = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "panels")))
+ o->dock_windows = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "desktop")))
+ o->desktop_windows = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "direction"))) {
+ gchar *s = obt_xml_node_string(n);
if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up"))
o->direction = OB_DIRECTION_NORTH;
@@ -87,14 +172,14 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
g_free(s);
}
- if ((n = parse_find_node("finalactions", node))) {
+ if ((n = obt_xml_find_node(node, "finalactions"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_xml_find_node(n->children, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->actions = g_slist_append(o->actions, action);
- m = parse_find_node("action", m->next);
+ m = obt_xml_find_node(m->next, "action");
}
}
else {
@@ -109,18 +194,22 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o;
}
-static gpointer setup_cycle_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->interactive = TRUE;
+ *input = i_input_func;
+ *cancel = i_cancel_func;
return o;
}
-static gpointer setup_target_func(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_target_func(xmlNodePtr node)
{
- Options *o = setup_func(i, doc, node);
+ Options *o = setup_func(node);
o->interactive = FALSE;
return o;
}
@@ -220,3 +309,149 @@ static void end_cycle(gboolean cancel, guint state, Options *o)
stacking_restore();
}
+
+/* 3.4-compatibility */
+static gpointer setup_north_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_cycle_func(node, pre, input, cancel, post);
+ o->direction = OB_DIRECTION_NORTH;
+ return o;
+}
+
+static gpointer setup_south_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_cycle_func(node, pre, input, cancel, post);
+ o->direction = OB_DIRECTION_SOUTH;
+ return o;
+}
+
+static gpointer setup_east_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_cycle_func(node, pre, input, cancel, post);
+ o->direction = OB_DIRECTION_EAST;
+ return o;
+}
+
+static gpointer setup_west_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_cycle_func(node, pre, input, cancel, post);
+ o->direction = OB_DIRECTION_WEST;
+ return o;
+}
+
+static gpointer setup_northwest_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_cycle_func(node, pre, input, cancel, post);
+ o->direction = OB_DIRECTION_NORTHWEST;
+ return o;
+}
+
+static gpointer setup_northeast_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_cycle_func(node, pre, input, cancel, post);
+ o->direction = OB_DIRECTION_EAST;
+ return o;
+}
+
+static gpointer setup_southwest_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_cycle_func(node, pre, input, cancel, post);
+ o->direction = OB_DIRECTION_SOUTHWEST;
+ return o;
+}
+
+static gpointer setup_southeast_cycle_func(xmlNodePtr node,
+ ObActionsIPreFunc *pre,
+ ObActionsIInputFunc *input,
+ ObActionsICancelFunc *cancel,
+ ObActionsIPostFunc *post)
+{
+ Options *o = setup_cycle_func(node, pre, input, cancel, post);
+ o->direction = OB_DIRECTION_SOUTHEAST;
+ return o;
+}
+
+static gpointer setup_north_target_func(xmlNodePtr node)
+{
+ Options *o = setup_target_func(node);
+ o->direction = OB_DIRECTION_NORTH;
+ return o;
+}
+
+static gpointer setup_south_target_func(xmlNodePtr node)
+{
+ Options *o = setup_target_func(node);
+ o->direction = OB_DIRECTION_SOUTH;
+ return o;
+}
+
+static gpointer setup_east_target_func(xmlNodePtr node)
+{
+ Options *o = setup_target_func(node);
+ o->direction = OB_DIRECTION_EAST;
+ return o;
+}
+
+static gpointer setup_west_target_func(xmlNodePtr node)
+{
+ Options *o = setup_target_func(node);
+ o->direction = OB_DIRECTION_WEST;
+ return o;
+}
+
+static gpointer setup_northwest_target_func(xmlNodePtr node)
+{
+ Options *o = setup_target_func(node);
+ o->direction = OB_DIRECTION_NORTHWEST;
+ return o;
+}
+
+static gpointer setup_northeast_target_func(xmlNodePtr node)
+{
+ Options *o = setup_target_func(node);
+ o->direction = OB_DIRECTION_NORTHEAST;
+ return o;
+}
+
+static gpointer setup_southwest_target_func(xmlNodePtr node)
+{
+ Options *o = setup_target_func(node);
+ o->direction = OB_DIRECTION_SOUTHWEST;
+ return o;
+}
+
+static gpointer setup_southeast_target_func(xmlNodePtr node)
+{
+ Options *o = setup_target_func(node);
+ o->direction = OB_DIRECTION_SOUTHEAST;
+ return o;
+}
+
diff --git a/openbox/actions/dockautohide.c b/openbox/actions/dockautohide.c
index 5e5382d4..4a750b2c 100644
--- a/openbox/actions/dockautohide.c
+++ b/openbox/actions/dockautohide.c
@@ -8,8 +8,7 @@ void action_dockautohide_startup(void)
{
actions_register("ToggleDockAutoHide",
NULL, NULL,
- run_func,
- NULL, NULL);
+ run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c
index cb3ab247..77244d8f 100644
--- a/openbox/actions/execute.c
+++ b/openbox/actions/execute.c
@@ -1,8 +1,10 @@
#include "openbox/actions.h"
#include "openbox/event.h"
#include "openbox/startupnotify.h"
+#include "openbox/client.h"
#include "openbox/prompt.h"
#include "openbox/screen.h"
+#include "obt/paths.h"
#include "gettext.h"
#ifdef HAVE_STDLIB_H
@@ -18,7 +20,7 @@ typedef struct {
gchar *prompt;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
/*
@@ -31,41 +33,37 @@ static void i_cancel_func(gpointer options);
void action_execute_startup(void)
{
- actions_register("Execute",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Execute", setup_func, free_func, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("command", node)) ||
- (n = parse_find_node("execute", node)))
+ if ((n = obt_xml_find_node(node, "command")) ||
+ (n = obt_xml_find_node(node, "execute")))
{
- gchar *s = parse_string(doc, n);
- o->cmd = parse_expand_tilde(s);
+ gchar *s = obt_xml_node_string(n);
+ o->cmd = obt_paths_expand_tilde(s);
g_free(s);
}
- if ((n = parse_find_node("prompt", node)))
- o->prompt = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "prompt")))
+ o->prompt = obt_xml_node_string(n);
- if ((n = parse_find_node("startupnotify", node))) {
+ if ((n = obt_xml_find_node(node, "startupnotify"))) {
xmlNodePtr m;
- if ((m = parse_find_node("enabled", n->xmlChildrenNode)))
- o->sn = parse_bool(doc, m);
- if ((m = parse_find_node("name", n->xmlChildrenNode)))
- o->sn_name = parse_string(doc, m);
- if ((m = parse_find_node("icon", n->xmlChildrenNode)))
- o->sn_icon = parse_string(doc, m);
- if ((m = parse_find_node("wmclass", n->xmlChildrenNode)))
- o->sn_wmclass = parse_string(doc, m);
+ if ((m = obt_xml_find_node(n->children, "enabled")))
+ o->sn = obt_xml_node_bool(m);
+ if ((m = obt_xml_find_node(n->children, "name")))
+ o->sn_name = obt_xml_node_string(m);
+ if ((m = obt_xml_find_node(n->children, "icon")))
+ o->sn_icon = obt_xml_node_string(m);
+ if ((m = obt_xml_find_node(n->children, "wmclass")))
+ o->sn_wmclass = obt_xml_node_string(m);
}
return o;
}
@@ -114,7 +112,7 @@ static void prompt_cleanup(ObPrompt *p, gpointer options)
/* Always return FALSE because its not interactive */
static gboolean run_func(ObActionsData *data, gpointer options)
{
- GError *e = NULL;
+ GError *e;
gchar **argv = NULL;
gchar *cmd;
Options *o = options;
@@ -143,16 +141,81 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE;
}
+ if (data->client) {
+ gchar *c, *before, *expand;
+
+ /* replace occurrences of $pid and $wid */
+
+ expand = NULL;
+ before = cmd;
+
+ while ((c = strchr(before, '$'))) {
+ if ((c[1] == 'p' || c[1] == 'P') &&
+ (c[2] == 'i' || c[2] == 'I') &&
+ (c[3] == 'd' || c[3] == 'D') &&
+ !g_ascii_isalnum(c[4]))
+ {
+ /* found $pid */
+ gchar *tmp;
+
+ *c = '\0';
+ tmp = expand;
+ expand = g_strdup_printf("%s%s%u",
+ (expand ? expand : ""),
+ before,
+ data->client->pid);
+ g_free(tmp);
+
+ before = c + 4; /* 4 = strlen("$pid") */
+ }
+ else if ((c[1] == 'w' || c[1] == 'W') &&
+ (c[2] == 'i' || c[2] == 'I') &&
+ (c[3] == 'd' || c[3] == 'D') &&
+ !g_ascii_isalnum(c[4]))
+ {
+ /* found $wid */
+ gchar *tmp;
+
+ *c = '\0';
+ tmp = expand;
+ expand = g_strdup_printf("%s%s%lu",
+ (expand ? expand : ""),
+ before,
+ data->client->window);
+ g_free(tmp);
+
+ before = c + 4; /* 4 = strlen("$wid") */
+ }
+ else
+ before = c + 1; /* no infinite loops plz */
+ }
+
+ if (expand) {
+ gchar *tmp;
+
+ /* add on the end of the string after the last replacement */
+ tmp = expand;
+ expand = g_strconcat(expand, before, NULL);
+ g_free(tmp);
+
+ /* replace the command with the expanded one */
+ g_free(cmd);
+ cmd = expand;
+ }
+ }
+
/* If there is a keyboard grab going on then we need to cancel
it so the application can grab things */
event_cancel_all_key_grabs();
+ e = NULL;
if (!g_shell_parse_argv(cmd, NULL, &argv, &e)) {
g_message(e->message, o->cmd);
g_error_free(e);
}
else {
gchar *program = NULL;
+ gboolean ok;
if (o->sn) {
program = g_path_get_basename(argv[0]);
@@ -163,18 +226,20 @@ static gboolean run_func(ObActionsData *data, gpointer options)
screen_desktop);
}
- if (!g_spawn_async(NULL, argv, NULL,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- NULL, NULL, NULL, &e))
- {
+ e = NULL;
+ ok = g_spawn_async(NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH |
+ G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL, NULL, NULL, &e);
+ if (!ok) {
g_message(e->message, o->cmd);
g_error_free(e);
-
- if (o->sn)
- sn_spawn_cancel();
}
- if (o->sn)
+
+ if (o->sn) {
+ if (!ok) sn_spawn_cancel();
unsetenv("DESKTOP_STARTUP_ID");
+ }
g_free(program);
g_strfreev(argv);
diff --git a/openbox/actions/exit.c b/openbox/actions/exit.c
index 567926e1..f2b0cafb 100644
--- a/openbox/actions/exit.c
+++ b/openbox/actions/exit.c
@@ -8,16 +8,16 @@ typedef struct {
gboolean prompt;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_exit_startup(void)
{
- actions_register("Exit", setup_func, NULL, run_func, NULL, NULL);
- actions_register("SessionLogout", setup_func, NULL, run_func, NULL, NULL);
+ actions_register("Exit", setup_func, NULL, run_func);
+ actions_register("SessionLogout", setup_func, NULL, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
@@ -25,8 +25,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o = g_new0(Options, 1);
o->prompt = TRUE;
- if ((n = parse_find_node("prompt", node)))
- o->prompt = parse_bool(doc, n);
+ if ((n = obt_xml_find_node(node, "prompt")))
+ o->prompt = obt_xml_node_bool(n);
return o;
}
diff --git a/openbox/actions/focus.c b/openbox/actions/focus.c
index 1b544910..8bae49c7 100644
--- a/openbox/actions/focus.c
+++ b/openbox/actions/focus.c
@@ -9,20 +9,15 @@ typedef struct {
gboolean stop_int;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_focus_startup(void)
{
- actions_register("Focus",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Focus", setup_func, g_free, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
@@ -30,20 +25,13 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o = g_new0(Options, 1);
o->stop_int = TRUE;
- if ((n = parse_find_node("here", node)))
- o->here = parse_bool(doc, n);
- if ((n = parse_find_node("stopInteractive", node)))
- o->stop_int = parse_bool(doc, n);
+ if ((n = obt_xml_find_node(node, "here")))
+ o->here = obt_xml_node_bool(n);
+ if ((n = obt_xml_find_node(node, "stopInteractive")))
+ o->stop_int = obt_xml_node_bool(n);
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)
{
diff --git a/openbox/actions/focustobottom.c b/openbox/actions/focustobottom.c
index 49c945b9..a3e5b5ac 100644
--- a/openbox/actions/focustobottom.c
+++ b/openbox/actions/focustobottom.c
@@ -5,7 +5,7 @@ static gboolean run_func(ObActionsData *data, gpointer options);
void action_focustobottom_startup(void)
{
- actions_register("FocusToBottom", NULL, NULL, run_func, NULL, NULL);
+ actions_register("FocusToBottom", NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/fullscreen.c b/openbox/actions/fullscreen.c
index 7579b95d..e1fdf232 100644
--- a/openbox/actions/fullscreen.c
+++ b/openbox/actions/fullscreen.c
@@ -5,8 +5,7 @@ static gboolean run_func_toggle(ObActionsData *data, gpointer options);
void action_fullscreen_startup(void)
{
- actions_register("ToggleFullscreen", NULL, NULL, run_func_toggle,
- NULL, NULL);
+ actions_register("ToggleFullscreen", NULL, NULL, run_func_toggle);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/growtoedge.c b/openbox/actions/growtoedge.c
index 69b8ef77..9589d3f6 100644
--- a/openbox/actions/growtoedge.c
+++ b/openbox/actions/growtoedge.c
@@ -7,31 +7,42 @@
typedef struct {
ObDirection dir;
+ gboolean shrink;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
+static gpointer setup_shrink_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
+/* 3.4-compatibility */
+static gpointer setup_north_func(xmlNodePtr node);
+static gpointer setup_south_func(xmlNodePtr node);
+static gpointer setup_east_func(xmlNodePtr node);
+static gpointer setup_west_func(xmlNodePtr node);
void action_growtoedge_startup(void)
{
- actions_register("GrowToEdge",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("GrowToEdge", setup_func,
+ g_free, run_func);
+ actions_register("ShrinkToEdge", setup_shrink_func,
+ g_free, run_func);
+ /* 3.4-compatibility */
+ actions_register("GrowToEdgeNorth", setup_north_func, g_free, run_func);
+ actions_register("GrowToEdgeSouth", setup_south_func, g_free, run_func);
+ actions_register("GrowToEdgeEast", setup_east_func, g_free, run_func);
+ actions_register("GrowToEdgeWest", setup_west_func, g_free, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
o->dir = OB_DIRECTION_NORTH;
+ o->shrink = FALSE;
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "direction"))) {
+ gchar *s = obt_xml_node_string(n);
if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up"))
o->dir = OB_DIRECTION_NORTH;
@@ -50,11 +61,14 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o;
}
-static void free_func(gpointer options)
+static gpointer setup_shrink_func(xmlNodePtr node)
{
- Options *o = options;
+ Options *o;
- g_free(o);
+ o = setup_func(node);
+ o->shrink = TRUE;
+
+ return o;
}
static gboolean do_grow(ObActionsData *data, gint x, gint y, gint w, gint h)
@@ -98,11 +112,13 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE;
}
- /* try grow */
- client_find_resize_directional(data->client, o->dir, TRUE,
- &x, &y, &w, &h);
- if (do_grow(data, x, y, w, h))
- return FALSE;
+ if (!o->shrink) {
+ /* try grow */
+ client_find_resize_directional(data->client, o->dir, TRUE,
+ &x, &y, &w, &h);
+ if (do_grow(data, x, y, w, h))
+ return FALSE;
+ }
/* we couldn't grow, so try shrink! */
opp = (o->dir == OB_DIRECTION_NORTH ? OB_DIRECTION_SOUTH :
@@ -143,3 +159,36 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE;
}
+
+/* 3.4-compatibility */
+static gpointer setup_north_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->shrink = FALSE;
+ o->dir = OB_DIRECTION_NORTH;
+ return o;
+}
+
+static gpointer setup_south_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->shrink = FALSE;
+ o->dir = OB_DIRECTION_SOUTH;
+ return o;
+}
+
+static gpointer setup_east_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->shrink = FALSE;
+ o->dir = OB_DIRECTION_EAST;
+ return o;
+}
+
+static gpointer setup_west_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->shrink = FALSE;
+ o->dir = OB_DIRECTION_WEST;
+ return o;
+}
diff --git a/openbox/actions/iconify.c b/openbox/actions/iconify.c
index 6f14a2e0..e6bdbb7b 100644
--- a/openbox/actions/iconify.c
+++ b/openbox/actions/iconify.c
@@ -7,8 +7,7 @@ void action_iconify_startup(void)
{
actions_register("Iconify",
NULL, NULL,
- run_func,
- NULL, NULL);
+ run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/if.c b/openbox/actions/if.c
index 4c989664..dd86086b 100644
--- a/openbox/actions/if.c
+++ b/openbox/actions/if.c
@@ -23,81 +23,77 @@ typedef struct {
GSList *elseacts;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_if_startup(void)
{
- actions_register("If",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("If", setup_func, free_func, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("shaded", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_xml_find_node(node, "shaded"))) {
+ if (obt_xml_node_bool(n))
o->shaded_on = TRUE;
else
o->shaded_off = TRUE;
}
- if ((n = parse_find_node("maximized", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_xml_find_node(node, "maximized"))) {
+ if (obt_xml_node_bool(n))
o->maxfull_on = TRUE;
else
o->maxfull_off = TRUE;
}
- if ((n = parse_find_node("maximizedhorizontal", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_xml_find_node(node, "maximizedhorizontal"))) {
+ if (obt_xml_node_bool(n))
o->maxhorz_on = TRUE;
else
o->maxhorz_off = TRUE;
}
- if ((n = parse_find_node("maximizedvertical", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_xml_find_node(node, "maximizedvertical"))) {
+ if (obt_xml_node_bool(n))
o->maxvert_on = TRUE;
else
o->maxvert_off = TRUE;
}
- if ((n = parse_find_node("iconified", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_xml_find_node(node, "iconified"))) {
+ if (obt_xml_node_bool(n))
o->iconic_on = TRUE;
else
o->iconic_off = TRUE;
}
- if ((n = parse_find_node("focused", node))) {
- if (parse_bool(doc, n))
+ if ((n = obt_xml_find_node(node, "focused"))) {
+ if (obt_xml_node_bool(n))
o->focused = TRUE;
else
o->unfocused = TRUE;
}
- if ((n = parse_find_node("then", node))) {
+ if ((n = obt_xml_find_node(node, "then"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_xml_find_node(n->children, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->thenacts = g_slist_append(o->thenacts, action);
- m = parse_find_node("action", m->next);
+ m = obt_xml_find_node(m->next, "action");
}
}
- if ((n = parse_find_node("else", node))) {
+ if ((n = obt_xml_find_node(node, "else"))) {
xmlNodePtr m;
- m = parse_find_node("action", n->xmlChildrenNode);
+ m = obt_xml_find_node(n->children, "action");
while (m) {
- ObActionsAct *action = actions_parse(i, doc, m);
+ ObActionsAct *action = actions_parse(m);
if (action) o->elseacts = g_slist_append(o->elseacts, action);
- m = parse_find_node("action", m->next);
+ m = obt_xml_find_node(m->next, "action");
}
}
@@ -108,6 +104,15 @@ static void free_func(gpointer options)
{
Options *o = options;
+ while (o->thenacts) {
+ actions_act_unref(o->thenacts->data);
+ o->thenacts = g_slist_delete_link(o->thenacts, o->thenacts);
+ }
+ while (o->elseacts) {
+ actions_act_unref(o->elseacts->data);
+ o->elseacts = g_slist_delete_link(o->elseacts, o->elseacts);
+ }
+
g_free(o);
}
diff --git a/openbox/actions/kill.c b/openbox/actions/kill.c
index 68244407..b7d547b9 100644
--- a/openbox/actions/kill.c
+++ b/openbox/actions/kill.c
@@ -7,8 +7,7 @@ void action_kill_startup(void)
{
actions_register("Kill",
NULL, NULL,
- run_func,
- NULL, NULL);
+ run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/layer.c b/openbox/actions/layer.c
index 92fa4806..2b4d325a 100644
--- a/openbox/actions/layer.c
+++ b/openbox/actions/layer.c
@@ -6,24 +6,33 @@ typedef struct {
gboolean toggle;
} Options;
-static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
-static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node);
+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);
+/* 3.4-compatibility */
+static gpointer setup_sendtop_func(xmlNodePtr node);
+static gpointer setup_sendbottom_func(xmlNodePtr node);
+static gpointer setup_sendnormal_func(xmlNodePtr node);
void action_layer_startup(void)
{
actions_register("ToggleAlwaysOnTop", setup_func_top, g_free,
- run_func, NULL, NULL);
+ run_func);
actions_register("ToggleAlwaysOnBottom", setup_func_bottom, g_free,
- run_func, NULL, NULL);
+ run_func);
actions_register("SendToLayer", setup_func_send, g_free,
- run_func, NULL, NULL);
+ run_func);
+ /* 3.4-compatibility */
+ actions_register("SendToTopLayer", setup_sendtop_func, g_free,
+ run_func);
+ actions_register("SendToBottomLayer", setup_sendbottom_func, g_free,
+ run_func);
+ actions_register("SendToNormalLayer", setup_sendnormal_func, g_free,
+ run_func);
}
-static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func_top(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = 1;
@@ -31,8 +40,7 @@ static gpointer setup_func_top(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o;
}
-static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_func_bottom(xmlNodePtr node)
{
Options *o = g_new0(Options, 1);
o->layer = -1;
@@ -40,16 +48,15 @@ static gpointer setup_func_bottom(ObParseInst *i, xmlDocPtr doc,
return o;
}
-static gpointer setup_func_send(ObParseInst *i, xmlDocPtr doc,
- xmlNodePtr node)
+static gpointer setup_func_send(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("layer", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "layer"))) {
+ gchar *s = obt_xml_node_string(n);
if (!g_ascii_strcasecmp(s, "above") ||
!g_ascii_strcasecmp(s, "top"))
o->layer = 1;
@@ -91,3 +98,29 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE;
}
+
+/* 3.4-compatibility */
+static gpointer setup_sendtop_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->layer = 1;
+ o->toggle = FALSE;
+ return o;
+}
+
+static gpointer setup_sendbottom_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->layer = -1;
+ o->toggle = FALSE;
+ return o;
+}
+
+static gpointer setup_sendnormal_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->layer = 0;
+ o->toggle = FALSE;
+ return o;
+}
+
diff --git a/openbox/actions/lower.c b/openbox/actions/lower.c
index d34e933b..80ca6b8b 100644
--- a/openbox/actions/lower.c
+++ b/openbox/actions/lower.c
@@ -8,8 +8,7 @@ void action_lower_startup(void)
{
actions_register("Lower",
NULL, NULL,
- run_func,
- NULL, NULL);
+ run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/maximize.c b/openbox/actions/maximize.c
index bb6f470a..4c615078 100644
--- a/openbox/actions/maximize.c
+++ b/openbox/actions/maximize.c
@@ -12,22 +12,42 @@ typedef struct {
MaxDirection dir;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func_on(ObActionsData *data, gpointer options);
static gboolean run_func_off(ObActionsData *data, gpointer options);
static gboolean run_func_toggle(ObActionsData *data, gpointer options);
+/* 3.4-compatibility */
+static gpointer setup_both_func(xmlNodePtr node);
+static gpointer setup_horz_func(xmlNodePtr node);
+static gpointer setup_vert_func(xmlNodePtr node);
void action_maximize_startup(void)
{
- actions_register("Maximize", setup_func, g_free, run_func_on,
- NULL, NULL);
- actions_register("Unmaximize", setup_func, g_free, run_func_off,
- NULL, NULL);
- actions_register("ToggleMaximize", setup_func, g_free, run_func_toggle,
- NULL, NULL);
+ actions_register("Maximize", setup_func, g_free, run_func_on);
+ actions_register("Unmaximize", setup_func, g_free, run_func_off);
+ actions_register("ToggleMaximize", setup_func, g_free, run_func_toggle);
+ /* 3.4-compatibility */
+ actions_register("MaximizeFull", setup_both_func, g_free,
+ run_func_on);
+ actions_register("UnmaximizeFull", setup_both_func, g_free,
+ run_func_off);
+ actions_register("ToggleMaximizeFull", setup_both_func, g_free,
+ run_func_toggle);
+ actions_register("MaximizeHorz", setup_horz_func, g_free,
+ run_func_on);
+ actions_register("UnmaximizeHorz", setup_horz_func, g_free,
+ run_func_off);
+ actions_register("ToggleMaximizeHorz", setup_horz_func, g_free,
+ run_func_toggle);
+ actions_register("MaximizeVert", setup_vert_func, g_free,
+ run_func_on);
+ actions_register("UnmaximizeVert", setup_vert_func, g_free,
+ run_func_off);
+ actions_register("ToggleMaximizeVert", setup_vert_func, g_free,
+ run_func_toggle);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
@@ -35,8 +55,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o = g_new0(Options, 1);
o->dir = BOTH;
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "direction"))) {
+ gchar *s = obt_xml_node_string(n);
if (!g_ascii_strcasecmp(s, "vertical") ||
!g_ascii_strcasecmp(s, "vert"))
o->dir = VERT;
@@ -89,3 +109,26 @@ static gboolean run_func_toggle(ObActionsData *data, gpointer options)
}
return FALSE;
}
+
+/* 3.4-compatibility */
+static gpointer setup_both_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->dir = BOTH;
+ return o;
+}
+
+static gpointer setup_horz_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->dir = HORZ;
+ return o;
+}
+
+static gpointer setup_vert_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->dir = VERT;
+ return o;
+}
+
diff --git a/openbox/actions/move.c b/openbox/actions/move.c
index 1a8ea204..ba8372a5 100644
--- a/openbox/actions/move.c
+++ b/openbox/actions/move.c
@@ -1,6 +1,6 @@
#include "openbox/actions.h"
-#include "openbox/prop.h"
#include "openbox/moveresize.h"
+#include "obt/prop.h"
static gboolean run_func(ObActionsData *data, gpointer options);
@@ -8,8 +8,7 @@ void action_move_startup(void)
{
actions_register("Move",
NULL, NULL,
- run_func,
- NULL, NULL);
+ run_func);
}
/* Always return FALSE because its not interactive */
@@ -19,8 +18,8 @@ static gboolean run_func(ObActionsData *data, gpointer options)
guint32 corner;
corner = data->button != 0 ?
- prop_atoms.net_wm_moveresize_move :
- prop_atoms.net_wm_moveresize_move_keyboard;
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE) :
+ OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD);
moveresize_start(data->client, data->x, data->y, data->button, corner);
}
diff --git a/openbox/actions/moverelative.c b/openbox/actions/moverelative.c
index 1d1189cd..ff9f719b 100644
--- a/openbox/actions/moverelative.c
+++ b/openbox/actions/moverelative.c
@@ -9,41 +9,29 @@ typedef struct {
gint y;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_moverelative_startup(void)
{
- actions_register("MoveRelative",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("MoveRelative", setup_func, g_free, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("x", node)))
- o->x = parse_int(doc, n);
- if ((n = parse_find_node("y", node)))
- o->y = parse_int(doc, n);
+ if ((n = obt_xml_find_node(node, "x")))
+ o->x = obt_xml_node_int(n);
+ if ((n = obt_xml_find_node(node, "y")))
+ o->y = obt_xml_node_int(n);
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)
{
@@ -54,15 +42,15 @@ static gboolean run_func(ObActionsData *data, gpointer options)
gint x, y, lw, lh, w, h;
c = data->client;
- x = data->client->area.x + o->x;
- y = data->client->area.y + o->y;
- w = data->client->area.width;
- h = data->client->area.height;
- client_try_configure(data->client, &x, &y, &w, &h, &lw, &lh, TRUE);
- client_find_onscreen(data->client, &x, &y, w, h, FALSE);
+ x = c->area.x + o->x;
+ y = c->area.y + o->y;
+ w = c->area.width;
+ h = c->area.height;
+ client_try_configure(c, &x, &y, &w, &h, &lw, &lh, TRUE);
+ client_find_onscreen(c, &x, &y, w, h, FALSE);
actions_client_move(data, TRUE);
- client_configure(data->client, x, y, w, h, TRUE, TRUE, FALSE);
+ client_configure(c, x, y, w, h, TRUE, TRUE, FALSE);
actions_client_move(data, FALSE);
}
diff --git a/openbox/actions/moveresizeto.c b/openbox/actions/moveresizeto.c
index 29780c49..f0472797 100644
--- a/openbox/actions/moveresizeto.c
+++ b/openbox/actions/moveresizeto.c
@@ -23,23 +23,22 @@ typedef struct {
gint monitor;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
+/* 3.4-compatibility */
+static gpointer setup_center_func(xmlNodePtr node);
void action_moveresizeto_startup(void)
{
- actions_register("MoveResizeTo",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("MoveResizeTo", setup_func, g_free, run_func);
+ /* 3.4-compatibility */
+ actions_register("MoveToCenter", setup_center_func, g_free, run_func);
}
-static void parse_coord(xmlDocPtr doc, xmlNodePtr n, gint *pos,
+static void parse_coord(xmlNodePtr n, gint *pos,
gboolean *opposite, gboolean *center)
{
- gchar *s = parse_string(doc, n);
+ gchar *s = obt_xml_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0) {
if (!g_ascii_strcasecmp(s, "center"))
*center = TRUE;
@@ -55,7 +54,7 @@ static void parse_coord(xmlDocPtr doc, xmlNodePtr n, gint *pos,
g_free(s);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
@@ -67,27 +66,27 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o->h = G_MININT;
o->monitor = CURRENT_MONITOR;
- if ((n = parse_find_node("x", node)))
- parse_coord(doc, n, &o->x, &o->xopposite, &o->xcenter);
+ if ((n = obt_xml_find_node(node, "x")))
+ parse_coord(n, &o->x, &o->xopposite, &o->xcenter);
- if ((n = parse_find_node("y", node)))
- parse_coord(doc, n, &o->y, &o->yopposite, &o->ycenter);
+ if ((n = obt_xml_find_node(node, "y")))
+ parse_coord(n, &o->y, &o->yopposite, &o->ycenter);
- if ((n = parse_find_node("width", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "width"))) {
+ gchar *s = obt_xml_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0)
- o->w = parse_int(doc, n);
+ o->w = obt_xml_node_int(n);
g_free(s);
}
- if ((n = parse_find_node("height", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "height"))) {
+ gchar *s = obt_xml_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0)
- o->h = parse_int(doc, n);
+ o->h = obt_xml_node_int(n);
g_free(s);
}
- if ((n = parse_find_node("monitor", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "monitor"))) {
+ gchar *s = obt_xml_node_string(n);
if (g_ascii_strcasecmp(s, "current") != 0) {
if (!g_ascii_strcasecmp(s, "all"))
o->monitor = ALL_MONITORS;
@@ -96,7 +95,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
else if(!g_ascii_strcasecmp(s, "prev"))
o->monitor = PREV_MONITOR;
else
- o->monitor = parse_int(doc, n) - 1;
+ o->monitor = obt_xml_node_int(n) - 1;
}
g_free(s);
}
@@ -104,13 +103,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
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)
{
@@ -188,3 +180,19 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE;
}
+
+/* 3.4-compatibility */
+static gpointer setup_center_func(xmlNodePtr node)
+{
+ Options *o;
+
+ o = g_new0(Options, 1);
+ o->x = G_MININT;
+ o->y = G_MININT;
+ o->w = G_MININT;
+ o->h = G_MININT;
+ o->monitor = -1;
+ o->xcenter = TRUE;
+ o->ycenter = TRUE;
+ return o;
+}
diff --git a/openbox/actions/movetoedge.c b/openbox/actions/movetoedge.c
index 5941bde9..f81ded41 100644
--- a/openbox/actions/movetoedge.c
+++ b/openbox/actions/movetoedge.c
@@ -9,20 +9,25 @@ typedef struct {
ObDirection dir;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
+/* 3.4-compatibility */
+static gpointer setup_north_func(xmlNodePtr node);
+static gpointer setup_south_func(xmlNodePtr node);
+static gpointer setup_east_func(xmlNodePtr node);
+static gpointer setup_west_func(xmlNodePtr node);
void action_movetoedge_startup(void)
{
- actions_register("MoveToEdge",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("MoveToEdge", setup_func, g_free, run_func);
+ /* 3.4-compatibility */
+ actions_register("MoveToEdgeNorth", setup_north_func, g_free, run_func);
+ actions_register("MoveToEdgeSouth", setup_south_func, g_free, run_func);
+ actions_register("MoveToEdgeEast", setup_east_func, g_free, run_func);
+ actions_register("MoveToEdgeWest", setup_west_func, g_free, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
@@ -30,8 +35,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
o = g_new0(Options, 1);
o->dir = OB_DIRECTION_NORTH;
- if ((n = parse_find_node("direction", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "direction"))) {
+ gchar *s = obt_xml_node_string(n);
if (!g_ascii_strcasecmp(s, "north") ||
!g_ascii_strcasecmp(s, "up"))
o->dir = OB_DIRECTION_NORTH;
@@ -50,13 +55,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
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)
{
@@ -75,3 +73,33 @@ static gboolean run_func(ObActionsData *data, gpointer options)
return FALSE;
}
+
+/* 3.4-compatibility */
+static gpointer setup_north_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->dir = OB_DIRECTION_NORTH;
+ return o;
+}
+
+static gpointer setup_south_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->dir = OB_DIRECTION_SOUTH;
+ return o;
+}
+
+static gpointer setup_east_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->dir = OB_DIRECTION_EAST;
+ return o;
+}
+
+static gpointer setup_west_func(xmlNodePtr node)
+{
+ Options *o = g_new0(Options, 1);
+ o->dir = OB_DIRECTION_WEST;
+ return o;
+}
+
diff --git a/openbox/actions/omnipresent.c b/openbox/actions/omnipresent.c
index 030a0159..4309acc6 100644
--- a/openbox/actions/omnipresent.c
+++ b/openbox/actions/omnipresent.c
@@ -6,8 +6,7 @@ static gboolean run_func_toggle(ObActionsData *data, gpointer options);
void action_omnipresent_startup(void)
{
- actions_register("ToggleOmnipresent", NULL, NULL, run_func_toggle,
- NULL, NULL);
+ actions_register("ToggleOmnipresent", NULL, NULL, run_func_toggle);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/raise.c b/openbox/actions/raise.c
index 6837bce2..f6ac1452 100644
--- a/openbox/actions/raise.c
+++ b/openbox/actions/raise.c
@@ -6,10 +6,7 @@ static gboolean run_func(ObActionsData *data, gpointer options);
void action_raise_startup(void)
{
- actions_register("Raise",
- NULL, NULL,
- run_func,
- NULL, NULL);
+ actions_register("Raise", NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/raiselower.c b/openbox/actions/raiselower.c
index 80fc917f..dbe41d85 100644
--- a/openbox/actions/raiselower.c
+++ b/openbox/actions/raiselower.c
@@ -5,10 +5,7 @@ static gboolean run_func(ObActionsData *data, gpointer options);
void action_raiselower_startup(void)
{
- actions_register("RaiseLower",
- NULL, NULL,
- run_func,
- NULL, NULL);
+ actions_register("RaiseLower", NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/reconfigure.c b/openbox/actions/reconfigure.c
index cef81414..813a1221 100644
--- a/openbox/actions/reconfigure.c
+++ b/openbox/actions/reconfigure.c
@@ -5,10 +5,7 @@ static gboolean run_func(ObActionsData *data, gpointer options);
void action_reconfigure_startup(void)
{
- actions_register("Reconfigure",
- NULL, NULL,
- run_func,
- NULL, NULL);
+ actions_register("Reconfigure", NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/resize.c b/openbox/actions/resize.c
index 3714e38b..fbcdf24a 100644
--- a/openbox/actions/resize.c
+++ b/openbox/actions/resize.c
@@ -1,16 +1,15 @@
#include "openbox/actions.h"
-#include "openbox/prop.h"
#include "openbox/moveresize.h"
#include "openbox/client.h"
#include "openbox/frame.h"
+#include "obt/prop.h"
typedef struct {
gboolean corner_specified;
guint32 corner;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch,
@@ -18,40 +17,36 @@ static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch,
void action_resize_startup(void)
{
- actions_register("Resize",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Resize", setup_func, g_free, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("edge", node))) {
- gchar *s = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "edge"))) {
+ gchar *s = obt_xml_node_string(n);
o->corner_specified = TRUE;
if (!g_ascii_strcasecmp(s, "top"))
- o->corner = prop_atoms.net_wm_moveresize_size_top;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP);
else if (!g_ascii_strcasecmp(s, "bottom"))
- o->corner = prop_atoms.net_wm_moveresize_size_bottom;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM);
else if (!g_ascii_strcasecmp(s, "left"))
- o->corner = prop_atoms.net_wm_moveresize_size_left;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT);
else if (!g_ascii_strcasecmp(s, "right"))
- o->corner = prop_atoms.net_wm_moveresize_size_right;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT);
else if (!g_ascii_strcasecmp(s, "topleft"))
- o->corner = prop_atoms.net_wm_moveresize_size_topleft;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT);
else if (!g_ascii_strcasecmp(s, "topright"))
- o->corner = prop_atoms.net_wm_moveresize_size_topright;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT);
else if (!g_ascii_strcasecmp(s, "bottomleft"))
- o->corner = prop_atoms.net_wm_moveresize_size_bottomleft;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT);
else if (!g_ascii_strcasecmp(s, "bottomright"))
- o->corner = prop_atoms.net_wm_moveresize_size_bottomright;
+ o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT);
else
o->corner_specified = FALSE;
@@ -60,13 +55,6 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
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)
{
@@ -77,7 +65,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
guint32 corner;
if (!data->button)
- corner = prop_atoms.net_wm_moveresize_size_keyboard;
+ corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD);
else if (o->corner_specified)
corner = o->corner; /* it was specified in the binding */
else
@@ -163,30 +151,30 @@ static guint32 pick_corner(gint x, gint y, gint cx, gint cy, gint cw, gint ch,
if (shaded) {
/* for shaded windows, you can only resize west/east and move */
if (b)
- return prop_atoms.net_wm_moveresize_size_left;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT);
if (c)
- return prop_atoms.net_wm_moveresize_size_right;
- return prop_atoms.net_wm_moveresize_move;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT);
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE);
}
if (y < A && y >= C)
- return prop_atoms.net_wm_moveresize_size_topleft;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT);
else if (y >= A && y >= B && a)
- return prop_atoms.net_wm_moveresize_size_top;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP);
else if (y < B && y >= D)
- return prop_atoms.net_wm_moveresize_size_topright;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT);
else if (y < C && y >= E && b)
- return prop_atoms.net_wm_moveresize_size_left;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT);
else if (y < D && y >= F && c)
- return prop_atoms.net_wm_moveresize_size_right;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT);
else if (y < E && y >= G)
- return prop_atoms.net_wm_moveresize_size_bottomleft;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT);
else if (y < G && y < H && d)
- return prop_atoms.net_wm_moveresize_size_bottom;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM);
else if (y >= H && y < F)
- return prop_atoms.net_wm_moveresize_size_bottomright;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT);
else
- return prop_atoms.net_wm_moveresize_move;
+ return OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE);
#undef X
#undef A
diff --git a/openbox/actions/resizerelative.c b/openbox/actions/resizerelative.c
index f705c292..c5fc1ea1 100644
--- a/openbox/actions/resizerelative.c
+++ b/openbox/actions/resizerelative.c
@@ -11,47 +11,35 @@ typedef struct {
gint bottom;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
-static void free_func(gpointer options);
+static gpointer setup_func(xmlNodePtr node);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_resizerelative_startup(void)
{
- actions_register("ResizeRelative",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("ResizeRelative", setup_func, g_free, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("left", node)))
- o->left = parse_int(doc, n);
- if ((n = parse_find_node("right", node)))
- o->right = parse_int(doc, n);
- if ((n = parse_find_node("top", node)) ||
- (n = parse_find_node("up", node)))
- o->top = parse_int(doc, n);
- if ((n = parse_find_node("bottom", node)) ||
- (n = parse_find_node("down", node)))
- o->bottom = parse_int(doc, n);
+ if ((n = obt_xml_find_node(node, "left")))
+ o->left = obt_xml_node_int(n);
+ if ((n = obt_xml_find_node(node, "right")))
+ o->right = obt_xml_node_int(n);
+ if ((n = obt_xml_find_node(node, "top")) ||
+ (n = obt_xml_find_node(node, "up")))
+ o->top = obt_xml_node_int(n);
+ if ((n = obt_xml_find_node(node, "bottom")) ||
+ (n = obt_xml_find_node(node, "down")))
+ o->bottom = obt_xml_node_int(n);
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)
{
diff --git a/openbox/actions/restart.c b/openbox/actions/restart.c
index 4b52f9d3..7d1689cb 100644
--- a/openbox/actions/restart.c
+++ b/openbox/actions/restart.c
@@ -1,35 +1,32 @@
#include "openbox/actions.h"
#include "openbox/openbox.h"
+#include "obt/paths.h"
typedef struct {
gchar *cmd;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_restart_startup(void)
{
- actions_register("Restart",
- setup_func,
- free_func,
- run_func,
- NULL, NULL);
+ actions_register("Restart", setup_func, free_func, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("command", node)) ||
- (n = parse_find_node("execute", node)))
+ if ((n = obt_xml_find_node(node, "command")) ||
+ (n = obt_xml_find_node(node, "execute")))
{
- gchar *s = parse_string(doc, n);
- o->cmd = parse_expand_tilde(s);
+ gchar *s = obt_xml_node_string(n);
+ o->cmd = obt_paths_expand_tilde(s);
g_free(s);
}
return o;
@@ -38,11 +35,8 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
static void free_func(gpointer options)
{
Options *o = options;
-
- if (o) {
- g_free(o->cmd);
- g_free(o);
- }
+ g_free(o->cmd);
+ g_free(o);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/session.c b/openbox/actions/session.c
new file mode 100644
index 00000000..b9e33b74
--- /dev/null
+++ b/openbox/actions/session.c
@@ -0,0 +1,78 @@
+#include "openbox/actions.h"
+#include "openbox/prompt.h"
+#include "openbox/session.h"
+#include "gettext.h"
+
+typedef struct {
+ gboolean prompt;
+ gboolean silent;
+} Options;
+
+static gpointer setup_func(xmlNodePtr node);
+static gboolean logout_func(ObActionsData *data, gpointer options);
+
+void action_session_startup(void)
+{
+ actions_register("SessionLogout", setup_func, NULL, logout_func,
+ NULL, NULL);
+}
+
+static gpointer setup_func(xmlNodePtr node)
+{
+ xmlNodePtr n;
+ Options *o;
+
+ o = g_new0(Options, 1);
+ o->prompt = TRUE;
+
+ if ((n = obt_parse_find_node(node, "prompt")))
+ o->prompt = obt_parse_node_bool(n);
+
+ return o;
+}
+
+static gboolean prompt_cb(ObPrompt *p, gint result, gpointer data)
+{
+ if (result) {
+#ifdef USE_SM
+ Options *o = data;
+ session_request_logout(o->silent);
+#else
+ /* TRANSLATORS: Don't translate the word "SessionLogout" as it's the
+ name of the action you write in rc.xml */
+ g_message(_("The SessionLogout action is not available since Openbox was built without session management support"));
+#endif
+ }
+ return TRUE; /* call cleanup func */
+}
+
+static void prompt_cleanup(ObPrompt *p, gpointer data)
+{
+ g_free(data);
+ prompt_unref(p);
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean logout_func(ObActionsData *data, gpointer options)
+{
+ Options *o = options;
+
+ if (o->prompt) {
+ Options *o2;
+ ObPrompt *p;
+ ObPromptAnswer answers[] = {
+ { _("Cancel"), 0 },
+ { _("Log Out"), 1 }
+ };
+
+ o2 = g_memdup(o, sizeof(Options));
+ p = prompt_new(_("Are you sure you want to log out?"),
+ _("Log Out"),
+ answers, 2, 0, 0, prompt_cb, prompt_cleanup, o2);
+ prompt_show(p, NULL, FALSE);
+ }
+ else
+ prompt_cb(NULL, 1, o);
+
+ return FALSE;
+}
diff --git a/openbox/actions/shade.c b/openbox/actions/shade.c
index 2342067f..502781dd 100644
--- a/openbox/actions/shade.c
+++ b/openbox/actions/shade.c
@@ -7,9 +7,9 @@ static gboolean run_func_toggle(ObActionsData *data, gpointer options);
void action_shade_startup(void)
{
- actions_register("Shade", NULL, NULL, run_func_on, NULL, NULL);
- actions_register("Unshade", NULL, NULL, run_func_off, NULL, NULL);
- actions_register("ToggleShade", NULL, NULL, run_func_toggle, NULL, NULL);
+ actions_register("Shade", NULL, NULL, run_func_on);
+ actions_register("Unshade", NULL, NULL, run_func_off);
+ actions_register("ToggleShade", NULL, NULL, run_func_toggle);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/shadelowerraise.c b/openbox/actions/shadelowerraise.c
new file mode 100644
index 00000000..414e2817
--- /dev/null
+++ b/openbox/actions/shadelowerraise.c
@@ -0,0 +1,40 @@
+#include "openbox/actions.h"
+#include "openbox/client.h"
+
+static gboolean run_func_sl(ObActionsData *data, gpointer options);
+static gboolean run_func_ur(ObActionsData *data, gpointer options);
+
+void action_shadelowerraise_startup()
+{
+ /* 3.4-compatibility */
+ actions_register("ShadeLower", NULL, NULL, run_func_sl);
+ actions_register("UnshadeRaise", NULL, NULL, run_func_ur);
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func_sl(ObActionsData *data, gpointer options)
+{
+ if (data->client) {
+ actions_client_move(data, TRUE);
+ if (data->client->shaded)
+ stacking_lower(CLIENT_AS_WINDOW(data->client));
+ else
+ client_shade(data->client, TRUE);
+ actions_client_move(data, FALSE);
+ }
+ return FALSE;
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func_ur(ObActionsData *data, gpointer options)
+{
+ if (data->client) {
+ actions_client_move(data, TRUE);
+ if (data->client->shaded)
+ client_shade(data->client, FALSE);
+ else
+ stacking_raise(CLIENT_AS_WINDOW(data->client));
+ actions_client_move(data, FALSE);
+ }
+ return FALSE;
+}
diff --git a/openbox/actions/showdesktop.c b/openbox/actions/showdesktop.c
index c9ba86c4..6dc77d5e 100644
--- a/openbox/actions/showdesktop.c
+++ b/openbox/actions/showdesktop.c
@@ -5,10 +5,7 @@ static gboolean run_func(ObActionsData *data, gpointer options);
void action_showdesktop_startup(void)
{
- actions_register("ToggleShowDesktop",
- NULL, NULL,
- run_func,
- NULL, NULL);
+ actions_register("ToggleShowDesktop", NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */
diff --git a/openbox/actions/showmenu.c b/openbox/actions/showmenu.c
index c1d53e41..e60f1c69 100644
--- a/openbox/actions/showmenu.c
+++ b/openbox/actions/showmenu.c
@@ -6,25 +6,24 @@ typedef struct {
gchar *name;
} Options;
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
static gboolean run_func(ObActionsData *data, gpointer options);
void action_showmenu_startup(void)
{
- actions_register("ShowMenu", setup_func, free_func, run_func,
- NULL, NULL);
+ actions_register("ShowMenu", setup_func, free_func, run_func);
}
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+static gpointer setup_func(xmlNodePtr node)
{
xmlNodePtr n;
Options *o;
o = g_new0(Options, 1);
- if ((n = parse_find_node("menu", node)))
- o->name = parse_string(doc, n);
+ if ((n = obt_xml_find_node(node, "menu")))
+ o->name = obt_xml_node_string(n);
return o;
}
diff --git a/openbox/actions/unfocus.c b/openbox/actions/unfocus.c
index 22a9378c..3db00ca3 100644
--- a/openbox/actions/unfocus.c
+++ b/openbox/actions/unfocus.c
@@ -5,7 +5,7 @@ static gboolean run_func(ObActionsData *data, gpointer options);
void action_unfocus_startup(void)
{
- actions_register("Unfocus", NULL, NULL, run_func, NULL, NULL);
+ actions_register("Unfocus", NULL, NULL, run_func);
}
/* Always return FALSE because its not interactive */