Bug 161911 - SWT_AWT.new_Shell() in GTK version : SWT component not displayed
Summary: SWT_AWT.new_Shell() in GTK version : SWT component not displayed
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-23 04:47 EDT by Nico CLA
Modified: 2009-06-05 05:07 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nico CLA 2006-10-23 04:47:36 EDT
When I tried with the simple code below, which add an AWT Button and a SWT Button in an AWT Frame, the SWT Components never display.
Here is the code :
public static void main(String[] args) {
        java.awt.Frame frame = new java.awt.Frame("AWT Frame");
        java.awt.Button button = new java.awt.Button("AWT Button");
        frame.add(button, java.awt.BorderLayout.NORTH);
        java.awt.Canvas canvas = new java.awt.Canvas();
        frame.add(canvas, java.awt.BorderLayout.CENTER);

        frame.addNotify();

        Display display = new Display();
        Shell shell = SWT_AWT.new_Shell(display, canvas);
        shell.setLayout(new FillLayout());
        Button swtButton = new Button(shell, SWT.PUSH);
        swtButton.setText("SWT Button");

        frame.setBounds(20, 20, 300, 300);
        shell.layout();
        frame.setVisible(true);

        shell.layout(true, true);
        while (!shell.isDisposed()) {
                if (!display.readAndDispatch()) display.sleep();
        }
}

I tried with "xwininfo -children -all" and I get the following :

0x2000008 "Content window": ("sun-awt-X11-XContentWindow"
"moulinette-TestSWT_AWT")  300x300+-4+-20  +20+20
        2 children:
        0x200000a "sun-awt-X11-XButtonPeer": ("sun-awt-X11-XButtonPeer"
"moulinette-TestSWT_AWT")  290x23+5+25  +25+45
        0x200000c "sun-awt-X11-XCanvasPeer": ("sun-awt-X11-XCanvasPeer"
"moulinette-TestSWT_AWT")  290x247+5+48  +25+68
           1 child:
           0x2a0001f "": ("SWT" "SWT")  1x1+0+0  +25+68
              2 children:
              0x2a00021 (has no name): ()  290x247+0+0  +25+68
                 1 child:
                 0x2a00022 (has no name): ()  290x247+0+0  +25+68
              0x2a00020 (has no name): ()  1x1+-1+-1  +24+67

So it seems that the SWT component is created, but I can't see it.
I tried to debug the code with Eclipse, and the it seems it comes from the
_gtk_widget_realize(widget) method from OS class.
It may be a GTK bug ?
I tried under Mandrake 8.1 under GTK 2.4.14, with Fedora Core 3 with GTK 2.4.14-3-fc3-1 and with Ubuntu Dapper under GTK 2.8.17.
According to Silenio Quarti, it works under Fedora Core 5.
Comment 1 Zhaohui Gao CLA 2007-05-07 14:04:06 EDT
We are experiencing the same problem on Redhat Linux. We want to use SWT_AWT Bridge to embed SWT widgets in Swing/SWT applications. Everything works fine on Windows, but not on Linux. 

org.eclipse.swt.gtk.linux.x86_3.2.1.v3235.jar
RedHat Enterprise Linux AS Release 3
ibm-java2-sdk-5.0-4.0-linux-i386 
Comment 2 Steve Northover CLA 2007-05-24 09:57:10 EDT
Under consideration for Eclipse 3.3 RC2.
Comment 3 Zhaohui Gao CLA 2007-05-24 14:04:53 EDT
Some additional info for my previous comment:

We experienced this problem when we tried to test embedding SWT browser widget in Swing JFrame. The problem, according to the description here, seems genetic and has nothing to do with the SWT browser widget. However, if possible, please also test the fix for the browser widget, so that we can be sure that the build containing the fix is good for us. Thanks.
Comment 4 Silenio Quarti CLA 2007-05-24 15:06:04 EDT
Ok, I tracked this one down. The problem here is that the AWT canvas is not mapping the X window of our GTK plug in response to the PropertyNotify event for _XEMBED_INFO.

