-
Notifications
You must be signed in to change notification settings - Fork 658
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
call windowManager.show() and windowManager.restore() together as an extension #3671
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good that you found this method, @levkropp! But there are multiple places where we call show
, and I think those might need to be replaced by restore
as well :)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3671 /- ##
==========================================
- Coverage 88.85% 88.85% -0.01%
==========================================
Files 254 254
Lines 14261 14269 8
==========================================
Hits 12672 12679 7
- Misses 1589 1590 1 ☔ View full report in Codecov by Sentry. |
c4dcfd1
to
f9d76ac
Compare
Good catch @andrei-toterman , thank you! I have replaced the other occurrence of The only other instance of |
@levkropp check |
f9d76ac
to
1724626
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, replacing show
with restore
breaks things on Windows, since the window no longer appears at all after being hidden. Looking at the window_manager
source code, it seems that the Windows implementation of restore
does not call some of the functions called by show
. So there are several options. We could call show
and restore
together all the time. We could fork the plugin and make it do what we need in one function call. Or we could introduce a platform-specific method that calls the appropriate window_manager
methods when needed i.e. show
for Windows and restore
for the rest. Opinions, @levkropp and @ricab?
Do you foresee any issues with just calling show restore? Would it perhaps make things slow? If not, I guess that would be an easy fix. Otherwise, if we find that there is something wrong with the |
No, I don't think there would be any issues with calling both all the time, and that would indeed be an easy fix. Just wanted to hear other opinions :) |
1724626
to
99b27ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@levkropp I think we first need show
and then restore
. On Windows, restore
has no effect until show
is called (which might not be a problem, but better safe than sorry). Also, you could group those two method calls into a single function, so you don't have to actually call them together all the time.
You could look into creating an extension method for the WindowManager
class called showAndRestore
or something like that. Make sure the method is async and awaits both show
and restore
;)
You can place that extension in the tray menu file, since that's the most relevant place I can think of...
Thank you for the feedback @andrei-toterman ! I like the idea of making an extension for window_manager to handle this as well If we place the extension in the tray_menu file then I believe we'll have to import tray_menu.dart to access it if we want to use it for goToPrimary in main.dart We could make a new .dart file to hold the extension, or perhaps not import the extension at all for the main.dart case since goToPrimary is the only place where restore() is needed |
@levkropp we already import |
99b27ab
to
5a93cd1
Compare
src/client/gui/lib/tray_menu.dart
Outdated
callback: (_, __) async => await windowManager.isVisible() | ||
? windowManager.hide() | ||
: windowManager.show(), | ||
callback: (_, __) async => await windowManager.showAndRestore(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this change? 'Toggle window' is supposed to hide the window if it's visible and show it if it's not.
5a93cd1
to
418162b
Compare
resolve #3667
windowManager.restore()
calls gtk_window_deiconify as well as gtk_window_present https://docs.gtk.org/gtk3/method.Window.deiconify.htmlIn my testing, this has made it so "Open in Multipass" for an instance either
100% of the time, and fixes the issues seen from #3667 without needing to fork the flutter window_manager plugin