Lol actually fix screen wakeup lookup..
parent
a232e8bc39
commit
8501a9be4f
|
@ -1,5 +1,5 @@
|
||||||
# piker: trading gear for hackers
|
# piker: trading gear for hackers
|
||||||
# Copyright (C) 2018-present Tyler Goodlet (in stewardship of piker0)
|
# Copyright (C) Tyler Goodlet (in stewardship for piker0)
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as published by
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
@ -56,26 +56,29 @@ _qt_app: QtGui.QApplication = None
|
||||||
_qt_win: QtGui.QMainWindow = None
|
_qt_win: QtGui.QMainWindow = None
|
||||||
|
|
||||||
|
|
||||||
def current_screen(timeout: float = 6) -> QtGui.QScreen:
|
def current_screen() -> QtGui.QScreen:
|
||||||
print('yo screen zonnnee')
|
"""Get a frickin screen (if we can, gawd).
|
||||||
|
|
||||||
|
"""
|
||||||
global _qt_win, _qt_app
|
global _qt_win, _qt_app
|
||||||
screen = _qt_app.screenAt(_qt_win.centralWidget().geometry().center())
|
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
# breakpoint()
|
tries = 3
|
||||||
# wait for 6 seconds to grab screen
|
for _ in range(3):
|
||||||
while screen is None and (
|
screen = _qt_app.screenAt(_qt_win.pos())
|
||||||
(time.time() - start) < timeout
|
print(f'trying to get screen....')
|
||||||
):
|
if screen is None:
|
||||||
screen = _qt_app.screenAt(_qt_win.centralWidget().geometry().center())
|
time.sleep(0.5)
|
||||||
time.sleep(0.1)
|
continue
|
||||||
log.info("Couldn't acquire screen trying again...")
|
|
||||||
|
|
||||||
if screen is None:
|
break
|
||||||
raise RuntimeError("Failed to acquire screen?")
|
else:
|
||||||
|
if screen is None:
|
||||||
|
# try for the first one we can find
|
||||||
|
screen = _qt_app.screens()[0]
|
||||||
|
|
||||||
|
assert screen, "Wow Qt is dumb as shit and has no screen..."
|
||||||
return screen
|
return screen
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue