; Module/File: Window_GetGtkFromGdkWindow.pb ; Function: Get GtkWindow from GdkWindow - Linux gtk2/gtk3 ; Author: Omi ; Date: Aug. 20, 2015 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31/5.40 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- EnableExplicit ImportC "" gtk_widget_get_window(*widget.GtkWidget) EndImport ; Object constants #Win_Main = 0 #But1 = 0 Global.i gEvent, gQuit, gpointer Global *GdkWindow.GdkWindowObject Procedure.i GetGdkWindow(Window) ProcedureReturn gtk_widget_get_window(WindowID(Window)) EndProcedure If OpenWindow(#Win_Main, 300, 200, 200, 200, "Window Gdk<->Gtk", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ButtonGadget(#But1, 5, 5, 190, 26, "Get Gtk- & GdkWindow") Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True Case #PB_Event_Gadget If EventGadget()= #But1 Debug "GtkWindow from PB-Window index (" + Str(#Win_Main) + ") : " + Str(WindowID(#Win_Main)) *GdkWindow= GetGdkWindow(#Win_Main) Debug "GdkWindow from GtkWindow : " + Str(*GdkWindow) ;2 ways to get Gtk- from GdkWindow ... gdk_window_get_user_data_(*GdkWindow, @gpointer) Debug "GtkWindow from GdkWindow (API) : " + Str(gpointer) ;or Debug "GtkWindow from GdkWindow (PB)?: " + Str(*GdkWindow\user_data); stored from PB, seems wrong in PB5.40+gtk3 EndIf EndSelect Until gQuit EndIf ; IDE Options = PureBasic 5.40 LTS (Linux - x86) ; CursorPosition = 1 ; FirstLine = 9 ; Folding = - ; EnableUnicode ; EnableXP