I’m in the final stages of making my app slick and I notice a weird height flickering in certain cases when I’m resizing the main window. (The content in my window doesn’t flick, that works rock-solidly during resizes, very slick!)
I traced it down to a feedback loop with my persistence layer that would occasionally trigger for a few rounds. It seems hard to avoid, now I’ve traced it down…
So, is there any way to detect whether a resize() (or moved()) update to your main window was triggered by a user action? Failing that, is there a way to get a callback when the user finishes resizing (or moving) your main window? (That’s really what I want - right now, I get a stream of changes which I apply, but for my persistence layer I’d much rather just store the value once, when the user has finished the operation…)
Everything’s already done asynchronously exactly that way.
In fact, that’s part of the issue. When someone’s vigorously resizing my fairly complex window, a lot of events get posted and then appear quite a bit later on the MessageManagerLock. My persistence layer sees these as a new event, undoing the event that the persistence layer just stored, when in fact it’s a late arrival from the window being resized in a hurry.
Really, what I need is an event when a user has finished resizing or moving a window. That’s the sort of thing that pretty well anyone who was trying to persist the state of their main window could make good use of…
AFAIK I don’t think there is a reliable way to get an event for that on all platforms… It could be possible to have a method that can ask whether the user is currently resizing, but again I’m not 100% sure if that’s possible everywhere. Hmm.
haydnx: wow, that’s an incredibly useful bit of code you have there, noted!
However, I don’t think this will work for me. The trouble is that I’m interested in the resizing of the main window, so I don’t think I get an initial mouse-down event anywhere…
So right now my best guess is to have another thread that makes sure that you haven’t done anything for a few hundred milliseconds before actually sending off the “official” window resize event into the persistence system - sort of an extension of the “call async” strategy. This prevents the underlying issue, where callbacks from the persistence system and the GUI are interleaving.
This is really not a bad idea anyway, so I’m on it. One more thread, not a huge cost…