forked from e16/e16
1
0
Fork 0

arrange: Introduce screen struts

Can be used to  restrict area where windows are normally placed.
Works like struts set by clients with _NET_WM_STRUT.

Sugested by Milan Maljković.
This commit is contained in:
Kim Woelders 2022-05-03 16:34:20 +02:00
parent 398622f986
commit f8d7cb8c00
4 changed files with 48 additions and 3 deletions

View File

@ -253,6 +253,9 @@ typedef struct {
#ifdef USE_XINERAMA_no /* Not implemented */
char extra_head; /* Not used */
#endif
struct {
int left, right, top, bottom;
} screen_struts;
} place;
struct {
char enable_script;

View File

@ -461,6 +461,7 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
int gnum, num, i, j, k, odx, ody;
static char last_res = 0;
int top_bound, bottom_bound, left_bound, right_bound, w, h;
int top_strut, bottom_strut, left_strut, right_strut;
if (!ewin)
return;
@ -477,6 +478,11 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
right_bound = left_bound + w;
bottom_bound = top_bound + h;
left_strut = left_bound + Conf.place.screen_struts.left;
right_strut = right_bound - Conf.place.screen_struts.right;
top_strut = top_bound + Conf.place.screen_struts.top;
bottom_strut = bottom_bound - Conf.place.screen_struts.bottom;
/* Find the list of windows to check against */
lst1 = EwinListGetAll(&num);
if (!lst1)
@ -527,6 +533,13 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
{
dx = left_bound - ewin->shape_x;
}
else if (left_strut > left_bound &&
IN_BELOW(ewin->shape_x + dx, left_strut,
Conf.snap.screen_snap_dist) &&
(ewin->shape_x >= left_strut))
{
dx = left_strut - ewin->shape_x;
}
else
{
for (i = 0; i < num; i++)
@ -555,6 +568,13 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
{
dx = right_bound - (ewin->shape_x + EoGetW(ewin));
}
else if (right_strut < right_bound &&
IN_ABOVE(ewin->shape_x + EoGetW(ewin) + dx, right_strut,
Conf.snap.screen_snap_dist) &&
(ewin->shape_x + EoGetW(ewin) <= right_strut))
{
dx = right_strut - (ewin->shape_x + EoGetW(ewin));
}
else
{
for (i = 0; i < num; i++)
@ -583,6 +603,13 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
{
dy = top_bound - ewin->shape_y;
}
else if (top_strut > top_bound &&
IN_BELOW(ewin->shape_y + dy, top_strut,
Conf.snap.screen_snap_dist) &&
(ewin->shape_y >= top_strut))
{
dy = top_strut - ewin->shape_y;
}
else
{
for (i = 0; i < num; i++)
@ -611,6 +638,13 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
{
dy = bottom_bound - (ewin->shape_y + EoGetH(ewin));
}
else if (bottom_strut < bottom_bound &&
IN_ABOVE(ewin->shape_y + EoGetH(ewin) + dy, bottom_strut,
Conf.snap.screen_snap_dist) &&
(ewin->shape_y + EoGetH(ewin) <= bottom_strut))
{
dy = bottom_strut - (ewin->shape_y + EoGetH(ewin));
}
else
{
for (i = 0; i < num; i++)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2021 Kim Woelders
* Copyright (C) 2003-2022 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -179,6 +179,10 @@ static const CfgItem MiscCfgItems[] = {
CFG_ITEM_BOOL(Conf, place.ignore_struts, 0),
CFG_ITEM_BOOL(Conf, place.ignore_struts_fullscreen, 0),
CFG_ITEM_BOOL(Conf, place.ignore_struts_maximize, 0),
CFG_ITEM_INT(Conf, place.screen_struts.left, 0),
CFG_ITEM_INT(Conf, place.screen_struts.right, 0),
CFG_ITEM_INT(Conf, place.screen_struts.top, 0),
CFG_ITEM_INT(Conf, place.screen_struts.bottom, 0),
CFG_ITEM_BOOL(Conf, place.raise_fullscreen, 0),
CFG_ITEM_BOOL(Conf, place.slidein, 0),
CFG_ITEM_BOOL(Conf, place.cleanupslide, 1),

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2003-2019 Kim Woelders
* Copyright (C) 2003-2022 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -379,7 +379,11 @@ _VRootGetAvailableArea(int *px, int *py, int *pw, int *ph)
EWin *const *lst, *ewin;
int i, num, l, r, t, b;
l = r = t = b = 0;
l = Conf.place.screen_struts.left;
r = Conf.place.screen_struts.right;
t = Conf.place.screen_struts.top;
b = Conf.place.screen_struts.bottom;
lst = EwinListGetAll(&num);
for (i = 0; i < num; i++)
{