summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-08-14 16:44:05 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-08-14 16:44:20 +0200
commit32c316b78fd0b7ca5e6dbb49226d3475bd118c8c (patch)
tree9fa277dc52ccba3a86c211434a60e2b229b93aed /src
parent7b34385511f35a23da8782fa7d5676468aaa8155 (diff)
Add Fl_Window::screen_num(int) to fully control window location
on multi-screen systems having distinct per-screen scaling factors.
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Window.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index a999511d2..f489fe89a 100644
--- a/src/Fl_Window.cxx
+++ b/src/Fl_Window.cxx
@@ -642,6 +642,24 @@ int Fl_Window::screen_num() {
return pWindowDriver->screen_num();
}
+/** Set the number of the screen where to map the window.
+ Call this and set also the window's desired position before show()'ing the window.
+ This can be necessary when a system has several screens with
+ distinct scaling factor values because the window's x() and y() may not suffice to
+ uniquely identify one screen.
+ To see that, consider a system with two screens where the screen at left is A pixel-wide
+ and has a scale factor of 1 whereas the screen at right has a scale factor of 2.
+ For the sake of simplicity, consider only
+ the X coordinates of windows. FLTK coordinates translate directly to pixel coordinates on the
+ left screen, whereas FLTK coordinates multiplied by 2 correspond to pixel coordinates
+ on the right screen. Consequently, FLTK coordinates between A/2 + 1 and A-1 can map to both
+ screens. Both window coordinates and screen number are necessary to uniquely identify
+ where a window is to be mapped.
+ */
+void Fl_Window::screen_num(int screen_num) {
+ if (!shown() && screen_num >= 0 && screen_num < Fl::screen_count()) pWindowDriver->screen_num(screen_num);
+}
+
/** Assigns a non-rectangular shape to the window.
This function gives an arbitrary shape (not just a rectangular region) to an Fl_Window.
An Fl_Image of any dimension can be used as mask; it is rescaled to the window's dimension as needed.