From 30e3dbcfbc8adf9944a1ee2fd6f1b2c0f48bbcb8 Mon Sep 17 00:00:00 2001 From: Piotr Wieczorek Date: Sat, 1 Jul 2023 09:13:17 +0200 Subject: [PATCH] Add ScreenNum function and add comments to Screen... functions --- fltk.cxx | 5 ++++- fltk.go | 18 ++++++++++++++++++ fltk.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/fltk.cxx b/fltk.cxx index 14c92d0..65e1e03 100644 --- a/fltk.cxx +++ b/fltk.cxx @@ -142,6 +142,9 @@ void go_fltk_dnd() { Fl::dnd(); } +int go_fltk_screen_num(int x, int y) { + return Fl::screen_num(x, y); +} void go_fltk_screen_work_area(int *x, int *y, int *w, int *h, int n) { Fl::screen_work_area(*x, *y, *w, *h, n); } @@ -177,4 +180,4 @@ int go_fltk_menu_linespacing() { int go_fltk_test_shortcut(int shortcut) { return Fl::test_shortcut((unsigned int)shortcut); -} \ No newline at end of file +} diff --git a/fltk.go b/fltk.go index 99c3501..d518581 100644 --- a/fltk.go +++ b/fltk.go @@ -247,25 +247,42 @@ func CopyToSelectionBuffer(text string) { func DragAndDrop() { C.go_fltk_dnd() } + +// ScreenNum gets the screen number of a screen that contains the specified screen position x, y. +func ScreenNum(x, y int) int { + return int(C.go_fltk_screen_num(C.int(x), C.int(y))) +} + +// ScreenWorkArea gets the bounding box of the work area of the given screen. func ScreenWorkArea(screenNum int) (int, int, int, int) { var x, y, w, h C.int C.go_fltk_screen_work_area(&x, &y, &w, &h, C.int(screenNum)) return int(x), int(y), int(w), int(h) } + +// ScreenDPI gets the screen resolution in dots-per-inch for the given screen. func ScreenDPI(screenNum int) (float32, float32) { var w, h C.float C.go_fltk_screen_dpi(&w, &h, C.int(screenNum)) return float32(w), float32(h) } + +// ScreenCount gets the total count of available screens. func ScreenCount() int { return int(C.go_fltk_screen_count()) } + +// ScreenScale gets current value of the GUI scaling factor for the given screen. func ScreenScale(screenNum int) float32 { return float32(C.go_fltk_screen_scale(C.int(screenNum))) } + +// SetScreenScale sets the value of the GUI scaling factor for the given screen. func SetScreenScale(screenNum int, scale float32) { C.go_fltk_set_screen_scale(C.int(screenNum), C.float(scale)) } + +// SetKeyboardScreenScaling controls the possibility to scale all windows by ctrl/+/-/0/ or cmd/+/-/0/ func SetKeyboardScreenScaling(value bool) { if value { C.go_fltk_set_keyboard_screen_scaling(1) @@ -288,6 +305,7 @@ func SetMenuLinespacing(size int) { func TestShortcut(shortcut int) bool { return C.go_fltk_test_shortcut(C.int(shortcut)) != 0 } + // Couldn't figure out how to export a func array... // For now, just gonna hide it at the bottom of the file and pretend it // doesn't exist diff --git a/fltk.h b/fltk.h index 7b3efea..fc823b5 100644 --- a/fltk.h +++ b/fltk.h @@ -38,6 +38,7 @@ extern "C" { extern void go_fltk_copy(const char* data, int len, int destination); extern void go_fltk_dnd(); + extern int go_fltk_screen_num(int x, int y); extern void go_fltk_screen_work_area(int *x, int *y, int *w, int *h, int n); extern void go_fltk_screen_dpi(float *w, float *h, int n); extern int go_fltk_screen_count();