Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod_dock: width of the *dock* area #348

Open
chertyhansky opened this issue Nov 14, 2022 · 8 comments
Open

mod_dock: width of the *dock* area #348

chertyhansky opened this issue Nov 14, 2022 · 8 comments

Comments

@chertyhansky
Copy link
Contributor

I'm using mod_dock and conky, placed to the dock. But the dock width is always 64px, and not depend on the width of conky window. Is it possible to add parameter for dock size to cfg_dock.lua, or any other way to change it?

@rabarbar42
Copy link

rabarbar42 commented Nov 29, 2022 via email

@chertyhansky
Copy link
Contributor Author

2022 11 30-03:34:27

Yes, dock display in vertical. cfg_dock.lua is visible on the screenshot.
Now I'm just edited mod_dock/dock.c to set 430 px width (in a bottom frame, line 285). By default there was 64.

@drheld
Copy link

drheld commented Mar 30, 2023

I'm also seeing this as a regression from notion3 to notion4 where notion3 seemed to size the dock appropriately.

Any ideas? Thanks!

@drheld
Copy link

drheld commented Mar 30, 2023

Adding more details: I'm seeing the dock size 64 pixels wide regardless of how wide the dock actually is.

Not sure if there's a way to customize this if auto-detecting the size is problematic.

@wilhelmy
Copy link
Collaborator

I'm assuming it's hardcoded here: https://github.com/raboof/notion/blob/main/mod_dock/dock.c#L281

Seems the size policy code was added in 2007 and is not available under LGPL and thus can't be added verbatim to notion 4 but should rather be rewritten, given enough interest: https://github.com/raboof/notion/blob/notion3/mod_dock/dock.c#L938

@wilhelmy
Copy link
Collaborator

wilhelmy commented Mar 31, 2023

See below for the diff between notion4 and notion3 (non-lgpl) branch. Please don't copy this code into a pull request. Since the dock code seems more or less self-contained you might have luck running notion4 with the changes from notion3 dock.c applied locally. In this diff output, minus sign indicates notion4 and plus sign notion3.

diff --git a/mod_dock/dock.c b/mod_dock/dock.c
index 581ea5c5..a0dfb848 100644
--- a/mod_dock/dock.c
+++ b/mod_dock/dock.c
@@ -2,7 +2,7 @@
  * Ion dock module
  * Copyright (C) 2003 Tom Payne
  * Copyright (C) 2003 Per Olofsson
- * Copyright (C) 2004-2007 Tuomo Valkonen
+ * Copyright (C) 2004-2009 Tuomo Valkonen
  *
  * by Tom Payne <[email protected]>
  * based on code by Per Olofsson <[email protected]>
@@ -594,34 +594,6 @@ static void dock_arrange_dockapps(WDock *dock, const WRectangle *bd_dockg,
 }
 
 
-static void calc_dock_pos(WRectangle *dg, const WRectangle *pg, int pos)
-{
-    switch(pos&DOCK_HPOS_MASK){
-    case DOCK_HPOS_LEFT:
-        dg->x=pg->x;
-        break;
-    case DOCK_HPOS_CENTER:
-        dg->x=pg->x+(pg->w-dg->w)/2;
-        break;
-    case DOCK_HPOS_RIGHT:
-        dg->x=pg->x+(pg->w-dg->w);
-        break;
-    }
-
-    switch(pos&DOCK_VPOS_MASK){
-    case DOCK_VPOS_TOP:
-        dg->y=pg->y;
-        break;
-    case DOCK_VPOS_MIDDLE:
-        dg->y=pg->y+(pg->h-dg->h)/2;
-        break;
-    case DOCK_VPOS_BOTTOM:
-        dg->y=pg->y+(pg->h-dg->h);
-        break;
-    }
-}
-
-
 static void dock_set_minmax(WDock *dock, int grow, const WRectangle *g)
 {
     dock->min_w=g->w;
@@ -660,12 +632,11 @@ static void dock_managed_rqgeom_(WDock *dock, WRegion *reg, int flags,
                                  bool just_update_minmax)
 {
     WDockApp *dockapp=NULL, *thisdockapp=NULL, thisdockapp_copy;
-    WRectangle parent_geom, dock_geom, border_dock_geom;
+    WRectangle dock_geom, border_dock_geom;
     GrBorderWidths dock_bdw, dockapp_bdw;
     int n_dockapps=0, max_w=1, max_h=1, total_w=0, total_h=0;
     int pos, grow;
     WRectangle tile_size;
-    WWindow *par=REGION_PARENT(dock);
 
     /* dock_resize calls with NULL parameters. */
     assert(reg!=NULL || (geomret==NULL && !(flags&REGION_RQGEOM_TRYONLY)));
@@ -673,18 +644,6 @@ static void dock_managed_rqgeom_(WDock *dock, WRegion *reg, int flags,
     dock_get_pos_grow(dock, &pos, &grow);
     dock_get_tile_size(dock, &tile_size);
 
-    /* Determine parent and tile geoms */
-    parent_geom.x=0;
-    parent_geom.y=0;
-    if(par!=NULL){
-        parent_geom.w=REGION_GEOM(par).w;
-        parent_geom.h=REGION_GEOM(par).h;
-    }else{
-        /* Should not happen in normal operation. */
-        parent_geom.w=1;
-        parent_geom.h=1;
-    }
-
     /* Determine dock and dockapp border widths */
     memset(&dock_bdw, 0, sizeof(GrBorderWidths));
     memset(&dockapp_bdw, 0, sizeof(GrBorderWidths));
@@ -778,14 +737,15 @@ static void dock_managed_rqgeom_(WDock *dock, WRegion *reg, int flags,
             break;
         }
     }else{
-        dock_geom.w=0;
-        dock_geom.h=0;
+        dock_geom.w=tile_size.w;
+        dock_geom.h=tile_size.h;
     }
+
+    border_dock_geom.x=REGION_GEOM(dock).x;
+    border_dock_geom.y=REGION_GEOM(dock).y;
     border_dock_geom.w=dock_bdw.left+dock_geom.w+dock_bdw.right;
     border_dock_geom.h=dock_bdw.top+dock_geom.h+dock_bdw.bottom;
 
-    calc_dock_pos(&border_dock_geom, &parent_geom, pos);
-
     /* Fit dock to new geom if required */
     if(!(flags&REGION_RQGEOM_TRYONLY)){
         WRQGeomParams rq=RQGEOMPARAMS_INIT;
@@ -975,6 +935,33 @@ static void mplexpos(int pos, int *mpos)
 }
 
 
+static void mplexszplcy(int pos, WSizePolicy *szplcy)
+{
+    int hp=pos&DOCK_HPOS_MASK, vp=pos&DOCK_VPOS_MASK;
+    WSizePolicy p;
+
+    p=(vp!=DOCK_VPOS_MIDDLE
+       ? (vp==DOCK_VPOS_TOP
+          ? (hp!=DOCK_HPOS_CENTER
+             ? (hp==DOCK_HPOS_RIGHT
+                ? SIZEPOLICY_GRAVITY_NORTHEAST
+                : SIZEPOLICY_GRAVITY_NORTHWEST)
+             : SIZEPOLICY_GRAVITY_NORTH)
+          : (hp!=DOCK_HPOS_CENTER
+             ? (hp==DOCK_HPOS_RIGHT
+                ? SIZEPOLICY_GRAVITY_SOUTHEAST
+                : SIZEPOLICY_GRAVITY_SOUTHWEST)
+             : SIZEPOLICY_GRAVITY_SOUTH))
+       : (hp!=DOCK_HPOS_CENTER
+          ? (hp==DOCK_HPOS_RIGHT
+             ? SIZEPOLICY_GRAVITY_EAST
+             : SIZEPOLICY_GRAVITY_WEST)
+          : SIZEPOLICY_GRAVITY_CENTER));
+
+    *szplcy=p;
+}
+
+
 static void dock_do_set(WDock *dock, ExtlTab conftab, bool resize)
 {
     char *s;
@@ -1018,6 +1005,10 @@ static void dock_do_set(WDock *dock, ExtlTab conftab, bool resize)
                     dock_managed_rqgeom_(dock, NULL, 0, NULL, NULL, TRUE);
                 }
                 mplex_set_stdisp(par, (WRegion*)dock, &din);
+            }else if((WRegion*)par==REGION_MANAGER(dock)){
+                WSizePolicy szplcy;
+                mplexszplcy(dock->pos, &szplcy);
+                mplex_set_szplcy(par, (WRegion*)dock, szplcy);
             }
         }
 
@@ -1106,8 +1097,6 @@ static bool dock_init(WDock *dock, WWindow *parent, const WFitParams *fp)
 
     region_add_bindmap((WRegion*)dock, dock_bindmap);
 
-    ((WRegion*)dock)->flags|=REGION_SKIP_FOCUS;
-
     window_select_input(&(dock->win), IONCORE_EVENTMASK_CWINMGR);
 
     dock_brush_get(dock);
@@ -1147,6 +1136,7 @@ WDock *mod_dock_create(ExtlTab tab)
     WDock *dock=NULL;
     WRegion *stdisp=NULL;
     WMPlexSTDispInfo din;
+    WFitParams fp;
 
     if(extl_table_gets_s(tab, "mode", &mode)){
         if(strcmp(mode, "floating")==0){
@@ -1184,62 +1174,52 @@ WDock *mod_dock_create(ExtlTab tab)
     }
 
     /* Create the dock */
+    fp.mode=REGION_FIT_BOUNDS|REGION_FIT_WHATEVER;
+    fp.g.x=0;
+    fp.g.y=0;
+    fp.g.w=1;
+    fp.g.h=1;
 
-    if(floating){
-        WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
-
-        par.flags=(MPLEX_ATTACH_UNNUMBERED
-                   |MPLEX_ATTACH_SIZEPOLICY
-                   |MPLEX_ATTACH_GEOM);
-
-        par.szplcy=SIZEPOLICY_FREE;
-        par.geom.x=0;
-        par.geom.y=0;
-        par.geom.w=1;
-        par.geom.h=1;
-
-        if(extl_table_is_bool_set(tab, "floating_hidden"))
-            par.flags|=MPLEX_ATTACH_HIDDEN;
-
-        dock=(WDock*)mplex_do_attach_new((WMPlex*)screen, &par,
-                                         (WRegionCreateFn*)create_dock,
-                                         NULL);
-    }else{
-        WFitParams fp;
-
-        fp.mode=REGION_FIT_BOUNDS|REGION_FIT_WHATEVER;
-        fp.g.x=0;
-        fp.g.y=0;
-        fp.g.w=1;
-        fp.g.h=1;
-
-        dock=create_dock((WWindow*)screen, &fp);
-    }
+    dock=create_dock((WWindow*)screen, &fp);
 
     if(dock==NULL){
         warn("Failed to create dock.");
         return NULL;
     }
 
+
     /* Get parameters */
     dock->save=FALSE;
     dock_do_set(dock, tab, FALSE);
 
+    /* Calculate min/max size */
+    dock_managed_rqgeom_(dock, NULL, 0, NULL, NULL, TRUE);
+
     /* Final setup */
     if(floating){
-        WRQGeomParams rq=RQGEOMPARAMS_INIT;
-        const WRectangle *pg=&REGION_GEOM(screen);
+        WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
+        WRegionAttachData data;
+
+        par.flags=(MPLEX_ATTACH_UNNUMBERED
+                   |MPLEX_ATTACH_SIZEPOLICY
+                   |MPLEX_ATTACH_GEOM
+                   |MPLEX_ATTACH_PASSIVE);
 
-        /* Just calculate real min/max size */
-        dock_managed_rqgeom_(dock, NULL, 0, NULL, NULL, TRUE);
+        par.geom.w=dock->min_w;
+        par.geom.h=dock->min_h;
+        par.geom.x=0;
+        par.geom.y=0;
 
-        rq.geom.w=MINOF(dock->min_w, pg->w);
-        rq.geom.h=MINOF(dock->min_h, pg->h);
-        calc_dock_pos(&rq.geom, pg, dock->pos);
+        mplexszplcy(dock->pos, &par.szplcy);
 
-        region_rqgeom((WRegion*)dock, &rq, NULL);
+        if(extl_table_is_bool_set(tab, "floating_hidden"))
+            par.flags|=MPLEX_ATTACH_HIDDEN;
 
-        return dock;
+        data.type=REGION_ATTACH_REPARENT;
+        data.u.reg=(WRegion*)dock;
+
+        if(mplex_do_attach((WMPlex*)screen, &par, &data))
+            return dock;
     }else{
         mplexpos(dock->pos, &din.pos);
         din.fullsize=FALSE; /* not supported */

@wilhelmy
Copy link
Collaborator

Actually, the file header for notion3 dock.c states LGPL 2.1+ license with original authorship by Tom Payne and Per Olofsson as main authors for mod_dock. I think this means we can use notion3 mod_dock in lgpl notion4?

@wilhelmy
Copy link
Collaborator

I've verified this, the updated ion3 LICENSE document I found in other places (such as https://github.com/jan0sch/Ion3/blob/master/LICENSE) states Unless otherwise indicated in components taken from elsewhere, this software is licensed under the GNU Lesser General Public License, version 2.1 ("LGPL", reproduced below), extended and modified with the following terms and all other files reference the LICENSE document for copyright terms. This means that mod_dock from ion3/notion3 can be legally imported into notion 4.

Any volunteers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants