RamonUnch / AltSnap

Maintained continuation of Stefan Sundin's AltDrag
GNU General Public License v3.0
2.08k stars 66 forks source link

Snap Layout Preview #511

Closed RamonUnch closed 5 months ago

RamonUnch commented 7 months ago

Here is a new version of AltSnap with Snap Layout preview. It only applies if you enabled the Snap to layout option in the General config.

In the [Zones] section of the ini file, you can configure it:

ShowZonesPrevw=1
; Enable/Disables Layout preview (default 1)

ZonesPrevwOpacity=160
; Opacity from 0-255 of the Zone preview (default 160)
; if you disabled Desktop composition, use 0.

ZonesPrevwBGCol=FF FF FF
ZonesPrevwBDCol=00 00 00
; Color of the Snap Layout preview, ZPrevwBGcol for background color
; and ZPrevwBDcol for the border color. default are white and black.

AltSnap-1.63test1_i386.zip AltSnap1.63test1_x64.zip

@shodanx2 You may be interested by this test build.

shodanx2 commented 7 months ago

Thank you for the heads up

For reference, here is my fancyzones layout file custom-layouts.json

I asked chatgpt to convert per above specification, while playing a game so might have gotten something wrong, but here is

[Zones] ZoneCount=6 Zone0=0,0,523,580 Zone1=523,0,1654,462 Zone2=1654,0,1920,661 Zone3=523,462,1654,1040 Zone4=1654,661,1920,1040 Zone5=0,580,523,1040

[Zones] ZoneCount=6 Zone0=1698,0,3072,844 Zone1=1698,844,3072,1688 Zone2=0,0,551,844 Zone3=0,844,551,1688 Zone4=551,0,1698,844 Zone5=551,844,1698,1688

[Zones] ZoneCount=6 Zone0=0,0,1374,844 Zone1=0,844,1374,1688 Zone2=2521,0,3072,844 Zone3=2521,844,3072,1688 Zone4=1374,0,2521,844 Zone5=1374,844,2521,1688

shodanx2 commented 7 months ago

I am curious, is it possible to enable pressing another mouse button to toggle the zone layout display and snapping ?

In fancyzone

image

In fancyzone, I currently use right click to trigger zone display and snapping

I also have middleclick for multizone snapping toggle

image

I used to use mouse4 for multizone snapping toggle but that required the terrible logitech software

Today I use Mouse4 to simulate the ALT of AltSnap, it's great but I'm still ironing out the quirks (mostly stuck-keys issues)

I don't currently understand how layouts work. I imagine one layout contains a set of zone, and each monitor has a currently set layout ?

I reworked my fancyzone layout as close as I think, but I didn't make it work yet

;COMM Layout Zone0=0,0,523,580. Zone1=523,0,1654,462. Zone2=1654,0,1920,661. Zone3=523,462,1654,1040. Zone4=1654,661,1920,1040. Zone5=0,580,523,1040.

;Top4K layout Zone0=0,0,427,844. Zone1=0,844,427,1688. Zone2=2725,0,3072,844. Zone3=2725,844,3072,1688. Zone4=427,0,2725,844. Zone5=427,844,2725,1688. Zone6=427,0,2725,1688.

;Left4K layout Zone0=1698,0,3072,844. Zone1=1698,844,3072,1688. Zone2=0,0,551,844. Zone3=0,844,551,1688. Zone4=551,0,1698,844. Zone5=551,844,1698,1688.

; Right4K layout Zone0=0,0,1374,844. Zone1=0,844,1374,1688. Zone2=2521,0,3072,844. Zone3=2521,844,3072,1688. Zone4=1374,0,2521,844. Zone5=1374,844,2521,1688.

;4-way layout Zone0=0,0,960,540. Zone1=960,0,1920,540. Zone2=0,540,960,1080. Zone3=960,540,1920,1080.

