Skip to content

Commit

Permalink
fix forced z index (fix #80)
Browse files Browse the repository at this point in the history
  • Loading branch information
blurfx committed Apr 19, 2024
1 parent 6607e58 commit c1d8534
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/ad.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func HideMainWindowAd(windowClass string, handle windows.HWND) {
// @deprecated
if windowClass == "BannerAdWnd" {
winapi.ShowWindow(handle, 0)
winapi.SetWindowPos(handle, 0, 0, 0, 0, 0, winapi.SwpNomove)
winapi.MoveWindow(handle, 0, 0, 0, 0, true)
}
if windowClass == "BannerAdContainer" {
parentHandle := winapi.GetParent(handle)
winapi.ShowWindow(parentHandle, 0)
winapi.SetWindowPos(parentHandle, 0, 0, 0, 0, 0, winapi.SwpNomove)
winapi.MoveWindow(parentHandle, 0, 0, 0, 0, true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func removeAd() {
for _, candidate := range candidates {
if candidate[1] == mainWindowParentHandle {
winapi.ShowWindow(candidate[0], 0)
winapi.SetWindowPos(candidate[0], 0, 0, 0, 0, 0, winapi.SwpNomove)
winapi.MoveWindow(candidate[0], 0, 0, 0, 0, true)
break
}
}
Expand Down
17 changes: 17 additions & 0 deletions internal/win/winapi/user32.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
defWindowProc = user32.NewProc("DefWindowProcW")
registerClassEx = user32.NewProc("RegisterClassExW")
createWindowEx = user32.NewProc("CreateWindowExW")
moveWindow = user32.NewProc("MoveWindow")
)

func cStr(str string) uintptr {
Expand Down Expand Up @@ -167,3 +168,19 @@ func LoadIcon(instance uintptr, iconName *uint16) (uintptr, error) {
}
return ret, nil
}

func MoveWindow(hWnd windows.HWND, x, y, width, height int32, repaint bool) bool {
shouldRepaint := 0
if repaint {
shouldRepaint = 1
}
r, _, _ := moveWindow.Call(
uintptr(hWnd),
uintptr(x),
uintptr(y),
uintptr(width),
uintptr(height),
uintptr(shouldRepaint),
)
return r != 0
}

0 comments on commit c1d8534

Please sign in to comment.