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
7 clientUpdateIconPix (Client * c);
10 clientNewMaxSize (Client * c, XWindowChanges *wc);
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
20 + c->pretiling_height = -1;
21 + c->pretiling_width = -1;
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;
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
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
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))
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)
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);
106 + clientNewMaxSize(c, &wc);
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;
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);
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;
137 + c->y = wc.y + c->height + frameBottom(c) + frameTop(c);
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);
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
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;
165 + else if (xevent->xmotion.x_root > screen_info->width - TILING_EDGE)
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);
181 + else if (xevent->xmotion.y_root < TILING_EDGE)
183 + // see previous tilings' comments
186 + c->width = wc.width;
187 + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
192 + // see previous tilings' comments
193 + c->width = wc.width;
194 + c->height = (wc.height - frameBottom(c) - frameTop(c))/2;
196 + c->y = wc.y + c->height + frameBottom(c) + frameTop(c);
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
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;