Page 1 of 1

[SOLVED] XWindow ID From GtkWindow

Posted: Sun Jun 28, 2015 1:22 pm
by grabiller
Hi,

I'm trying to retrieve the XWindow ID of a Purebasic existing Window.

Purebasic WindowID() returns a GtkWindow*.

This is what I've found, in C, to get the XWindow ID from it:

Code: Select all

GtkWindow *mywindow;
GdkWindow *gwin;
gwin = gtk_widget_get_window(GTK_WIDGET(mywindow));
printf("the X11 id is %u\n", GDK_DRAWABLE_XID(gwin));
Unfortunately, this way uses 2 macros GTK_WIDGET & GDK_DRAWABLE_XID that can't be directly used in Purebasic.

I've tried to search for functions equivalent to these macros without success (or perhaps I've missed those ?).

My question is then: How to accomplish this in Purebasic ?

Perhaps there is a smarter way to retrieve the XWindow ID out of a GtkWindow ?

Cheers,
Guy.

Re: XWindow ID From GtkWindow

Posted: Sun Jun 28, 2015 2:18 pm
by grabiller
Of course, just after posting my message I've found one function to replace the macro GDK_DRAWABLE_XID():

Code: Select all

Window gdk_x11_window_get_xid (GdkWindow *window);
#define GDK_DRAWABLE_XID(win)         (gdk_x11_window_get_xid (win))
Still unsuccessful for GTK_WIDGET() though : /

Any idea ?

Cheers,
Guy.

Re: XWindow ID From GtkWindow

Posted: Sun Jun 28, 2015 2:50 pm
by freak
GTK_WIDGET() just performs a type check and a cast. You can just leave it out in PB.

Re: XWindow ID From GtkWindow

Posted: Sun Jun 28, 2015 3:04 pm
by grabiller
freak wrote:GTK_WIDGET() just performs a type check and a cast. You can just leave it out in PB.
Thanks a lot, should work then.


The only issue I have left is that PB don't link to "gdk_x11_window_get_xid" with:

Code: Select all

ImportC ""
  gtk_widget_get_window.i ( self.i )
  gdk_x11_window_get_xid.i ( window.i )
EndImport
gtk_widget_get_window is found but not gdk_x11_window_get_xid.

Should I point to a specific library ?

Cheers,
Guy.

Re: XWindow ID From GtkWindow

Posted: Sun Jun 28, 2015 3:36 pm
by grabiller
Hmm I'm afraid gdk_x11_window_get_xid is part of GTK 3 and not 2 which, afaik, Purebasic uses : /

Well, if anyone has any idea how I could solve this issue, you are welcome.

Cheers,
Guy.

Re: XWindow ID From GtkWindow

Posted: Sun Jun 28, 2015 3:45 pm
by ts-soft
SubSystem gtk3?

Re: XWindow ID From GtkWindow

Posted: Sun Jun 28, 2015 3:56 pm
by grabiller
ts-soft wrote:SubSystem gtk3?
Yes!

Thanks a lot.

Cheers,
Guy.