This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository e16.
View the commit online.
commit ebd3b74f4990905a0c9167a353b4251f655f444f
Author: Kim Woelders <[email protected]>
AuthorDate: Sat May 7 07:25:17 2022 +0200
moveresize: Move SnapEwin() to where it is used.
---
src/arrange.c | 230 ------------------------------------------------------
src/ewins.h | 2 -
src/moveresize.c | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 232 insertions(+), 233 deletions(-)
diff --git a/src/arrange.c b/src/arrange.c
index 96bf6c0c..4d0b8144 100644
--- a/src/arrange.c
+++ b/src/arrange.c
@@ -453,236 +453,6 @@ ArrangeRects(const RectBox * fixed, int fixed_count, RectBox * floating,
Efree(spaces);
}
-void
-SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
-{
- EWin *const *lst1;
- EWin **lst, **gwins, *e;
- 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;
-
- if (!Conf.snap.enable)
- {
- *new_dx = dx;
- *new_dy = dy;
- return;
- }
-
- ScreenGetGeometry(ewin->shape_x, ewin->shape_y,
- &left_bound, &top_bound, &w, &h);
- 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)
- return;
-
- lst = EMALLOC(EWin *, num);
- if (!lst)
- return;
-
- gwins =
- ListWinGroupMembersForEwin(ewin, GROUP_ACTION_MOVE, Mode.nogroup, &gnum);
- if (gwins)
- {
- for (j = k = 0; j < num; j++)
- {
- e = lst1[j];
- if (e == ewin) /* Skip self */
- continue;
- if (!EoIsSticky(e) && EoGetDesk(ewin) != EoGetDesk(e))
- continue; /* Skip if other desk */
- if (EoIsFloating(e) || e->state.iconified ||
- e->props.ignorearrange)
- continue;
- for (i = 0; i < gnum; i++)
- {
- if (lst1[j] == gwins[i])
- goto skip; /* Skip group members */
- }
- lst[k++] = e; /* Add to list */
- skip:
- ;
- }
- num = k;
- Efree(gwins);
- }
- else
- {
- num = 0; /* We should never go here */
- }
-
- odx = dx;
- ody = dy;
- if (dx < 0)
- {
- if (IN_BELOW(ewin->shape_x + dx, left_bound,
- Conf.snap.screen_snap_dist) &&
- (ewin->shape_x >= left_bound))
- {
- 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++)
- {
- e = lst[i];
- if (IN_BELOW(ewin->shape_x + dx,
- EoGetX(e) + EoGetW(e) - 1,
- Conf.snap.edge_snap_dist) &&
- SPANS_COMMON(ewin->shape_y, EoGetH(ewin),
- EoGetY(e), EoGetH(e)) &&
- (ewin->shape_x >= (EoGetX(e) + EoGetW(e))))
- {
- dx = (EoGetX(e) + EoGetW(e)) - ewin->shape_x;
- break;
- }
- }
- }
- if ((ewin->req_x - ewin->shape_x) > 0)
- dx = 0;
- }
- else if (dx > 0)
- {
- if (IN_ABOVE(ewin->shape_x + EoGetW(ewin) + dx, right_bound,
- Conf.snap.screen_snap_dist) &&
- (ewin->shape_x + EoGetW(ewin) <= right_bound))
- {
- 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++)
- {
- e = lst[i];
- if (IN_ABOVE(ewin->shape_x + EoGetW(ewin) + dx - 1,
- EoGetX(e), Conf.snap.edge_snap_dist) &&
- SPANS_COMMON(ewin->shape_y, EoGetH(ewin),
- EoGetY(e), EoGetH(e)) &&
- ((ewin->shape_x + EoGetW(ewin)) <= EoGetX(e)))
- {
- dx = EoGetX(e) - (ewin->shape_x + EoGetW(ewin));
- break;
- }
- }
- }
- if ((ewin->req_x - ewin->shape_x) < 0)
- dx = 0;
- }
-
- if (dy < 0)
- {
- if (IN_BELOW(ewin->shape_y + dy, top_bound,
- Conf.snap.screen_snap_dist) &&
- (ewin->shape_y >= top_bound))
- {
- 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++)
- {
- e = lst[i];
- if (IN_BELOW(ewin->shape_y + dy,
- EoGetY(e) + EoGetH(e) - 1,
- Conf.snap.edge_snap_dist) &&
- SPANS_COMMON(ewin->shape_x, EoGetW(ewin),
- EoGetX(e), EoGetW(e)) &&
- (ewin->shape_y >= (EoGetY(e) + EoGetH(e))))
- {
- dy = (EoGetY(e) + EoGetH(e)) - ewin->shape_y;
- break;
- }
- }
- }
- if ((ewin->req_y - ewin->shape_y) > 0)
- dy = 0;
- }
- else if (dy > 0)
- {
- if (IN_ABOVE(ewin->shape_y + EoGetH(ewin) + dy, bottom_bound,
- Conf.snap.screen_snap_dist) &&
- (ewin->shape_y + EoGetH(ewin) <= bottom_bound))
- {
- 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++)
- {
- e = lst[i];
- if (IN_ABOVE(ewin->shape_y + EoGetH(ewin) + dy - 1,
- EoGetY(e), Conf.snap.edge_snap_dist) &&
- SPANS_COMMON(ewin->shape_x, EoGetW(ewin),
- EoGetX(e), EoGetW(e)) &&
- (ewin->shape_y + EoGetH(ewin) <= EoGetY(e)))
- {
- dy = EoGetY(e) - (ewin->shape_y + EoGetH(ewin));
- break;
- }
- }
- }
- if ((ewin->req_y - ewin->shape_y) < 0)
- dy = 0;
- }
-
- Efree(lst);
-
- if ((odx != dx) || (ody != dy))
- {
- if (!last_res)
- {
- /* SoundPlay(SOUND_MOVE_RESIST); */
- last_res = 1;
- }
- }
- else
- {
- last_res = 0;
- }
- *new_dx = dx;
- *new_dy = dy;
-}
-
void
ArrangeEwin(EWin * ewin)
{
diff --git a/src/ewins.h b/src/ewins.h
index 0bc928a2..7bb931cd 100644
--- a/src/ewins.h
+++ b/src/ewins.h
@@ -336,8 +336,6 @@ struct _ewin {
#define EwinGetIcccmClass(ewin) EoGetClass(ewin)
/* arrange.c */
-void SnapEwin(EWin * ewin, int dx, int dy, int *new_dx,
- int *new_dy);
void ArrangeEwin(EWin * ewin);
void ArrangeEwinCentered(EWin * ewin);
void ArrangeEwinXY(EWin * ewin, int *px, int *py);
diff --git a/src/moveresize.c b/src/moveresize.c
index 7026cd2f..30f1cf36 100644
--- a/src/moveresize.c
+++ b/src/moveresize.c
@@ -36,6 +36,7 @@
#include "grabs.h"
#include "groups.h"
#include "hints.h"
+#include "screen.h"
#include "timers.h"
#include "xwin.h"
@@ -467,6 +468,236 @@ _MoveResizeResizeEnd(EWin * ewin)
}
}
+static void
+_SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy)
+{
+ EWin *const *lst1;
+ EWin **lst, **gwins, *e;
+ 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;
+
+ if (!Conf.snap.enable)
+ {
+ *new_dx = dx;
+ *new_dy = dy;
+ return;
+ }
+
+ ScreenGetGeometry(ewin->shape_x, ewin->shape_y,
+ &left_bound, &top_bound, &w, &h);
+ 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)
+ return;
+
+ lst = EMALLOC(EWin *, num);
+ if (!lst)
+ return;
+
+ gwins =
+ ListWinGroupMembersForEwin(ewin, GROUP_ACTION_MOVE, Mode.nogroup, &gnum);
+ if (gwins)
+ {
+ for (j = k = 0; j < num; j++)
+ {
+ e = lst1[j];
+ if (e == ewin) /* Skip self */
+ continue;
+ if (!EoIsSticky(e) && EoGetDesk(ewin) != EoGetDesk(e))
+ continue; /* Skip if other desk */
+ if (EoIsFloating(e) || e->state.iconified ||
+ e->props.ignorearrange)
+ continue;
+ for (i = 0; i < gnum; i++)
+ {
+ if (lst1[j] == gwins[i])
+ goto skip; /* Skip group members */
+ }
+ lst[k++] = e; /* Add to list */
+ skip:
+ ;
+ }
+ num = k;
+ Efree(gwins);
+ }
+ else
+ {
+ num = 0; /* We should never go here */
+ }
+
+ odx = dx;
+ ody = dy;
+ if (dx < 0)
+ {
+ if (IN_BELOW(ewin->shape_x + dx, left_bound,
+ Conf.snap.screen_snap_dist) &&
+ (ewin->shape_x >= left_bound))
+ {
+ 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++)
+ {
+ e = lst[i];
+ if (IN_BELOW(ewin->shape_x + dx,
+ EoGetX(e) + EoGetW(e) - 1,
+ Conf.snap.edge_snap_dist) &&
+ SPANS_COMMON(ewin->shape_y, EoGetH(ewin),
+ EoGetY(e), EoGetH(e)) &&
+ (ewin->shape_x >= (EoGetX(e) + EoGetW(e))))
+ {
+ dx = (EoGetX(e) + EoGetW(e)) - ewin->shape_x;
+ break;
+ }
+ }
+ }
+ if ((ewin->req_x - ewin->shape_x) > 0)
+ dx = 0;
+ }
+ else if (dx > 0)
+ {
+ if (IN_ABOVE(ewin->shape_x + EoGetW(ewin) + dx, right_bound,
+ Conf.snap.screen_snap_dist) &&
+ (ewin->shape_x + EoGetW(ewin) <= right_bound))
+ {
+ 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++)
+ {
+ e = lst[i];
+ if (IN_ABOVE(ewin->shape_x + EoGetW(ewin) + dx - 1,
+ EoGetX(e), Conf.snap.edge_snap_dist) &&
+ SPANS_COMMON(ewin->shape_y, EoGetH(ewin),
+ EoGetY(e), EoGetH(e)) &&
+ ((ewin->shape_x + EoGetW(ewin)) <= EoGetX(e)))
+ {
+ dx = EoGetX(e) - (ewin->shape_x + EoGetW(ewin));
+ break;
+ }
+ }
+ }
+ if ((ewin->req_x - ewin->shape_x) < 0)
+ dx = 0;
+ }
+
+ if (dy < 0)
+ {
+ if (IN_BELOW(ewin->shape_y + dy, top_bound,
+ Conf.snap.screen_snap_dist) &&
+ (ewin->shape_y >= top_bound))
+ {
+ 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++)
+ {
+ e = lst[i];
+ if (IN_BELOW(ewin->shape_y + dy,
+ EoGetY(e) + EoGetH(e) - 1,
+ Conf.snap.edge_snap_dist) &&
+ SPANS_COMMON(ewin->shape_x, EoGetW(ewin),
+ EoGetX(e), EoGetW(e)) &&
+ (ewin->shape_y >= (EoGetY(e) + EoGetH(e))))
+ {
+ dy = (EoGetY(e) + EoGetH(e)) - ewin->shape_y;
+ break;
+ }
+ }
+ }
+ if ((ewin->req_y - ewin->shape_y) > 0)
+ dy = 0;
+ }
+ else if (dy > 0)
+ {
+ if (IN_ABOVE(ewin->shape_y + EoGetH(ewin) + dy, bottom_bound,
+ Conf.snap.screen_snap_dist) &&
+ (ewin->shape_y + EoGetH(ewin) <= bottom_bound))
+ {
+ 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++)
+ {
+ e = lst[i];
+ if (IN_ABOVE(ewin->shape_y + EoGetH(ewin) + dy - 1,
+ EoGetY(e), Conf.snap.edge_snap_dist) &&
+ SPANS_COMMON(ewin->shape_x, EoGetW(ewin),
+ EoGetX(e), EoGetW(e)) &&
+ (ewin->shape_y + EoGetH(ewin) <= EoGetY(e)))
+ {
+ dy = EoGetY(e) - (ewin->shape_y + EoGetH(ewin));
+ break;
+ }
+ }
+ }
+ if ((ewin->req_y - ewin->shape_y) < 0)
+ dy = 0;
+ }
+
+ Efree(lst);
+
+ if ((odx != dx) || (ody != dy))
+ {
+ if (!last_res)
+ {
+ /* SoundPlay(SOUND_MOVE_RESIST); */
+ last_res = 1;
+ }
+ }
+ else
+ {
+ last_res = 0;
+ }
+ *new_dx = dx;
+ *new_dy = dy;
+}
+
static void
_MoveResizeMoveHandleMotion(void)
{
@@ -534,7 +765,7 @@ _MoveResizeMoveHandleMotion(void)
ndx = dx;
ndy = dy;
/* make our ewin resist other ewins around the place */
- SnapEwin(gwins[i], dx, dy, &ndx, &ndy);
+ _SnapEwin(gwins[i], dx, dy, &ndx, &ndy);
if ((dx < 0) && (ndx <= 0))
{
if (ndx > min_dx)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.