-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: attach/detach bound devices in tray context menu #6
base: master
Are you sure you want to change the base?
feat: attach/detach bound devices in tray context menu #6
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.
This is a good change so I'll accept it. However there's some changes needed before I merge this.
fb73bb0
to
b4eae05
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.
So I've actually gone and tested this PR, it's a really neat feature!
There's one more issue though: errors while attaching are not reported to the user. We should really spawn a dialog box with the error message, see how it's done in other parts of the attaching code.
Additionally, I've noticed that since attaching takes quite some time, once you click on a device in the menu for attaching it, the menu disappears and it won't open up until the attaching is completed. Now, I'm not even sure how to easily fix this, as every way I come up with requires complex state tracking, so maybe it's fine?
Agreed! I think that I can cause an error by opening the menu, unplugging the device, then attempting to forward it. And trying to forward with WSL shutdown. |
Yeah, it's the same for the main window. I hate threads and state, so my vote is to keep it simple. I see this whenever interacting with Windows USB. Their APIs must block for 200ms - 2s during attach/detach events. |
b4eae05
to
a3ae37a
Compare
I've been running this branch from morning to evening everyday at work for the last month - haven't noticed any problems. |
This PR adds a "nice to have" feature. Generally, I think that the GUI is great and it would be a mistake to put too much functionality in the system tray. Instead, users should be encourage dto open the main window where operations will be less ambiguous.
However, my day-to-day usage rarely involves inspecting unbound devices, binding devices, or setting up auto attach. I have 2 or 3 bound devices and I either want them attached or not.
And so, this PR adds the connected + bound devices in the context menu. A check mark is displayed next to devices that are forwarded. Clicking on a device either attaches or detaches depending on the state.
I am new to Rust and this was hard for me to do. 😢 I am concerned about memory leaks. I have already resolved a stack overflow caused by the event handler closure not being unbound. It was getting added to the stack on every context menu open:
I've tested the current implementation quite a bit now and it seems OK, but it could be totally wrong and unsafe - I simply don't have enough experience with Rust to know! Nevertheless, I think the feature is a good one.
Unaddressed issues: