kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=f8d7cb8c006591c04aa63f0b53ba2b0ac3b8ff11

commit f8d7cb8c006591c04aa63f0b53ba2b0ac3b8ff11
Author: Kim Woelders <[email protected]>
Date:   Tue May 3 16:34:20 2022 +0200

    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ć.
---
 src/E.h        |  3 +++
 src/arrange.c  | 34 ++++++++++++++++++++++++++++++++++
 src/mod-misc.c |  6 +++++-
 src/screen.c   |  8 ++++++--
 4 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/src/E.h b/src/E.h
index 44fced22..449d78dd 100644
--- a/src/E.h
+++ b/src/E.h
@@ -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;
diff --git a/src/arrange.c b/src/arrange.c
index 8c741590..96bf6c0c 100644
--- a/src/arrange.c
+++ b/src/arrange.c
@@ -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++)
diff --git a/src/mod-misc.c b/src/mod-misc.c
index 962ab068..ab4c3c0e 100644
--- a/src/mod-misc.c
+++ b/src/mod-misc.c
@@ -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),
diff --git a/src/screen.c b/src/screen.c
index fb4b0ff1..b25b9f21 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-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++)
      {

-- 


Reply via email to