Skip to content

Commit 255b483

Browse files
author
Soham Dasgupta
committed
feat: add all Fourth layouts
1 parent 68133f1 commit 255b483

File tree

4 files changed

+73
-29
lines changed

4 files changed

+73
-29
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [v0.4.0](https://github.com/thesobercoder/polygon/compare/v0.3.0...v0.4.0) (2023-11-20)
2+
3+
### Features
4+
5+
- Add First Fourth
6+
- Add Second Fourth
7+
- Add Third Fourth
8+
- Add Last Fourth
9+
110
## [v0.3.0](https://github.com/thesobercoder/polygon/compare/v0.2.0...v0.3.0) (2023-10-06)
211

312
### Features

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ Here are the shortcuts available in Polygon.
6161
| :white_check_mark: | <kbd>CTRL</kbd>+<kbd>WIN</kbd>+<kbd>I</kbd> | Top Right | |
6262
| :white_check_mark: | <kbd>CTRL</kbd>+<kbd>WIN</kbd>+<kbd>J</kbd> | Bottom Left | |
6363
| :white_check_mark: | <kbd>CTRL</kbd>+<kbd>WIN</kbd>+<kbd>K</kbd> | Bottom Right | |
64-
| :construction: | | First Fourth | |
65-
| :construction: | | Second Fourth | |
66-
| :construction: | | Third Fourth | |
67-
| :construction: | | Last Fourth | |
64+
| :white_check_mark: | <kbd>CTRL</kbd>+<kbd>WIN</kbd>+<kbd>;</kbd> | First Fourth | |
65+
| :white_check_mark: | <kbd>CTRL</kbd>+<kbd>WIN</kbd>+<kbd>'</kbd> | Second Fourth | |
66+
| :white_check_mark: | <kbd>CTRL</kbd>+<kbd>WIN</kbd>+<kbd>,</kbd> | Third Fourth | |
67+
| :white_check_mark: | <kbd>CTRL</kbd>+<kbd>WIN</kbd>+<kbd>.</kbd> | Last Fourth | |
6868
| :construction: | | Next Display | |
6969
| :construction: | | Previous Display | |
7070

polygon.ahk

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
;-- Ahk2Exe properties
77
;@Ahk2Exe-SetName Polygon
8-
;@Ahk2Exe-SetVersion 0.3.0
8+
;@Ahk2Exe-SetVersion 0.4.0
99
;@Ahk2Exe-SetCompanyName Soham Dasgupta
1010
;@Ahk2Exe-SetDescription A window manager for Windows 10/11 powered by AutoHotkey
1111

1212
;-- Globals
13-
global APP_VERSION := "0.3.0"
13+
global APP_VERSION := "0.4.0"
1414
global APP_VERSION_NAME := "v" . APP_VERSION
1515
global APP_NAME := "Polygon"
1616
global APP_REPO_OWNER := "thesobercoder"
@@ -43,6 +43,10 @@ global APP_SHORTCUT_BOTTOMLEFT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT
4343
global APP_SHORTCUT_BOTTOMRIGHT := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomRight", "^#k")
4444
global APP_SHORTCUT_TOPHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "TopHalf", "^#-")
4545
global APP_SHORTCUT_BOTTOMHALF := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "BottomHalf", "^#=")
46+
global APP_SHORTCUT_FIRSTFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "FirstFourth", "^#;")
47+
global APP_SHORTCUT_SECONDFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "SecondFourth", "^#'")
48+
global APP_SHORTCUT_THIRDFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "ThirdFourth", "^#,")
49+
global APP_SHORTCUT_LASTFOURTH := IniRead(APP_INI_FILE, APP_INI_SECTION_SHORTCUT, "LastFourth", "^#.")
4650
;--Tooltip
4751
A_IconTip := APP_NAME
4852
;-- Register global error logging
@@ -211,6 +215,11 @@ Hotkey(APP_SHORTCUT_BOTTOMLEFT, BottomLeft)
211215
Hotkey(APP_SHORTCUT_BOTTOMRIGHT, BottomRight)
212216
Hotkey(APP_SHORTCUT_TOPHALF, TopHalf)
213217
Hotkey(APP_SHORTCUT_BOTTOMHALF, BottomHalf)
218+
Hotkey(APP_SHORTCUT_FIRSTFOURTH, FirstFourth)
219+
Hotkey(APP_SHORTCUT_SECONDFOURTH, SecondFourth)
220+
Hotkey(APP_SHORTCUT_THIRDFOURTH, ThirdFourth)
221+
Hotkey(APP_SHORTCUT_LASTFOURTH, LastFourth)
222+
;-- Layout Functions
214223
Center(*) {
215224
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
216225
{
@@ -238,28 +247,6 @@ CenterHD(*) {
238247
Toast("Center HD", r, l, t, b)
239248
}
240249
}
241-
FirstFourth(*) {
242-
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
243-
{
244-
;-- Calculate the width of one fourth of the monitor
245-
OneFourthWidth := Ceil((r - l) / 4)
246-
;-- Set the window position to the left one fourth of the monitor
247-
WinMove(l - ofl, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
248-
;-- Show layout toast
249-
Toast("First Fourth", r, l, t, b)
250-
}
251-
}
252-
LastFourth(*) {
253-
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
254-
{
255-
;-- Calculate the width of one fourth of the monitor
256-
OneFourthWidth := Ceil((r - l) / 4)
257-
;-- Set the window position to the right one fourth of the monitor
258-
WinMove(r - OneFourthWidth - ofr, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
259-
;-- Show layout toast
260-
Toast("Last Fourth", r, l, t, b)
261-
}
262-
}
263250
CenterHalf(*) {
264251
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
265252
{
@@ -493,6 +480,50 @@ BottomHalf(*) {
493480
Toast("Bottom Half", r, l, t, b)
494481
}
495482
}
483+
FirstFourth(*) {
484+
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
485+
{
486+
;-- Calculate the width of one fourth of the monitor
487+
OneFourthWidth := Ceil((r - l) / 4)
488+
;-- Set the window position to the left one fourth of the monitor
489+
WinMove(l - ofl, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
490+
;-- Show layout toast
491+
Toast("First Fourth", r, l, t, b)
492+
}
493+
}
494+
SecondFourth(*) {
495+
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
496+
{
497+
; Calculate the width of one-fourth of the monitor
498+
OneFourthWidth := Ceil((r - l) / 4)
499+
; Set the window position to the left one-fourth of the monitor
500+
WinMove(l - ofl + OneFourthWidth, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
501+
; Show layout toast
502+
Toast("Second Fourth", r, l, t, b)
503+
}
504+
}
505+
ThirdFourth(*) {
506+
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
507+
{
508+
; Calculate the width of one-fourth of the monitor
509+
OneFourthWidth := Ceil((r - l) / 4)
510+
; Set the window position to the right one-fourth of the monitor
511+
WinMove(l - ofl + 2 * OneFourthWidth, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
512+
; Show layout toast
513+
Toast("Third Fourth", r, l, t, b)
514+
}
515+
}
516+
LastFourth(*) {
517+
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
518+
{
519+
;-- Calculate the width of one fourth of the monitor
520+
OneFourthWidth := Ceil((r - l) / 4)
521+
;-- Set the window position to the right one fourth of the monitor
522+
WinMove(r - OneFourthWidth - ofr, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
523+
;-- Show layout toast
524+
Toast("Last Fourth", r, l, t, b)
525+
}
526+
}
496527
GetWindowRectEx(&hWindow := 0, &winX := 0, &winY := 0, &winW := 0, &winH := 0, &winOffsetLeft := 0, &winOffsetRight := 0, &winOffsetTop := 0, &winOffsetBottom := 0, &monRight := 0, &monLeft := 0, &monTop := 0, &monBottom := 0) {
497528
;-- Get the handle of the active window
498529
hWindow := WinExist("A")
@@ -566,4 +597,4 @@ WinGetPosEx(hWindow, &winX := 0, &winY := 0, &winW := 0, &winH := 0, &winOffsetL
566597
NumPut("Int", winOffsetRight := GWR_Right - Right, RECTPlus, 24)
567598
NumPut("Int", winOffsetBottom := GWR_Bottom - Bottom, RECTPlus, 28)
568599
Return &RECTPlus
569-
}
600+
}

polygon.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ BottomLeft="^#j"
2020
BottomRight="^#k"
2121
TopHalf="^#-"
2222
BottomHalf="^#="
23+
FirstFourth="^#;"
24+
SecondFourth="^#'"
25+
ThirdFourth="^#,"
26+
LastFourth="^#."
2327

2428
[Toast]
2529
Show=1

0 commit comments

Comments
 (0)