Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347579

Summary: Metacity-Hack in Shell breaks things instead of fixing them
Product: [Eclipse Project] Platform Reporter: Daniel Migowski <dmigowski>
Component: SWTAssignee: Eric Williams <ericwill>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, ericwill, gheorghe, pwebster, remy.suen, xixiyan
Version: 3.6.2Keywords: triaged
Target Milestone: 4.9 M2   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/124799
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=48e508c2ce47ad9cf833776891ac30e305bfd84e
Whiteboard:
Attachments:
Description Flags
Snippet to test the behaviour. none

Description Daniel Migowski CLA 2011-05-29 11:32:10 EDT
Created attachment 196850 [details]
Snippet to test the behaviour.

I have problems using the forceActive() function in Shell, on Linux-gdk with a Metacity 2.22 window manager.

The source code of Shell contains the following lines:

		/*
		* Bug in metacity.  Calling gdk_window_focus() with a timestamp more
		* recent than the last user interaction time can cause windows not
		* to come forward in versions > 2.10.0.  The fix is to use the last
		* user event time. 
		*/
		if (display.windowManager.toLowerCase ().equals ("metacity")) {
			OS.gdk_window_focus (window, display.lastUserEventTime);
		} else {
			OS.gdk_window_focus (window, OS.GDK_CURRENT_TIME);
		}

In my case the lastUserEventTime hack does not work, but the other line the the OS.GDK_CURRENT_TIME does.

To reproduce try my attached snipped. It will create a shell with a tree and waits for input on the command line. For each time pressing enter here (I usually do this from within my Eclise IDEs console), the window should be brought to front, but this does not work here. Only if I override the windowmanager in Display the function works. 

I do not know in which cases the hack is needed, but for me it just breaks things. PS: Bringing the window to front in my snippet forst works, since lastUserEventTime is still 0 then, which is the same as the OS constant.

Please remove this hack altogether until you find more information on when it is really needed. Please contact me if you need more info.

PS: I tested this with SWT 3.5.2, but 3.6.2 also still contains this piece of code.
Comment 1 Eclipse Genie CLA 2018-06-20 15:32:19 EDT
New Gerrit change created: https://git.eclipse.org/r/124799
Comment 3 Eric Williams CLA 2018-06-20 15:49:14 EDT
(In reply to Eclipse Genie from comment #2)
> Gerrit change https://git.eclipse.org/r/124799 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=48e508c2ce47ad9cf833776891ac30e305bfd84e

Patch is merged, removed dead metacity code.