Callback for application changed vs window changed

I’m trying to handle the situation where a user is switching to/from my application.

In other words, I want to know when my application is made the “current” one, or if another app is made “current”, if that makes any sense.

I was thinking that I could use the activeWindowStatusChanged() callback on all my windows, and from there, call the TopLevelWindow::getActiveTopLevelWindow() function. Am I correct in thinking that if getActiveTopLevelWindow() returns 0, my application isn’t “current”?

You might want to look at Process::isForegroundProcess() too.

Yeah, I guess that is what I’d want to use. But since there’s no callback for when the foreground process changes, would you still recommend I use activeWindowStatusChanged() to do the isForegroundProcess() check?

Yes, that’d work.