Skip to content

Fix window position inconsistency in MacOS#3479

Merged
leaanthony merged 2 commits into
wailsapp:masterfrom
cenan:feature/3478_window-position-inconsistency-in-macos
May 14, 2024
Merged

Fix window position inconsistency in MacOS#3479
leaanthony merged 2 commits into
wailsapp:masterfrom
cenan:feature/3478_window-position-inconsistency-in-macos

Conversation

@cenan

@cenan cenan commented May 14, 2024

Copy link
Copy Markdown
Contributor

Description

There is an inconsistency of window position values on MacOS. When getting the window position using runtime.WindowGetPosition() and setting it back using runtime.WindowSetPosition() the y value decrements. This is caused by using different screen frame sizes while reading and writing window positions.

We are using [screen frame] while setting the position and using [screen visibleFrame] while reading it.

frame property returns the fullscreen rectangle of the screen, while visibleFrame returns the area not occupied by dock and menubar.

I have changed [screen frame] to [screen visibleFrame] in v2/internal/frontend/desktop/darwin/WailsContext.m and the issue seems to be fixed on my tests.

Fixes #3478

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

Test Configuration

# Wails
Version  | v2.8.2
Revision | 43f0dd6624ba477bc9aba75cef63790e8928b6e5
Modified | true

# System
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | MacOS                                                                                                                       |
| Version      | 14.4.1                                                                                                                      |
| ID           | 23E224                                                                                                                      |
| Go Version   | go1.22.2                                                                                                                    |
| Platform     | darwin                                                                                                                      |
| Architecture | arm64                                                                                                                       |
| CPU          | Apple M1 Pro                                                                                                                |
| GPU          | Chipset Model: Apple M1 Pro Type: GPU Bus: Built-In Total Number of Cores: 14 Vendor: Apple (0x106b) Metal Support: Metal 3 |
| Memory       | 16GB                                                                                                                        |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version        |
| Xcode command line tools  | N/A          | Installed | 2406           |
| Nodejs                    | N/A          | Installed | 20.11.1        |
| npm                       | N/A          | Installed | 10.2.4         |
| *Xcode                    | N/A          | Installed | 15.3 (15E204a) |
| *upx                      | N/A          | Available |                |
| *nsis                     | N/A          | Available |                |
└─────────────────────── * - Optional Dependency ───────────────────────┘

# Diagnosis
Optional package(s) installation details:
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@cenan

cenan commented May 14, 2024

Copy link
Copy Markdown
Contributor Author

Sorry I think I was supposed to create a draft PR but didn't know how. There is a link to convert my PR to a draft request, should I click it?

@leaanthony

Copy link
Copy Markdown
Member

Thanks 🙏 Please could you add an entry to the changelog located at website/src/pages/changelog.mdx?

@leaanthony leaanthony left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! I'm amazed it wasn't discovered earlier 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting and setting window position on MacOS changes window position

2 participants