all repos — openbox @ 1e6c375fdd1d10ba0b019505436069d21c751945

openbox fork - make it a bit more like ryudo

add the moveto action
Dana Jansens danakj@orodu.net
commit

1e6c375fdd1d10ba0b019505436069d21c751945

parent

06ed8ab6c03337710acba8d6a70781456e979384

M Makefile.amMakefile.am

@@ -168,6 +168,7 @@ openbox/actions/iconify.c \

openbox/actions/lower.c \ openbox/actions/maximize.c \ openbox/actions/move.c \ + openbox/actions/moveto.c \ openbox/actions/raise.c \ openbox/actions/raiselower.c \ openbox/actions/reconfigure.c \
M openbox/action.copenbox/action.c

@@ -500,11 +500,6 @@ action_move_relative_vert,

setup_client_action }, { - "movetocenter", - action_move_to_center, - setup_client_action - }, - { "resizerelativehorz", action_resize_relative_horz, setup_client_action

@@ -522,36 +517,6 @@ },

{ "resizerelative", action_resize_relative, - setup_client_action - }, - { - "maximizehorz", - action_maximize_horz, - setup_client_action - }, - { - "unmaximizehorz", - action_unmaximize_horz, - setup_client_action - }, - { - "togglemaximizehorz", - action_toggle_maximize_horz, - setup_client_action - }, - { - "maximizevert", - action_maximize_vert, - setup_client_action - }, - { - "unmaximizevert", - action_unmaximize_vert, - setup_client_action - }, - { - "togglemaximizevert", - action_toggle_maximize_vert, setup_client_action }, {

@@ -1055,18 +1020,6 @@ client_move(c, c->area.x, c->area.y + data->relative.deltax);

client_action_end(data, FALSE); } -void action_move_to_center(union ActionData *data) -{ - ObClient *c = data->client.any.c; - Rect *area; - area = screen_area(c->desktop, client_monitor(c), NULL); - client_action_start(data); - client_move(c, area->x + area->width / 2 - c->area.width / 2, - area->y + area->height / 2 - c->area.height / 2); - client_action_end(data, FALSE); - g_free(area); -} - void action_resize_relative_horz(union ActionData *data) { ObClient *c = data->relative.any.c;

@@ -1125,14 +1078,6 @@ xoff = xoff == 0 ? 0 : (xoff < 0 ? MAX(xoff, ow-nw) : MIN(xoff, ow-nw));

yoff = yoff == 0 ? 0 : (yoff < 0 ? MAX(yoff, oh-nh) : MIN(yoff, oh-nh)); client_move_resize(c, x + xoff, y + yoff, nw, nh); client_action_end(data, FALSE); -} - -void action_toggle_maximize_vert(union ActionData *data) -{ - client_action_start(data); - client_maximize(data->client.any.c, - !data->client.any.c->max_vert, 2); - client_action_end(data, config_focus_under_mouse); } void action_send_to_desktop(union ActionData *data)
M openbox/actions/all.copenbox/actions/all.c

@@ -21,4 +21,5 @@ action_unfocus_startup();

action_iconify_startup(); action_fullscreen_startup(); action_maximize_startup(); + action_moveto_startup(); }
M openbox/actions/all.hopenbox/actions/all.h

@@ -22,5 +22,6 @@ void action_unfocus_startup();

void action_iconify_startup(); void action_fullscreen_startup(); void action_maximize_startup(); +void action_moveto_startup(); #endif
A openbox/actions/moveto.c

@@ -0,0 +1,111 @@

+#include "openbox/actions.h" +#include "openbox/client.h" +#include "openbox/screen.h" +#include "openbox/frame.h" +#include <stdlib.h> /* for atoi */ + +typedef struct { + gboolean xcenter; + gboolean ycenter; + gint x; + gint y; + gint monitor; +} Options; + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); +static void free_func(gpointer options); +static gboolean run_func(ObActionsData *data, gpointer options); + +void action_moveto_startup() +{ + actions_register("MoveTo", + setup_func, + free_func, + run_func, + NULL, NULL); +} + +static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) +{ + xmlNodePtr n; + Options *o; + + o = g_new0(Options, 1); + o->x = G_MININT; + o->y = G_MININT; + o->monitor = -1; + + if ((n = parse_find_node("x", node))) { + gchar *s = parse_string(doc, n); + if (!g_ascii_strcasecmp(s, "center")) + o->xcenter = TRUE; + else + o->x = atoi(s); + g_free(s); + } + + if ((n = parse_find_node("y", node))) { + gchar *s = parse_string(doc, n); + if (!g_ascii_strcasecmp(s, "center")) + o->ycenter = TRUE; + else + o->y = atoi(s); + g_free(s); + } + + if ((n = parse_find_node("monitor", node))) + o->monitor = parse_int(doc, n) - 1; + + 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) +{ + Options *o = options; + + if (data->client) { + Rect *area, *carea; + ObClient *c; + gint mon, cmon; + gint x, y, lw, lh, w, h; + + c = data->client; + mon = o->monitor; + cmon = client_monitor(c); + if (mon < 0) mon = cmon; + area = screen_area(c->desktop, mon, NULL); + carea = screen_area(c->desktop, cmon, NULL); + x = o->x; + if (x == G_MININT) x = c->frame->area.x - carea->x; + if (o->xcenter) x = (area->width - c->frame->area.width) / 2; + x += area->x; + y = o->y; + if (y == G_MININT) y = c->frame->area.y - carea->y; + if (o->ycenter) y = (area->height - c->frame->area.height) / 2; + y += area->y; + w = c->area.width; + h = c->area.height; + + frame_frame_gravity(c->frame, &x, &y); /* get the client coords */ + client_try_configure(c, &x, &y, &w, &h, &lw, &lh, TRUE); + /* force it on screen if its moving to another monitor */ + client_find_onscreen(c, &x, &y, w, h, mon != cmon); + + actions_client_move(data, TRUE); + client_configure(c, x, y, w, h, TRUE, TRUE, FALSE); + actions_client_move(data, FALSE); + + g_free(area); + g_free(carea); + } + + return FALSE; +}
M openbox/client.copenbox/client.c

