diff options
Diffstat (limited to 'openbox/actions')
| -rw-r--r-- | openbox/actions/addremovedesktop.c | 84 | ||||
| -rw-r--r-- | openbox/actions/all.c | 2 | ||||
| -rw-r--r-- | openbox/actions/all.h | 76 | ||||
| -rw-r--r-- | openbox/actions/cyclewindows.c | 72 | ||||
| -rw-r--r-- | openbox/actions/debug.c | 21 | ||||
| -rw-r--r-- | openbox/actions/desktop.c | 227 | ||||
| -rw-r--r-- | openbox/actions/directionalwindows.c | 217 | ||||
| -rw-r--r-- | openbox/actions/execute.c | 127 | ||||
| -rw-r--r-- | openbox/actions/exit.c | 8 | ||||
| -rw-r--r-- | openbox/actions/focus.c | 22 | ||||
| -rw-r--r-- | openbox/actions/growtoedge.c | 87 | ||||
| -rw-r--r-- | openbox/actions/if.c | 59 | ||||
| -rw-r--r-- | openbox/actions/layer.c | 57 | ||||
| -rw-r--r-- | openbox/actions/maximize.c | 54 | ||||
| -rw-r--r-- | openbox/actions/move.c | 6 | ||||
| -rw-r--r-- | openbox/actions/moverelative.c | 40 | ||||
| -rw-r--r-- | openbox/actions/moveresizeto.c | 67 | ||||
| -rw-r--r-- | openbox/actions/movetoedge.c | 64 | ||||
| -rw-r--r-- | openbox/actions/resize.c | 66 | ||||
| -rw-r--r-- | openbox/actions/resizerelative.c | 37 | ||||
| -rw-r--r-- | openbox/actions/restart.c | 26 | ||||
| -rw-r--r-- | openbox/actions/session.c | 78 | ||||
| -rw-r--r-- | openbox/actions/shadelowerraise.c | 40 | ||||
| -rw-r--r-- | openbox/actions/showmenu.c | 8 |
24 files changed, 1117 insertions, 428 deletions
diff --git a/openbox/actions/addremovedesktop.c b/openbox/actions/addremovedesktop.c index 8125b9bb..1e7f0b57 100644 --- a/openbox/actions/addremovedesktop.c +++ b/openbox/actions/addremovedesktop.c @@ -7,36 +7,43 @@ 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, + actions_register("AddDesktop", setup_add_func, g_free, run_func, NULL, NULL); - actions_register("RemoveDesktop", - setup_remove_func, - free_func, - run_func, + actions_register("RemoveDesktop", setup_remove_func, g_free, run_func, + NULL, NULL); + + /* 3.4-compatibility */ + actions_register("AddDesktopLast", setup_addlast_func, g_free, run_func, + NULL, NULL); + actions_register("RemoveDesktopLast", setup_removelast_func, g_free, run_func, + NULL, NULL); + actions_register("AddDesktopCurrent", setup_addcurrent_func, g_free, run_func, + NULL, NULL); + actions_register("RemoveDesktopCurrent", setup_removecurrent_func, g_free, run_func, NULL, NULL); } -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_parse_find_node(node, "where"))) { + gchar *s = obt_parse_node_string(n); if (!g_ascii_strcasecmp(s, "last")) o->current = FALSE; else if (!g_ascii_strcasecmp(s, "current")) @@ -47,28 +54,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 +84,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/cyclewindows.c b/openbox/actions/cyclewindows.c index 6fba17ff..5354f087 100644 --- a/openbox/actions/cyclewindows.c +++ b/openbox/actions/cyclewindows.c @@ -8,23 +8,21 @@ 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); +static gpointer setup_func(xmlNodePtr node); +static gpointer setup_forward_func(xmlNodePtr node); +static gpointer setup_backward_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, @@ -43,38 +41,42 @@ void action_cyclewindows_startup(void) run_func, i_input_func, i_cancel_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->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_parse_find_node(node, "linear"))) + o->linear = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "dialog"))) { + if (obt_parse_node_contains(n, "none")) + o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_NONE; + else if (obt_parse_node_contains(n, "icons")) + o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_ICONS; + } + if ((n = obt_parse_find_node(node, "bar"))) + o->bar = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "raise"))) + o->raise = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "panels"))) + o->dock_windows = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "desktop"))) + o->desktop_windows = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "allDesktops"))) + o->all_desktops = obt_parse_node_bool(n); + + if ((n = obt_parse_find_node(node, "finalactions"))) { xmlNodePtr m; - m = parse_find_node("action", n->xmlChildrenNode); + m = obt_parse_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_parse_find_node(m->next, "action"); } } else { @@ -89,18 +91,16 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) return o; } -static gpointer setup_forward_func(ObParseInst *i, xmlDocPtr doc, - xmlNodePtr node) +static gpointer setup_forward_func(xmlNodePtr node) { - Options *o = setup_func(i, doc, node); + Options *o = setup_func(node); o->forward = TRUE; return o; } -static gpointer setup_backward_func(ObParseInst *i, xmlDocPtr doc, - xmlNodePtr node) +static gpointer setup_backward_func(xmlNodePtr node) { - Options *o = setup_func(i, doc, node); + Options *o = setup_func(node); o->forward = FALSE; return o; } @@ -129,7 +129,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) o->linear, TRUE, o->bar, - o->dialog, + o->dialog_mode, FALSE, FALSE); cycling = TRUE; @@ -189,7 +189,7 @@ static void end_cycle(gboolean cancel, guint state, Options *o) o->linear, TRUE, o->bar, - o->dialog, + o->dialog_mode, TRUE, cancel); cycling = FALSE; diff --git a/openbox/actions/debug.c b/openbox/actions/debug.c index f71b685d..99e838a6 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, NULL, NULL); } -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_parse_find_node(node, "string"))) + o->str = obt_parse_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/desktop.c b/openbox/actions/desktop.c index 07416151..3b33afbd 100644 --- a/openbox/actions/desktop.c +++ b/openbox/actions/desktop.c @@ -26,11 +26,26 @@ typedef struct { gboolean follow; } 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); +static gpointer setup_send_func(xmlNodePtr node); static gboolean run_func(ObActionsData *data, 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); +static gpointer setup_send_next_func(xmlNodePtr node); +static gpointer setup_go_prev_func(xmlNodePtr node); +static gpointer setup_send_prev_func(xmlNodePtr node); +static gpointer setup_go_left_func(xmlNodePtr node); +static gpointer setup_send_left_func(xmlNodePtr node); +static gpointer setup_go_right_func(xmlNodePtr node); +static gpointer setup_send_right_func(xmlNodePtr node); +static gpointer setup_go_up_func(xmlNodePtr node); +static gpointer setup_send_up_func(xmlNodePtr node); +static gpointer setup_go_down_func(xmlNodePtr node); +static gpointer setup_send_down_func(xmlNodePtr node); void action_desktop_startup(void) { @@ -38,23 +53,55 @@ void action_desktop_startup(void) NULL, NULL); actions_register("SendToDesktop", setup_send_func, g_free, run_func, NULL, NULL); + /* 3.4-compatibility */ + actions_register("DesktopLast", setup_go_last_func, g_free, run_func, + NULL, NULL); + actions_register("SendToDesktopLast", setup_send_last_func, g_free, run_func, + NULL, NULL); + actions_register("Desktop", setup_go_abs_func, g_free, run_func, + NULL, NULL); + actions_register("SendToDesktop", setup_send_abs_func, g_free, run_func, + NULL, NULL); + actions_register("DesktopNext", setup_go_next_func, g_free, run_func, + NULL, NULL); + actions_register("SendToDesktopNext", setup_send_next_func, g_free, run_func, + NULL, NULL); + actions_register("DesktopPrevious", setup_go_prev_func, g_free, run_func, + NULL, NULL); + actions_register("SendToDesktopPrevious", setup_send_prev_func, g_free, run_func, + NULL, NULL); + actions_register("DesktopLeft", setup_go_left_func, g_free, run_func, + NULL, NULL); + actions_register("SendToDesktopLeft", setup_send_left_func, g_free, run_func, + NULL, NULL); + actions_register("DesktopRight", setup_go_right_func, g_free, run_func, + NULL, NULL); + actions_register("SendToDesktopRight", setup_send_right_func, g_free, run_func, + NULL, NULL); + actions_register("DesktopUp", setup_go_up_func, g_free, run_func, + NULL, NULL); + actions_register("SendToDesktopUp", setup_send_up_func, g_free, run_func, + NULL, NULL); + actions_register("DesktopDown", setup_go_down_func, g_free, run_func, + NULL, NULL); + actions_register("SendToDesktopDown", setup_send_down_func, g_free, run_func, + NULL, NULL); } -static gpointer setup_go_func(ObParseInst *i, xmlDocPtr doc, - xmlNodePtr node) +static gpointer setup_go_func(xmlNodePtr node) { 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_parse_find_node(node, "to"))) { + gchar *s = obt_parse_node_string(n); if (!g_ascii_strcasecmp(s, "last")) o->type = LAST; else if (!g_ascii_strcasecmp(s, "next")) { @@ -94,24 +141,23 @@ 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_parse_find_node(node, "wrap"))) + o->u.rel.wrap = obt_parse_node_bool(n); return o; } -static gpointer setup_send_func(ObParseInst *i, xmlDocPtr doc, - xmlNodePtr node) +static gpointer setup_send_func(xmlNodePtr node) { xmlNodePtr n; Options *o; - o = setup_go_func(i, doc, node); + o = setup_go_func(node); o->send = TRUE; o->follow = TRUE; - if ((n = parse_find_node("follow", node))) - o->follow = parse_bool(doc, n); + if ((n = obt_parse_find_node(node, "follow"))) + o->follow = obt_parse_node_bool(n); return o; } @@ -133,6 +179,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) { @@ -154,3 +202,150 @@ static gboolean run_func(ObActionsData *data, gpointer options) } return FALSE; } + +/* 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_parse_find_node(node, "follow"))) + o->follow = obt_parse_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_parse_find_node(node, "desktop"))) + o->u.abs.desktop = obt_parse_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_parse_find_node(node, "desktop"))) + o->u.abs.desktop = obt_parse_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) +{ + xmlNodePtr n; + + o->type = RELATIVE; + o->u.rel.linear = lin; + o->u.rel.dir = dir; + o->u.rel.wrap = TRUE; + + if ((n = obt_parse_find_node(node, "wrap"))) + o->u.rel.wrap = obt_parse_node_bool(n); +} + +static gpointer setup_go_next_func(xmlNodePtr node) +{ + Options *o = g_new0(Options, 1); + setup_rel(o, node, TRUE, OB_DIRECTION_EAST); + return o; +} + +static gpointer setup_send_next_func(xmlNodePtr node) +{ + Options *o = setup_follow(node); + setup_rel(o, node, TRUE, OB_DIRECTION_EAST); + return o; +} + +static gpointer setup_go_prev_func(xmlNodePtr node) +{ + Options *o = g_new0(Options, 1); + setup_rel(o, node, TRUE, OB_DIRECTION_WEST); + return o; +} + +static gpointer setup_send_prev_func(xmlNodePtr node) +{ + Options *o = setup_follow(node); + setup_rel(o, node, TRUE, OB_DIRECTION_WEST); + return o; +} + +static gpointer setup_go_left_func(xmlNodePtr node) +{ + Options *o = g_new0(Options, 1); + setup_rel(o, node, FALSE, OB_DIRECTION_WEST); + return o; +} + +static gpointer setup_send_left_func(xmlNodePtr node) +{ + Options *o = setup_follow(node); + setup_rel(o, node, FALSE, OB_DIRECTION_WEST); + return o; +} + +static gpointer setup_go_right_func(xmlNodePtr node) +{ + Options *o = g_new0(Options, 1); + setup_rel(o, node, FALSE, OB_DIRECTION_EAST); + return o; +} + +static gpointer setup_send_right_func(xmlNodePtr node) +{ + Options *o = setup_follow(node); + setup_rel(o, node, FALSE, OB_DIRECTION_EAST); + return o; +} + +static gpointer setup_go_up_func(xmlNodePtr node) +{ + Options *o = g_new0(Options, 1); + setup_rel(o, node, FALSE, OB_DIRECTION_NORTH); + return o; +} + +static gpointer setup_send_up_func(xmlNodePtr node) +{ + Options *o = setup_follow(node); + setup_rel(o, node, FALSE, OB_DIRECTION_NORTH); + return o; +} + +static gpointer setup_go_down_func(xmlNodePtr node) +{ + Options *o = g_new0(Options, 1); + setup_rel(o, node, FALSE, OB_DIRECTION_SOUTH); + return o; +} + +static gpointer setup_send_down_func(xmlNodePtr node) +{ + Options *o = setup_follow(node); + setup_rel(o, node, FALSE, OB_DIRECTION_SOUTH); + return o; +} diff --git a/openbox/actions/directionalwindows.c b/openbox/actions/directionalwindows.c index d9f24d61..acd4f8a2 100644 --- a/openbox/actions/directionalwindows.c +++ b/openbox/actions/directionalwindows.c @@ -20,11 +20,9 @@ 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); +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 +33,66 @@ 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); +static gpointer setup_south_cycle_func(xmlNodePtr node); +static gpointer setup_east_cycle_func(xmlNodePtr node); +static gpointer setup_west_cycle_func(xmlNodePtr node); +static gpointer setup_northwest_cycle_func(xmlNodePtr node); +static gpointer setup_northeast_cycle_func(xmlNodePtr node); +static gpointer setup_southwest_cycle_func(xmlNodePtr node); +static gpointer setup_southeast_cycle_func(xmlNodePtr node); +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("DirectionalTargetWindow", setup_target_func, free_func, run_func, NULL, NULL); + /* 3.4-compatibility */ + actions_register("DirectionalFocusNorth", setup_north_cycle_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalFocusSouth", setup_south_cycle_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalFocusWest", setup_west_cycle_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalFocusEast", setup_east_cycle_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalFocusNorthWest", setup_northwest_cycle_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalFocusNorthEast", setup_northeast_cycle_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalFocusSouthWest", setup_southwest_cycle_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalFocusSouthEast", setup_southeast_cycle_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalTargetNorth", setup_north_target_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalTargetSouth", setup_south_target_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalTargetWest", setup_west_target_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalTargetEast", setup_east_target_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalTargetNorthWest", setup_northwest_target_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalTargetNorthEast", setup_northeast_target_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalTargetSouthWest", setup_southwest_target_func, + free_func, run_func, i_input_func, i_cancel_func); + actions_register("DirectionalTargetSouthEast", setup_southeast_target_func, + free_func, run_func, i_input_func, i_cancel_func); } -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; @@ -52,18 +101,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_parse_find_node(node, "dialog"))) + o->dialog = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "bar"))) + o->bar = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "raise"))) + o->raise = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "panels"))) + o->dock_windows = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "desktop"))) + o->desktop_windows = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "direction"))) { + gchar *s = obt_parse_node_string(n); if (!g_ascii_strcasecmp(s, "north") || !g_ascii_strcasecmp(s, "up")) o->direction = OB_DIRECTION_NORTH; @@ -87,14 +136,14 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) g_free(s); } - if ((n = parse_find_node("finalactions", node))) { + if ((n = obt_parse_find_node(node, "finalactions"))) { xmlNodePtr m; - m = parse_find_node("action", n->xmlChildrenNode); + m = obt_parse_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_parse_find_node(m->next, "action"); } } else { @@ -109,18 +158,16 @@ 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) { - Options *o = setup_func(i, doc, node); + Options *o = setup_func(node); o->interactive = TRUE; 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 +267,117 @@ static void end_cycle(gboolean cancel, guint state, Options *o) stacking_restore(); } + +/* 3.4-compatibility */ +static gpointer setup_north_cycle_func(xmlNodePtr node) +{ + Options *o = setup_cycle_func(node); + o->direction = OB_DIRECTION_NORTH; + return o; +} + +static gpointer setup_south_cycle_func(xmlNodePtr node) +{ + Options *o = setup_cycle_func(node); + o->direction = OB_DIRECTION_SOUTH; + return o; +} + +static gpointer setup_east_cycle_func(xmlNodePtr node) +{ + Options *o = setup_cycle_func(node); + o->direction = OB_DIRECTION_EAST; + return o; +} + +static gpointer setup_west_cycle_func(xmlNodePtr node) +{ + Options *o = setup_cycle_func(node); + o->direction = OB_DIRECTION_WEST; + return o; +} + +static gpointer setup_northwest_cycle_func(xmlNodePtr node) +{ + Options *o = setup_cycle_func(node); + o->direction = OB_DIRECTION_NORTHWEST; + return o; +} + +static gpointer setup_northeast_cycle_func(xmlNodePtr node) +{ + Options *o = setup_cycle_func(node); + o->direction = OB_DIRECTION_EAST; + return o; +} + +static gpointer setup_southwest_cycle_func(xmlNodePtr node) +{ + Options *o = setup_cycle_func(node); + o->direction = OB_DIRECTION_SOUTHWEST; + return o; +} + +static gpointer setup_southeast_cycle_func(xmlNodePtr node) +{ + Options *o = setup_cycle_func(node); + 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/execute.c b/openbox/actions/execute.c index cb3ab247..4d29fc19 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, NULL, NULL); } -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_parse_find_node(node, "command")) || + (n = obt_parse_find_node(node, "execute"))) { - gchar *s = parse_string(doc, n); - o->cmd = parse_expand_tilde(s); + gchar *s = obt_parse_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_parse_find_node(node, "prompt"))) + o->prompt = obt_parse_node_string(n); - if ((n = parse_find_node("startupnotify", node))) { + if ((n = obt_parse_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_parse_find_node(n->children, "enabled"))) + o->sn = obt_parse_node_bool(m); + if ((m = obt_parse_find_node(n->children, "name"))) + o->sn_name = obt_parse_node_string(m); + if ((m = obt_parse_find_node(n->children, "icon"))) + o->sn_icon = obt_parse_node_string(m); + if ((m = obt_parse_find_node(n->children, "wmclass"))) + o->sn_wmclass = obt_parse_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..3bfebbce 100644 --- a/openbox/actions/exit.c +++ b/openbox/actions/exit.c @@ -8,7 +8,7 @@ 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) @@ -17,7 +17,7 @@ void action_exit_startup(void) actions_register("SessionLogout", setup_func, NULL, run_func, NULL, NULL); } -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_parse_find_node(node, "prompt"))) + o->prompt = obt_parse_node_bool(n); return o; } diff --git a/openbox/actions/focus.c b/openbox/actions/focus.c index 0ef9d268..4d0f220d 100644 --- a/openbox/actions/focus.c +++ b/openbox/actions/focus.c @@ -7,38 +7,26 @@ typedef struct { gboolean here; } 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, NULL, NULL); } -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("here", node))) - o->here = parse_bool(doc, n); + if ((n = obt_parse_find_node(node, "here"))) + o->here = obt_parse_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/growtoedge.c b/openbox/actions/growtoedge.c index 69b8ef77..2a31496a 100644 --- a/openbox/actions/growtoedge.c +++ b/openbox/actions/growtoedge.c @@ -7,31 +7,46 @@ 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, + actions_register("GrowToEdge", setup_func, + g_free, run_func, NULL, NULL); + actions_register("ShrinkToEdge", setup_shrink_func, + g_free, run_func, NULL, NULL); + /* 3.4-compatibility */ + actions_register("GrowToEdgeNorth", setup_north_func, g_free, run_func, + NULL, NULL); + actions_register("GrowToEdgeSouth", setup_south_func, g_free, run_func, + NULL, NULL); + actions_register("GrowToEdgeEast", setup_east_func, g_free, run_func, + NULL, NULL); + actions_register("GrowToEdgeWest", setup_west_func, g_free, run_func, NULL, NULL); } -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_parse_find_node(node, "direction"))) { + gchar *s = obt_parse_node_string(n); if (!g_ascii_strcasecmp(s, "north") || !g_ascii_strcasecmp(s, "up")) o->dir = OB_DIRECTION_NORTH; @@ -50,11 +65,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; + + o = setup_func(node); + o->shrink = TRUE; - g_free(o); + return o; } static gboolean do_grow(ObActionsData *data, gint x, gint y, gint w, gint h) @@ -98,11 +116,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 +163,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/if.c b/openbox/actions/if.c index 4c989664..833bdd3a 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, NULL, NULL); } -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_parse_find_node(node, "shaded"))) { + if (obt_parse_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_parse_find_node(node, "maximized"))) { + if (obt_parse_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_parse_find_node(node, "maximizedhorizontal"))) { + if (obt_parse_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_parse_find_node(node, "maximizedvertical"))) { + if (obt_parse_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_parse_find_node(node, "iconified"))) { + if (obt_parse_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_parse_find_node(node, "focused"))) { + if (obt_parse_node_bool(n)) o->focused = TRUE; else o->unfocused = TRUE; } - if ((n = parse_find_node("then", node))) { + if ((n = obt_parse_find_node(node, "then"))) { xmlNodePtr m; - m = parse_find_node("action", n->xmlChildrenNode); + m = obt_parse_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_parse_find_node(m->next, "action"); } } - if ((n = parse_find_node("else", node))) { + if ((n = obt_parse_find_node(node, "else"))) { xmlNodePtr m; - m = parse_find_node("action", n->xmlChildrenNode); + m = obt_parse_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_parse_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/layer.c b/openbox/actions/layer.c index 92fa4806..1d522bbc 100644 --- a/openbox/actions/layer.c +++ b/openbox/actions/layer.c @@ -6,12 +6,14 @@ 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) { @@ -21,9 +23,16 @@ void action_layer_startup(void) run_func, NULL, NULL); actions_register("SendToLayer", setup_func_send, g_free, run_func, NULL, NULL); + /* 3.4-compatibility */ + actions_register("SendToTopLayer", setup_sendtop_func, g_free, + run_func, NULL, NULL); + actions_register("SendToBottomLayer", setup_sendbottom_func, g_free, + run_func, NULL, NULL); + actions_register("SendToNormalLayer", setup_sendnormal_func, g_free, + run_func, NULL, NULL); } -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_parse_find_node(node, "layer"))) { + gchar *s = obt_parse_node_string(n); if (!g_ascii_strcasecmp(s, "above") || !g_ascii_strcasecmp(s, "top")) o->layer = 1; @@ -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/maximize.c b/openbox/actions/maximize.c index bb6f470a..5cc7141b 100644 --- a/openbox/actions/maximize.c +++ b/openbox/actions/maximize.c @@ -12,10 +12,14 @@ 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) { @@ -25,9 +29,28 @@ void action_maximize_startup(void) NULL, NULL); actions_register("ToggleMaximize", setup_func, g_free, run_func_toggle, NULL, NULL); + /* 3.4-compatibility */ + actions_register("MaximizeFull", setup_both_func, g_free, + run_func_on, NULL, NULL); + actions_register("UnmaximizeFull", setup_both_func, g_free, + run_func_off, NULL, NULL); + actions_register("ToggleMaximizeFull", setup_both_func, g_free, + run_func_toggle, NULL, NULL); + actions_register("MaximizeHorz", setup_horz_func, g_free, + run_func_on, NULL, NULL); + actions_register("UnmaximizeHorz", setup_horz_func, g_free, + run_func_off, NULL, NULL); + actions_register("ToggleMaximizeHorz", setup_horz_func, g_free, + run_func_toggle, NULL, NULL); + actions_register("MaximizeVert", setup_vert_func, g_free, + run_func_on, NULL, NULL); + actions_register("UnmaximizeVert", setup_vert_func, g_free, + run_func_off, NULL, NULL); + actions_register("ToggleMaximizeVert", setup_vert_func, g_free, + run_func_toggle, NULL, NULL); } -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; @@ -35,8 +58,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_parse_find_node(node, "direction"))) { + gchar *s = obt_parse_node_string(n); if (!g_ascii_strcasecmp(s, "vertical") || !g_ascii_strcasecmp(s, "vert")) o->dir = VERT; @@ -89,3 +112,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..ddd3f59a 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); @@ -19,8 +19,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..4e6e5998 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, NULL, NULL); } -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_parse_find_node(node, "x"))) + o->x = obt_parse_node_int(n); + if ((n = obt_parse_find_node(node, "y"))) + o->y = obt_parse_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..fc171fcc 100644 --- a/openbox/actions/moveresizeto.c +++ b/openbox/actions/moveresizeto.c @@ -23,23 +23,23 @@ 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, + actions_register("MoveResizeTo", setup_func, g_free, run_func, NULL, NULL); +/* 3.4-compatibility */ + actions_register("MoveToCenter", setup_center_func, g_free, run_func, NULL, NULL); } -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_parse_node_string(n); if (g_ascii_strcasecmp(s, "current") != 0) { if (!g_ascii_strcasecmp(s, "center")) *center = TRUE; @@ -55,7 +55,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 +67,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_parse_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_parse_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_parse_find_node(node, "width"))) { + gchar *s = obt_parse_node_string(n); if (g_ascii_strcasecmp(s, "current") != 0) - o->w = parse_int(doc, n); + o->w = obt_parse_node_int(n); g_free(s); } - if ((n = parse_find_node("height", node))) { - gchar *s = parse_string(doc, n); + if ((n = obt_parse_find_node(node, "height"))) { + gchar *s = obt_parse_node_string(n); if (g_ascii_strcasecmp(s, "current") != 0) - o->h = parse_int(doc, n); + o->h = obt_parse_node_int(n); g_free(s); } - if ((n = parse_find_node("monitor", node))) { - gchar *s = parse_string(doc, n); + if ((n = obt_parse_find_node(node, "monitor"))) { + gchar *s = obt_parse_node_string(n); if (g_ascii_strcasecmp(s, "current") != 0) { if (!g_ascii_strcasecmp(s, "all")) o->monitor = ALL_MONITORS; @@ -96,7 +96,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_parse_node_int(n) - 1; } g_free(s); } @@ -104,13 +104,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 +181,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..51215fd2 100644 --- a/openbox/actions/movetoedge.c +++ b/openbox/actions/movetoedge.c @@ -9,20 +9,29 @@ 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, + actions_register("MoveToEdge", setup_func, g_free, run_func, NULL, NULL); + /* 3.4-compatibility */ + actions_register("MoveToEdgeNorth", setup_north_func, g_free, run_func, + NULL, NULL); + actions_register("MoveToEdgeSouth", setup_south_func, g_free, run_func, + NULL, NULL); + actions_register("MoveToEdgeEast", setup_east_func, g_free, run_func, + NULL, NULL); + actions_register("MoveToEdgeWest", setup_west_func, g_free, run_func, NULL, NULL); } -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; @@ -30,8 +39,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_parse_find_node(node, "direction"))) { + gchar *s = obt_parse_node_string(n); if (!g_ascii_strcasecmp(s, "north") || !g_ascii_strcasecmp(s, "up")) o->dir = OB_DIRECTION_NORTH; @@ -50,13 +59,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 +77,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/resize.c b/openbox/actions/resize.c index 3714e38b..47f45f5b 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, NULL, NULL); } -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_parse_find_node(node, "edge"))) { + gchar *s = obt_parse_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..5742e1fc 100644 --- a/openbox/actions/resizerelative.c +++ b/openbox/actions/resizerelative.c @@ -11,47 +11,36 @@ 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, + actions_register("ResizeRelative", setup_func, g_free, run_func, NULL, NULL); } -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_parse_find_node(node, "left"))) + o->left = obt_parse_node_int(n); + if ((n = obt_parse_find_node(node, "right"))) + o->right = obt_parse_node_int(n); + if ((n = obt_parse_find_node(node, "top")) || + (n = obt_parse_find_node(node, "up"))) + o->top = obt_parse_node_int(n); + if ((n = obt_parse_find_node(node, "bottom")) || + (n = obt_parse_find_node(node, "down"))) + o->bottom = obt_parse_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..47f332b1 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, NULL, NULL); } -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_parse_find_node(node, "command")) || + (n = obt_parse_find_node(node, "execute"))) { - gchar *s = parse_string(doc, n); - o->cmd = parse_expand_tilde(s); + gchar *s = obt_parse_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/shadelowerraise.c b/openbox/actions/shadelowerraise.c new file mode 100644 index 00000000..1070a965 --- /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, NULL, NULL); + actions_register("UnshadeRaise", NULL, NULL, run_func_ur, NULL, NULL); +} + +/* 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/showmenu.c b/openbox/actions/showmenu.c index c1d53e41..9590bd15 100644 --- a/openbox/actions/showmenu.c +++ b/openbox/actions/showmenu.c @@ -6,7 +6,7 @@ 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); @@ -16,15 +16,15 @@ void action_showmenu_startup(void) NULL, NULL); } -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_parse_find_node(node, "menu"))) + o->name = obt_parse_node_string(n); return o; } |
