Fork me on GitHub
#java
<
2022-03-30
>
Nundrum13:03:53

Time for a crazy java question. My goal is to do in Java/AWT/X11 what happens in vroot.h: find the ID of an existing window and use that ID to draw in that window. Easy to do in C. But Java necessarily covers that up. I believe all I need to do is take the line below and replace the call to XCreateWindow and just assign the window ID I have. https://github.com/openjdk/client/blob/master/src/java.desktop/unix/classes/sun/awt/X11/XBaseWindow.java#L380 The question is how to do that without patching AWT itself.

Nundrum13:03:36

I think I can do that by extending all of the classes in this tree? Class XWindowPeer

sun.awt.X11.XBaseWindow                     <-- XCreateWindow happens here  
   sun.awt.X11.XWindow                                                     
       sun.awt.X11.XComponentPeer                                          
           sun.awt.X11.XCanvasPeer                                         
               sun.awt.X11.XPanelPeer                                      
                   sun.awt.X11.XWindowPeer                                 

emccue13:03:07

Why not copy paste those classes and put a 2 on the end?

emccue13:03:36

No need to be smart particuarly

Nundrum14:03:26

I guess? I was going to call them, for example, XForeignBaseWindow

Nundrum14:03:42

I've pretty much tried that but keep running into compile issues

Nundrum14:03:25

symbol: class ForeignComponentPeer
/home/robbie/Wrkspc/jnatest/src/java/XForeignComponentPeer.java:112: error: cannot find symbol
    XForeignComponentPeer (XCreateWindowParams params) {

Nundrum14:03:47

I put this in project.clj: *:java-source-paths* ["src/java","/home/robbie/Git/openjdk-client/src/java.desktop"]

Nundrum14:03:56

Hrm I got some improvement by changing java source paths to:

openjdk-client/src/java.desktop/unix/classes
openjdk-client/src/java.desktop/unix/native 
openjdk-client/src/java.desktop/share/classes

Nundrum15:03:41

Keep getting stuck on this:

src/java/XForeignComponentPeer.java:1162: error: cannot find symbol                                                                                                                   
    protected boolean isEventDisabled(XEvent e) {
                                      ^
  symbol:   class XEvent
  location: class XForeignComponentPeer

Nundrum22:03:48

Here's an attempt to separate out just the Java parts https://github.com/robbieh/AWTForeignXWindow/