If chosen monitor is not available, choose one that does exist

This commit is contained in:
Grant Sanderson 2021-03-18 17:32:45 -07:00
parent b48ce3f1de
commit 120d26defa
2 changed files with 6 additions and 2 deletions

View file

@ -234,7 +234,9 @@ def get_configuration(args):
# Default to making window half the screen size
# but make it full screen if -f is passed in
monitor = get_monitors()[custom_config["window_monitor"]]
monitors = get_monitors()
mon_index = custom_config["window_monitor"]
monitor = monitors[min(mon_index, len(monitors) - 1)]
window_width = monitor.width
if not args.full_screen:
window_width //= 2

View file

@ -38,7 +38,9 @@ class Window(PygletWindow):
def find_initial_position(self, size):
custom_position = get_customization()["window_position"]
monitor = get_monitors()[get_customization()["window_monitor"]]
monitors = get_monitors()
mon_index = get_customization()["window_monitor"]
monitor = monitors[min(mon_index, len(monitors) - 1)]
window_width, window_height = size
# Position might be specified with a string of the form
# x,y for integers x and y