Skip to content

Commit

Permalink
Add ScreenNum function and add comments to Screen... functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pwiecz committed Jul 1, 2023
1 parent bb29d08 commit 30e3dbc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fltk.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -177,4 +180,4 @@ int go_fltk_menu_linespacing() {

int go_fltk_test_shortcut(int shortcut) {
return Fl::test_shortcut((unsigned int)shortcut);
}
}
18 changes: 18 additions & 0 deletions fltk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions fltk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 30e3dbc

Please sign in to comment.