1212
1313# Local imports
1414from backend .common import clean_window_title , format_coords , match_titles , parse_coords
15- from backend .constants import AOT_HOTKEY , IGNORED_WINDOWS , LayoutDefaults
15+ from backend .constants import AOT_HOTKEY , IGNORED_WINDOWS , LayoutDefaults , UIConstants
1616
1717DEFAULT_LAYOUTS = {
1818 1 : LayoutDefaults .ONE_WINDOW ,
2727class ApplicationSettings :
2828 """Application settings container."""
2929
30+ screen_resolution_override : str = ""
3031 compact : bool = False
3132 use_images : bool = False
3233 snap : int = 0
@@ -157,6 +158,7 @@ def load_settings(self)-> ApplicationSettings:
157158 try :
158159 settings = json .load (f )
159160 ui_settings = settings .get ("ui" , {})
161+ screen_resolution_override = ui_settings .get ("screen_resolution_override" , "" )
160162 compact = ui_settings .get ("compact" , False )
161163 use_images = ui_settings .get ("use_images" , False )
162164 snap = ui_settings .get ("snap" , 0 )
@@ -171,6 +173,7 @@ def load_settings(self)-> ApplicationSettings:
171173 return ApplicationSettings ()
172174
173175 return ApplicationSettings (
176+ screen_resolution_override ,
174177 compact ,
175178 use_images ,
176179 snap ,
@@ -187,6 +190,7 @@ def load_settings(self)-> ApplicationSettings:
187190 def save_settings (self , app_settings : ApplicationSettings )-> bool :
188191 """Save application settings, optionally including layouts and overrides."""
189192 settings = {"ui" : {
193+ "screen_resolution_override" : app_settings .screen_resolution_override ,
190194 "compact" : app_settings .compact ,
191195 "use_images" : app_settings .use_images ,
192196 "snap" : app_settings .snap ,
@@ -325,3 +329,16 @@ def delete_config(self, name:str)->bool:
325329 return False
326330 return True
327331 return True
332+
333+ def validate_screen_res_override (self , screen_resolution : str ) -> bool :
334+ """Validate the screen resolution override."""
335+ min_w = UIConstants .WINDOW_MIN_WIDTH
336+ min_h = UIConstants .WINDOW_MIN_HEIGHT
337+ if not screen_resolution :
338+ return False
339+ split_res = screen_resolution .split ("," )
340+ if len (split_res ) != 2 :
341+ return False
342+ return all (res .strip ().isdigit () for res in split_res ) and (
343+ int (split_res [0 ]) >= min_w and int (split_res [1 ]) >= min_h
344+ )
0 commit comments