GUI: Strip Centre() work-around

This commit is contained in:
Mykola Grymalyuk
2023-05-29 09:28:25 -06:00
parent 984ba65d41
commit 0388eaa6f2
10 changed files with 11 additions and 59 deletions
-48
View File
@@ -101,54 +101,6 @@ class GaugePulseCallback:
time.sleep(0.005)
class Centre:
"""
Alternative to wx.Frame.Centre() for macOS Ventura+ on non-Metal GPUs
----------
As reported by socamx#3874, all of their non-Metal Mac minis would incorrectly centre
at the top of the screen, rather than the screen centre. Half of the window frame would
be off-screen, making it rather difficult to grab frame handle and move the window.
This bug is only triggered when the application is launched via AppleScript,
ie. Relaunch as root for root patching.
As calculating screen centre is trivial, this is safe for all non-Metal Macs.
Test unit specs:
- Macmini4,1 (2010, Nvidia Tesla)
- Asus VP228HE 21.5" Display (1920x1080)
"""
def __init__(self, frame: wx.Frame, global_constants: constants.Constants) -> None:
self.frame: wx.Frame = frame
self.constants: constants.Constants = global_constants
self._centre()
def _centre(self) -> None:
"""
Calculate centre position of screen and set window position
"""
if self.constants.detected_os < os_data.os_data.ventura:
self.frame.Centre()
return
if CheckProperties(self.constants).host_is_non_metal() is False:
self.frame.Centre()
return
# Get screen resolution
screen_resolution = wx.DisplaySize()
window_size = self.frame.GetSize()
# Calculate window position
x_pos = int((screen_resolution[0] - window_size[0]) / 2)
y_pos = int((screen_resolution[1] - window_size[1]) / 2)
self.frame.SetPosition((x_pos, y_pos))
class CheckProperties:
def __init__(self, global_constants: constants.Constants) -> None: