]>
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_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
, "center"))
41 if (s
[0] == '-' || s
[0] == '+')
49 static gpointer
setup_func(ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
)
54 o
= g_new0(Options
, 1);
61 if ((n
= parse_find_node("x", node
)))
62 parse_coord(doc
, n
, &o
->x
, &o
->xopposite
, &o
->xcenter
);
64 if ((n
= parse_find_node("y", node
)))
65 parse_coord(doc
, n
, &o
->y
, &o
->yopposite
, &o
->ycenter
);
67 if ((n
= parse_find_node("width", node
)))
68 o
->w
= parse_int(doc
, n
);
69 if ((n
= parse_find_node("height", node
)))
70 o
->h
= parse_int(doc
, n
);
72 if ((n
= parse_find_node("monitor", node
)))
73 o
->monitor
= parse_int(doc
, n
) - 1;
78 static void free_func(gpointer options
)
85 /* Always return FALSE because its not interactive */
86 static gboolean
run_func(ObActionsData
*data
, gpointer options
)
94 gint x
, y
, lw
, lh
, w
, h
;
98 cmon
= client_monitor(c
);
99 if (mon
< 0) mon
= cmon
;
100 area
= screen_area(c
->desktop
, mon
, NULL
);
101 carea
= screen_area(c
->desktop
, cmon
, NULL
);
104 if (w
== G_MININT
) w
= c
->area
.width
;
107 if (h
== G_MININT
) h
= c
->area
.height
;
109 /* it might not be able to resize how they requested, so find out what
110 it will actually be resized to */
113 client_try_configure(c
, &x
, &y
, &w
, &h
, &lw
, &lh
, TRUE
);
115 /* get the frame's size */
116 w
+= c
->frame
->size
.left
+ c
->frame
->size
.right
;
117 h
+= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
120 if (o
->xcenter
) x
= (area
->width
- w
) / 2;
121 else if (x
== G_MININT
) x
= c
->frame
->area
.x
- carea
->x
;
122 else if (o
->xopposite
) x
= area
->width
- w
;
126 if (o
->ycenter
) y
= (area
->height
- h
) / 2;
127 else if (y
== G_MININT
) y
= c
->frame
->area
.y
- carea
->y
;
128 else if (o
->yopposite
) y
= area
->height
- h
;
131 /* get the client's size back */
132 w
-= c
->frame
->size
.left
+ c
->frame
->size
.right
;
133 h
-= c
->frame
->size
.top
+ c
->frame
->size
.bottom
;
135 frame_frame_gravity(c
->frame
, &x
, &y
); /* get the client coords */
136 client_try_configure(c
, &x
, &y
, &w
, &h
, &lw
, &lh
, TRUE
);
137 /* force it on screen if its moving to another monitor */
138 client_find_onscreen(c
, &x
, &y
, w
, h
, mon
!= cmon
);
140 actions_client_move(data
, TRUE
);
141 client_configure(c
, x
, y
, w
, h
, TRUE
, TRUE
, FALSE
);
142 actions_client_move(data
, FALSE
);
This page took 0.038448 seconds and 4 git commands to generate.