Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change window minimumSize to 750x450, and default size based on screen resolution #3663

Merged
merged 4 commits into from
Sep 16, 2024

Conversation

levkropp
Copy link
Contributor

@levkropp levkropp commented Sep 5, 2024

close #3590

We can use the window_size flutter plugin from google's flutter desktop embeddings repository https://github.com/google/flutter-desktop-embedding/tree/main/plugins/window_size
to check the size of the screen, and

  • if the size of the screen is below 1600x900, open a small 750x450 window
  • if the size of the screen is larger then open the 1400x822 window that multipass is currently set to by default. We can also think of more reactive functionality than this but I don't think it's necessary.

We'll need to add this plugin to pubspec.yaml, but it's an official plugin from Google the closest-to-official Flutter plugin that handles screen size and it seems that the only reason that this plugin needs to be added at all is because Google has not yet added this functionality to the Flutter framework itself

@levkropp levkropp linked an issue Sep 5, 2024 that may be closed by this pull request
Copy link

codecov bot commented Sep 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.86%. Comparing base (eca4986) to head (42ce182).
Report is 74 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3663      +/-   ##
==========================================
- Coverage   88.88%   88.86%   -0.03%     
==========================================
  Files         254      254              
  Lines       14256    14269      +13     
==========================================
+ Hits        12672    12680       +8     
- Misses       1584     1589       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@levkropp levkropp changed the title change window minimumSize to 750x500 from 1000x600 in main.dart change window minimumSize to 750x450, and default size based on screen resolution Sep 5, 2024
ricab
ricab previously approved these changes Sep 6, 2024
Copy link
Collaborator

@ricab ricab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo the inline suggestion.

Comment on lines 29 to 30
if (screen != null && screen.frame.size.width > 1600
&& screen.frame.size.height > 900) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolutions tend to stick to round numbers, so maybe use >=.

Comment on lines 24 to 26

await setupLogger();
// Get the current screen size
final screen = await getCurrentScreen();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removing the logger setup?

Also, since we only care about the screen size, not the entire screen object, you could do something like

final screenSize = await getCurrentScreen().then((screen) {
    return screen?.frame.size;
});

so that you don't have to do the .frame.size thing multiple times

Comment on lines 27 to 34
Size windowSize;

await windowManager.ensureInitialized();
const windowOptions = WindowOptions(
if (screen != null && screen.frame.size.width >= 1600
&& screen.frame.size.height >= 900) {
windowSize = const Size(1400, 822); // For screens larger than 1600x900
} else {
windowSize = const Size(750, 450); // Default window size
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removing the initialization of the window manager?

Also, you could make windowSize final and initialize it with a ternary operator instead of the if-else.

Copy link
Contributor

@andrei-toterman andrei-toterman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, @levkropp! It looks much better now. But I noticed something is missing. You added a plugin, which also modified the plugin registry files for each platform. And those changes must also be committed.

So you'll have to do something like this in the src/client/gui directory:

flutter config --enable-macos-desktop --enable-windows-desktop
flutter pub get

This should modify some files inside the linux, macos and windows directories related to registered plugins. Please commit those as well.

If you don't already have flutter in your PATH, you can add the multipass/3rd-party/flutter/bin directory to your path. (And by this I mean of course the entire path of that directory)

Copy link
Contributor

@andrei-toterman andrei-toterman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, LGTM. Thanks, @levkropp!

@ricab ricab added this pull request to the merge queue Sep 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 16, 2024
@andrei-toterman andrei-toterman added this pull request to the merge queue Sep 16, 2024
Merged via the queue into main with commit 431d500 Sep 16, 2024
14 checks passed
@andrei-toterman andrei-toterman deleted the gui-window-size-adjustment branch September 16, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GUI opens larger than screen on lower resolutions
3 participants