If a process which is not the current foreground process displays a wxTipWindow, it steals the foreground status from the current foreground process.
I expect displaying a wxTipWindow not to affect which process is the foreground process. However, if a process which is not the current foreground process displays a wxTipWindow, it becomes the foreground process. However, changing the foreground process only happens if the SPI_GETFOREGROUNDLOCKTIMEOUT has expired (see https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow#remarks). I have tried two computers, on one the timeout is 0, so the process changes immediately, and on the other the timeout is 200 seconds, so it takes a few minutes. I have not tried to change the timeout on either computer.
appactive is 1 (meaning that the minimal sample is the foreground process)appactive is 0 (meaning that the minimal sample is NOT the foreground process)cntr in the minimal sample status bar reaches 5, it will display a wxTipWindow. The status bar displays the SPI_GETFOREGROUNDLOCKTIMEOUT. If the timeout has expired, notice that the Task Manager's display changes to the non-foreground state, and the minimal status bar appactive reports 1. (Strangely, the minimal sample display color does not change to the foreground state.)Additional notes:
cntr, reaches 10, the minimal sample will dismiss the wxTipWindowwxTipWindow is dismissed, the cntr resets to 0wxTipWindow is displayed, a wxASSERT reports a double-destroy of the wxTipWindow. I have found a work-around for this problem, but I'm not sure if it's worth applying since the wxASSERT failure might be a side-effect of the focus changes.—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
The foreground change happens because wxPopupWindow::Show() calls SetForegroundWindow(). The call is commented as being required to support mouse capture, but I don't understand why a non-foreground process would need to capture the mouse. On the other hand, I think I only noticed this behavior because my main computer is the one that has the SPI_GETFOREGROUNDLOCKTIMEOUT 0, so my wxWidgets program would steal the foreground even when I was actively doing something else. I don't know what is responsible for setting SPI_GETFOREGROUNDLOCKTIMEOUT, so I am reluctant to try to override the value. I would much rather have my wxWidgets process not try to become the foreground process.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
Can anyone (@New Pagodi) explain why wxPopupWindow::Show() calls SetForegroundWindow() (commit 07f64c3)?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
The way I understand this is that SetForegroundWindow() only does something when the process is in the foreground and that Windows blocks it from doing anything otherwise and the documentation seems to confirm this. But it's obviously not the way it works for you, so maybe we should test if the process is actually foreground (i.e. any of its TLWs is) before doing it?
OTOH I don't know why does a popup window not containing controls need to capture the mouse, so maybe we indeed shouldn't do it at all... But I'd rather keep it as is as I'm not aware of any (other) problems with doing it.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
The way I understand this is that
SetForegroundWindow()only does something when the process is in the foreground and that Windows blocks it from doing anything otherwise and the documentation seems to confirm this.
My interpretation of https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow#remarks is that a traditional desktop application CAN move from background to foreground if SPI_GETFOREGROUNDLOCKTIMEOUT has expired. What documentation confirms that SetForegroundWindow() only acts if the process is in the foreground?
But it's obviously not the way it works for you, so maybe we should test if the process is actually foreground (i.e. any of its TLWs is) before doing it?
I tried this, and it does prevent the activation change. Would you accept a PR making this change?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
Let's add the foreground check, I don't see any harm in doing this.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()