updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / xfwm4-tiling / xfwm4-4.8.3-tiling-1.patch
blob2c27d4b320a868f6ac147bacab822b9ff6d51223
1 diff -rupN xfwm4-4.8.3/src/client.c xfwm4-4.8.3-tiling/src/client.c
2 --- xfwm4-4.8.3/src/client.c 2011-12-19 14:22:19.000000000 -0500
3 +++ xfwm4-4.8.3-tiling/src/client.c 2011-12-22 23:22:00.538436871 -0500
4 @@ -107,7 +107,7 @@ struct _ButtonPressData
5 /* Forward decl */
6 static void
7 clientUpdateIconPix (Client * c);
8 -static void
9 +void
10 clientNewMaxSize (Client * c, XWindowChanges *wc);
12 Display *
13 @@ -2153,6 +2153,12 @@ clientFrameAll (ScreenInfo *screen_info)
14 if ((attr.map_state == IsViewable) && (attr.root == screen_info->xroot))
16 Client *c = clientFrame (display_info, wins[i], TRUE);
17 + // initial values for existing windows
18 + if (c)
19 + {
20 + c->pretiling_height = -1;
21 + c->pretiling_width = -1;
22 + }
23 if ((c) && ((screen_info->params->raise_on_click) || (screen_info->params->click_to_focus)))
25 clientGrabMouseButton (c);
26 @@ -3232,7 +3238,7 @@ clientNewMaxState (Client * c, XWindowCh
27 wc->height = c->old_height;
30 -static void
31 +void
32 clientNewMaxSize (Client * c, XWindowChanges *wc)
34 ScreenInfo *screen_info;
35 @@ -3259,7 +3265,7 @@ clientNewMaxSize (Client * c, XWindowCha
36 full_h = MIN (screen_info->height - screen_info->params->xfwm_margins[STRUTS_BOTTOM],
37 rect.y + rect.height) - full_y;
39 - if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED))
40 + if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED) || FLAG_TEST (c->flags, CLIENT_FLAG_TILED))
42 /* Adjust size to the largest size available, not covering struts */
43 clientMaxSpace (screen_info, &full_x, &full_y, &full_w, &full_h);
44 diff -rupN xfwm4-4.8.3/src/client.h xfwm4-4.8.3-tiling/src/client.h
45 --- xfwm4-4.8.3/src/client.h 2011-12-19 14:22:19.000000000 -0500
46 +++ xfwm4-4.8.3-tiling/src/client.h 2011-12-22 23:22:00.538436871 -0500
47 @@ -161,6 +161,7 @@
48 #define CLIENT_FLAG_DEMANDS_ATTENTION (1L<<17)
49 #define CLIENT_FLAG_HAS_SHAPE (1L<<18)
50 #define CLIENT_FLAG_FULLSCREN_MONITORS (1L<<19)
51 +#define CLIENT_FLAG_TILED (1L<<20)
53 #define WM_FLAG_DELETE (1L<<0)
54 #define WM_FLAG_INPUT (1L<<1)
55 @@ -283,6 +284,8 @@ struct _Client
56 gint old_y;
57 gint old_width;
58 gint old_height;
59 + gint pretiling_width;
60 + gint pretiling_height;
61 gint fullscreen_old_x;
62 gint fullscreen_old_y;
63 gint fullscreen_old_width;
64 @@ -338,6 +341,8 @@ struct _Client
65 extern Client *clients;
66 extern unsigned int client_count;
68 +void clientNewMaxSize (Client * c,
69 + XWindowChanges *wc);
70 Display *clientGetXDisplay (Client *);
71 void clientClearLastOpTime (Client *);
72 void clientUpdateWinState (Client *,
73 diff -rupN xfwm4-4.8.3/src/moveresize.c xfwm4-4.8.3-tiling/src/moveresize.c
74 --- xfwm4-4.8.3/src/moveresize.c 2011-12-19 14:22:19.000000000 -0500
75 +++ xfwm4-4.8.3-tiling/src/moveresize.c 2011-12-22 23:42:48.471676235 -0500
76 @@ -874,6 +874,162 @@ clientMoveEventFilter (XEvent * xevent,
78 c->x = passdata->ox + (xevent->xmotion.x_root - passdata->mx);
79 c->y = passdata->oy + (xevent->xmotion.y_root - passdata->my);
81 + // if window is not maximized
82 + if (!FLAG_TEST_ALL(c->flags, CLIENT_FLAG_MAXIMIZED))
83 + {
84 + // if user moved cursor to the edge of the screen
85 + if (xevent->xmotion.x_root < TILING_EDGE
86 + || xevent->xmotion.x_root > screen_info->width - TILING_EDGE
87 + || xevent->xmotion.y_root < TILING_EDGE
88 + || xevent->xmotion.y_root > screen_info->height - TILING_EDGE)
89 + {
90 + // save pretiling sizes for future restore
92 + // initial values for pretiling_width and pretiling_height
93 + // are set in functions:
94 + // placement.c => clientInitPosition - for new windows
95 + // client.c => clientFrameAll - for existing windows
96 + // P.S. maybe it's a dirty hack :-)
98 + if (c->pretiling_width == -1)
99 + c->pretiling_width = c->width;
100 + if (c->pretiling_height == -1)
101 + c->pretiling_height = c->height;
103 + // get information about maximum available space
104 + FLAG_SET (c->flags, CLIENT_FLAG_TILED);
105 + XWindowChanges wc;
106 + clientNewMaxSize(c, &wc);
108 + //Top left
109 + if (xevent->xmotion.x_root < TILING_EDGE
110 + && xevent->xmotion.y_root < TILING_EDGE)
112 + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
113 + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
115 + c->x = wc.x;
116 + c->y = wc.y;
119 + //Top Right
120 + else if (xevent->xmotion.x_root > screen_info->width - TILING_EDGE
121 + && xevent->xmotion.y_root < TILING_EDGE)
123 + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
124 + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
126 + c->x = wc.x + c->width + frameRight(c) + frameLeft(c);
127 + c->y = wc.y;
129 + //Bottom Left
130 + else if (xevent->xmotion.x_root < TILING_EDGE
131 + && xevent->xmotion.y_root > screen_info->height - TILING_EDGE)
133 + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
134 + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
136 + c->x = wc.x;
137 + c->y = wc.y + c->height + frameBottom(c) + frameTop(c);
139 + //Bottom Right
140 + else if (xevent->xmotion.x_root > screen_info->width - TILING_EDGE
141 + && xevent->xmotion.y_root > screen_info->height - TILING_EDGE)
143 + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
144 + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
146 + c->x = wc.x + c->width + frameRight(c) + frameLeft(c);
147 + c->y = wc.y + c->height + frameBottom(c) + frameTop(c);
149 + //Left
150 + else if (xevent->xmotion.x_root < TILING_EDGE)
152 + // wc.x = avialable screen x + 1 x left frame's width
153 + // wc.width = available screen width - 1 x left frame's width - 1 x right frame's width
155 + c->x = wc.x;
156 + c->y = wc.y;
158 + // we need to substract another two (left, right) frames' width
159 + // because of two windows we have
161 + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
162 + c->height = wc.height;
164 + //Right
165 + else if (xevent->xmotion.x_root > screen_info->width - TILING_EDGE)
167 + // see upper
168 + c->width = (wc.width - frameRight(c) - frameLeft(c))/2;
169 + c->height = wc.height;
171 + // c->width has to be first (left) window's width
172 + // but two windows we have are equal,
173 + // consequently we can use second windows's width
175 + // frameRight(c) + frameLeft(c) = width of frames between windows
177 + c->x = wc.x + c->width + frameRight(c) + frameLeft(c);
178 + c->y = wc.y;
180 + //Top
181 + else if (xevent->xmotion.y_root < TILING_EDGE)
183 + // see previous tilings' comments
184 + c->x = wc.x;
185 + c->y = wc.y;
186 + c->width = wc.width;
187 + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
189 + //Bottom
190 + else
192 + // see previous tilings' comments
193 + c->width = wc.width;
194 + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
195 + c->x = wc.x;
196 + c->y = wc.y + c->height + frameBottom(c) + frameTop(c);
199 + else
201 + if (c->pretiling_width != -1)
203 + // calculate x-resize ratio
204 + double ratio_x = ((double) c->pretiling_width) / ((double) c->width);
206 + // restore pretiling size (by x)
207 + c->width = c->pretiling_width;
208 + c->pretiling_width = -1;
210 + // fix cursor position (by x)
211 + passdata->mx *= ratio_x;
212 + passdata->ox *= ratio_x;
215 + if (c->pretiling_height != -1)
217 + // calculate y-resize ratio
218 + double ratio_y = ((double) c->pretiling_height) / ((double) c->height);
220 + // restore pretiling size (by y)
221 + c->height = c->pretiling_height;
222 + c->pretiling_height = -1;
224 + // fix cursor position (by y)
225 + passdata->my *= ratio_y;
226 + passdata->oy *= ratio_y;
229 + FLAG_UNSET (c->flags, CLIENT_FLAG_TILED);
233 + // we need it for our window to be not only moved, but resized too
234 + passdata->move_resized = 1;
237 clientSnapPosition (c, prev_x, prev_y);
238 if (screen_info->params->restore_on_move)
239 diff -rupN xfwm4-4.8.3/src/moveresize.h xfwm4-4.8.3-tiling/src/moveresize.h
240 --- xfwm4-4.8.3/src/moveresize.h 2011-12-06 12:14:44.000000000 -0500
241 +++ xfwm4-4.8.3-tiling/src/moveresize.h 2011-12-22 23:22:00.538436871 -0500
242 @@ -31,6 +31,8 @@
243 #include "screen.h"
244 #include "client.h"
246 +#define TILING_EDGE 10
248 #ifndef INC_MOVERESIZE_H
249 #define INC_MOVERESIZE_H
250 void clientSetWidth (Client *,
251 diff -rupN xfwm4-4.8.3/src/placement.c xfwm4-4.8.3-tiling/src/placement.c
252 --- xfwm4-4.8.3/src/placement.c 2011-12-19 14:22:19.000000000 -0500
253 +++ xfwm4-4.8.3-tiling/src/placement.c 2011-12-22 23:22:00.538436871 -0500
254 @@ -739,6 +739,10 @@ clientInitPosition (Client * c)
256 clientAutoMaximize (c, full_w, full_h);
259 + // initial values for new windows
260 + c->pretiling_width = -1;
261 + c->pretiling_height = -1;