Bug 384950 - Windows 7: if open a file via --launcher.openFile in an already running application, the window isn't brought to front
Summary: Windows 7: if open a file via --launcher.openFile in an already running appli...
Status: CLOSED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Launcher (show other bugs)
Version: 3.8.0 Juno   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: Luna M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-12 10:15 EDT by Holger Voormann CLA
Modified: 2014-04-15 14:25 EDT (History)
4 users (show)

See Also:


Attachments
Screenshot: "--launcher.openFile" in Windows 7 (119.51 KB, image/png)
2012-07-12 10:15 EDT, Holger Voormann CLA
no flags Details
Proposed patch (455 bytes, patch)
2012-08-08 16:40 EDT, Holger Voormann CLA
no flags Details | Diff
Patched 32-bit "eclipse_1503.dll" compiled by "Microsoft Visual Studio 2010 Express" (plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120522-1813\eclipse_1503.dll) (48.00 KB, application/octet-stream)
2012-08-08 16:46 EDT, Holger Voormann CLA
no flags Details
library (52.00 KB, application/x-msdownload)
2012-08-16 16:20 EDT, Silenio Quarti CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Voormann CLA 2012-07-12 10:15:57 EDT
Created attachment 218643 [details]
Screenshot: "--launcher.openFile" in Windows 7

In contrast to Windows XP, Windows 7 prevents an application window to bring itself to the front. Instead, the window will stay in the background and the associated taskbar button is flashing.

This happens if a file is opened via --launcher.openFile. If the application is not yet running then the application will be started and its window will be brought to front and will get the focus. Unfortunately, if the application is already running then the file is opened in the already opened window in the background. The task bar icon is flashing but the window will be stay in the background.

Maybe Windows 7 allows the second started application process that triggers the SWT.OpenDocument event somehow to transfers its focus to the already running application (instead, that the already running application tries to grab the focus itself), similar to an already opened folder on the Desktop that is double-clicked again.
Comment 1 Holger Voormann CLA 2012-08-08 16:40:49 EDT
Created attachment 219690 [details]
Proposed patch
Comment 2 Holger Voormann CLA 2012-08-08 16:46:32 EDT
Created attachment 219692 [details]
Patched 32-bit "eclipse_1503.dll" compiled by "Microsoft Visual Studio 2010 Express" (plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120522-1813\eclipse_1503.dll)

Patched DLL successfully tested in Windows Server 2008 R2 64-bit and Windows XP 32-bit (both with a 32-bit JRE).
Comment 3 Holger Voormann CLA 2012-08-14 02:35:10 EDT
(In reply to comment #2)
> Created attachment 219692 [details]
> Patched 32-bit "eclipse_1503.dll" compiled by "Microsoft Visual Studio 2010
> Express"

Unfortunately, in a Windows 7 (German) system eclipse.exe fails to start with the patched "eclipse_1503.dll" because "msvcr100.dll" is required but missing. It seems the patched DLL was linked dynamically instead of statically (see http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx). Maybe, this was caused by using Microsoft Visual Studio 2010 Express instead of Microsoft Visual C/C++ Compiler 6.0 to compile and link the patched DLL.

Would it possible to create a patched DLL by the Eclipse tool chain (Visual C/C++ 6.0)?

Git repository: git://git.eclipse.org/gitroot/equinox/rt.equinox.framework.git
(or download as ZIP from GitHub: https://github.com/eclipse/rt.equinox.framework/zipball/master)
Build file: root/bundles/org.eclipse.equinox.executable/library/win32/build.bat
Comment 4 Holger Voormann CLA 2012-08-16 16:06:09 EDT
It is not about statically vs. dynamically linking but compiling with "Microsoft Visual Studio 2010 Express" vs. "Microsoft Visual C++ 6.0" (see http://kobyk.wordpress.com/2007/07/20/dynamically-linking-with-msvcrtdll-using-visual-c-2005/). Unfortunately, there is no free edition of Visual C++ 6.0. Could someone apply the patch and use the Eclipse tool chain to create the DLL?

I like to use Eclipse Help as help system for a Windows application by using the "openFile" feature to reusing an already opened Help window (code available at http://helpaddons.sf.net). In this scenario this issue is very important because without this patch an already opened Help window is not brought to front.
Comment 5 Silenio Quarti CLA 2012-08-16 16:20:43 EDT
Created attachment 219978 [details]
library

Here is it.
Comment 6 Holger Voormann CLA 2012-08-16 18:51:44 EDT
(In reply to comment #5)
> Created attachment 219978 [details]
> library
> 
> Here is it.

Thank you very much! :-)))

Your DLL solves the openFile focus problem without the requirement of "msvcr100.dll". Great!
Comment 7 Thomas Watson CLA 2014-01-30 08:35:47 EST
There is a gerrit patch set for this at:

https://git.eclipse.org/r/#/c/21315/
Comment 8 Holger Voormann CLA 2014-02-25 04:27:07 EST
(In reply to Thomas Watson from comment #7)
> There is a gerrit patch set for this at:
> 
> https://git.eclipse.org/r/#/c/21315/
>
See Bug 427775 - Always failing Hudson job seems to block contributions via Gerrit
Comment 9 Holger Voormann CLA 2014-03-27 19:07:36 EDT
cc'ing Silenio: Could you please review https://git.eclipse.org/r/21315 ?
Comment 10 Silenio Quarti CLA 2014-03-28 10:16:11 EDT
I believe the patch is fine.

Arun please review it and decide whether this should be commit for 4.4.
Comment 11 Arun Thondapu CLA 2014-04-09 15:13:26 EDT
(In reply to Silenio Quarti from comment #10)
> I believe the patch is fine.
> 
> Arun please review it and decide whether this should be commit for 4.4.

Thanks Silenio, the patch looks good and I think we should fix this for Luna.
Comment 12 Arun Thondapu CLA 2014-04-14 17:42:01 EDT
Thanks for committing the patch Silenio! The rebuilt binaries are also committed now - https://git.eclipse.org/c/equinox/rt.equinox.binaries.git/commit/?id=332c87e5ef36644994b776fbc826965a5737a0db , marking the bug as resolved.
Comment 13 Holger Voormann CLA 2014-04-15 14:25:07 EDT
Verified with:
- eclipse-SDK-I20140415-0800-win32
- eclipse-SDK-I20140415-0800-win32-x86_64

Thx for fixing this bug! :-)