1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2000-01-06 00:13:30 -08:00
|
|
|
* Copyright (C) 2000 Carsten Haitzler, Geoff Harrison and various contributors
|
2003-07-20 11:02:16 -07:00
|
|
|
* Copyright (C) 2003 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"
|
|
|
|
|
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-07-20 11:02:16 -07:00
|
|
|
#define MAX_ABSOLUTE 0
|
|
|
|
#define MAX_AVAILABLE 1
|
|
|
|
#define MAX_CONSERVATIVE 2
|
|
|
|
|
|
|
|
static void
|
|
|
|
MaxSizeHV(EWin * ewin, char *resize_type, int direction)
|
|
|
|
{
|
|
|
|
int x, y, w, h, x1, x2, y1, y2, type;
|
|
|
|
EWin **lst, *pe;
|
|
|
|
int i, num;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
if (!ewin)
|
|
|
|
return;
|
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
if (ewin->toggle)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
MoveResizeEwin(ewin, ewin->lx, ewin->ly, ewin->lw, ewin->lh);
|
|
|
|
ewin->lx = ewin->x;
|
|
|
|
ewin->ly = ewin->y;
|
|
|
|
ewin->lw = ewin->client.w;
|
|
|
|
ewin->lh = ewin->client.h;
|
|
|
|
ewin->toggle = 0;
|
2003-07-20 11:02:16 -07:00
|
|
|
goto exit;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
if ((resize_type) && (!strcmp(resize_type, "available")))
|
|
|
|
type = MAX_AVAILABLE;
|
|
|
|
else if ((resize_type) && (!strcmp(resize_type, "conservative")))
|
|
|
|
type = MAX_CONSERVATIVE;
|
|
|
|
else
|
|
|
|
type = MAX_ABSOLUTE;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
/* Default is no change */
|
|
|
|
y = ewin->y;
|
|
|
|
h = ewin->h;
|
|
|
|
x = ewin->x;
|
|
|
|
w = ewin->w;
|
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-07-20 11:02:16 -07:00
|
|
|
case MAX_ABSOLUTE:
|
|
|
|
if (direction & MAX_HOR)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-07-20 11:02:16 -07:00
|
|
|
x = 0;
|
|
|
|
w = root.w - ewin->border->border.left -
|
|
|
|
ewin->border->border.right;
|
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;
|
|
|
|
h = root.h - ewin->border->border.top -
|
|
|
|
ewin->border->border.bottom;
|
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-07-20 11:02:16 -07:00
|
|
|
case MAX_CONSERVATIVE:
|
|
|
|
case MAX_AVAILABLE:
|
|
|
|
lst = (EWin **) ListItemType(&num, LIST_TYPE_EWIN);
|
|
|
|
if (!lst)
|
|
|
|
break;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
ScreenGetGeometry(ewin->x, ewin->y, &x1, &y1, &x2, &y2);
|
|
|
|
x2 += x1;
|
|
|
|
y2 += y1;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-03-23 19:48:09 -08:00
|
|
|
#if ENABLE_KDE
|
2003-07-20 11:02:16 -07:00
|
|
|
if (mode.kde_support)
|
|
|
|
{
|
|
|
|
if (x1 < mode.kde_x1)
|
|
|
|
x1 = mode.kde_x1;
|
|
|
|
if (x2 > mode.kde_x2)
|
|
|
|
x2 = mode.kde_x2;
|
|
|
|
if (y1 < mode.kde_y1)
|
|
|
|
y1 = mode.kde_y1;
|
|
|
|
if (y2 > mode.kde_y2)
|
|
|
|
y2 = mode.kde_y2;
|
|
|
|
}
|
2003-03-23 19:48:09 -08:00
|
|
|
#endif
|
2000-03-26 14:05:16 -08: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 ||
|
|
|
|
pe->iconified ||
|
|
|
|
pe->floating ||
|
|
|
|
pe->ignorearrange ||
|
|
|
|
(ewin->desktop != pe->desktop && !pe->sticky) ||
|
|
|
|
(pe->type & (EWIN_TYPE_DIALOG | EWIN_TYPE_MENU)) ||
|
|
|
|
(type == MAX_AVAILABLE && pe->never_use_area) ||
|
|
|
|
!SPANS_COMMON(x, w, pe->x, pe->w))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((pe->y + pe->h) <= y) && ((pe->y + pe->h) >= y1))
|
|
|
|
y1 = pe->y + pe->h;
|
|
|
|
else if (((y + h) <= pe->y) && (y2 >= pe->y))
|
|
|
|
y2 = pe->y;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-07-20 11:02:16 -07:00
|
|
|
y = y1;
|
|
|
|
h = y2 - y1 - (ewin->border->border.top +
|
|
|
|
ewin->border->border.bottom);
|
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 ||
|
|
|
|
pe->iconified ||
|
|
|
|
pe->floating ||
|
|
|
|
pe->ignorearrange ||
|
|
|
|
(ewin->desktop != pe->desktop && !pe->sticky) ||
|
|
|
|
(pe->type & (EWIN_TYPE_DIALOG | EWIN_TYPE_MENU)) ||
|
|
|
|
(type == MAX_AVAILABLE && pe->never_use_area) ||
|
|
|
|
!SPANS_COMMON(y, h, pe->y, pe->h))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (((pe->x + pe->w) <= x) && ((pe->x + pe->w) >= x1))
|
|
|
|
x1 = pe->x + pe->w;
|
|
|
|
else if (((x + w) <= pe->x) && (x2 >= pe->x))
|
|
|
|
x2 = pe->x;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-07-20 11:02:16 -07:00
|
|
|
x = x1;
|
|
|
|
w = x2 - x1 - (ewin->border->border.left +
|
|
|
|
ewin->border->border.right);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-07-20 11:02:16 -07:00
|
|
|
|
|
|
|
Efree(lst);
|
|
|
|
break;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
ewin->lx = ewin->x;
|
|
|
|
ewin->ly = ewin->y;
|
|
|
|
ewin->lw = ewin->client.w;
|
|
|
|
ewin->lh = ewin->client.h;
|
|
|
|
MoveResizeEwin(ewin, x, y, w, h);
|
|
|
|
ewin->toggle = 1;
|
|
|
|
|
|
|
|
exit:;
|
2003-03-23 19:48:09 -08:00
|
|
|
#if ENABLE_KDE
|
1999-09-21 09:55:01 -07:00
|
|
|
if (mode.kde_support)
|
|
|
|
KDE_UpdateClient(ewin);
|
2003-03-23 19:48:09 -08:00
|
|
|
#endif
|
2003-07-20 11:02:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MaxWidth(EWin * ewin, char *resize_type)
|
|
|
|
{
|
|
|
|
MaxSizeHV(ewin, resize_type, MAX_HOR);
|
|
|
|
}
|
1999-09-21 09:55:01 -07:00
|
|
|
|
2003-07-20 11:02:16 -07:00
|
|
|
void
|
|
|
|
MaxHeight(EWin * ewin, char *resize_type)
|
|
|
|
{
|
|
|
|
MaxSizeHV(ewin, resize_type, MAX_VER);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MaxSize(EWin * ewin, char *resize_type)
|
|
|
|
{
|
|
|
|
MaxSizeHV(ewin, resize_type, MAX_HOR | MAX_VER);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|