forked from adamk33n3r/GoBorderless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathborderless.go
More file actions
36 lines (31 loc) · 1.14 KB
/
borderless.go
File metadata and controls
36 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
"github.com/lxn/win"
)
func isBorderless(window Window) bool {
style := getWindowStyle(window.hwnd)
return !(style&win.WS_CAPTION > 0 &&
((style&win.WS_BORDER) > 0 || (style&win.WS_THICKFRAME) > 0))
}
func makeBorderless(window Window, appSetting AppSetting) {
// fmt.Println("Making window borderless:", window.title, window.exePath)
style := getWindowStyle(window.hwnd)
// Remove the border and title bar
setWindowStyle(window.hwnd, style & ^win.WS_CAPTION & ^win.WS_THICKFRAME)
monitor := monitors[appSetting.Monitor-1]
setWindowPos(window.hwnd, appSetting.OffsetX+monitor.left, appSetting.OffsetY+monitor.top, appSetting.Width, appSetting.Height)
}
/**
* Only restores the window if it's borderless
*/
func restoreWindow(window Window, appSetting AppSetting) {
if !isBorderless(window) {
return
}
fmt.Println("Restoring window:", window.title, window.exePath)
style := getWindowStyle(window.hwnd)
// Restore the border and title bar
setWindowStyle(window.hwnd, style|win.WS_OVERLAPPEDWINDOW)
setWindowPos(window.hwnd, appSetting.PreOffsetX, appSetting.PreOffsetY, appSetting.PreWidth, appSetting.PreHeight)
}