FLTK logo

[master] 32c316b - Add Fl_Window::screen_num(int) to fully control window location on multi-screen systems having distinct per-screen scaling factors.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 32c316b - Add Fl_Window::screen_num(int) to fully control window location on multi-screen systems having distinct per-screen scaling factors. "ManoloFLTK" Aug 14, 2020  
 
commit 32c316b78fd0b7ca5e6dbb49226d3475bd118c8c
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Fri Aug 14 16:44:05 2020 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Fri Aug 14 16:44:20 2020 +0200

    Add Fl_Window::screen_num(int) to fully control window location
    on multi-screen systems having distinct per-screen scaling factors.

 FL/Fl_Window.H    |  1 +
 src/Fl_Window.cxx | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git FL/Fl_Window.H FL/Fl_Window.H
index 965d292..3798885 100644
--- FL/Fl_Window.H
+++ FL/Fl_Window.H
@@ -540,6 +540,7 @@ public:
   void shape(const Fl_Image& b) ;
   const Fl_Image *shape();
   int screen_num();
+  void screen_num(int screen_num);
   static bool is_a_rescale();
 };
 
diff --git src/Fl_Window.cxx src/Fl_Window.cxx
index a999511..f489fe8 100644
--- src/Fl_Window.cxx
+++ 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.
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.