all repos — openbox @ 9d42df6ab4099c9365d3631ea86348a8f21752a0

openbox fork - make it a bit more like ryudo

add urgent actions
add some macros for moving/resizing clients
add 'vibrate' action
Dana Jansens danakj@orodu.net
commit

9d42df6ab4099c9365d3631ea86348a8f21752a0

parent

a1fdeedbf20de74df8cf438f702a7a3e0de03064

M openbox/action.copenbox/action.c

@@ -700,6 +700,11 @@ action_growtoedge,

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 @@ default:

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 @@ }

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; + } + } +}
M openbox/action.hopenbox/action.h

@@ -244,5 +244,7 @@ /* Any */

void action_show_desktop(union ActionData *data); /* Any */ void action_unshow_desktop(union ActionData *data); +/* Client */ +void action_vibrate(union ActionData *data); #endif
M openbox/client.copenbox/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 @@ self->frame->area.height,

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 @@ /* update the list hints */

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 @@ int y = self->area.y;

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 @@ ob_debug("Urgent Hint for 0x%lx: %s\n", self->window,

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 @@ self->shaded = FALSE;

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 @@ }

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 @@ client_setup_decor_and_functions(self);

/* 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)
M openbox/client.hopenbox/client.h

@@ -273,6 +273,16 @@

/* 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)
M openbox/config.copenbox/config.c

@@ -40,6 +40,8 @@

gint config_resist_win; gint config_resist_edge; +GSList *config_urgent_actions; + /* <keybind key="C-x">

@@ -352,6 +354,33 @@ if ((n = parse_find_node("screen_edge_strength", 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 @@

config_menu_files = NULL; parse_register(i, "menu", parse_menu, NULL); + + parse_register(i, "urgent", parse_urgent, NULL); } void config_shutdown()
M openbox/config.hopenbox/config.h

@@ -71,6 +71,9 @@

/*! 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();
M openbox/moveresize.copenbox/moveresize.c

@@ -7,6 +7,7 @@ #include "frame.h"

#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 @@

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 @@ resist_move(moveresize_client, &cur_x, &cur_y);

/* 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 */