According to the XEmbed protocol (http://standards.freedesktop.org/xembed-spec/xembed-spec-0.5.html), the embedder needs to listen for the PropertyNotify event and map the client window when the XEMBED_MAPPED flag is set. 

Oleg, do you know any way we can make the AWT canvas (or any other awt widget) listen for that property change event? I guess we need to know if AWT implemented the server side of the XEmbed procotol?
Comment 5 Oleg Sukhodolsky CLA 2007-05-31 06:28:48 EDT
> Oleg, do you know any way we can make the AWT canvas (or any other awt widget)
> listen for that property change event? I guess we need to know if AWT
> implemented the server side of the XEmbed protocol?

AWT implemented server side of XEmbed protocol (you should enable it however by setting sun.awt.xembedserver property to true).

At the same time I see that the problem is reproducible with swt 3.3RC2 with jdk
6 and 6u1.  Good new is that we have made big changes in this area for 7.0 and
the test works fine with 7.0b09 and there is a chance that the problem will be
fixed in 6u2 (since we have back-ported most of XEmbed-related changes there).

If 6u2 will still have the same problem and someone really wants to see it fixed
in 6uX, I'd suggest to file bug against AWT ans escalate it.
Comment 6 Oleg Sukhodolsky CLA 2007-05-31 08:40:34 EDT
Just checked with latest build of 6u2 and it looks like the test works correctly.
Comment 7 Steve Northover CLA 2007-06-06 13:22:58 EDT
This is a bug in AWT.  We WONTFIX it (Oleg will).
Comment 8 Zhaohui Gao CLA 2007-06-06 15:13:15 EDT
Hi Oleg, can you please post details of how to get the build for the fix? Seems that the fix is in JDK/AWT. Do we have to use a certain version of JDK for this fix and where we can get the build?  Thanks.
Comment 9 Oleg Sukhodolsky CLA 2007-06-07 00:33:58 EDT
I've used latest builds of jdk7 (can get it from https://jdk7.dev.java.net/)
And 6u3 which you can get until it will be shipped (not sure what is the target date for this :(

I've verified the problem with the test from this bug, so you can download jdk7 and double-check if the problem you have is fixed there.

If you need/think that the problem should be fixed in 5uX then you need to file a separate Sun bug and escalate it.

Hope this helps.
Comment 10 Zhaohui Gao CLA 2007-06-11 14:03:17 EDT
Hi Oleg, thanks for the response. Yes, I would like to open a defect against 5ux and 6ux (if needed). Could you help draft the details of the defect? From the information provided below, I could not figure out what to write so that JDK team understands the problem. It may be even better if you can open the defect since you can explain the root cause better. Either way, please let me know, thanks!
Comment 11 Oleg Sukhodolsky CLA 2007-06-11 14:44:52 EDT
> Yes, I would like to open a defect against 5ux and 6ux (if needed). Could you
> help draft the details of the defect? From the information provided below, I
> could not figure out what to write so that JDK team understands the problem. It
> may be even better if you can open the defect since you can explain the root
> cause better.

I do not know the cause, I've just verified that the problem is not reproducible
with latest builds.  I think that link to this bug will be enough to file a bug.
As for escalation, I'm not sure about exact algorithm, but it should be 
something like "contact Sun's java support and ask them to fix this problem" :) 
of course you need to have some kind of support agreement (as far as I can see 
you are from IBM so I think it is not a problem for you :)

Of course the bug should be filed against AWT and you could also mention me in 
it (this could speed up evaluation of the problem)
Comment 12 Oleg Sukhodolsky CLA 2007-06-11 16:01:32 EDT
BTW I think it is worth to mention:  AWT provides support for server side XEmbed 
protocol from 6.0.  So, the same issue in 5.0 might have completely different 
cause (I presume that SWT uses something else in this case).  XEmebed server support can be backported to 5.0 :(
Comment 13 Jan Kümmel CLA 2007-06-16 05:12:14 EDT
I can still reproduce the problem with swt 3.2.1 and jdk7-b09 as well as jdk7-b13.

java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b13)
Java HotSpot(TM) 64-Bit Server VM (build 1.7.0-ea-b13, mixed mode)

Has anyone filed a sun issue yet?
Comment 14 Oleg Sukhodolsky CLA 2007-06-18 05:30:05 EDT
have you set sun.awt.xembedserver property to true?
Comment 15 Silenio Quarti CLA 2007-06-18 09:47:15 EDT
I tried setting the property, but it did not make a difference for me. I noticed that a new type of peer was created, but the widget was still invisible.
Comment 16 Silenio Quarti CLA 2007-06-18 09:50:30 EDT
Just to clarify, I tried setting the property on jdk1.6.0. So I was not expecting it to work.
Comment 17 Oleg Sukhodolsky CLA 2007-06-18 10:09:16 EDT
It is expected that the test doesn't work with 6.0.
But what about 7.0 b13?
Comment 18 Jan Kümmel CLA 2007-06-18 15:12:35 EDT
I tried with and without setting sun.awt.xembedserver property to true. I never see the swt component.
Comment 19 Oleg Sukhodolsky CLA 2007-06-19 12:37:32 EDT
for me it works with jdk 7.0 b13 swt 3.3RC2 and doesn't work with SWT 3.2.2 :( it 
looks like there is no XEMBED_INFO atom on embedded window in case of 3.2.2, so I 
suspect this is an SWT issue.
Comment 20 Jan Kümmel CLA 2007-06-19 14:48:43 EDT
yes, I finally got it working with jdk1.7-b13 and swt-3.3_rc4. No need to manually set sun.awt.xembedserver to true, though. Obviously, some change in swt fixed it, shouldn't this issue be set to fixed, then? Btw, I used the sun xembed layer in jdk6 and jdk7 successfully in my own gtk/awt bridge, so I can confirm that it generally worked (although I had to call XEmbedCanvasPeer embedChild manually per reflection in jdk6)
Comment 21 P.Q.Huy CLA 2007-07-09 09:24:32 EDT
(In reply to comment #20)
> yes, I finally got it working with jdk1.7-b13 and swt-3.3_rc4. No need to
> manually set sun.awt.xembedserver to true, though. Obviously, some change in
> swt fixed it, shouldn't this issue be set to fixed, then? Btw, I used the sun
> xembed layer in jdk6 and jdk7 successfully in my own gtk/awt bridge, so I can
> confirm that it generally worked (although I had to call XEmbedCanvasPeer
> embedChild manually per reflection in jdk6)

hey, i tried with JDK 7-b15, SWT 3.3 and GTK 2.10 (Fedora 7), and SWT component not displayed.
Comment 22 Oleg Sukhodolsky CLA 2007-07-09 09:30:36 EDT
(In reply to comment #21)
> (In reply to comment #20)
> > yes, I finally got it working with jdk1.7-b13 and swt-3.3_rc4. No need to
> > manually set sun.awt.xembedserver to true, though. Obviously, some change in
> > swt fixed it, shouldn't this issue be set to fixed, then? Btw, I used the sun
> > xembed layer in jdk6 and jdk7 successfully in my own gtk/awt bridge, so I can
> > confirm that it generally worked (although I had to call XEmbedCanvasPeer
> > embedChild manually per reflection in jdk6)
> 
> hey, i tried with JDK 7-b15, SWT 3.3 and GTK 2.10 (Fedora 7), and SWT component
> not displayed.
> 

do you use exactly the same test as in the description? and have use set sun.awt.xembedserver to true?
Comment 23 Christopher Deckers CLA 2008-03-06 11:54:46 EST
There is now a bug on Sun's database to fix embedding native components in Swing on Linux with Java 5.

Cast your votes here:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6671386