-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
widget_utils - Remove the overlay on cleanup #3394
Conversation
Yeah I think this is safe, I do have a few ideas about being able to share |
I have thought about extracting the code for handling "background" watches and screen event handlers into a library. Maybe it would be useful in a library for shared overlay access. |
While we're on the topic, I suppose we need to figure out what should happen if two apps want to use the overlay at once. Do we raise an error? Block on a promise? |
I think there should be some kind of priority based decision. Higher priority overlays replace other overlays and the removed overlay is informed via callback that it has been removed. An example would be swiped down widgets on a clock and a message incoming. The message overlay would be displayed directly and the lower priority overlay is just removed. |
I like the sound of that, I suppose the promise blocking could be surprising to a user - for example, they've just hidden one overlay, then another pops up immediately as if it just arrived, when it's actually been waiting all along. What about something like this: var overlay = require("overlay")
var priority = ??? // A number?
var o = overlay.claim(priority)
if (o) {
// We can now draw to the overlay, move it around, etc
o.setOverlay(...)
// At some later point in time
o.release()
// Or we can:
o.onRemove = () => {
// A higher priority overlay event came in
}
o.onAttempt = () => {
// A lower (or same) priority overlay event came in, but we still have the overlay
// Perhaps we draw a little icon or alter a widget to indicate there's something else wanting to appear
// (I feel like `onAttempt` isn't a great name here)
}
} else {
// Current overlay is notified via its `onAttempt`, we don't have the overlay
overlay.onRelease(() => {
// Add ourselves to the queue?
})
} |
Seems like that could work. An alternative would be extending the |
Good idea - #3417 |
Change looks good btw, thanks! |
Hi - Sorry, I just saw this one. I guess from my point of view, this looks like quite a lot of code when just Was there a specific app/thing where this really caused a problem? I just mentioned in #3417 - maybe I change the firmware to allow >1 overlay? I guess priority could still be an issue but I wonder how much we care for things that are only supposed to display for a few seconds if the most recent thing displays on top |
My usecase is Example: Be in clock with swiped down widgets, message is drawn as overlay (replacing widgets), timeout of
|
Ok, thanks for the explanation. As it's in we might as well make any new changes after #3417 - my concern is that this code pattern might be copied (eg for messagesoverlay) and then all kinds of problems get introduced with overwritten |
Currently a swiped down widget bar stays on display when fastloading from clock to launcher. This cleans up the overlay if nothing else called
setLCDOverlay
in the meantime.This will fail if something else replaces
setLCDOverlay
. That might not be problematic since there are limited use cases for doing that?