Skip to content

Commit

Permalink
Add functions for getting xid of a Window for unix and MacOS
Browse files Browse the repository at this point in the history
For #133
  • Loading branch information
pwiecz committed Nov 2, 2024
1 parent c837371 commit 03f3ccb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
15 changes: 12 additions & 3 deletions window.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 1 addition & 3 deletions window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 0 additions & 12 deletions window_windows.go

This file was deleted.

0 comments on commit 03f3ccb

Please sign in to comment.