]>
Dogcows Code - chaz/openbox/blob - openbox/actions/moveresizeto.c
48b6e3bf2b369625f75f60c3779902da0cbdc7c6
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_moveresizeto_startup()
25 actions_register("MoveResizeTo",
32 static void parse_coord(xmlDocPtr doc
, xmlNodePtr n
, gint
*pos
,
33 gboolean
*opposite
, gboolean
*center
)
35 gchar
*s
= parse_string(doc
, n
);
36 if (g_ascii_strcasecmp(s
, "current") != 0) {
37 if (!g_ascii_strcasecmp(s
, "center"))
42 if (s
[0] == '-' || s
[0] == '+')
51 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
56 o
= g_new0(Options
, 1);
63 if ((n
= parse_find_node("x", node
)))
64 parse_coord(doc
, n
, &o
->x
, &o
->xopposite
, &o
->xcenter
);
66 if ((n
= parse_find_node("y", node
)))
67 parse_coord(doc
, n
, &o
->y
, &o
->yopposite
, &o
->ycenter
);
69 if ((n
= parse_find_node("width", node
))) {
70 gchar
*s
= parse_string(doc
, n
);
71 if (g_ascii_strcasecmp(s
, "current") != 0)
72 o
->w
= parse_int(doc
, n
);
75 if ((n
= parse_find_node("height", node
))) {
76 gchar
*s
= parse_string(doc
, n
);
77 if (g_ascii_strcasecmp(s
, "current") != 0)
78 o
->h
= parse_int(doc
, n
);
82 if ((n
= parse_find_node("monitor", node
))) {
83 gchar
*s
= parse_string(doc
, n
);
84 if (g_ascii_strcasecmp(s
, "current") != 0)
85 o
->monitor
= parse_int(doc
, n
) - 1;
92 static void free_func(gpointer options
)
99 /* Always return FALSE because its not interactive */
100 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
102 Options
*o
= options
;
108 gint x
, y
, lw
, lh
, w
, h
;
112 cmon
= client_monitor(c
);
113 if (mon
< 0) mon
= cmon
;
114 area
= screen_area(c
->desktop
, mon
, NULL
);
115 carea
= screen_area(c
->desktop
, cmon
, NULL
);
118 if (w
== G_MININT
) w
= c
->area
.width
;
121 if (h
== G_MININT
) h
= c
->area
.height
;
123 /* it might not be able to resize how they requested, so find out what
124 it will actually be resized to */
127 client_try_configure(c
, &x
, &y
, &w
, &h
, &lw
, &lh
, TRUE
);
129 /* get the frame's size */
130 w
+= c
->frame
->size
.left
+ c
->frame
->size
.right
;
131 h
+= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
134 if (o
->xcenter
) x
= (area
->width
- w
) / 2;
135 else if (x
== G_MININT
) x
= c
->frame
->area
.x
- carea
->x
;
136 else if (o
->xopposite
) x
= area
->width
- w
;
140 if (o
->ycenter
) y
= (area
->height
- h
) / 2;
141 else if (y
== G_MININT
) y
= c
->frame
->area
.y
- carea
->y
;
142 else if (o
->yopposite
) y
= area
->height
- h
;
145 /* get the client's size back */
146 w
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
147 h
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
149 frame_frame_gravity(c
->frame
, &x
, &y
); /* get the client coords */
150 client_try_configure(c
, &x
, &y
, &w
, &h
, &lw
, &lh
, TRUE
);
151 /* force it on screen if its moving to another monitor */
152 client_find_onscreen(c
, &x
, &y
, w
, h
, mon
!= cmon
);
154 actions_client_move(data
, TRUE
);
155 client_configure(c
, x
, y
, w
, h
, TRUE
, TRUE
, FALSE
);
156 actions_client_move(data
, FALSE
);
This page took 0.042153 seconds and 4 git commands to generate.