diff --git a/window.cxx b/window.cxx index 67f1298..26e1aad 100644 --- a/window.cxx +++ b/window.cxx @@ -75,11 +75,20 @@ void go_fltk_Window_size_range(Fl_Window* w, int minW, int minH, int maxW, int m w->size_range(minW, minH, maxW, maxH, deltaX, deltaY, aspectRatio); } -#ifdef _WIN32 -void* go_fltk_Window_win32_xid(Fl_Window* w) { +void *go_fltk_Window_xid(Fl_Window *w) { +#if defined(_WIN32) return fl_win32_xid(w); -} +#elif defined(__APPLE__) + return fl_xid(w); +#elif defined(__unix__) +// TODO: Recognize in runtime if we're using Wayland or X11 +#if FLTK_USE_X11 + return (void*)(uintptr_t)fl_xid(w); +#elif FLTK_USE_WAYLAND + return fl_wl_xid(w); +#endif #endif +} const int go_FL_CURSOR_DEFAULT = (int)FL_CURSOR_DEFAULT; const int go_FL_CURSOR_ARROW = (int)FL_CURSOR_ARROW; diff --git a/window.go b/window.go index 7a19286..b776743 100644 --- a/window.go +++ b/window.go @@ -83,6 +83,10 @@ func (w *Window) SetSizeRange(minW, minH, maxW, maxH, deltaX, deltaY int, aspect C.go_fltk_Window_size_range((*C.Fl_Window)(w.ptr()), C.int(minW), C.int(minH), C.int(maxW), C.int(maxH), C.int(deltaX), C.int(deltaY), C.int(ratio)) } +func (w *Window) RawHandle() uintptr { + return uintptr(C.go_fltk_Window_xid((*C.Fl_Window)(w.ptr()))) +} + type Cursor int var ( diff --git a/window.h b/window.h index 8a65ca3..ab4cfc3 100644 --- a/window.h +++ b/window.h @@ -24,9 +24,7 @@ extern "C" { extern void go_fltk_Window_set_non_modal(Fl_Window *w); extern void go_fltk_Window_set_icons(Fl_Window* w, const Fl_RGB_Image* images[], int length); extern void go_fltk_Window_size_range(Fl_Window* w, int minW, int minH, int maxW, int maxH, int deltaX, int deltaY, int aspectRatio); -#ifdef _WIN32 - extern void* go_fltk_Window_win32_xid(Fl_Window* w); -#endif + extern void* go_fltk_Window_xid(Fl_Window* w); extern const int go_FL_CURSOR_DEFAULT; extern const int go_FL_CURSOR_ARROW; diff --git a/window_windows.go b/window_windows.go deleted file mode 100644 index 6aa6a67..0000000 --- a/window_windows.go +++ /dev/null @@ -1,12 +0,0 @@ -//go:build windows - -package fltk - -/* -#include "window.h" -*/ -import "C" - -func (w *Window) RawHandle() uintptr { - return uintptr(C.go_fltk_Window_win32_xid((*C.Fl_Window)(w.ptr()))) -}