Thread: [java-gnome-hackers] GtkWindow XID
Brought to you by:
afcowie
From: Goundy <go...@gm...> - 2009-10-24 12:52:56
|
Hi, I'm trying to use gstreamer in a simple java-gnome app by using gstreamer-java. But to be able to embed a video into a Window I've to get back its native xid. So, I modified Java-gnome to implement this: in GtkWindow.java I added: static public final long getWindowXID (Window w){ return pointerOf(w); } and in Window.java I added: public long getWindowXID (){ return GtkWindow.getWindowXID(this); } But when I use this id to embed the video X says BadWindow. Am I getting the xid the right way ? Thanks in advance |
From: Emmanuel R. <emm...@gm...> - 2009-10-24 13:16:35
|
On Sat, Oct 24, 2009 at 2:52 PM, Goundy <go...@gm...> wrote: > Hi, > > I'm trying to use gstreamer in a simple java-gnome app by using > gstreamer-java. But to be able to embed a video into a Window I've to > get back its native xid. > So, I modified Java-gnome to implement this: > > in GtkWindow.java I added: > static public final long getWindowXID (Window w){ > return pointerOf(w); > } > > the XID has to be taken from GdkDrawable, from which GdkWindow inherits. You used a GtkWindow, instead of GdkWindow. I've checked the doc of GdkDrawable [1] and it is missing the accessor for xid wich in C is provide by the function gdk_x11_drawable_get_xid [2]. Without that accesor you will not be able to take the XID of a window. Here's an example on how to embed Gstreamer in a custom Gtk2 application: http://github.com/potyl/perl-GStreamer-Interfaces/blob/master/examples/gst-video-sample.pl The code in Perl, but you should be able to understand easily what's going on. [1] http://java-gnome.sourceforge.net/4.0/doc/api/org/gnome/gdk/Drawable.html [2] http://library.gnome.org/devel/gdk/unstable/gdk-X-Window-System-Interaction.html#gdk-x11-drawable-get-xid -- Emmanuel Rodriguez |
From: Goundy <go...@gm...> - 2009-10-24 14:23:16
|
Emmanuel Rodriguez thank you very much, you helped lot Emmanuel Rodriguez wrote: > > > the XID has to be taken from GdkDrawable, from which GdkWindow > inherits. You used a GtkWindow, instead of GdkWindow. I've checked the > doc of GdkDrawable [1] and it is missing the accessor for xid wich in > C is provide by the function gdk_x11_drawable_get_xid [2]. Without > that accesor you will not be able to take the XID of a window. > > > > -- > Emmanuel Rodriguez The only problem now is that I'm getting: Exception in thread "main" java.lang.UnsatisfiedLinkError: org.gnome.gdk.GdkDrawable.gdk_x11_drawable_get_xid(J)I at org.gnome.gdk.GdkDrawable.gdk_x11_drawable_get_xid(Native Method) at org.gnome.gdk.GdkDrawable.getXID(GdkDrawable.java:508) And I added a call to that native function as: GdkWindow.java: static final long getXID(Drawable self) { long result; if (self == null) { throw new IllegalArgumentException("self can't be null"); } synchronized (lock) { result = gdk_x11_drawable_get_xid(pointerOf(self)); return result; } } Any ideas ? Thanks |
From: Goundy <go...@gm...> - 2009-10-24 14:24:26
|
Goundy wrote: > Emmanuel Rodriguez thank you very much, you helped lot > > Emmanuel Rodriguez wrote: >> >> >> the XID has to be taken from GdkDrawable, from which GdkWindow >> inherits. You used a GtkWindow, instead of GdkWindow. I've checked >> the doc of GdkDrawable [1] and it is missing the accessor for xid >> wich in C is provide by the function gdk_x11_drawable_get_xid [2]. >> Without that accesor you will not be able to take the XID of a window. >> >> >> >> -- >> Emmanuel Rodriguez > The only problem now is that I'm getting: > Exception in thread "main" java.lang.UnsatisfiedLinkError: > org.gnome.gdk.GdkDrawable.gdk_x11_drawable_get_xid(J)I > at org.gnome.gdk.GdkDrawable.gdk_x11_drawable_get_xid(Native Method) > at org.gnome.gdk.GdkDrawable.getXID(GdkDrawable.java:508) > > And I added a call to that native function as: > > GdkWindow.java: > > static final long getXID(Drawable self) { > long result; > > if (self == null) { > throw new IllegalArgumentException("self can't be null"); > } > > synchronized (lock) { > result = gdk_x11_drawable_get_xid(pointerOf(self)); > > return result; > } > } > > Any ideas ? > Thanks > Oh Sorry, I meant GdkDrawable.java * |
From: Emmanuel R. <emm...@gm...> - 2009-10-24 17:01:12
|
On Sat, Oct 24, 2009 at 4:22 PM, Goundy <go...@gm...> wrote: > Emmanuel Rodriguez thank you very much, you helped lot > > Emmanuel Rodriguez wrote: > > > > > > the XID has to be taken from GdkDrawable, from which GdkWindow > > inherits. You used a GtkWindow, instead of GdkWindow. I've checked the > > doc of GdkDrawable [1] and it is missing the accessor for xid wich in > > C is provide by the function gdk_x11_drawable_get_xid [2]. Without > > that accesor you will not be able to take the XID of a window. > > > > > > > > -- > > Emmanuel Rodriguez > The only problem now is that I'm getting: > Exception in thread "main" java.lang.UnsatisfiedLinkError: > org.gnome.gdk.GdkDrawable.gdk_x11_drawable_get_xid(J)I > at org.gnome.gdk.GdkDrawable.gdk_x11_drawable_get_xid(Native Method) > at org.gnome.gdk.GdkDrawable.getXID(GdkDrawable.java:508) > java-gnome is probably not linking against gdk-x11 Try to see if you can link it with gdk-x11-2.0 from pkg-config You can find the exact linker flags by running: pkg-config --libs gdk-x11-2.0 -- Emmanuel Rodriguez |
From: Goundy <go...@gm...> - 2009-10-25 10:34:43
|
Morning, Emmanuel Rodriguez wrote: > > > java-gnome is probably not linking against gdk-x11 > Try to see if you can link it with gdk-x11-2.0 from pkg-config > > You can find the exact linker flags by running: > > pkg-config --libs gdk-x11-2.0 > > Actually it is, I've: goundy@localhost ~ $ pkg-config --libs gdk-x11-2.0 -lgdk-x11-2.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 That's kinda weird. |
From: Emmanuel R. <emm...@gm...> - 2009-10-25 12:03:40
|
On Sun, Oct 25, 2009 at 12:34 PM, Goundy <go...@gm...> wrote: > Morning, > > Emmanuel Rodriguez wrote: > > > > > > java-gnome is probably not linking against gdk-x11 > > Try to see if you can link it with gdk-x11-2.0 from pkg-config > > > > You can find the exact linker flags by running: > > > > pkg-config --libs gdk-x11-2.0 > > > > > Actually it is, I've: > goundy@localhost ~ $ pkg-config --libs gdk-x11-2.0 > -lgdk-x11-2.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo > -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 > > That's kinda weird. > No exactly, this just means that you have the libraries installed, but java-gnome might not be using them (linked). Check with ldd if the java-gnome .so is linked with gdk-x11 ldd tmp/libgtkjni-*.so | grep gdk-x11-2.0 If ldd doesn't show the file then it isn't linked. Try to link it your self by hand: rm tmp/libgtkjni-*.so LDFLAGS=`pkg-config --libs gdk-x11-2.0` build/faster If ldd shows the file in the dependency list then there's something strange going on. -- Emmanuel Rodriguez |
From: Goundy <go...@gm...> - 2009-10-25 12:43:16
|
Emmanuel Rodriguez wrote: > No exactly, this just means that you have the libraries installed, but > java-gnome might not be using them (linked). > > Check with ldd if the java-gnome .so is linked with gdk-x11 > ldd tmp/libgtkjni-*.so | grep gdk-x11-2.0 > > If ldd doesn't show the file then it isn't linked. Try to link it your > self by hand: > rm tmp/libgtkjni-*.so > LDFLAGS=`pkg-config --libs gdk-x11-2.0` build/faster > > If ldd shows the file in the dependency list then there's something > strange going on. > goundy@localhost ~/java-gnome/working/tmp $ ldd libgtkjni-4.0.12-dev.so | grep gdk-x11 libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0xb78ec000) that's odd :°) Btw, I haven't modified any .def file yet, I just added the new accessor in GdkDrawable.java and then linked (in eclipse) the java-gnome project to my testing project. |
From: Emmanuel R. <emm...@gm...> - 2009-10-25 12:49:26
|
On Sun, Oct 25, 2009 at 2:42 PM, Goundy <go...@gm...> wrote: > Emmanuel Rodriguez wrote: > >> No exactly, this just means that you have the libraries installed, but >> java-gnome might not be using them (linked). >> >> Check with ldd if the java-gnome .so is linked with gdk-x11 >> ldd tmp/libgtkjni-*.so | grep gdk-x11-2.0 >> >> If ldd doesn't show the file then it isn't linked. Try to link it your >> self by hand: >> rm tmp/libgtkjni-*.so >> LDFLAGS=`pkg-config --libs gdk-x11-2.0` build/faster >> >> If ldd shows the file in the dependency list then there's something >> strange going on. >> >> goundy@localhost ~/java-gnome/working/tmp $ ldd libgtkjni-4.0.12-dev.so | grep gdk-x11 > libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0xb78ec000) > that's odd :°) > Btw, I haven't modified any .def file yet, I just added the new accessor in > GdkDrawable.java and then linked (in eclipse) the java-gnome project to my > testing project. > Are you sure then that eclipse is picking up the right gtkjini.so file? Did you install your new bindings? -- Emmanuel Rodriguez |
From: Goundy <go...@gm...> - 2009-10-25 12:57:58
|
Emmanuel Rodriguez wrote: > > Are you sure then that eclipse is picking up the right gtkjini.so file? > Did you install your new bindings? > Oh my! when I rebuild my branch, actually my method is being erased as the GdkDrawable file gets replace by the new generated one which doesn't contain my method. I guess I have to edit the source .def file to keep my method right ? |
From: Emmanuel R. <emm...@gm...> - 2009-10-25 13:46:25
|
On Sun, Oct 25, 2009 at 2:57 PM, Goundy <go...@gm...> wrote: > Emmanuel Rodriguez wrote: > >> >> Are you sure then that eclipse is picking up the right gtkjini.so file? >> Did you install your new bindings? >> >> > Oh my! when I rebuild my branch, actually my method is being erased as the > GdkDrawable file gets replace by the new generated one which doesn't contain > my method. > I guess I have to edit the source .def file to keep my method right ? > I think so, I haven't used the java-gnome bindings in a long time. I wish that someone else that's using the bindings could help you :( -- Emmanuel Rodriguez |
From: Goundy <go...@gm...> - 2009-10-25 13:49:55
|
Emmanuel Rodriguez wrote: > On Sun, Oct 25, 2009 at 2:57 PM, Goundy <go...@gm... > <mailto:go...@gm...>> wrote: > > Emmanuel Rodriguez wrote: > > > Are you sure then that eclipse is picking up the right > gtkjini.so file? > Did you install your new bindings? > > > Oh my! when I rebuild my branch, actually my method is being > erased as the GdkDrawable file gets replace by the new generated > one which doesn't contain my method. > I guess I have to edit the source .def file to keep my method right ? > > I think so, I haven't used the java-gnome bindings in a long time. > I wish that someone else that's using the bindings could help you :( > > -- > Emmanuel Rodriguez Okay thank you Emmanuel, you helped a lot :P Well, the generator is giving me: static final FIXME getXid(Drawable self) throws BlacklistedMethodError { throw new BlacklistedMethodError("long"); } and I have the following code in GdkDrawable.defs: (define-method get_xid (of-object "GdkDrawable") (c-name "gdk_x11_drawable_get_xid") (caller-owns-return #t) (return-type "long") ) Am I missing something here ? Thanks |
From: Goundy <go...@gm...> - 2009-10-25 13:59:56
|
Goundy wrote: > Emmanuel Rodriguez wrote: >> On Sun, Oct 25, 2009 at 2:57 PM, Goundy <go...@gm... >> <mailto:go...@gm...>> wrote: >> >> Emmanuel Rodriguez wrote: >> >> >> Are you sure then that eclipse is picking up the right >> gtkjini.so file? >> Did you install your new bindings? >> >> >> Oh my! when I rebuild my branch, actually my method is being >> erased as the GdkDrawable file gets replace by the new generated >> one which doesn't contain my method. >> I guess I have to edit the source .def file to keep my method >> right ? >> >> I think so, I haven't used the java-gnome bindings in a long time. >> I wish that someone else that's using the bindings could help you :( >> >> -- >> Emmanuel Rodriguez > Okay thank you Emmanuel, you helped a lot :P > > Well, the generator is giving me: > > static final FIXME getXid(Drawable self) throws > BlacklistedMethodError { > throw new BlacklistedMethodError("long"); > } > > and I have the following code in GdkDrawable.defs: > > (define-method get_xid > (of-object "GdkDrawable") > (c-name "gdk_x11_drawable_get_xid") > (caller-owns-return #t) > (return-type "long") > ) > > Am I missing something here ? > Thanks > Oh I get the correct one :P (define-method get_xid (of-object "GdkDrawable") (c-name "gdk_x11_drawable_get_xid") (caller-owns-return #t) (return-type "gulong") ) Is fine, it gives: static final long getXid(Drawable self) { long result; if (self == null) { throw new IllegalArgumentException("self can't be null"); } synchronized (lock) { result = gdk_x11_drawable_get_xid(pointerOf(self)); return result; } } private static native final long gdk_x11_drawable_get_xid(long self); But when I build java-gnome I get: generated/bindings/org/gnome/gdk/GdkDrawable.c: In function 'Java_org_gnome_gdk_GdkDrawable_gdk_1x11_1drawable_1get_1xid': generated/bindings/org/gnome/gdk/GdkDrawable.c:1044: error: implicit declaration of function 'gdk_x11_drawable_get_xid' compilation terminated due to -Wfatal-errors. make: *** [build-java] Error 1 Which is really weird... Ideas are welcome :) |
From: Emmanuel R. <emm...@gm...> - 2009-10-25 14:12:36
|
On Sun, Oct 25, 2009 at 3:59 PM, Goundy <go...@gm...> wrote: > Goundy wrote: > > and I have the following code in GdkDrawable.defs: > > > > (define-method get_xid > > (of-object "GdkDrawable") > > (c-name "gdk_x11_drawable_get_xid") > > (caller-owns-return #t) > > (return-type "long") > > ) > > > > Am I missing something here ? > > Thanks > > > Oh I get the correct one :P > (define-method get_xid > (of-object "GdkDrawable") > (c-name "gdk_x11_drawable_get_xid") > (caller-owns-return #t) > (return-type "gulong") > ) > That fix the first problem: the function is now generated. > Is fine, it gives: > > static final long getXid(Drawable self) { > long result; > > if (self == null) { > throw new IllegalArgumentException("self can't be null"); > } > > synchronized (lock) { > result = gdk_x11_drawable_get_xid(pointerOf(self)); > > return result; > } > } > > private static native final long gdk_x11_drawable_get_xid(long self); > > But when I build java-gnome I get: > generated/bindings/org/gnome/gdk/GdkDrawable.c: In function > 'Java_org_gnome_gdk_GdkDrawable_gdk_1x11_1drawable_1get_1xid': > generated/bindings/org/gnome/gdk/GdkDrawable.c:1044: error: implicit > declaration of function 'gdk_x11_drawable_get_xid' > compilation terminated due to -Wfatal-errors. > make: *** [build-java] Error 1 > > Which is really weird... > Ideas are welcome :) > > Edit the file jni/bindings_java.h and add the following include after the other ones already there: #include <gdk/gdkx.h> -- Emmanuel Rodriguez |
From: Goundy <go...@gm...> - 2009-10-25 14:24:33
|
Emmanuel Rodriguez wrote: > > Edit the file jni/bindings_java.h and add the following include after > the other ones already there: > #include <gdk/gdkx.h> > > > -- > Emmanuel Rodriguez Emmanuel, You nailed it ! That worked \o/ Bad damn, I've been spending too much time for nothing... X is still giving a BadWindow... Anyway I better digg a bit arround this :) Thanks for help emmanuel ;) |