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 c9ab3da348c5185bcbe741846287ad66ac6d4165
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Sun Aug 22 09:28:18 2021 +0200

    Pass screen geometry around in Area struct
---
 src/arrange.c    | 47 +++++++++++++++-----------------
 src/ewin-ops.c   |  9 ++++--
 src/ewins.c      | 21 +++++++-------
 src/menus.c      | 50 +++++++++++++++++-----------------
 src/moveresize.c | 14 ++++++----
 src/screen.c     | 83 ++++++++++++++++++++++++--------------------------------
 src/screen.h     | 18 +++++-------
 src/size.c       |  9 ++++--
 src/warp.c       |  7 +++--
 9 files changed, 126 insertions(+), 132 deletions(-)

diff --git a/src/arrange.c b/src/arrange.c
index 0dee023e..a1a7ceef 100644
--- a/src/arrange.c
+++ b/src/arrange.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
- * Copyright (C) 2004-2022 Kim Woelders
+ * Copyright (C) 2004-2023 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
@@ -323,20 +323,17 @@ ArrangeRects(const RectBox *fixed, int fixed_count, RectBox *floating,
     ty2 = starty + height;
     if (initial_window)
     {
-        int             xx1, yy1, xx2, yy2;
-
-        ScreenGetAvailableAreaByPointer(&xx1, &yy1, &xx2, &yy2,
-                                        Conf.place.ignore_struts);
-        xx2 += xx1;
-        yy2 += yy1;
-        if (tx1 < xx1)
-            tx1 = xx1;
-        if (tx2 > xx2)
-            tx2 = xx2;
-        if (ty1 < yy1)
-            ty1 = yy1;
-        if (ty2 > yy2)
-            ty2 = yy2;
+        Area            area;
+
+        ScreenGetAvailableAreaByPointer(&area, Conf.place.ignore_struts);
+        if (tx1 < area.x)
+            tx1 = area.x;
+        if (tx2 > area.x + area.w)
+            tx2 = area.x + area.w;
+        if (ty1 < area.y)
+            ty1 = area.y;
+        if (ty2 > area.y + area.h)
+            ty2 = area.y + area.h;
     }
 #if DEBUG_ARRANGE
     Eprintf("Target area %d,%d -> %d,%d\n", tx1, ty1, tx2, ty2);
@@ -663,28 +660,28 @@ ArrangeEwinXY(EWin *ewin, int *px, int *py)
 void
 ArrangeEwinCenteredXY(EWin *ewin, int *px, int *py)
 {
-    int             x, y, w, h;
+    Area            area;
 
-    ScreenGetAvailableAreaByPointer(&x, &y, &w, &h, Conf.place.ignore_struts);
-    *px = (w - EoGetW(ewin)) / 2 + x;
-    *py = (h - EoGetH(ewin)) / 2 + y;
+    ScreenGetAvailableAreaByPointer(&area, Conf.place.ignore_struts);
+    *px = (area.w - EoGetW(ewin)) / 2 + area.x;
+    *py = (area.h - EoGetH(ewin)) / 2 + area.y;
 }
 
 void
 ArrangeEwinCenteredOn(EWin *ewin, int x, int y, int w, int h, int *px, int *py)
 {
-    int             sx, sy, sw, sh;
+    Area            area;
 
     x += (w - EoGetW(ewin)) / 2;
     y += (h - EoGetH(ewin)) / 2;
 
-    ScreenGetAvailableArea(x, y, &sx, &sy, &sw, &sh, Conf.place.ignore_struts);
+    ScreenGetAvailableArea(x, y, &area, Conf.place.ignore_struts);
 
     /* keep it all on this screen if possible */
-    x = MIN(x, sx + sw - EoGetW(ewin));
-    y = MIN(y, sy + sh - EoGetH(ewin));
-    x = MAX(x, sx);
-    y = MAX(y, sy);
+    x = MIN(x, area.x + area.w - EoGetW(ewin));
+    y = MIN(y, area.y + area.h - EoGetH(ewin));
+    x = MAX(x, area.x);
+    y = MAX(y, area.y);
 
     *px = x;
     *py = y;
diff --git a/src/ewin-ops.c b/src/ewin-ops.c
index 674fd728..2a73bc8e 100644
--- a/src/ewin-ops.c
+++ b/src/ewin-ops.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
- * Copyright (C) 2004-2022 Kim Woelders
+ * Copyright (C) 2004-2023 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
@@ -1218,6 +1218,7 @@ void
 EwinOpFullscreen(EWin *ewin, int source __UNUSED__, int on)
 {
     int             x, y, w, h, ww, hh;
+    Area            area;
     EWin          **lst;
     int             i, num;
     const Border   *b;
@@ -1248,8 +1249,12 @@ EwinOpFullscreen(EWin *ewin, int source __UNUSED__, int on)
         {
             EventsUpdateXY(&x, &y);
         }
-        ScreenGetAvailableArea(x, y, &x, &y, &w, &h,
+        ScreenGetAvailableArea(x, y, &area,
                                Conf.place.ignore_struts_fullscreen);
+        x = area.x;
+        y = area.y;
+        w = area.w;
+        h = area.h;
 
         ewin->state.fullscreen = 1;
 
diff --git a/src/ewins.c b/src/ewins.c
index f35f3156..50407760 100644
--- a/src/ewins.c
+++ b/src/ewins.c
@@ -636,29 +636,30 @@ EwinGetPosition(const EWin *ewin, int x, int y, int grav, int *px, int *py)
 static void
 EwinKeepOnScreen(const EWin *ewin, int wn, int hn, int *px, int *py)
 {
-    int             x = *px, y = *py, w, h;
-    int             sx, sy, sw, sh, xy;
+    int             x = *px, y = *py, w, h, xy;
+    Area            area;
 
     w = EoGetW(ewin);
     h = EoGetH(ewin);
 
-    ScreenGetAvailableArea(x, y, &sx, &sy, &sw, &sh, Conf.place.ignore_struts);
+    ScreenGetAvailableArea(x, y, &area, Conf.place.ignore_struts);
 
     /* Quit if not on-screen to begin with */
-    if (x < sx || x + w > sx + sw || y < sy || y + h > sy + sh)
+    if (x < area.x || x + w > area.x + area.w ||
+        y < area.y || y + h > area.y + area.h)
         return;
 
     /* Attempt to keep on-screen */
-    xy = sx + sw - (w - ewin->client.w + wn);
+    xy = area.x + area.w - (w - ewin->client.w + wn);
     if (x > xy)
         x = xy;
-    if (x < sx)
-        x = sx;
-    xy = sy + sh - (h - ewin->client.h + hn);
+    if (x < area.x)
+        x = area.x;
+    xy = area.y + area.h - (h - ewin->client.h + hn);
     if (y > xy)
         y = xy;
-    if (y < sy)
-        y = sy;
+    if (y < area.y)
+        y = area.y;
 
     *px = x;
     *py = y;
diff --git a/src/menus.c b/src/menus.c
index 267627aa..b2ffef44 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -334,22 +334,22 @@ MenuShow(Menu *m, char noshow)
         b = BorderFind(m->style->border_name);
         if (b)
         {
-            int             sx, sy, sw, sh;
+            Area            area;
             const EImageBorder *pad;
 
             pad = BorderGetSize(b);
 
-            head_num = ScreenGetGeometryByPointer(&sx, &sy, &sw, &sh);
+            head_num = ScreenGetGeometryByPointer(&area);
 
-            if (wx > sx + sw - mw - pad->right)
-                wx = sx + sw - mw - pad->right;
-            if (wx < sx + pad->left)
-                wx = sx + pad->left;
+            if (wx > area.x + area.w - mw - pad->right)
+                wx = area.x + area.w - mw - pad->right;
+            if (wx < area.x + pad->left)
+                wx = area.x + pad->left;
 
-            if (wy > sy + sh - mh - pad->bottom)
-                wy = sy + sh - mh - pad->bottom;
-            if (wy < sy + pad->top)
-                wy = sy + pad->top;
+            if (wy > area.y + area.h - mh - pad->bottom)
+                wy = area.y + area.h - mh - pad->bottom;
+            if (wy < area.y + pad->top)
+                wy = area.y + pad->top;
         }
     }
 
@@ -1471,7 +1471,7 @@ static void
 _MenusSlideCheck(Menu *m, int xo, int yo, int ww, int hh, int *pdx, int *pdy)
 {
     EWin           *ewin;
-    int             sx, sy, sw, sh;
+    Area            area;
     int             xdist, ydist;
 
     xdist = ydist = 0;
@@ -1479,23 +1479,23 @@ _MenusSlideCheck(Menu *m, int xo, int yo, int ww, int hh, int *pdx, int *pdy)
     if (!Conf.menus.onscreen)
         goto done;
 
-    ScreenGetGeometryByHead(Mode_menus.first->ewin->head, &sx, &sy, &sw, &sh);
+    ScreenGetGeometryByHead(Mode_menus.first->ewin->head, &area);
 
     ewin = m->ewin;
 
-    if (EoGetX(Mode_menus.first->ewin) < sx)
-        xdist = sx - EoGetX(Mode_menus.first->ewin);
-    if (EoGetX(ewin) + xdist + xo + ww > sx + sw)
-        xdist = sx + sw - (EoGetX(ewin) + xo + ww);
-    if (EoGetX(ewin) + xdist + xo < sx)
-        xdist = sx - (EoGetX(ewin) + xo);
-
-    if (EoGetY(Mode_menus.first->ewin) < sy)
-        ydist = sy - EoGetY(Mode_menus.first->ewin);
-    if (EoGetY(ewin) + ydist + yo + hh > sy + sh)
-        ydist = sy + sh - (EoGetY(ewin) + yo + hh);
-    if (EoGetY(ewin) + ydist + yo < sy)
-        ydist = sy - (EoGetY(ewin) + yo);
+    if (EoGetX(Mode_menus.first->ewin) < area.x)
+        xdist = area.x - EoGetX(Mode_menus.first->ewin);
+    if (EoGetX(ewin) + xdist + xo + ww > area.x + area.w)
+        xdist = area.x + area.w - (EoGetX(ewin) + xo + ww);
+    if (EoGetX(ewin) + xdist + xo < area.x)
+        xdist = area.x - (EoGetX(ewin) + xo);
+
+    if (EoGetY(Mode_menus.first->ewin) < area.y)
+        ydist = area.y - EoGetY(Mode_menus.first->ewin);
+    if (EoGetY(ewin) + ydist + yo + hh > area.y + area.h)
+        ydist = area.y + area.h - (EoGetY(ewin) + yo + hh);
+    if (EoGetY(ewin) + ydist + yo < area.y)
+        ydist = area.y - (EoGetY(ewin) + yo);
 
   done:
     *pdx = xdist;
diff --git a/src/moveresize.c b/src/moveresize.c
index 3f880c14..011af94e 100644
--- a/src/moveresize.c
+++ b/src/moveresize.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
- * Copyright (C) 2004-2022 Kim Woelders
+ * Copyright (C) 2004-2023 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
@@ -475,8 +475,9 @@ _SnapEwin(EWin *ewin, int dx, int dy, int *new_dx, int *new_dy)
     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_bound, bottom_bound, left_bound, right_bound;
     int             top_strut, bottom_strut, left_strut, right_strut;
+    Area            area;
 
     if (!ewin)
         return;
@@ -488,10 +489,11 @@ _SnapEwin(EWin *ewin, int dx, int dy, int *new_dx, int *new_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;
+    ScreenGetGeometry(ewin->shape_x, ewin->shape_y, &area);
+    left_bound = area.x;
+    top_bound = area.y;
+    right_bound = left_bound + area.w;
+    bottom_bound = top_bound + area.h;
 
     left_strut = left_bound + Conf.place.screen_struts.left;
     right_strut = right_bound - Conf.place.screen_struts.right;
diff --git a/src/screen.c b/src/screen.c
index 19535d51..44fe62df 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
- * Copyright (C) 2003-2022 Kim Woelders
+ * Copyright (C) 2003-2023 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
@@ -300,31 +300,25 @@ ScreenShowInfo(const char *prm __UNUSED__)
 }
 
 void
-ScreenGetGeometryByHead(int head, int *px, int *py, int *pw, int *ph)
+ScreenGetGeometryByHead(int head, Area *pa)
 {
     EScreen        *ps;
-    int             x, y, w, h;
 
     if (head >= 0 && head < n_screens)
     {
         ps = p_screens + head;
-        x = ps->x;
-        y = ps->y;
-        w = ps->w;
-        h = ps->h;
+        pa->x = ps->x;
+        pa->y = ps->y;
+        pa->w = ps->w;
+        pa->h = ps->h;
     }
     else
     {
-        x = 0;
-        y = 0;
-        w = WinGetW(VROOT);
-        h = WinGetH(VROOT);
+        pa->x = 0;
+        pa->y = 0;
+        pa->w = WinGetW(VROOT);
+        pa->h = WinGetH(VROOT);
     }
-
-    *px = x;
-    *py = y;
-    *pw = w;
-    *ph = h;
 }
 
 int
@@ -363,18 +357,18 @@ ScreenGetHead(int xi, int yi)
 }
 
 int
-ScreenGetGeometry(int xi, int yi, int *px, int *py, int *pw, int *ph)
+ScreenGetGeometry(int xi, int yi, Area *pa)
 {
     int             head;
 
     head = ScreenGetHead(xi, yi);
-    ScreenGetGeometryByHead(head, px, py, pw, ph);
+    ScreenGetGeometryByHead(head, pa);
 
     return head;
 }
 
 static void
-_VRootGetAvailableArea(int *px, int *py, int *pw, int *ph)
+_VRootGetAvailableArea(Area *pa)
 {
     EWin           *const *lst, *ewin;
     int             i, num, l, r, t, b;
@@ -385,6 +379,7 @@ _VRootGetAvailableArea(int *px, int *py, int *pw, int *ph)
     b = Conf.place.screen_struts.bottom;
 
     lst = EwinListGetAll(&num);
+
     for (i = 0; i < num; i++)
     {
         ewin = lst[i];
@@ -399,59 +394,53 @@ _VRootGetAvailableArea(int *px, int *py, int *pw, int *ph)
             b = ewin->strut.bottom;
     }
 
-    *px = l;
-    *py = t;
-    *pw = WinGetW(VROOT) - (l + r);
-    *ph = WinGetH(VROOT) - (t + b);
+    pa->x = l;
+    pa->y = t;
+    pa->w = WinGetW(VROOT) - (l + r);
+    pa->h = WinGetH(VROOT) - (t + b);
 }
 
 int
-ScreenGetAvailableArea(int xi, int yi, int *px, int *py, int *pw, int *ph,
-                       int ignore_struts)
+ScreenGetAvailableArea(int xi, int yi, Area *pa, int ignore_struts)
 {
-    int             x1, y1, w1, h1, x2, y2, w2, h2, head;
+    int             head;
+    Area            area;       /* Available */
 
-    head = ScreenGetGeometry(xi, yi, &x1, &y1, &w1, &h1);
+    head = ScreenGetGeometry(xi, yi, pa);
 
     if (!ignore_struts)
     {
-        _VRootGetAvailableArea(&x2, &y2, &w2, &h2);
-        if (x1 < x2)
-            x1 = x2;
-        if (y1 < y2)
-            y1 = y2;
-        if (w1 > w2)
-            w1 = w2;
-        if (h1 > h2)
-            h1 = h2;
-    }
+        _VRootGetAvailableArea(&area);
+        if (pa->x < area.x)
+            pa->x = area.x;
+        if (pa->y < area.y)
+            pa->y = area.y;
+        if (pa->w > area.w)
+            pa->w = area.w;
+        if (pa->h > area.h)
+            pa->h = area.h;
 
-    *px = x1;
-    *py = y1;
-    *pw = w1;
-    *ph = h1;
+    }
 
     return head;
 }
 
 int
-ScreenGetGeometryByPointer(int *px, int *py, int *pw, int *ph)
+ScreenGetGeometryByPointer(Area *pa)
 {
     int             pointer_x, pointer_y;
 
     EQueryPointer(NULL, &pointer_x, &pointer_y, NULL, NULL);
 
-    return ScreenGetGeometry(pointer_x, pointer_y, px, py, pw, ph);
+    return ScreenGetGeometry(pointer_x, pointer_y, pa);
 }
 
 int
-ScreenGetAvailableAreaByPointer(int *px, int *py, int *pw, int *ph,
-                                int ignore_struts)
+ScreenGetAvailableAreaByPointer(Area *pa, int ignore_struts)
 {
     int             pointer_x, pointer_y;
 
     EQueryPointer(NULL, &pointer_x, &pointer_y, NULL, NULL);
 
-    return ScreenGetAvailableArea(pointer_x, pointer_y, px, py, pw, ph,
-                                  ignore_struts);
+    return ScreenGetAvailableArea(pointer_x, pointer_y, pa, ignore_struts);
 }
diff --git a/src/screen.h b/src/screen.h
index 06f145c4..9fe35a78 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
- * Copyright (C) 2004-2016 Kim Woelders
+ * Copyright (C) 2004-2023 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
@@ -29,15 +29,11 @@ void            ScreenSplit(unsigned int nx, unsigned int ny);
 void            ScreenShowInfo(const char *prm);
 int             ScreenGetCurrent(void);
 int             ScreenGetHead(int xi, int yi);
-int             ScreenGetGeometry(int x, int y, int *px, int *py,
-                                  int *pw, int *ph);
-void            ScreenGetGeometryByHead(int head, int *px, int *py,
-                                        int *pw, int *ph);
-int             ScreenGetAvailableArea(int x, int y, int *px, int *py,
-                                       int *pw, int *ph, int ignore_struts);
-int             ScreenGetGeometryByPointer(int *px, int *py, int *pw, int *ph);
-int             ScreenGetAvailableAreaByPointer(int *px, int *py,
-                                                int *pw, int *ph,
-                                                int ignore_struts);
+int             ScreenGetGeometry(int x, int y, Area * pa);
+void            ScreenGetGeometryByHead(int head, Area * pa);
+int             ScreenGetAvailableArea(int x, int y, Area * pa,
+                                       int ignore_struts);
+int             ScreenGetGeometryByPointer(Area * pa);
+int             ScreenGetAvailableAreaByPointer(Area * pa, int ignore_struts);
 
 #endif                          /* _SCREEN_H_ */
diff --git a/src/size.c b/src/size.c
index 6bb04876..44d8edfa 100644
--- a/src/size.c
+++ b/src/size.c
@@ -815,6 +815,7 @@ void
 MaxSizeHV(EWin *ewin, const char *resize_type, int hor, int ver, int flags)
 {
     int             x, y, w, h, x1, x2, y1, y2, type, bl, br, bt, bb;
+    Area            area;
     EWin           *const *lst;
     int             num, speed;
     int             old_hor = ewin->state.maximized_horz != 0;
@@ -936,10 +937,12 @@ MaxSizeHV(EWin *ewin, const char *resize_type, int hor, int ver, int flags)
     case MAX_HALF_S:
     case MAX_HALF_E:
     case MAX_HALF_W:
-        ScreenGetAvailableArea(x + w / 2, y + h / 2, &x1, &y1, &x2, &y2,
+        ScreenGetAvailableArea(x + w / 2, y + h / 2, &area,
                                Conf.place.ignore_struts_maximize);
-        x2 += x1;
-        y2 += y1;
+        x1 = area.x;
+        y1 = area.y;
+        x2 = x1 + area.w;
+        y2 = y1 + area.h;
 
         if (Conf.movres.dragbar_nocover && type != MAX_ABSOLUTE)
         {
diff --git a/src/warp.c b/src/warp.c
index 5ce949de..29133d37 100644
--- a/src/warp.c
+++ b/src/warp.c
@@ -145,6 +145,7 @@ WarpFocusWinShow(WarpFocusWin *fw)
     EImageBorder   *pad;
     EWin           *ewin;
     int             i, x, y, w, h, ww, hh;
+    Area            area;
     char            s[1024], ss[32];
     const char     *fmt;
 
@@ -199,9 +200,9 @@ WarpFocusWinShow(WarpFocusWin *fw)
     /* Reset shape */
     EShapeSetMask(EoGetWin(fw), 0, 0, NoXID);
 
-    ScreenGetAvailableAreaByPointer(&x, &y, &ww, &hh, Conf.place.ignore_struts);
-    x += (ww - w) / 2;
-    y += (hh - h * warplist_num) / 2;
+    ScreenGetAvailableAreaByPointer(&area, Conf.place.ignore_struts);
+    x = area.x + (area.w - w) / 2;
+    y = area.y + (area.h - h * warplist_num) / 2;
     EoMoveResize(fw, x, y, w, h * warplist_num);
 
     for (i = 0; i < warplist_num; i++)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to