1 #include "openbox/actions.h"
2 #include "openbox/client.h"
4 /* These match the values for client_maximize */
15 static gpointer
setup_func(xmlNodePtr node
);
16 static void free_func(gpointer o
);
17 static gboolean
run_func_on(ObActionsData
*data
, gpointer options
);
18 static gboolean
run_func_off(ObActionsData
*data
, gpointer options
);
19 static gboolean
run_func_toggle(ObActionsData
*data
, gpointer options
);
20 /* 3.4-compatibility */
21 static gpointer
setup_both_func(xmlNodePtr node
);
22 static gpointer
setup_horz_func(xmlNodePtr node
);
23 static gpointer
setup_vert_func(xmlNodePtr node
);
25 void action_maximize_startup(void)
27 actions_register("Maximize", setup_func
, free_func
, run_func_on
);
28 actions_register("Unmaximize", setup_func
, free_func
, run_func_off
);
29 actions_register("ToggleMaximize", setup_func
, free_func
, run_func_toggle
);
30 /* 3.4-compatibility */
31 actions_register("MaximizeFull", setup_both_func
, free_func
,
33 actions_register("UnmaximizeFull", setup_both_func
, free_func
,
35 actions_register("ToggleMaximizeFull", setup_both_func
, free_func
,
37 actions_register("MaximizeHorz", setup_horz_func
, free_func
,
39 actions_register("UnmaximizeHorz", setup_horz_func
, free_func
,
41 actions_register("ToggleMaximizeHorz", setup_horz_func
, free_func
,
43 actions_register("MaximizeVert", setup_vert_func
, free_func
,
45 actions_register("UnmaximizeVert", setup_vert_func
, free_func
,
47 actions_register("ToggleMaximizeVert", setup_vert_func
, free_func
,
51 static gpointer
setup_func(xmlNodePtr node
)
56 o
= g_slice_new0(Options
);
59 if ((n
= obt_xml_find_node(node
, "direction"))) {
60 gchar
*s
= obt_xml_node_string(n
);
61 if (!g_ascii_strcasecmp(s
, "vertical") ||
62 !g_ascii_strcasecmp(s
, "vert"))
64 else if (!g_ascii_strcasecmp(s
, "horizontal") ||
65 !g_ascii_strcasecmp(s
, "horz"))
73 static void free_func(gpointer o
)
75 g_slice_free(Options
, o
);
78 /* Always return FALSE because its not interactive */
79 static gboolean
run_func_on(ObActionsData
*data
, gpointer options
)
83 actions_client_move(data
, TRUE
);
84 client_maximize(data
->client
, TRUE
, o
->dir
);
85 actions_client_move(data
, FALSE
);
90 /* Always return FALSE because its not interactive */
91 static gboolean
run_func_off(ObActionsData
*data
, gpointer options
)
95 actions_client_move(data
, TRUE
);
96 client_maximize(data
->client
, FALSE
, o
->dir
);
97 actions_client_move(data
, FALSE
);
102 /* Always return FALSE because its not interactive */
103 static gboolean
run_func_toggle(ObActionsData
*data
, gpointer options
)
105 Options
*o
= options
;
108 actions_client_move(data
, TRUE
);
109 toggle
= ((o
->dir
== HORZ
&& !data
->client
->max_horz
) ||
110 (o
->dir
== VERT
&& !data
->client
->max_vert
) ||
112 !(data
->client
->max_horz
&& data
->client
->max_vert
)));
113 client_maximize(data
->client
, toggle
, o
->dir
);
114 actions_client_move(data
, FALSE
);
119 /* 3.4-compatibility */
120 static gpointer
setup_both_func(xmlNodePtr node
)
122 Options
*o
= g_slice_new0(Options
);
127 static gpointer
setup_horz_func(xmlNodePtr node
)
129 Options
*o
= g_slice_new0(Options
);
134 static gpointer
setup_vert_func(xmlNodePtr node
)
136 Options
*o
= g_slice_new0(Options
);