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

[STR New]

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


As discussed in fltk.development, I finally (I hope so) propose the
following changes:

1) add: void Fl_Window::force_position(int); // the set method

2) add: int Fl_Window::force_position(); // the get method

3) use FL_READ, FL_WRITE, and FL_EXCEPT instead of POLLIN, POLLOUT, and
POLLERR resp. in Fl_win32.cxx.

Please test the attached diff file, if the proposed changes compile with
VC 2008 Express. I tested them with cygwin/MinGW gcc, and everything
compiled fine.

I think that I have a test case with Fl::add_fd() for Windows that I can
use to do regression testing for Fl::add_fd(), but this will have to wait
until tomorrow.

Possible changes for other platforms, regarding POLLIN etc., as mentioned
in fltk.development, should be considered separately.


Link: http://www.fltk.org/str.php?L2301
Version: 1.3-current
Index: src/Fl_win32.cxx
===================================================================
--- src/Fl_win32.cxx    (revision 6969)
+++ src/Fl_win32.cxx    (working copy)
@@ -233,9 +233,9 @@
 static int maxfd = 0;
 static fd_set fdsets[3];
 
-# define POLLIN 1
-# define POLLOUT 4
-# define POLLERR 8
+// # define POLLIN 1
+// # define POLLOUT 4
+// # define POLLERR 8
 
 #if !defined(__GNUC__) || __GNUC__ >= 3
 extern IDropTarget *flIDropTarget;
@@ -292,14 +292,14 @@
   fd[i].cb = cb;
   fd[i].arg = v;
 
-  if (events & POLLIN) FD_SET((unsigned)n, &fdsets[0]);
-  if (events & POLLOUT) FD_SET((unsigned)n, &fdsets[1]);
-  if (events & POLLERR) FD_SET((unsigned)n, &fdsets[2]);
+  if (events & FL_READ) FD_SET((unsigned)n, &fdsets[0]);
+  if (events & FL_WRITE) FD_SET((unsigned)n, &fdsets[1]);
+  if (events & FL_EXCEPT) FD_SET((unsigned)n, &fdsets[2]);
   if (n > maxfd) maxfd = n;
 }
 
 void Fl::add_fd(int fd, void (*cb)(int, void*), void* v) {
-  Fl::add_fd(fd, POLLIN, cb, v);
+  Fl::add_fd(fd, FL_READ, cb, v);
 }
 
 void Fl::remove_fd(int n, int events) {
@@ -318,9 +318,9 @@
   }
   nfds = j;
 
-  if (events & POLLIN) FD_CLR(unsigned(n), &fdsets[0]);
-  if (events & POLLOUT) FD_CLR(unsigned(n), &fdsets[1]);
-  if (events & POLLERR) FD_CLR(unsigned(n), &fdsets[2]);
+  if (events & FL_READ) FD_CLR(unsigned(n), &fdsets[0]);
+  if (events & FL_WRITE) FD_CLR(unsigned(n), &fdsets[1]);
+  if (events & FL_EXCEPT) FD_CLR(unsigned(n), &fdsets[2]);
 }
 
 void Fl::remove_fd(int n) {
@@ -374,9 +374,9 @@
       for (int i = 0; i < nfds; i ++) {
        SOCKET f = fd[i].fd;
        short revents = 0;
-       if (fl_wsk_fd_is_set(f, &fdt[0])) revents |= POLLIN;
-       if (fl_wsk_fd_is_set(f, &fdt[1])) revents |= POLLOUT;
-       if (fl_wsk_fd_is_set(f, &fdt[2])) revents |= POLLERR;
+       if (fl_wsk_fd_is_set(f, &fdt[0])) revents |= FL_READ;
+       if (fl_wsk_fd_is_set(f, &fdt[1])) revents |= FL_WRITE;
+       if (fl_wsk_fd_is_set(f, &fdt[2])) revents |= FL_EXCEPT;
        if (fd[i].events & revents) fd[i].cb(f, fd[i].arg);
       }
       time_to_wait = 0.0; // just peek for any messages
@@ -1292,7 +1292,7 @@
   int resize_from_program = (this != resize_bug_fix);
   if (!resize_from_program) resize_bug_fix = 0;
   if (X != x() || Y != y()) {
-    set_flag(FORCE_POSITION);
+    force_position(1);
   } else {
     if (!is_a_resize) return;
     flags |= SWP_NOMOVE;
@@ -1474,7 +1474,7 @@
       wp += 2*bx;
       hp += 2*by+bt;
     }
-    if (!(w->flags() & Fl_Widget::FORCE_POSITION)) {
+    if (!w->force_position()) {
       xp = yp = CW_USEDEFAULT;
     } else {
       if (!Fl::grab()) {
Index: FL/Fl_Window.H
===================================================================
--- FL/Fl_Window.H      (revision 6969)
+++ FL/Fl_Window.H      (working copy)
@@ -237,11 +237,42 @@
   void hotspot(const Fl_Widget*, int offscreen = 0);
   /** See void Fl_Window::hotspot(int x, int y, int offscreen = 0) */
   void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);}
+
+protected:
+
   /**
-    Undoes the effect of a previous resize() or show()
-    so that the next time show() is called the window manager is
-    free to position the window.
+    Sets an internal flag that tells FLTK and the window manager to
+    honor position requests.
+    
+    This is used internally and should not be used by user code.
+    
+    \todo this method should probably be protected.
   */
+  void force_position(int force) {
+    if (force) set_flag(FORCE_POSITION);
+    else clear_flag(FORCE_POSITION);
+  }
+  /**
+    Returns the internal state of the window's force_position flag.
+
+    \retval 1 if flag is set
+    \retval 0 otherwise
+
+    \see force_position(int)
+    \todo this method should probably be protected.
+  */
+  int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
+
+public:
+
+  /**
+    Undoes the effect of a previous resize() or show() so that the next time
+    show() is called the window manager is free to position the window.
+
+    This is for Forms compatibility only.
+
+    \deprecated please use force_position(0) instead
+  */
   void free_position() {clear_flag(FORCE_POSITION);}
   /**
     Set the allowable range the user can resize this window to.  This only
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to