summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-09-01 02:02:40 +0000
committerDana Jansens <danakj@orodu.net>2003-09-01 02:02:40 +0000
commit9d42df6ab4099c9365d3631ea86348a8f21752a0 (patch)
tree23137c07f0db03e7904475b6b1c2d26e3df1bb84 /openbox
parenta1fdeedbf20de74df8cf438f702a7a3e0de03064 (diff)
add urgent actions
add some macros for moving/resizing clients add 'vibrate' action
Diffstat (limited to 'openbox')
-rw-r--r--openbox/action.c56
-rw-r--r--openbox/action.h2
-rw-r--r--openbox/client.c32
-rw-r--r--openbox/client.h10
-rw-r--r--openbox/config.c31
-rw-r--r--openbox/config.h3
-rw-r--r--openbox/moveresize.c11
7 files changed, 110 insertions, 35 deletions
diff --git a/openbox/action.c b/openbox/action.c
index 6a81f792..6e750d6f 100644
--- a/openbox/action.c
+++ b/openbox/action.c
@@ -700,6 +700,11 @@ ActionString actionstrings[] =
setup_action_growtoedge_east
},
{
+ "vibrate",
+ action_vibrate,
+ NULL
+ },
+ {
NULL,
NULL,
NULL
@@ -917,38 +922,31 @@ void action_move_relative_horz(union ActionData *data)
{
ObClient *c = data->relative.any.c;
if (c)
- client_configure(c, OB_CORNER_TOPLEFT,
- c->area.x + data->relative.delta, c->area.y,
- c->area.width, c->area.height, TRUE, TRUE);
+ client_move(c, c->area.x + data->relative.delta, c->area.y);
}
void action_move_relative_vert(union ActionData *data)
{
ObClient *c = data->relative.any.c;
if (c)
- client_configure(c, OB_CORNER_TOPLEFT,
- c->area.x, c->area.y + data->relative.delta,
- c->area.width, c->area.height, TRUE, TRUE);
+ client_move(c, c->area.x, c->area.y + data->relative.delta);
}
void action_resize_relative_horz(union ActionData *data)
{
ObClient *c = data->relative.any.c;
if (c)
- client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
- c->area.width +
- data->relative.delta * c->size_inc.width,
- c->area.height, TRUE, TRUE);
+ client_resize(c,
+ c->area.width + data->relative.delta * c->size_inc.width,
+ c->area.height);
}
void action_resize_relative_vert(union ActionData *data)
{
ObClient *c = data->relative.any.c;
if (c && !c->shaded)
- client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y,
- c->area.width, c->area.height +
- data->relative.delta * c->size_inc.height,
- TRUE, TRUE);
+ client_resize(c, c->area.width, c->area.height +
+ data->relative.delta * c->size_inc.height);
}
void action_maximize_full(union ActionData *data)
@@ -1147,8 +1145,7 @@ void action_movetoedge(union ActionData *data)
g_assert_not_reached();
}
frame_frame_gravity(c->frame, &x, &y);
- client_configure(c, OB_CORNER_TOPLEFT,
- x, y, c->area.width, c->area.height, TRUE, TRUE);
+ client_move(c, x, y);
}
@@ -1211,7 +1208,7 @@ void action_growtoedge(union ActionData *data)
frame_frame_gravity(c->frame, &x, &y);
width -= c->frame->size.left + c->frame->size.right;
height -= c->frame->size.top + c->frame->size.bottom;
- client_configure(c, OB_CORNER_TOPLEFT, x, y, width, height, TRUE, TRUE);
+ client_move(c, x, y);
}
void action_send_to_layer(union ActionData *data)
@@ -1246,3 +1243,28 @@ void action_unshow_desktop(union ActionData *data)
{
screen_show_desktop(FALSE);
}
+
+void action_vibrate(union ActionData *data)
+{
+ ObClient *c = data->client.any.c;
+ gint x, y, thr, length, i;
+
+ if (!c) return;
+
+ x = c->frame->area.x;
+ y = c->frame->area.y;
+ thr = 120;
+ length = y + thr;
+ for (i = 0; i < 5; ++i) {
+ while (y < length) {
+ client_move(c, x, y);
+ y += 4;
+ x -= 1;
+ }
+ while (y >= length - thr) {
+ client_move(c, x, y);
+ y -= 4;
+ x += 1;
+ }
+ }
+}
diff --git a/openbox/action.h b/openbox/action.h
index 3f6d84eb..db618b36 100644
--- a/openbox/action.h
+++ b/openbox/action.h
@@ -244,5 +244,7 @@ void action_toggle_show_desktop(union ActionData *data);
void action_show_desktop(union ActionData *data);
/* Any */
void action_unshow_desktop(union ActionData *data);
+/* Client */
+void action_vibrate(union ActionData *data);
#endif
diff --git a/openbox/client.c b/openbox/client.c
index 70b13c7e..c7c9a548 100644
--- a/openbox/client.c
+++ b/openbox/client.c
@@ -49,6 +49,7 @@ static void client_change_state(ObClient *self);
static void client_apply_startup_state(ObClient *self);
static void client_restore_session_state(ObClient *self);
static void client_restore_session_stacking(ObClient *self);
+static void client_act_urgent(ObClient *self);
void client_startup()
{
@@ -330,9 +331,7 @@ void client_manage(Window window)
client_normal(self));
if (x != ox || y != oy)
- client_configure(self, OB_CORNER_TOPLEFT, x, y,
- self->area.width, self->area.height,
- TRUE, TRUE);
+ client_move(self, x, y);
}
client_showhide(self);
@@ -483,6 +482,18 @@ void client_unmanage(ObClient *self)
client_set_list();
}
+static void client_act_urgent(ObClient *self)
+{
+ GSList *it;
+
+ for (it = config_urgent_actions; it; it = g_slist_next(it)) {
+ ObAction *a = it->data;
+
+ a->data.any.c = self;
+ a->func(&a->data);
+ }
+}
+
static void client_restore_session_state(ObClient *self)
{
GList *it;
@@ -543,9 +554,7 @@ void client_move_onscreen(ObClient *self, gboolean rude)
if (client_find_onscreen(self, &x, &y,
self->frame->area.width,
self->frame->area.height, rude)) {
- client_configure(self, OB_CORNER_TOPLEFT, x, y,
- self->area.width, self->area.height,
- TRUE, TRUE);
+ client_move(self, x, y);
}
}
@@ -1296,9 +1305,8 @@ void client_update_wmhints(ObClient *self)
ur ? "ON" : "OFF");
/* fire the urgent callback if we're mapped, otherwise, wait until
after we're mapped */
- if (self->frame) {
- /* XXX do shit */
- }
+ if (self->frame && self->urgent)
+ client_act_urgent(self);
}
}
@@ -1722,7 +1730,7 @@ static void client_apply_startup_state(ObClient *self)
client_shade(self, TRUE);
}
if (self->urgent)
- /* XXX do shit */;
+ client_act_urgent(self);
if (self->max_vert && self->max_horz) {
self->max_vert = self->max_horz = FALSE;
@@ -2021,7 +2029,7 @@ void client_fullscreen(ObClient *self, gboolean fs, gboolean savearea)
client_setup_decor_and_functions(self);
- client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
+ client_move_resize(self, x, y, w, h);
/* try focus us when we go into fullscreen mode */
client_focus(self);
@@ -2197,7 +2205,7 @@ void client_maximize(ObClient *self, gboolean max, int dir, gboolean savearea)
/* figure out where the client should be going */
frame_frame_gravity(self->frame, &x, &y);
- client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
+ client_move_resize(self, x, y, w, h);
}
void client_shade(ObClient *self, gboolean shade)
diff --git a/openbox/client.h b/openbox/client.h
index 758851e1..b28acab2 100644
--- a/openbox/client.h
+++ b/openbox/client.h
@@ -273,6 +273,16 @@ gboolean client_normal(ObClient *self);
/* Returns if the window is focused */
gboolean client_focused(ObClient *self);
+#define client_move(self, x, y) \
+ client_configure(self, OB_CORNER_TOPLEFT, x, y, \
+ self->area.width, self->area.height, \
+ TRUE, TRUE)
+#define client_resize(self, w, h) \
+ client_configure(self, OB_CORNER_TOPLEFT, self->area.x, self->area.y, \
+ w, h, TRUE, TRUE)
+#define client_move_resize(self, x, y, w, h) \
+ client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE)
+
#define client_configure(self, anchor, x, y, w, h, user, final) \
client_configure_full(self, anchor, x, y, w, h, user, final, FALSE)
diff --git a/openbox/config.c b/openbox/config.c
index 21f03d3e..20950603 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -40,6 +40,8 @@ GSList *config_menu_files;
gint config_resist_win;
gint config_resist_edge;
+GSList *config_urgent_actions;
+
/*
<keybind key="C-x">
@@ -352,6 +354,33 @@ static void parse_resistance(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
config_resist_edge = parse_int(doc, n);
}
+static void parse_urgent(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
+ void *d)
+{
+ ObAction *action;
+ xmlNodePtr nact;
+
+ nact = parse_find_node("action", node->xmlChildrenNode);
+ while (nact) {
+ if ((action = action_parse(i, doc, nact))) {
+ /* validate that its okay for an urgent binding */
+ if (action->func == action_moveresize &&
+ action->data.moveresize.corner !=
+ prop_atoms.net_wm_moveresize_move_keyboard &&
+ action->data.moveresize.corner !=
+ prop_atoms.net_wm_moveresize_size_keyboard) {
+ action_free(action);
+ action = NULL;
+ }
+
+ if (action)
+ config_urgent_actions = g_slist_append(config_urgent_actions,
+ action);
+ }
+ nact = parse_find_node("action", nact->next);
+ }
+}
+
void config_startup(ObParseInst *i)
{
config_focus_new = TRUE;
@@ -405,6 +434,8 @@ void config_startup(ObParseInst *i)
config_menu_files = NULL;
parse_register(i, "menu", parse_menu, NULL);
+
+ parse_register(i, "urgent", parse_urgent, NULL);
}
void config_shutdown()
diff --git a/openbox/config.h b/openbox/config.h
index 02ee2457..ea9b5f61 100644
--- a/openbox/config.h
+++ b/openbox/config.h
@@ -71,6 +71,9 @@ extern gint config_resist_edge;
/*! User-specified menu files */
extern GSList *config_menu_files;
+/*! Actions to execute when a client sets its urgent flag */
+extern GSList *config_urgent_actions;
+
void config_startup(struct _ObParseInst *i);
void config_shutdown();
diff --git a/openbox/moveresize.c b/openbox/moveresize.c
index 8f92f71f..424b8a14 100644
--- a/openbox/moveresize.c
+++ b/openbox/moveresize.c
@@ -7,6 +7,7 @@
#include "openbox.h"
#include "resist.h"
#include "popup.h"
+#include "moveresize.h"
#include "config.h"
#include "render/render.h"
#include "render/theme.h"
@@ -143,10 +144,9 @@ void moveresize_end(gboolean cancel)
popup_hide(popup);
if (moving) {
- client_configure(moveresize_client, OB_CORNER_TOPLEFT,
- (cancel ? start_cx : cur_x),
- (cancel ? start_cy : cur_y),
- start_cw, start_ch, TRUE, TRUE);
+ client_move(moveresize_client,
+ (cancel ? start_cx : cur_x),
+ (cancel ? start_cy : cur_y));
} else {
client_configure(moveresize_client, lockcorner,
moveresize_client->area.x,
@@ -168,8 +168,7 @@ static void do_move(gboolean resist)
/* get where the client should be */
frame_frame_gravity(moveresize_client->frame, &cur_x, &cur_y);
- client_configure(moveresize_client, OB_CORNER_TOPLEFT, cur_x, cur_y,
- start_cw, start_ch, TRUE, FALSE);
+ client_move(moveresize_client, cur_x, cur_y);
/* this would be better with a fixed width font ... XXX can do it better
if there are 2 text boxes */