1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2006-01-06 23:20:58 -08:00
|
|
|
* Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors
|
|
|
|
* Copyright (C) 2003-2006 Kim Woelders
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "ewins.h"
|
2005-10-27 16:18:35 -07:00
|
|
|
#include "hints.h"
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
#define MAX_HOR 0x1
|
|
|
|
#define MAX_VER 0x2
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-08-08 11:30:34 -07:00
|
|
|
#define MAX_ABSOLUTE 0 /* Fill screen */
|
|
|
|
#define MAX_AVAILABLE 1 /* Expand until don't cover */
|
|
|
|
#define MAX_CONSERVATIVE 2 /* Expand until something */
|
|
|
|
#define MAX_XINERAMA 3 /* Fill Xinerama screen */
|
2003-07-20 11:02:16 -07:00
|
|
|
|
|
|
|
static void
|
2004-03-20 17:39:40 -08:00
|
|
|
MaxSizeHV(EWin * ewin, const char *resize_type, int direction)
|
2003-07-20 11:02:16 -07:00
|
|
|
{
|
2005-12-22 10:43:15 -08:00
|
|
|
int x, y, w, h, x1, x2, y1, y2, type, bl, br, bt, bb;
|
2004-03-26 13:21:47 -08:00
|
|
|
EWin *const *lst, *pe;
|
2003-07-20 11:02:16 -07:00
|
|
|
int i, num;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
if (!ewin)
|
|
|
|
return;
|
|
|
|
|
2005-07-26 10:01:18 -07:00
|
|
|
if (ewin->state.maximized_horz || ewin->state.maximized_vert)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2005-07-10 01:31:15 -07:00
|
|
|
EwinMoveResize(ewin, ewin->lx, ewin->ly, ewin->lw, ewin->lh);
|
2004-12-28 15:46:49 -08:00
|
|
|
ewin->lx = EoGetX(ewin);
|
|
|
|
ewin->ly = EoGetY(ewin);
|
2003-05-22 12:15:03 -07:00
|
|
|
ewin->lw = ewin->client.w;
|
|
|
|
ewin->lh = ewin->client.h;
|
2005-07-08 09:48:19 -07:00
|
|
|
ewin->state.maximized_horz = 0;
|
|
|
|
ewin->state.maximized_vert = 0;
|
2005-10-27 15:26:37 -07:00
|
|
|
goto done;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-11-02 15:03:03 -08:00
|
|
|
if (ewin->state.inhibit_max_hor && (direction & MAX_HOR))
|
|
|
|
return;
|
|
|
|
if (ewin->state.inhibit_max_ver && (direction & MAX_VER))
|
|
|
|
return;
|
|
|
|
|
2003-08-08 11:30:34 -07:00
|
|
|
type = MAX_ABSOLUTE; /* Select default */
|
|
|
|
if (!resize_type)
|
|
|
|
;
|
|
|
|
else if (!strcmp(resize_type, "absolute"))
|
|
|
|
type = MAX_ABSOLUTE;
|
|
|
|
else if (!strcmp(resize_type, "available"))
|
2003-07-20 11:02:16 -07:00
|
|
|
type = MAX_AVAILABLE;
|
2003-08-08 11:30:34 -07:00
|
|
|
else if (!strcmp(resize_type, "conservative"))
|
2003-07-20 11:02:16 -07:00
|
|
|
type = MAX_CONSERVATIVE;
|
2003-08-08 11:30:34 -07:00
|
|
|
else if (!strcmp(resize_type, "xinerama"))
|
|
|
|
type = MAX_XINERAMA;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
/* Default is no change */
|
2004-12-28 15:46:49 -08:00
|
|
|
y = EoGetY(ewin);
|
|
|
|
x = EoGetX(ewin);
|
2003-08-08 11:30:34 -07:00
|
|
|
h = ewin->client.h;
|
|
|
|
w = ewin->client.w;
|
2005-12-22 10:43:15 -08:00
|
|
|
EwinBorderGetSize(ewin, &bl, &br, &bt, &bb);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
switch (type)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-08-08 11:30:34 -07:00
|
|
|
case MAX_XINERAMA:
|
2003-07-20 11:02:16 -07:00
|
|
|
if (direction & MAX_HOR)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-07-20 11:02:16 -07:00
|
|
|
x = 0;
|
2005-12-22 10:43:15 -08:00
|
|
|
w = VRoot.w - bl - br;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-07-20 11:02:16 -07:00
|
|
|
if (direction & MAX_VER)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-07-20 11:02:16 -07:00
|
|
|
y = 0;
|
2005-12-22 10:43:15 -08:00
|
|
|
h = VRoot.h - bt - bb;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-07-20 11:02:16 -07:00
|
|
|
break;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-08-08 11:30:34 -07:00
|
|
|
case MAX_ABSOLUTE:
|
2003-07-20 11:02:16 -07:00
|
|
|
case MAX_AVAILABLE:
|
2003-08-08 11:30:34 -07:00
|
|
|
case MAX_CONSERVATIVE:
|
2004-12-28 15:46:49 -08:00
|
|
|
ScreenGetAvailableArea(EoGetX(ewin), EoGetY(ewin), &x1, &y1, &x2, &y2);
|
2003-07-20 11:02:16 -07:00
|
|
|
x2 += x1;
|
|
|
|
y2 += y1;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-08-08 11:30:34 -07:00
|
|
|
if (type == MAX_ABSOLUTE)
|
|
|
|
{
|
|
|
|
/* Simply ignore all windows */
|
|
|
|
lst = NULL;
|
|
|
|
num = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-04-01 14:41:22 -08:00
|
|
|
lst = EwinListGetAll(&num);
|
2003-08-08 11:30:34 -07:00
|
|
|
}
|
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
if (direction & MAX_VER)
|
|
|
|
{
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
pe = lst[i];
|
|
|
|
if (pe == ewin ||
|
2005-07-08 09:48:19 -07:00
|
|
|
pe->state.iconified || EoIsFloating(pe) ||
|
|
|
|
pe->props.ignorearrange ||
|
2004-12-28 15:46:49 -08:00
|
|
|
(EoGetDesk(ewin) != EoGetDesk(pe) && !EoIsSticky(pe)) ||
|
2003-07-20 11:02:16 -07:00
|
|
|
(pe->type & (EWIN_TYPE_DIALOG | EWIN_TYPE_MENU)) ||
|
2005-07-08 09:48:19 -07:00
|
|
|
(type == MAX_AVAILABLE && !pe->props.never_use_area) ||
|
2004-12-28 15:46:49 -08:00
|
|
|
!SPANS_COMMON(x, w, EoGetX(pe), EoGetW(pe)))
|
2003-07-20 11:02:16 -07:00
|
|
|
continue;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (((EoGetY(pe) + EoGetH(pe)) <= y)
|
|
|
|
&& ((EoGetY(pe) + EoGetH(pe)) >= y1))
|
|
|
|
y1 = EoGetY(pe) + EoGetH(pe);
|
|
|
|
else if (((y + h) <= EoGetY(pe)) && (y2 >= EoGetY(pe)))
|
|
|
|
y2 = EoGetY(pe);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-07-20 11:02:16 -07:00
|
|
|
y = y1;
|
2005-12-22 10:43:15 -08:00
|
|
|
h = y2 - y1 - (bt + bb);
|
2004-05-31 13:30:12 -07:00
|
|
|
|
2005-07-08 09:48:19 -07:00
|
|
|
ewin->state.maximized_vert = 1;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
if (direction & MAX_HOR)
|
|
|
|
{
|
|
|
|
for (i = 0; i < num; i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-07-20 11:02:16 -07:00
|
|
|
pe = lst[i];
|
|
|
|
if (pe == ewin ||
|
2005-07-08 09:48:19 -07:00
|
|
|
pe->state.iconified || EoIsFloating(pe) ||
|
|
|
|
pe->props.ignorearrange ||
|
2004-12-28 15:46:49 -08:00
|
|
|
(EoGetDesk(ewin) != EoGetDesk(pe) && !EoIsSticky(pe)) ||
|
2003-07-20 11:02:16 -07:00
|
|
|
(pe->type & (EWIN_TYPE_DIALOG | EWIN_TYPE_MENU)) ||
|
2005-07-08 09:48:19 -07:00
|
|
|
(type == MAX_AVAILABLE && !pe->props.never_use_area) ||
|
2004-12-28 15:46:49 -08:00
|
|
|
!SPANS_COMMON(y, h, EoGetY(pe), EoGetH(pe)))
|
2003-07-20 11:02:16 -07:00
|
|
|
continue;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (((EoGetX(pe) + EoGetW(pe)) <= x)
|
|
|
|
&& ((EoGetX(pe) + EoGetW(pe)) >= x1))
|
|
|
|
x1 = EoGetX(pe) + EoGetW(pe);
|
|
|
|
else if (((x + w) <= EoGetX(pe)) && (x2 >= EoGetX(pe)))
|
|
|
|
x2 = EoGetX(pe);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-07-20 11:02:16 -07:00
|
|
|
x = x1;
|
2005-12-22 10:43:15 -08:00
|
|
|
w = x2 - x1 - (bl + br);
|
2004-05-31 13:30:12 -07:00
|
|
|
|
2005-07-08 09:48:19 -07:00
|
|
|
ewin->state.maximized_horz = 1;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-07-20 11:02:16 -07:00
|
|
|
|
|
|
|
break;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
ewin->lx = EoGetX(ewin);
|
|
|
|
ewin->ly = EoGetY(ewin);
|
2003-07-20 11:02:16 -07:00
|
|
|
ewin->lw = ewin->client.w;
|
|
|
|
ewin->lh = ewin->client.h;
|
2006-03-30 14:35:20 -08:00
|
|
|
ewin->state.maximizing = 1;
|
2005-07-10 01:31:15 -07:00
|
|
|
EwinMoveResize(ewin, x, y, w, h);
|
2006-03-30 14:35:20 -08:00
|
|
|
ewin->state.maximizing = 0;
|
2005-10-27 15:26:37 -07:00
|
|
|
done:
|
|
|
|
HintsSetWindowState(ewin);
|
2003-07-20 11:02:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-20 17:39:40 -08:00
|
|
|
MaxWidth(EWin * ewin, const char *resize_type)
|
2003-07-20 11:02:16 -07:00
|
|
|
{
|
|
|
|
MaxSizeHV(ewin, resize_type, MAX_HOR);
|
|
|
|
}
|
1999-09-21 09:55:01 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
void
|
2004-03-20 17:39:40 -08:00
|
|
|
MaxHeight(EWin * ewin, const char *resize_type)
|
2003-07-20 11:02:16 -07:00
|
|
|
{
|
|
|
|
MaxSizeHV(ewin, resize_type, MAX_VER);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-20 17:39:40 -08:00
|
|
|
MaxSize(EWin * ewin, const char *resize_type)
|
2003-07-20 11:02:16 -07:00
|
|
|
{
|
|
|
|
MaxSizeHV(ewin, resize_type, MAX_HOR | MAX_VER);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|