Opened 3 years ago

Closed 18 months ago

#13251 closed defect (fixed)

wxExecute generates additional icon in Alt+Tab process list

Reported by: joim Owned by: vadz
Priority: normal Milestone: 2.9.5
Component: wxMSW Version: stable-latest
Keywords: wxExecute Cc:
Blocked By: Blocking:
Patch: yes

Description

I start from my wx program an external program with the wxExecute function (with the wxEXEC_SYNC default parameter).

When I press Alt+Tab while the external program is still running, there are two icons for my wx program in the process list shown by the windows operating system.

I am using Windows XP.

I think this comes from the dummy window "winActive"
in the function void *wxGUIAppTraits::BeforeChildWaitLoop()
in the file src/msw/app.cpp
on line 191

Attachments (1)

app.cpp.patch download (2.5 KB) - added by catalin 19 months ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 3 years ago by vadz

I can't reproduce this in the exec sample, if I synchronously execute notepadin it I only see one icon, not two.

OTOH I also noticed that this workaround with active but hidden window doesn't work anyhow under Windows 7 which still switches to another program when notepad is closed. So it really looks like we need to avoid disabling the main window anyhow. This would require relatively extensive changes however.

comment:2 follow-up: Changed 3 years ago by joim

I see. In the exec sample I also can't reproduce.

But I think, the icon that appears during the notepad is running, is not the icon of the main exec sample window, but the icon of the dummy window (when you debug step by step, you see first disappearing the task icon (wxWindowDisabler) and then reappearing (dummy window show), and you see, that there is no window title below the icon.

When I replace in the exec sample the OnSyncExec function with

Hide ();
wxExecute ("C:
Programme
Notepad++
notepad++.exe", wxEXEC_SYNC);
Show ();

I expect to see no icon, but I see one.

comment:3 Changed 3 years ago by vadz

  • Status changed from new to confirmed

Still not sure what to do about this. Some fresh ideas wanted as the current approach simply doesn't work under Win7 and we still lose focus/activation so we could just as well not do it at all.

comment:4 in reply to: ↑ 2 Changed 19 months ago by catalin

  • Patch set

I can confirm what the OP is seeing. When using wxExecute with wxEXEC_SYNC an icon for the dummy frame is shown in Alt+Tab list.
This can be fixed by changing the dummy frame to a dummy dialog. No secondary effects noticed. It also improves the workaround. Patch attached.

In reply to comment 3: I've tested this under Win7 and the workaround seems to work, I'll try to explain below.
With the dummy frame:
1) the app is active and opens Notepad in a sync way;
2) the user closes Notepad;
3) result: the focus is not always returned to the app; FWIS it is returned if the main frame is the last to have been activated before running wxExecute _and_ was moved around a bit;
With dummy dialog:
1) the app is active and opens Notepad in a sync way;
2) the user closes Notepad;
3) result: the focus is always returned to the app.
Notice that if the user switches to some other app after step 1, the focus is indeed not returned to the wx app after closing Notepad in any of the 2 cases.

Changed 19 months ago by catalin

comment:5 Changed 19 months ago by vadz

  • Milestone set to 2.9.5

Thanks, this looks like a decent workaround. I'll try to test it under XP and if it works there too will apply it. If anybody else can do it, please add a comment about the test results here.

comment:6 Changed 19 months ago by vadz

  • Owner set to vadz
  • Status changed from confirmed to accepted

Seems to work well under XP too, will commit soon, thanks.

comment:7 Changed 18 months ago by VZ

(In [72666]) Set the standard sample icon for the exec sample.

Do this for consistency with all the other ones and also because it makes it
simpler to notice any unwanted icons for hidden windows created by this sample.

See #13251.

comment:8 Changed 18 months ago by VZ

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [72667]) Use a "hidden" dialog, not frame, in sync wxExecute() hack in wxMSW.

Replace a "hidden" (not really, but shown far off screen) frame with a dialog
to avoid this frame appearing in the Alt+TAB list.

Closes #13251.

Note: See TracTickets for help on using tickets.