]>
Dogcows Code - chaz/openbox/blob - openbox/actions/moveresizeto.c
1 #include "openbox/actions.h"
2 #include "openbox/client.h"
3 #include "openbox/screen.h"
4 #include "openbox/frame.h"
5 #include <stdlib.h> /* for atoi */
19 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
);
20 static void free_func(gpointer options
);
21 static gboolean
run_func(ObActionsData
*data
, gpointer options
);
23 void action_moveto_startup()
25 actions_register("MoveTo",
32 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
37 o
= g_new0(Options
, 1);
44 if ((n
= parse_find_node("x", node
))) {
45 gchar
*s
= parse_string(doc
, n
);
46 if (!g_ascii_strcasecmp(s
, "center"))
51 if (s
[0] == '-' || s
[0] == '+')
59 if ((n
= parse_find_node("y", node
))) {
60 gchar
*s
= parse_string(doc
, n
);
61 if (!g_ascii_strcasecmp(s
, "center"))
66 if (s
[0] == '-' || s
[0] == '+')
74 if ((n
= parse_find_node("width", node
)))
75 o
->w
= parse_int(doc
, n
) - 1;
76 if ((n
= parse_find_node("height", node
)))
77 o
->h
= parse_int(doc
, n
) - 1;
79 if ((n
= parse_find_node("monitor", node
)))
80 o
->monitor
= parse_int(doc
, n
) - 1;
85 static void free_func(gpointer options
)
92 /* Always return FALSE because its not interactive */
93 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
101 gint x
, y
, lw
, lh
, w
, h
;
105 cmon
= client_monitor(c
);
106 if (mon
< 0) mon
= cmon
;
107 area
= screen_area(c
->desktop
, mon
, NULL
);
108 carea
= screen_area(c
->desktop
, cmon
, NULL
);
111 if (w
== G_MININT
) w
= c
->area
.width
;
114 if (h
== G_MININT
) h
= c
->area
.height
;
116 /* it might not be able to resize how they requested, so find out what
117 it will actually be resized to */
120 client_try_configure(c
, &x
, &y
, &w
, &h
, &lw
, &lh
, TRUE
);
122 /* get the frame's size */
123 w
+= c
->frame
->size
.left
+ c
->frame
->size
.right
;
124 h
+= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
127 if (o
->xcenter
) x
= (area
->width
- w
) / 2;
128 else if (x
== G_MININT
) x
= c
->frame
->area
.x
- carea
->x
;
129 else if (o
->xopposite
) x
= area
->width
- w
;
133 if (o
->ycenter
) y
= (area
->height
- h
) / 2;
134 else if (y
== G_MININT
) y
= c
->frame
->area
.y
- carea
->y
;
135 else if (o
->yopposite
) y
= area
->height
- h
;
138 /* get the client's size back */
139 w
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
140 h
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
142 frame_frame_gravity(c
->frame
, &x
, &y
); /* get the client coords */
143 client_try_configure(c
, &x
, &y
, &w
, &h
, &lw
, &lh
, TRUE
);
144 /* force it on screen if its moving to another monitor */
145 client_find_onscreen(c
, &x
, &y
, w
, h
, mon
!= cmon
);
147 actions_client_move(data
, TRUE
);
148 client_configure(c
, x
, y
, w
, h
, TRUE
, TRUE
, FALSE
);
149 actions_client_move(data
, FALSE
);
This page took 0.048158 seconds and 5 git commands to generate.