DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2857
Version: 1.3-current


There are two helper functions in screen_xywh that returns the "work area"
and "screen" where the mouse pointer is located. However, these initially
returns incorrect data when the application starts on a secondary screen.
This is because they are using the e_x_root/e_y_root variables, but these
cannot be trusted until a mouse or keyboard event has happened. As the
comment in Fl.H points out:

  /**
  Return where the mouse is on the screen by doing a round-trip query to
    the server.  You should use Fl::event_x_root() and 
    Fl::event_y_root() if possible, but this is necessary if you are
    not sure if a mouse event has been processed recently (such as to
    position your first window).  If the display is not open, this will
    open it.
  */
  static void get_mouse(int &,int &); // platform dependent

The bug is visible with the "fullscreen" test program. When starting it on
a secondary screen, you have to press "Update" to get the correct values
for "Mouse screen work area". Attaching patch.


Link: http://www.fltk.org/str.php?L2857
Version: 1.3-current
Index: FL/Fl.H
===================================================================
--- FL/Fl.H     (revision 9629)
+++ FL/Fl.H     (arbetskopia)
@@ -785,7 +785,9 @@
       \see void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my) 
   */
   static void screen_xywh(int &X, int &Y, int &W, int &H) {
-    screen_xywh(X, Y, W, H, e_x_root, e_y_root);
+    int x_root, y_root;
+    Fl::get_mouse(x_root, y_root);
+    screen_xywh(X, Y, W, H, x_root, y_root);
   }
   static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
   static void screen_xywh(int &X, int &Y, int &W, int &H, int n); 
@@ -799,7 +801,9 @@
    \see void screen_work_area(int &x, int &y, int &w, int &h, int mx, int my) 
    */
   static void screen_work_area(int &X, int &Y, int &W, int &H) {
-    screen_work_area(X, Y, W, H, e_x_root, e_y_root);
+    int x_root, y_root;
+    Fl::get_mouse(x_root, y_root);
+    screen_work_area(X, Y, W, H, x_root, y_root);
   }
 
   /**   @} */
Index: test/fullscreen.cxx
===================================================================
--- test/fullscreen.cxx (revision 9629)
+++ test/fullscreen.cxx (arbetskopia)
@@ -199,6 +199,9 @@
 
     sprintf(line, "Main screen work area: %dx%d@%d,%d", Fl::w(), Fl::h(), 
Fl::x(), Fl::y());
     browser->add(line);
+    Fl::screen_xywh(x, y, w, h);
+    sprintf(line, "Mouse screen: %dx%d@%d,%d", w, h, x, y);
+    browser->add(line);
     Fl::screen_work_area(x, y, w, h);
     sprintf(line, "Mouse screen work area: %dx%d@%d,%d", w, h, x, y);
     browser->add(line);
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to