;6-way layout
Zone0=0,0,640,540.
Zone1=640,0,1280,540.
Zone2=1280,0,1920,540.
Zone3=0,540,640,1080.
Zone4=640,540,1280,1080.
Zone5=1280,540,1920,1080.
;8-way layout
Zone0=0,0,480,540.
Zone1=480,0,960,540.
Zone2=960,0,1440,540.
Zone3=1440,0,1920,540.
Zone4=0,540,480,1080.
Zone5=480,540,960,1080.
Zone6=960,540,1440,1080.
Zone7=1440,540,1920,1080.

https://chat.openai.com/share/3136cf27-c651-4702-b32e-7cc252983a69

shodanx2 commented 7 months ago

Ah I just noticed there was a helper in AltSnap to build the zones !

image

I couldn't snap the testwindow because AltSnap runs as admin but fancyzone is not admin But I used AltSnap resize feature after filling all the zones with apps

image

Ah, I get it now, layout is for all monitors at once.

That is different from fancyzones where you apply layouts per monitor

Also, I realized I could just re-start AltSnap as non-admin temporarily for this purpose

This is the result config

[Zones]
UseZones=1
; If set to 1, enables Snap Layouts (Zones)
; If set to 3, enables Grid mode (configure below)
; If 4 is added window is extended without Ctrl.
; If 8 is added snapping will occur without Shift ie: 1+8 => UseZones=9.
; Shift will disable Zones instead.
; recomended is UseZones=1 or 9 for normal snap Layout with or w/o shift
; and 3+4 => UseZones=7 for grid mode.

ZSnapMode=0
; Zone snapping strategy
; Set to 0 to snap to the zones pointed by the cursor (default).
; Set to 1 to snap to the zone which center is the nearest from the cursor
; There is always a the InterZone tolerance to snap to several zones.

InterZone=32
; Size in pixels between zones from -128 to +127 (default 32)
; where the window will be snapped to the union of zones.
; If set to 0, you cannot cover more than one zone.

MaxLayouts=5
; Maximum number of layouts that you can switch btween
; Set to 0 or 1 if you want a single layout, 10 max.
LayoutNumber=4
; Currently selected layout (from 0 to MaxLayouts-1)

; If you set UseZones to 3 or 7 then you enabled the
; GRID MODE that simply cuts each screen into 'parts'.
; You can set the number of parts below:
GridNx=3
; Number of grid columns
GridNy=2
; Number of grid lines
GridNx1=4
GridNy1=3
GridNx2=2
GridNy2=2

FancyZone=1
; If set to 1, enables better FancyZones integration (x64 builds only!).
; Windows snapped by FancyZones will be restored by AltDrag.
; Set to 2 if you do not want AltSnap to rescale
; the window to the current dpi setting.

; Zone0=
; Zone1=
; Zone2=
; Zone3=

;Top4K layout
Zone0=6991,1055,7680,2111,
Zone1=6991,1,7680,1055,
Zone2=5557,1055,6991,2111,
Zone3=5557,1,6991,1055,
Zone4=3840,1055,5557,2110,
Zone5=3840,0,5557,1055,
Zone6=
AZone0=-3840,1055,-3152,2111,
AZone1=-3840,1,-3152,1055,
AZone2=-3152,1055,-1718,2111,
AZone3=-3152,1,-1718,1055,
AZone4=-1718,1055,0,2111,
AZone5=-1718,1,0,1055,
BZone0=2875,1055,3840,2110,
BZone1=1920,1055,2875,2110,
BZone2=964,1055,1920,2110,
BZone3=0,1055,964,2110,
BZone4=2875,0,3840,1055,
BZone5=1920,0,2875,1055,
BZone6=964,0,1920,1055,
BZone7=0,1,964,1055,
CZone0=3406,-1105,3840,-50,
CZone1=3406,-2160,3840,-1105,
CZone2=533,-1105,3406,-50,
CZone3=533,-2160,3406,-1105,
CZone4=0,-1105,533,-50,
CZone5=0,-2160,533,-1105,
DZone0=2875,1055,3840,2110,
DZone1=1920,1055,2875,2110,
DZone2=964,1055,1920,2110,
DZone3=0,1055,964,2110,
DZone4=2875,0,3840,1055,
DZone5=1920,0,2875,1055,
DZone6=964,0,1920,1055,
DZone7=0,0,964,1055,
DZone8=3406,-1105,3840,-50,
DZone9=3406,-2160,3840,-1105,
DZone10=0,-1105,533,-50,
DZone11=0,-2160,533,-1105,
DZone12=533,-2160,3406,-1105,
DZone13=533,-1105,3406,-50,
DZone14=-1718,1056,0,2111,
DZone15=-1718,1,0,1056,
DZone16=-3152,1,-1718,1056,
DZone17=-3152,1056,-1718,2111,
DZone18=-3840,1056,-3152,2111,
DZone19=-3840,1,-3152,1056,
DZone20=6991,1056,7680,2111,
DZone21=6991,1,7680,1056,
DZone22=5557,1056,6991,2111,
DZone23=5557,1,6991,1056,
DZone24=3840,1056,5557,2111,
DZone25=3840,1,5557,1056,

