-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect position being loaded on linux when using multiple moni…
…tors
- Loading branch information
1 parent
a50a49c
commit b474ea4
Showing
3 changed files
with
64 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package wailsextras | ||
|
||
import ( | ||
"context" | ||
"runtime" | ||
|
||
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" | ||
|
||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/utils" | ||
) | ||
|
||
// WindowSetPosition wraps Wails's WindowSetPosition, | ||
// but ensures that WindowSetPosition(WindowGetPosition()) | ||
// will result in the window remaining stationary | ||
// regardless of OS's behaviour with multiple displays | ||
func WindowSetPosition(ctx context.Context, x, y int) { | ||
if runtime.GOOS == "windows" || runtime.GOOS == "linux" { | ||
// WindowSetPosition expects relative to the current monitor, | ||
// but WindowGetPosition returns absolute | ||
curX, curY := wailsRuntime.WindowGetPosition(ctx) | ||
display := utils.GetDisplayBoundsAt(curX, curY) | ||
x -= display.Min.X | ||
y -= display.Min.Y | ||
} | ||
|
||
// It appears that on darwin Wails gets and sets the position | ||
// with values relative to the current monitor | ||
|
||
wailsRuntime.WindowSetPosition(ctx, x, y) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters