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 \
action_move_relative_vert,
setup_client_action
},
- {
- "movetocenter",
- action_move_to_center,
- setup_client_action
- },
{
"resizerelativehorz",
action_resize_relative_horz,
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
- },
{
"sendtodesktop",
action_send_to_desktop,
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;
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)
{
ObClient *c = data->sendto.any.c;
action_iconify_startup();
action_fullscreen_startup();
action_maximize_startup();
+ action_moveto_startup();
}
void action_iconify_startup();
void action_fullscreen_startup();
void action_maximize_startup();
+void action_moveto_startup();
#endif
--- /dev/null
+#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;
+}
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;
}
/* 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;
}
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 */
}
/* 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)) {
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) {
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) {
}
}
-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) {
{
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)
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 */
/* 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);
}
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)
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;
}
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;
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)
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;
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,