SO5OeQZhri

FancyZone often has the issue that my selected layout will change randomly, when I turn screens on and off (they disappear from windows when I do that). So maybe this method will be more reliable in AltSnap !

shodanx2 commented 7 months ago

Another thing that fancyzone does different, is, when you move the window while the zones are activated, it lights up the zone, instead of snapping your window immediately, while making that window low opacity. It's a bit less jarring but I can get used to this.

I think I would like Alt+leftdrag+rightclick to, instead of resize to fullscreen, resize to current Zone.

I want this action more often than fullscreen maximize.

RamonUnch commented 7 months ago

I am curious, is it possible to enable pressing another mouse button to toggle the zone layout display and snapping ?

By default you can press the middle button, If you disable the Advanced->Toggle Maximized state with resize while moving, then the right button will toggle zone-snapping

Another thing that fancyzone does different, is, when you move the window while the zones are activated, it lights up the zone, instead of snapping your window immediately, while making that window low opacity. It's a bit less jarring but I can get used to this.

This is a different issue, see #106 It is in my todo list and would apply to any kind of snapping.

shodanx2 commented 7 months ago

Got it, it's working great now !

Will report back after I've used it for a while, it seems the difference between altsnap zones and fancyzones are just cosmetic. At least in the way I use it.

https://github.com/RamonUnch/AltSnap/assets/10621885/eab14f5d-f175-4b11-b0ab-9bc6da289cd2

shodanx2 commented 5 months ago

I've been using this since my last post. It works great, I like it.

I especially like it since enabling mouse5 as the hotclick button.

It is not as pretty as fancyzone, but just as effective. (I mean the direct window snapping vs dragging half opacity windows).

Things like the right click being a snap toggle, and it will unsnap your held window if you untoggle snapping. Works great.

It's a bit difficult to span zones, but only because you have to do it two-handed because the span zone button is CTRL. I would love double-rightclick to toggle zone spanning. Or perhaps "press Mouse4". If there is a way to do that, I have missed it.

As far as I'm concerned, I don't really need fancyzones anymore if it weren't that regular window dragging by the titlebar is handled by fancyzones.

Here is my zones configuration

Zone0=2875,1055,3840,2110,
Zone1=1920,1055,2875,2110,
Zone2=964,1055,1920,2110,
Zone3=0,1055,964,2110,
Zone4=2875,0,3840,1055,
Zone5=1920,0,2875,1055,
Zone6=964,0,1920,1055,
Zone7=0,0,964,1055,
Zone8=3406,-1105,3840,-50,
Zone9=3406,-2160,3840,-1105,
Zone10=0,-1105,533,-50,
Zone11=0,-2160,533,-1105,
Zone12=533,-2160,3406,-1105,
Zone13=533,-1105,3406,-50,
Zone14=-1718,1056,0,2111,
Zone15=-1718,1,0,1056,
Zone16=-3152,1,-1718,1056,
Zone17=-3152,1056,-1718,2111,
Zone18=-3840,1056,-3152,2111,
Zone19=-3840,1,-3152,1056,
Zone20=6991,1056,7680,2111,
Zone21=6991,1,7680,1056,
Zone22=5557,1056,6991,2111,
Zone23=5557,1,6991,1056,
Zone24=3840,1056,5557,2111,
Zone25=3840,1,5557,1056,
RamonUnch commented 5 months ago

It's a bit difficult to span zones, but only because you have to do it two-handed because the span zone button is CTRL. I would love double-rightclick to toggle zone spanning. Or perhaps "press Mouse4". If there is a way to do that, I have missed it.

The Span can be by enabled by default if you Add 4 to the value of your UseZones ini setting, this would be UseZones=5 in your case.

However I do agree that this should be configurable to be a mouse button. I will open a different Issue for this because it is not related to the display of the layout

shodanx2 commented 5 months ago

Here is a colour scheme suggestion for dark mode users

ZonesPrevwBGCol=11 11 11 ZonesPrevwBDCol=fd f8 00

Changes this

image

to this

image

I think it looks pretty sick

That is the cyberpunk 2077 yellow

Heart1010 commented 5 months ago

@RamonUnch This preview snap layout is great - one problem I have is when we have zones definded which overlays each other. Then when moving the window + shift it gets immediately snapped to "one of that" layouts but I can't choose which one.

(e.g. I have a zone from left to 3/4 right width of the monitor and another zone from right to 3/4 left width of the monitor)

update: ok found ZSnapMode config - when set to 1 instead of 0 it is way better 👍

RamonUnch commented 5 months ago

@Heart1010 Use ZSnapMode=1, it should do the trick for you. I Will have to add GUI options at some time for all of layout options.

in the [Zones] section

ZSnapMode=0
; Zone snapping strategy
; Set to 0 to snap to the zones pointed by the cursor (default).
; Set to 1 to snap to the zone which center is the nearest from the cursor
; There is always a the InterZone tolerance to snap to several zones.
RamonUnch commented 5 months ago

I did not see your update, I just read the e-mail notification, congratulation for finding by yourself.

Heart1010 commented 4 months ago

@RamonUnch Is there a way I can use a keyboard shortcut to switch between my snap zones/windows?

Ichisich commented 4 months ago

@Heart1010 Keyboard tab -> Shortcut for action field -> Move to ... Zone.

Heart1010 commented 4 months ago

Perfect - but what is left/right/top/bottom zone when there are more than 4 window layouts present in that snap layout, or more zones/windows start from the left edge, ....

What I miss is a shortcut which I can use to "toggle from one layout to next layout, to next, to next,...".

Ichisich commented 4 months ago

As far as I know, there is currently no dedicated shortcut to switch layouts. You can switch layouts in the AltSnap tray context menu with a number key.

Perfect - but what is left/right/top/bottom zone when there are more than 4 window layouts present in that snap layout, or more zones/windows start from the left edge, ....

The move to zone action depends on the current position of the window and will move one zone a time from the original position towards the desired direction.

Heart1010 commented 4 months ago

I didn't mean switch from one snap layout to another (task symbol context menu) but let's say I'm in my "snap layout 1" and in there I have 8 windows/positions/sizes - what I want now is one keyboard shortcut which I can press again and again so the current program move always to the next window/position/size from one of those 8.

RamonUnch commented 4 months ago

I didn't mean switch from one snap layout to another (task symbol context menu) but let's say I'm in my "snap layout 1" and in there I have 8 windows/positions/sizes - what I want now is one keyboard shortcut which I can press again and again so the current program move always to the next window/position/size from one of those 8.

image

I do not see how this is different from the move to left/top/right/bottom zone, you can with keyboard shotcuts move the focused window to the zone you want with a few keystrokes.

RamonUnch commented 4 months ago

This is the zone just at the left/right/top bottom, NOT the leftmost, rightmost etc.

Heart1010 commented 4 months ago

These are my 'window zones' for example (1) left focused window - a liitle space at the right side -, 2) middle window, 3) right focused window - a liitle space at the left side -, 4) middle bottom window)

Snap_Layout

I've set it to move to left zone = ALT + LEFT move to right zone = ALT + RIGHT move to bottom zone = ALT + DOWN

The only thing thing which work is ALT + LEFT => window goes to 1) and ALT + RIGHT => window goes to 3).

I can't use the middel bottom window 4) for example - I thought this should work with ALT + DOWN but ALT + DOWN maximize the window to whole screen.