Re: [fltk.bugs] [MOD] STR #2857: screen_xywh mouse pointer functions initially returns wrong data

2012-10-17 Thread Ian MacArthur

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





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

___
fltk-bugs mailing list
fltk-bugs@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-bugs


[fltk.bugs] [MOD] STR #2857: screen_xywh mouse pointer functions initially returns wrong data

2012-06-26 Thread Peter Åstrand
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-currentIndex: 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
fltk-bugs@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-bugs