Skip to content

Commit 0d4538d

Browse files
jfkominskypeircej
authored andcommitted
Retina display position fix
Adds an if statement for correcting the position of non-fullscreen windows on retina displays.
1 parent 9b46ff0 commit 0d4538d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

psychopy/visual/backends/pygletbackend.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,16 @@ def __init__(self, win, *args, **kwargs):
202202
self.winHandle.set_mouse_visible(False)
203203
self.winHandle.on_resize = _onResize # avoid circular reference
204204
if not win.pos:
205-
# work out where the centre should be
206-
win.pos = [(thisScreen.width - win.size[0]) / 2,
207-
(thisScreen.height - win.size[1]) / 2]
205+
# work out where the centre should be
206+
if win.useRetina:
207+
win.pos = [(thisScreen.width - win.size[0]/2) / 2,
208+
(thisScreen.height - win.size[1]/2) / 2]
209+
else:
210+
win.pos = [(thisScreen.width - win.size[0]) / 2,
211+
(thisScreen.height - win.size[1]) / 2]
208212
if not win._isFullScr:
209-
# add the necessary amount for second screen
210-
self.winHandle.set_location(int(win.pos[0] + thisScreen.x),
213+
print(win.size[0])
214+
self.winHandle.set_location(int(win.pos[0] + thisScreen.x),
211215
int(win.pos[1] + thisScreen.y))
212216

213217
try: # to load an icon for the window

0 commit comments

Comments
 (0)