WinGrid tweaked: Added new Center, Grow and Shrink functions, try it if you like

Forum Forums antiX-development Development WinGrid tweaked: Added new Center, Grow and Shrink functions, try it if you like

  • This topic has 8 replies, 2 voices, and was last updated Jul 31-9:04 pm by BobC.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • #24398

    I am going to work on new tricks for WinGrid.

    Concepts are

    1. Do it all in 1 script, NOT! It runs fine now, if it ain’t broke, don’t fix it.
    2. Same functions as currently
    3. Add a Grow function that makes the current window larger
    4. Add a Shrink function that makes the current window smaller
    5. Provide symmetrical key maps for the number row and numeric keypad and mate nicely with WinArrange in IceWM.
    6. I was hoping to make a demo video of it on an old PIII 400 to show how fast it is on an antique PC, but all of my Pentium III machines are having video problems so have to use something else. My guess is that I can jockey 6 or 7 windows pretty well and it should be lightning fast compared to other distros. I have one old machine left that I haven’t tried down in the basement running Xp to control a robit. I might get lucky with that one.
    7. Add a 5th center window

    I did find a problem in my testing with a Firefox browser window, but not sure the real cause. Oh THAT is what you were talking about, skidoo. It never occurred to me that was why it did that.

    I am reminded of a lesson I learned at age 12, when we went 1500 miles pulling a trailer and 2 boats, and 7 people, and we stopped overnight up in the Smokey Mountains and camped for the night. The car had made it all that way, running reasonably well, considering all it was pulling in the mountains. Well my dad decided that it wasn’t running well enough, so even though he didn’t have a feeler gauge, he decided the ignition and points were set wrong, and concluded that a matchbook cover was the right thickness to set them to. So he changed it, and the car would barely start, let alone run and pull all that weight. He fiddled with it, cussing away, for hours, changing it and retesting it, until eventually he was lucky enough to get it close enough that it kinda ran. We made it to a town and he bought a gauge and timing light, and got it fixed the next day. After that he would always say “If it ain’t broke, don’t fix it”.

    PS: For best results get the latest zip file of code

    • This topic was modified 1 year ago by BobC. Reason: Getting older and wiser

    I am interested in this. It would be very usefull when I am on the tablet, as manually resizing with your finger is not ideal.

    On my 768p resolution, some apps just take up too much of the screen. For example, when extracting tar.gz, the program would open and ocupy more space than the screen provides, making it impossible for my mouse to reach the tittle bar. I would have to use Alt + right-click to resize and Alt + left-click to move the window each time until I got fed up and made fluxbox remember the window size and position for this app.
    Other times other programs did this, I opted for modifying the double click behavior on title bar of the window to toggle between maximize and placing the window in the top middle of the screen ocupying 70% wide and high of the screen. Very usefull, as now I only need to Maximize with Control + 9 (or my personal binding Super + Up-arrow) and double-clicking the window’s title bar to reset it to a good size.

    Let us know how this goes.


    The logic on it is tough, let alone trying to do it in bash (is it bash?, I never know, lol).

    I will think it aloud, need to adjust syntax for language used. I will just try to figure out how to grow the window first. If I can’t grow it, there is no point shrinking it.

    Is that the red pill or the blue pill? I always forget these things…

    Hmmmm, needs growth speed to be selectable, ie should the window grow 1/8th or 1/10th, etc

    # i removed the original pseudo code logic
    • This reply was modified 1 year ago by BobC. Reason: 2nd try
    • This reply was modified 1 year ago by BobC. Reason: make growth rate a variable = gdiv
    • This reply was modified 1 year ago by BobC.

    Ok, I got the Center function working, and the Grow function working (I think). The center function is called and the grow function is called

    For IceWM with the menu at the bottom and not double height or autohiding, the ~/.config/wingrid file needs the following line or the bottom of the windows will overlap the toolbar

    The center function was easy, but the grow function got pretty wild for someone that doesn’t really know the language syntax.

    Here are the ~/.icewm/keys entries I am using for this. I agree with skidoo that we should be more careful assigning keys, and would be happy to make the defaults something else if someone would suggest what keys to use instead. The control number row keys up to 0 have been the standard antiX assigned keys since I can remember, so I left them alone.

    I noticed that when it ran out of space, the resizing got funky. Also, when growing an LXTerminal window the font got bigger. Not sure how to fix that one, so suggestions will be appreciated…

    # Wingrid on Ctrl+ 1 thru 0 on number row
    key "Ctrl+1"
    key "Ctrl+2"
    key "Ctrl+3"
    key "Ctrl+4"
    key "Ctrl+5"
    key "Ctrl+6"
    key "Ctrl+7"
    key "Ctrl+8"
    key "Ctrl+9"
    key "Ctrl+0"
    key "Ctrl+minus"
    key "Ctrl+equal"
    key "Ctrl+plus"
    # Wingrid on Ctrl+ KP rose
    key "Ctrl+KP_Left" # Left-Move window to Left 
    key "Ctrl+KP_Right" # Right-Move window to Right 
    key "Ctrl+KP_Up" # Up-Move window Top 
    key "Ctrl+KP_Down" # Down-Move window to Bottom 
    key "Ctrl+KP_Home" # Home-Move window to Top Left 
    key "Ctrl+KP_Prior" # PgUp-Move window Top Right 
    key "Ctrl+KP_End" # End-Move window to Bottom Left 
    key "Ctrl+KP_Next" # PgDn-Move window to Bottom Right 
    key "Ctrl+KP_Insert" # 0-Maximize window 
    key "Ctrl+KP_Begin" # 5-Center window
    ##key "Ctrl+KP_Delete" # .-Close window
    key "Ctrl+KP_Add" # +-Grow window
    key "Ctrl+KP_Subtract" # --Shrink window
    # app-select on Ctrl+Space
    key "Ctrl+Space" app-select

    I attached the files renamed as .txt if anyone would be so kind as to look at them or try them 🙂

    Here is the main portion of the grow function…

    removed old code, see corrected code in later post
    • This reply was modified 1 year ago by BobC.
    • This reply was modified 1 year ago by BobC. Reason: updated code to current
    • This reply was modified 1 year ago by BobC. Reason: removed old code

    I found the height bug and got it fixed. I also improved the grow algorithm so it makes more sense visually.

    It still allows it to grow too wide, so I still need to look at that.

    It’s pretty close. Once I get the grow function working to where I’m totally happy with it, I’ll use it as a template for the shrink function.

    Let me know if anyone tries it or likes/dislikes/suggestions, etc.


    Ok, I think the grow function is working well, now. I like it! It grows any window up to full screen in a few steps, with how many depending on how big the initial window was as a ratio to net screen size. The initial window size can be any size or position, not just a WinGrid sized rectangle in a corner. It grows all the way around until it hits edges, and after that point it grows twice as fast to the other edge. It only works with one screen, but that is what WinGrid was built to work with.

    As mentioned above, for it to work correctly you need keys entries to run the scripts from above and:
    For IceWM with the menu at the bottom and not double height or autohiding, the ~/.config/wingrid file needs the following line or the bottom of the windows will overlap the toolbar

    Here is the corrected main section of code…

    # --------------------
    # Construct Parameters
    # --------------------
    # Capture screen resolution value
    SCREENRES=$(xdpyinfo | awk '/dimensions:/ { sub("x", " "); print $2" "$3 }')
    # Extract screen resolution into height and width components
    # Calculate 50% of the screen width and height values
    # Reference used by window manager when positioning the window (always zero)
    # Distance from screen top edge to top edge of top window
    # Distance from screen left edge to left edge of left window
    # Current Position and Dimensions of window
    WINID=$(xdotool getactivewindow)
    eval $(xwininfo -id "$WINID" |
          sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/WCURPOSX=\1/p" \
                 -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/WCURPOSY=\1/p" \
                 -e "s/^ \+Width: \+\([0-9]\+\).*/WINWIDTH=\1/p" \
                 -e "s/^ \+Height: \+\([0-9]\+\).*/WINHEIGHT=\1/p" )
    # current
    echo "wingrid-grow starting info"
    echo "Grav,XPos,YPos,Xwide,Xhigh g=$GRAVITY xp=$WCURPOSX yp=$WCURPOSY xw=$WINWIDTH yh=$WINHEIGHT"
    # total available screen size
    # growth divisor 8 = grow 1/8 of avail space on each side, each time if possible
    #    lower numbers will grow faster, like taking the red pill :)               
    # grow window logic
    # grow by 1/GROWDIV of remaining area on each side, limited to min and max screen coordinates
    # x axis
    # if any room, grow window wider
    if [ "$AVAILX" -gt "0" ]
       # if not enough room to left, limit and grow more to right if possible
       if [ "$WCURPOSX" -le "$OFFSETLEFT" ]
       # limit grow to right
       if [ "$WINWIDTH" -gt "$NETSCREENWIDTH" ]
    # y axis
    # if any room, grow window taller
    if [ "$AVAILY" -gt "0" ]
       # if not enough room above, limit and grow more below if possible
       if [ "$WCURPOSY" -le "$OFFSETTOP" ]
       # limit grow below
       if [ "$WINHEIGHT" -gt "$NETSCREENHEIGHT" ]
    echo "wingrid-grow results"
    echo "Grav,XPos,YPos,Xwide,Xhigh g=$GRAVITY xp=$WCURPOSX yp=$WCURPOSY xw=$WINWIDTH yh=$WINHEIGHT"
    # ----------------------------
    # Put Window into Grid Pattern
    # ----------------------------
    # Ensure the active window is not in maximized mode nor in fullscreen mode
    wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert
    wmctrl -r :ACTIVE: -b remove,fullscreen
    # Position and resize the active window 

    The shrink function is now working as well. I had to shrink slower than grow.

    Very strange!

    All current programs in this zip file. Let me know if you find any problems. My debug echos are still in, just in case…


    Fantastic work, BobC!
    Once I get back my tablet (I have lended it), I will test it out there. I have set up a custom layout for OnBoard onscreen keyboard and will assign some buttons to Control + Super + “plus symbol” (for increasing the Window size) and Control + Super + “minus symbol” for decreasing the window size.
    Thanks for your hard work.


    I did an upgrade to my wingrid….

    Thanks anticapitalista!

    And BTW, thanks Dave, your name isn’t in it anywhere but I heard you wrote it…

    So after upgrading the wingrid package…

    For this to work in IceWM add the following to the ~/.icewm/keys file (the current config has the wingrid on Ctrl+number row keys)

    key "Ctrl+minus"
    key "Ctrl+equal"
    key "Ctrl+plus"
    key "Ctrl+grave"

    For this to work in FluxBox add the following to the ~/.fluxbox/keys file

    Control minus :ExecCommand
    Control equal :ExecCommand
    Control plus :ExecCommand
    Control grave :ExecCommand

    For this to work in JWM, in the ~/.jwm/keys file, after this line (it is important to put them on the next line right under this one):
    <Key mask=”C” key=”0″></Key>

    Add the following lines:

    <Key mask="C" key="minus"></Key>
    <Key mask="C" key="equal"></Key>
    <Key mask="C" key="plus"></Key>
    <Key mask="C" key="grave"></Key>
    • This reply was modified 1 year ago by BobC.
    • This reply was modified 1 year ago by BobC.
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.