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.
-
AuthorPosts
-
July 12, 2019 at 7:13 pm #24398Moderator
BobC
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 windowI 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 3 years, 9 months ago by BobC. Reason: Getting older and wiser
July 13, 2019 at 3:30 am #24407Member
Xecure
::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.
antiX Live system enthusiast.
General Live Boot Parameters for antiX.July 13, 2019 at 8:57 am #24416ModeratorBobC
::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 3 years, 9 months ago by BobC. Reason: 2nd try
- This reply was modified 3 years, 9 months ago by BobC. Reason: make growth rate a variable = gdiv
- This reply was modified 3 years, 9 months ago by BobC.
July 13, 2019 at 11:43 pm #24443ModeratorBobC
::Ok, I got the Center function working, and the Grow function working (I think). The center function is called wingrid-center.sh and the grow function is called wingrid-grow.sh.
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
WINHEIGHT_MORE=24The 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" wingrid-left.sh key "Ctrl+2" wingrid-right.sh key "Ctrl+3" wingrid-top.sh key "Ctrl+4" wingrid-bottom.sh key "Ctrl+5" wingrid-topleft.sh key "Ctrl+6" wingrid-topright.sh key "Ctrl+7" wingrid-bottomleft.sh key "Ctrl+8" wingrid-bottomright.sh key "Ctrl+9" wingrid-maximize.sh key "Ctrl+0" wingrid-close.sh key "Ctrl+minus" wingrid-shrink.sh key "Ctrl+equal" wingrid-center.sh key "Ctrl+plus" wingrid-grow.sh # Wingrid on Ctrl+ KP rose key "Ctrl+KP_Left" wingrid-left.sh # Left-Move window to Left key "Ctrl+KP_Right" wingrid-right.sh # Right-Move window to Right key "Ctrl+KP_Up" wingrid-top.sh # Up-Move window Top key "Ctrl+KP_Down" wingrid-bottom.sh # Down-Move window to Bottom key "Ctrl+KP_Home" wingrid-topleft.sh # Home-Move window to Top Left key "Ctrl+KP_Prior" wingrid-topright.sh # PgUp-Move window Top Right key "Ctrl+KP_End" wingrid-bottomleft.sh # End-Move window to Bottom Left key "Ctrl+KP_Next" wingrid-bottomright.sh # PgDn-Move window to Bottom Right key "Ctrl+KP_Insert" wingrid-maximize.sh # 0-Maximize window key "Ctrl+KP_Begin" wingrid-center.sh # 5-Center window ##key "Ctrl+KP_Delete" wingrid-close.sh # .-Close window key "Ctrl+KP_Add" wingrid-grow.sh # +-Grow window key "Ctrl+KP_Subtract" wingrid-shrink.sh # --Shrink window # app-select on Ctrl+Space key "Ctrl+Space" app-selectI 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 3 years, 9 months ago by BobC.
- This reply was modified 3 years, 9 months ago by BobC. Reason: updated code to current
- This reply was modified 3 years, 9 months ago by BobC. Reason: removed old code
Attachments:
July 14, 2019 at 8:46 am #24459ModeratorBobC
::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.
Attachments:
July 14, 2019 at 9:11 am #24463ModeratorBobC
::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
WINHEIGHT_MORE=24Here 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 SCREENWIDTH=${SCREENRES% *} SCREENHEIGHT=${SCREENRES#* } # Calculate 50% of the screen width and height values SCREENHALFWIDTH=$(($SCREENWIDTH/2)) SCREENHALFHEIGHT=$(($SCREENHEIGHT/2)) # Reference used by window manager when positioning the window (always zero) GRAVITY=0 # Distance from screen top edge to top edge of top window OFFSETTOP=$GAPTOP # Distance from screen left edge to left edge of left window OFFSETLEFT=$GAPLEFT # 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 NETSCREENWIDTH=$(($SCREENWIDTH-$OFFSETLEFT)) NETSCREENHEIGHT=$(($SCREENHEIGHT-($OFFSETTOP+$WINHEIGHT_MORE))) # 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 :) GROWDIV=8 # grow window logic # grow by 1/GROWDIV of remaining area on each side, limited to min and max screen coordinates # x axis AVAILX=$(($NETSCREENWIDTH-$WINWIDTH)) # if any room, grow window wider if [ "$AVAILX" -gt "0" ] then CHGSIZX=$(($NETSCREENWIDTH/$GROWDIV)) WCURPOSX=$(($WCURPOSX-$CHGSIZX)) WINWIDTH=$(($WINWIDTH+$CHGSIZX)) # if not enough room to left, limit and grow more to right if possible if [ "$WCURPOSX" -le "$OFFSETLEFT" ] then CHGSIZX=$(($OFFSETLEFT-$WCURPOSX)) WINWIDTH=$(($WINWIDTH+$CHGSIZX)) WCURPOSX=$OFFSETLEFT fi # limit grow to right if [ "$WINWIDTH" -gt "$NETSCREENWIDTH" ] then WINWIDTH=$NETSCREENWIDTH fi fi # y axis AVAILY=$(($NETSCREENHEIGHT-$WINHEIGHT)) # if any room, grow window taller if [ "$AVAILY" -gt "0" ] then CHGSIZY=$(($NETSCREENHEIGHT/$GROWDIV)) WCURPOSY=$(($WCURPOSY-$CHGSIZY)) WINHEIGHT=$(($WINHEIGHT+$CHGSIZY)) # if not enough room above, limit and grow more below if possible if [ "$WCURPOSY" -le "$OFFSETTOP" ] then CHGSIZY=$(($OFFSETTOP-$WCURPOSY)) WINHEIGHT=$(($WINHEIGHT+$CHGSIZY)) WCURPOSY=$OFFSETTOP fi # limit grow below if [ "$WINHEIGHT" -gt "$NETSCREENHEIGHT" ] then WINHEIGHT=$NETSCREENHEIGHT fi fi 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 wmctrl -r :ACTIVE: -e $GRAVITY,$WCURPOSX,$WCURPOSY,$WINWIDTH,$WINHEIGHTAttachments:
July 14, 2019 at 11:58 am #24472ModeratorBobC
::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…
Attachments:
July 14, 2019 at 12:46 pm #24481Member
Xecure
::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.antiX Live system enthusiast.
General Live Boot Parameters for antiX.July 31, 2019 at 9:04 pm #25230ModeratorBobC
::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" wingrid-shrink.sh key "Ctrl+equal" wingrid-grow.sh key "Ctrl+plus" wingrid-grow.sh key "Ctrl+grave" wingrid-center.shFor this to work in FluxBox add the following to the ~/.fluxbox/keys file
Control minus :ExecCommand wingrid-shrink.sh Control equal :ExecCommand wingrid-grow.sh Control plus :ExecCommand wingrid-grow.sh Control grave :ExecCommand wingrid-center.shFor 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″>exec:wingrid-close.sh</Key>Add the following lines:
<Key mask="C" key="minus">exec:wingrid-shrink.sh</Key> <Key mask="C" key="equal">exec:wingrid-grow.sh</Key> <Key mask="C" key="plus">exec:wingrid-grow.sh</Key> <Key mask="C" key="grave">exec:wingrid-center.sh</Key>- This reply was modified 3 years, 9 months ago by BobC.
- This reply was modified 3 years, 9 months ago by BobC.
-
AuthorPosts
- You must be logged in to reply to this topic.