diff --git a/backend/consts/default_config.go b/backend/consts/default_config.go index 58f168b..42aceed 100644 --- a/backend/consts/default_config.go +++ b/backend/consts/default_config.go @@ -4,3 +4,5 @@ const DEFAULT_FONT_SIZE = 14 const DEFAULT_ASIDE_WIDTH = 300 const DEFAULT_WINDOW_WIDTH = 1024 const DEFAULT_WINDOW_HEIGHT = 768 +const MIN_WINDOW_WIDTH = 960 +const MIN_WINDOW_HEIGHT = 640 diff --git a/backend/services/preferences_service.go b/backend/services/preferences_service.go index bfe00fa..f54b65a 100644 --- a/backend/services/preferences_service.go +++ b/backend/services/preferences_service.go @@ -113,7 +113,7 @@ func (p *preferencesService) GetAppVersion() (resp types.JSResp) { } func (p *preferencesService) SaveWindowSize(width, height int) { - if width >= consts.DEFAULT_WINDOW_WIDTH && height >= consts.DEFAULT_WINDOW_HEIGHT { + if width >= consts.MIN_WINDOW_WIDTH && height >= consts.MIN_WINDOW_HEIGHT { p.UpdatePreferences(map[string]any{ "behavior.windowWidth": width, "behavior.windowHeight": height, diff --git a/backend/services/system_service.go b/backend/services/system_service.go index 0c6cc4e..679c3f1 100644 --- a/backend/services/system_service.go +++ b/backend/services/system_service.go @@ -6,6 +6,7 @@ import ( "log" "sync" "time" + "tinyrdm/backend/consts" "tinyrdm/backend/types" ) @@ -28,6 +29,18 @@ func System() *systemService { func (s *systemService) Start(ctx context.Context) { s.ctx = ctx + + // maximize the window if screen size is lower than the minimum window size + if screen, err := runtime.ScreenGetAll(ctx); err == nil && len(screen) > 0 { + for _, sc := range screen { + if sc.IsCurrent { + if sc.Size.Width < consts.MIN_WINDOW_WIDTH || sc.Size.Height < consts.MIN_WINDOW_HEIGHT { + runtime.WindowMaximise(ctx) + break + } + } + } + } } // SelectFile open file dialog to select a file diff --git a/backend/storage/preferences.go b/backend/storage/preferences.go index a19f2b4..14f3dc8 100644 --- a/backend/storage/preferences.go +++ b/backend/storage/preferences.go @@ -47,8 +47,8 @@ func (p *PreferencesStorage) GetPreferences() (ret types.Preferences) { ret = p.getPreferences() ret.Behavior.AsideWidth = max(ret.Behavior.AsideWidth, consts.DEFAULT_ASIDE_WIDTH) - ret.Behavior.WindowWidth = max(ret.Behavior.WindowWidth, consts.DEFAULT_WINDOW_WIDTH) - ret.Behavior.WindowHeight = max(ret.Behavior.WindowHeight, consts.DEFAULT_WINDOW_HEIGHT) + ret.Behavior.WindowWidth = max(ret.Behavior.WindowWidth, consts.MIN_WINDOW_WIDTH) + ret.Behavior.WindowHeight = max(ret.Behavior.WindowHeight, consts.MIN_WINDOW_HEIGHT) return } diff --git a/main.go b/main.go index 94ed2bb..ee76a97 100644 --- a/main.go +++ b/main.go @@ -44,8 +44,8 @@ func main() { Title: "Tiny RDM", Width: windowWidth, Height: windowHeight, - MinWidth: consts.DEFAULT_WINDOW_WIDTH, - MinHeight: consts.DEFAULT_WINDOW_HEIGHT, + MinWidth: consts.MIN_WINDOW_WIDTH, + MinHeight: consts.MIN_WINDOW_HEIGHT, Frameless: runtime.GOOS != "darwin", Menu: appMenu, AssetServer: &assetserver.Options{