@@ -933,7 +933,7 @@ RECT_SET(desired, *x, *y, w, h);

frame_rect_to_frame(self->frame, &desired); /* get where the frame would be */ - frame_client_gravity(self->frame, x, y, w, h); + frame_client_gravity(self->frame, x, y); /* get the requested size of the window with decorations */ fw = self->frame->size.left + w + self->frame->size.right;

@@ -1021,7 +1021,7 @@ g_free(a);

} /* get where the client should be */ - frame_frame_gravity(self->frame, x, y, w, h); + frame_frame_gravity(self->frame, x, y); return ox != *x || oy != *y; }

@@ -2702,7 +2702,7 @@ the updated frame dimensions. */

frame_adjust_area(self->frame, FALSE, TRUE, TRUE); /* gets the frame's position */ - frame_client_gravity(self->frame, x, y, *w, *h); + frame_client_gravity(self->frame, x, y); /* these positions are frame positions, not client positions */

@@ -2749,7 +2749,7 @@ g_free(a);

} /* gets the client's position */ - frame_frame_gravity(self->frame, x, y, *w, *h); + frame_frame_gravity(self->frame, x, y); /* work within the prefered sizes given by the window */ if (!(*w == self->area.width && *h == self->area.height)) {
M openbox/frame.copenbox/frame.c

@@ -755,9 +755,7 @@ /* find the new coordinates, done after setting the frame.size, for

frame_client_gravity. */ self->area.x = self->client->area.x; self->area.y = self->client->area.y; - frame_client_gravity(self, &self->area.x, &self->area.y, - self->client->area.width, - self->client->area.height); + frame_client_gravity(self, &self->area.x, &self->area.y); } if (!fake) {

@@ -1404,7 +1402,7 @@

return OB_FRAME_CONTEXT_NONE; } -void frame_client_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h) +void frame_client_gravity(ObFrame *self, gint *x, gint *y) { /* horizontal */ switch (self->client->gravity) {

@@ -1467,7 +1465,7 @@ break;

} } -void frame_frame_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h) +void frame_frame_gravity(ObFrame *self, gint *x, gint *y) { /* horizontal */ switch (self->client->gravity) {

@@ -1528,7 +1526,7 @@ void frame_rect_to_frame(ObFrame *self, Rect *r)

{ r->width += self->size.left + self->size.right; r->height += self->size.top + self->size.bottom; - frame_client_gravity(self, &r->x, &r->y, r->width, r->height); + frame_client_gravity(self, &r->x, &r->y); } static void flash_done(gpointer data)
M openbox/frame.hopenbox/frame.h

@@ -228,13 +228,13 @@ /*! Applies gravity to the client's position to find where the frame should

be positioned. @return The proper coordinates for the frame, based on the client. */ -void frame_client_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h); +void frame_client_gravity(ObFrame *self, gint *x, gint *y); /*! Reversly applies gravity to the frame's position to find where the client should be positioned. @return The proper coordinates for the client, based on the frame. */ -void frame_frame_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h); +void frame_frame_gravity(ObFrame *self, gint *x, gint *y); /*! Convert a rectangle in client coordinates/sizes to what it would be for the frame, given its current decorations sizes */
M openbox/moveresize.copenbox/moveresize.c

@@ -105,7 +105,7 @@

/* see how much it is actually going to resize */ { gint cx = *x, cy = *y; - frame_frame_gravity(moveresize_client->frame, &cx, &cy, w, h); + frame_frame_gravity(moveresize_client->frame, &cx, &cy); client_try_configure(moveresize_client, &cx, &cy, &w, &h, &lw, &lh, TRUE); }

@@ -127,7 +127,7 @@ *y -= dh;

break; } - frame_frame_gravity(moveresize_client->frame, x, y, w, h); + frame_frame_gravity(moveresize_client->frame, x, y); } static void popup_coords(ObClient *c, const gchar *format, gint a, gint b)
M openbox/place.copenbox/place.c

@@ -486,7 +486,6 @@ place_random(client, x, y);

g_assert(ret); /* get where the client should be */ - frame_frame_gravity(client->frame, x, y, - client->area.width, client->area.height); + frame_frame_gravity(client->frame, x, y); return ret; }
M openbox/resist.copenbox/resist.c

@@ -36,7 +36,7 @@ ObClient *snapx = NULL, *snapy = NULL;

if (!resist) return; - frame_client_gravity(c->frame, x, y, c->area.width, c->area.height); + frame_client_gravity(c->frame, x, y); w = c->frame->area.width; h = c->frame->area.height;

@@ -113,7 +113,7 @@

if (snapx && snapy) break; } - frame_frame_gravity(c->frame, x, y, c->area.width, c->area.height); + frame_frame_gravity(c->frame, x, y); } void resist_move_monitors(ObClient *c, gint resist, gint *x, gint *y)

@@ -129,7 +129,7 @@ Rect desired_area;

if (!resist) return; - frame_client_gravity(c->frame, x, y, c->area.width, c->area.height); + frame_client_gravity(c->frame, x, y); w = c->frame->area.width; h = c->frame->area.height;

@@ -188,7 +188,7 @@ g_free(area);

g_free(parea); } - frame_frame_gravity(c->frame, x, y, c->area.width, c->area.height); + frame_frame_gravity(c->frame, x, y); } void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,