2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2003-2008 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #define MAX_ABSOLUTE 0 /* Fill screen */
30 #define MAX_AVAILABLE 1 /* Expand until don't cover */
31 #define MAX_CONSERVATIVE 2 /* Expand until something */
32 #define MAX_XINERAMA 3 /* Fill Xinerama screen */
35 MaxSizeHV(EWin * ewin, const char *resize_type, int hor, int ver)
37 int x, y, w, h, x1, x2, y1, y2, type, bl, br, bt, bb;
38 EWin *const *lst, *pe;
44 if (ewin->state.inhibit_max_hor && hor)
46 if (ewin->state.inhibit_max_ver && ver)
49 if (ewin->state.maximized_horz || ewin->state.maximized_vert)
51 EwinMoveResize(ewin, ewin->save_max.x, ewin->save_max.y,
52 ewin->save_max.w, ewin->save_max.h);
53 ewin->save_max.x = EoGetX(ewin);
54 ewin->save_max.y = EoGetY(ewin);
55 ewin->save_max.w = ewin->client.w;
56 ewin->save_max.h = ewin->client.h;
57 ewin->state.maximized_horz = 0;
58 ewin->state.maximized_vert = 0;
62 type = MAX_ABSOLUTE; /* Select default */
63 if (!resize_type || !resize_type[0])
64 type = Conf.movres.mode_maximize_default;
65 else if (!strcmp(resize_type, "absolute"))
67 else if (!strcmp(resize_type, "available"))
69 else if (!strcmp(resize_type, "conservative"))
70 type = MAX_CONSERVATIVE;
71 else if (!strcmp(resize_type, "xinerama"))
74 /* Default is no change */
87 ewin->state.maximized_horz = 1;
93 ewin->state.maximized_vert = 1;
100 case MAX_CONSERVATIVE:
101 ScreenGetAvailableArea(x + w / 2, y + h / 2, &x1, &y1, &x2, &y2);
105 if (Conf.movres.dragbar_nocover && type != MAX_ABSOLUTE)
107 /* Leave room for the dragbar */
108 switch (Conf.desks.dragdir)
111 if (x1 < Conf.desks.dragbar_width)
112 x1 = Conf.desks.dragbar_width;
116 if (x2 > WinGetW(VROOT) - Conf.desks.dragbar_width)
117 x2 = WinGetW(VROOT) - Conf.desks.dragbar_width;
121 if (y1 < Conf.desks.dragbar_width)
122 y1 = Conf.desks.dragbar_width;
126 if (y2 > WinGetH(VROOT) - Conf.desks.dragbar_width)
127 y2 = WinGetH(VROOT) - Conf.desks.dragbar_width;
135 if (type == MAX_ABSOLUTE)
137 /* Simply ignore all windows */
143 lst = EwinListGetAll(&num);
148 for (i = 0; i < num; i++)
152 pe->state.iconified || EoIsFloating(pe) ||
153 pe->props.ignorearrange ||
154 (EoGetDesk(ewin) != EoGetDesk(pe) && !EoIsSticky(pe)) ||
155 (pe->type & (EWIN_TYPE_DIALOG | EWIN_TYPE_MENU)) ||
156 (type == MAX_AVAILABLE && !pe->props.never_use_area) ||
157 !SPANS_COMMON(x, w, EoGetX(pe), EoGetW(pe)))
160 if (((EoGetY(pe) + EoGetH(pe)) <= y)
161 && ((EoGetY(pe) + EoGetH(pe)) >= y1))
162 y1 = EoGetY(pe) + EoGetH(pe);
163 else if (((y + h) <= EoGetY(pe)) && (y2 >= EoGetY(pe)))
169 ewin->state.maximized_vert = 1;
174 for (i = 0; i < num; i++)
178 pe->state.iconified || EoIsFloating(pe) ||
179 pe->props.ignorearrange ||
180 (EoGetDesk(ewin) != EoGetDesk(pe) && !EoIsSticky(pe)) ||
181 (pe->type & (EWIN_TYPE_DIALOG | EWIN_TYPE_MENU)) ||
182 (type == MAX_AVAILABLE && !pe->props.never_use_area) ||
183 !SPANS_COMMON(y, h, EoGetY(pe), EoGetH(pe)))
186 if (((EoGetX(pe) + EoGetW(pe)) <= x)
187 && ((EoGetX(pe) + EoGetW(pe)) >= x1))
188 x1 = EoGetX(pe) + EoGetW(pe);
189 else if (((x + w) <= EoGetX(pe)) && (x2 >= EoGetX(pe)))
195 ewin->state.maximized_horz = 1;
201 EwinBorderGetSize(ewin, &bl, &br, &bt, &bb);
209 ewin->save_max.x = EoGetX(ewin);
210 ewin->save_max.y = EoGetY(ewin);
211 ewin->save_max.w = ewin->client.w;
212 ewin->save_max.h = ewin->client.h;
214 ewin->state.maximizing = 1;
215 EwinMoveResize(ewin, x, y, w, h);
216 ewin->state.maximizing = 0;
218 HintsSetWindowState(ewin);