From c83737161420741c9af40e52533da88d83c697cf Mon Sep 17 00:00:00 2001
From: Piotr Wieczorek
Date: Wed, 24 Jul 2024 18:10:56 +0200
Subject: [PATCH] Add function for getting raw handle of a window under Windows
For #133
---
window.cxx | 9 ++++++++-
window.h | 3 +++
window_windows.go | 12 ++++++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 window_windows.go
diff --git a/window.cxx b/window.cxx
index 3c6b903..67f1298 100644
--- a/window.cxx
+++ b/window.cxx
@@ -2,6 +2,7 @@
#include
#include
+#include
#include "event_handler.h"
@@ -71,9 +72,15 @@ void go_fltk_Window_set_icons(Fl_Window* w, const Fl_RGB_Image *images[], int le
}
void go_fltk_Window_size_range(Fl_Window* w, int minW, int minH, int maxW, int maxH, int deltaX, int deltaY, int aspectRatio) {
- w->size_range(minW, minH, maxW, maxH, deltaX, deltaY, aspectRatio);
+ w->size_range(minW, minH, maxW, maxH, deltaX, deltaY, aspectRatio);
}
+#ifdef _WIN32
+void* go_fltk_Window_win32_xid(Fl_Window* w) {
+ return fl_win32_xid(w);
+}
+#endif
+
const int go_FL_CURSOR_DEFAULT = (int)FL_CURSOR_DEFAULT;
const int go_FL_CURSOR_ARROW = (int)FL_CURSOR_ARROW;
const int go_FL_CURSOR_CROSS = (int)FL_CURSOR_CROSS;
diff --git a/window.h b/window.h
index 4bed2c0..8a65ca3 100644
--- a/window.h
+++ b/window.h
@@ -24,6 +24,9 @@ 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 const int go_FL_CURSOR_DEFAULT;
extern const int go_FL_CURSOR_ARROW;
diff --git a/window_windows.go b/window_windows.go
new file mode 100644
index 0000000..6aa6a67
--- /dev/null
+++ b/window_windows.go
@@ -0,0 +1,12 @@
+//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())))
+}