Author: spitzak
Date: 2008-08-04 15:53:30 -0700 (Mon, 04 Aug 2008)
New Revision: 6150
Log:
Changes from Rafal:

The very popular Window::maximize() method. Still needed is a way to turn
it off. NYI on OS/X.

X11 fullscreen() method uses modern window manager hints, works better.

Added Window::system_layout() so that Window::layout() can be overridden
and you can still call the code to resize the os window. This is different
than Rafal's solution of a flag. Only tested on X11 but I believe it is ok.

I also removed the makedepend files from svn. Type "make depend" to get
them correct for your system.


Removed:
   trunk/OpenGL/makedepend
   trunk/fluid/makedepend
   trunk/glut/makedepend
   trunk/images/makedepend
   trunk/src/makedepend
   trunk/test/makedepend
   trunk/themes/makedepend
Modified:
   trunk/CHANGES
   trunk/CREDITS
   trunk/README.mingw32
   trunk/README.unix
   trunk/README.windows
   trunk/configure.in
   trunk/fltk/Window.h
   trunk/src/Window_fullscreen.cxx
   trunk/src/osx/run.cxx
   trunk/src/win32/run.cxx
   trunk/src/x11/run.cxx
   trunk/test/fullscreen.cxx

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES       2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/CHANGES       2008-08-04 22:53:30 UTC (rev 6150)
@@ -2555,3 +2555,21 @@
 fl_color_win32.cxx loads SetDCPenColor and SetDCBrushColor functions 
dynamically.
 Uses alternative (old) method, if those functions cannot be loaded (older 
windows)
 from gdi32.dll
+
+////////////////////////////////////////////////////////////////
+* Added Window::Maximize
+  so far for X11 and Win32
+  TODO: MAC OS X version, and testing
+       And added example of maximize() as part of teset/fullscreen.cxx
+
+* Probably fixed bug: gifImage.cxx:105: error: ‘U32’ was not declared
+  by adding a work around to configure.in
+  in crosscompilation with mingw (linux 64 bit to windows)
+  And documented crosscompilation (TODO - finish it)
+
+* Added Window::system_layout() so that it is possible to override the
+  default Window::layout() method yet still do the operating system
+  stuff needed to resize the window. Only tested on X11.
+
+
+

Modified: trunk/CREDITS
===================================================================
--- trunk/CREDITS       2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/CREDITS       2008-08-04 22:53:30 UTC (rev 6150)
@@ -60,3 +60,4 @@
     Davy Durham ([EMAIL PROTECTED])
     Jan Fechner (#1837)
     Brian Olsen <[EMAIL PROTECTED]>
+    Rafal Maj <www.limcore.com>

Deleted: trunk/OpenGL/makedepend

Modified: trunk/README.mingw32
===================================================================
--- trunk/README.mingw32        2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/README.mingw32        2008-08-04 22:53:30 UTC (rev 6150)
@@ -2,3 +2,6 @@
 To compile FLTK using Mingw32, please follow the instructions in the
 README.cygwin file.  Building the toolkit requires tools from the Cygwin
 distribution and Cygwin contains a complete version of Mingw32.
+
+For crosscompiling see also README.mingw32_cross
+

Modified: trunk/README.unix
===================================================================
--- trunk/README.unix   2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/README.unix   2008-08-04 22:53:30 UTC (rev 6150)
@@ -53,3 +53,5 @@
     libraries).
 
 
+For crosscompiling see also README.mingw32_cross
+

Modified: trunk/README.windows
===================================================================
--- trunk/README.windows        2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/README.windows        2008-08-04 22:53:30 UTC (rev 6150)
@@ -7,12 +7,17 @@
 
     The second method is to use Borland C++. Please read the
     README.bc5 for details.
-    
+
     The third method is to use the Cygwin or MinGW GNU-based development
     tools. For information on how to build in this environment, please
     read the README.cygwin file.
 
+    Also, you can build windows version of the FLTK library on linux
+    using crossbuilding - see also README.mingw32_cross
+
     Current versions of FLTK may require the winsock2 DLL
     (WS2_32.DLL).  If you have an older version of Windows 95, you may
     not have this DLL and you will to get it from the Microsoft web
     site.
+
+

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in  2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/configure.in  2008-08-04 22:53:30 UTC (rev 6150)
@@ -289,6 +289,9 @@
 else
     if test $ac_cv_sizeof_long -eq 4; then
         AC_DEFINE(U32,unsigned long)
+    else
+        dnl fall back
+        AC_DEFINE(U32,unsigned long)
     fi
 fi
 if test $ac_cv_sizeof_int -eq 8; then

Modified: trunk/fltk/Window.h
===================================================================
--- trunk/fltk/Window.h 2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/fltk/Window.h 2008-08-04 22:53:30 UTC (rev 6150)
@@ -35,6 +35,8 @@
 class CreatedWindow;
 class Monitor;
 
+// implementations of methods of Window are in different files in src/
+
 class FL_API Window : public Group {
 public:
 
@@ -88,10 +90,13 @@
   bool exec(const Window* parent = 0, bool grab = false);
   void make_exec_return(bool);
   void show_inside(const Window* parent);
+  virtual void destroy();
+
   void iconize();
   bool iconic() const;
-  virtual void destroy();
 
+  void maximize();
+
   void fullscreen();
   void fullscreen(const Monitor&);
   void fullscreen_off(int,int,int,int);
@@ -100,6 +105,7 @@
 
   virtual int handle(int);
   virtual void layout();
+  void system_layout();
   virtual void flush();
   virtual void draw();
 

Deleted: trunk/fluid/makedepend

Deleted: trunk/glut/makedepend

Deleted: trunk/images/makedepend

Modified: trunk/src/Window_fullscreen.cxx
===================================================================
--- trunk/src/Window_fullscreen.cxx     2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/src/Window_fullscreen.cxx     2008-08-04 22:53:30 UTC (rev 6150)
@@ -85,12 +85,20 @@
     // Unfortunatly stoopid MetaCity raises the window. Sigh
     CreatedWindow::find(window)->sendxjunk();
 
-# if 0
+# if 1
     // Supposedly this tells the new X window managers to put this atop 
     // the taskbar. My tests have shown absolutly zero effect, so this is
     // either wrong or the window managers are ignoreing it. Newer X
     // window managers seem to work without this, they probably recognize
     // attempts to make the window the size of the screen
+
+    // this method does in fact work, and is used below in my maximize()
+    // so it should probably work here as well
+    // possible problem is that sometimes one have to process/flush events
+    // i.e. by using fltk::wait(1) to have this working
+    // Perhaps below code can be done correctly(?) again - look at maximize()
+    // (or perhaps Im totally wrong, Im new to Xlib  ;)  --Rafal
+
     static Atom _NET_WM_STATE;
     static Atom _NET_WM_STATE_REMOVE;
     static Atom _NET_WM_STATE_ADD;
@@ -98,7 +106,7 @@
     if (!_NET_WM_STATE) {
 # define MAX_ATOMS 30
       Atom* atom_ptr[MAX_ATOMS];
-      char* names[MAX_ATOMS];
+      const char* names[MAX_ATOMS];
       int i = 0;
 # define atom(a,b) atom_ptr[i] = &a; names[i] = b; i++
       atom(_NET_WM_STATE               , "_NET_WM_STATE");
@@ -107,7 +115,7 @@
       atom(_NET_WM_STATE_FULLSCREEN, "_NET_WM_STATE_FULLSCREEN");
 # undef atom
       Atom atoms[MAX_ATOMS];
-      XInternAtoms(xdisplay, names, i, 0, atoms);
+      XInternAtoms(xdisplay, (char**)names, i, 0, atoms);
       for (; i--;) *atom_ptr[i] = atoms[i];
     }
     XEvent e;
@@ -169,6 +177,48 @@
   window->resize(X, Y, W, H);
 }
 
+void Window::maximize() {
+#ifdef __WIN32__
+  // ShowWindow - http://msdn.microsoft.com/en-us/library/ms633548.aspx
+  // idea from Edzard Egberts - thanks
+
+  HWND hWnd = fltk::xid(this);
+  ShowWindow(hWnd, SW_MAXIMIZE);
+
+#elif USE_X11
+  // #elif __linux__
+  // by Rafal Maj on idea from Mans Rullgard http://tinyurl.com/68mvk3
+  // TODO: make it work on very old/simple WMs (as described in url above)
+  // TODO: test it more / cleanup (some Xlib expert, please take a look)
+
+  Display *dpy = xdisplay;
+
+  XEvent xev;
+  Atom wm_state = XInternAtom(dpy, "_NET_WM_STATE", False);
+  Atom maximizeV = XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False);
+  Atom maximizeH = XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
+  // XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); // that would give 
true fullscreen
+
+  memset(&xev, 0, sizeof(xev));
+  xev.type = ClientMessage;
+  xev.xclient.window = fltk::xid(this);
+  xev.xclient.message_type = wm_state;
+  xev.xclient.format = 32;
+  xev.xclient.data.l[0] = 1;
+  xev.xclient.data.l[1] = maximizeV;
+  xev.xclient.data.l[2] = maximizeH;
+  xev.xclient.data.l[3] = 0;
+  XSendEvent(xdisplay, RootWindow(xdisplay, xscreen), 0,
+             SubstructureNotifyMask|SubstructureRedirectMask, &xev);
+
+  // flush it right away? Also seems to works without this as well...
+  // XFlush(dpy);
+
+#else
+# warning "This method will not work on this system. (you can ignore this 
warning)"
+#endif
+}
+
 /*! void Window::clear_border()
   This may only be called on a newly constructed window before the
   first call to show().  There will not be any visible border around

Deleted: trunk/src/makedepend

Modified: trunk/src/osx/run.cxx
===================================================================
--- trunk/src/osx/run.cxx       2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/src/osx/run.cxx       2008-08-04 22:53:30 UTC (rev 6150)
@@ -1386,12 +1386,14 @@
   }
 }
 
-/*
- * Resizes the actual system window in response to a resize() call from
- * the program.
- */
-//+++ verify port to FLTK2
 void Window::layout() {
+  // Unlike X11 and Win32, we do need to propagate xy changes to child windows
+  /*if (layout_damage() & ~LAYOUT_XY)*/ Group::layout();
+  // Fix the window:
+  system_layout();
+}
+
+void Window::system_layout() {
   if (parent()) {
     // child windows are done entirely by us
     if (i) for (Widget* p = parent(); ; p = p->parent())
@@ -1411,7 +1413,6 @@
     SetWindowBounds(i->xid, kWindowContentRgn, &rect);
   }
   if (i) i->need_new_subRegion = true;
-  Group::layout();
 }
 
 ////////////////////////////////////////////////////////////////

Modified: trunk/src/win32/run.cxx
===================================================================
--- trunk/src/win32/run.cxx     2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/src/win32/run.cxx     2008-08-04 22:53:30 UTC (rev 6150)
@@ -1873,6 +1873,14 @@
 ////////////////////////////////////////////////////////////////
 
 void Window::layout() {
+  // If only the xy position changed, then win32 did everything for us, so 
don't
+  // call the Group layout.
+  if (layout_damage() & ~LAYOUT_XY) Group::layout();
+  // Fix the window:
+  system_layout();
+}
+
+void Window::system_layout() {
   UINT flags;
   if (layout_damage() & LAYOUT_WH) {
     free_backbuffer();
@@ -1882,10 +1890,6 @@
   } else {
     flags = 0;
   }
-  if (layout_damage() & ~LAYOUT_XY)
-    Group::layout();
-  else
-    layout_damage(0);
   if (i && flags) {
     fltk::Rectangle r(*this);
     borders(&r);

Modified: trunk/src/x11/run.cxx
===================================================================
--- trunk/src/x11/run.cxx       2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/src/x11/run.cxx       2008-08-04 22:53:30 UTC (rev 6150)
@@ -2692,11 +2692,20 @@
   }
 }
 
+void Window::layout() {
+  // If only the xy position changed, then X does everything for us, so don't
+  // call the Group layout.
+  if (layout_damage() & ~LAYOUT_XY) Group::layout();
+  // Fix the window:
+  system_layout();
+}
+
 /**
- * Resizes the actual system window in response to a resize() call from
- * the program.
+ * Resizes the actual system window to match the current size of the fltk
+ * widget. You should call this in your layout() method if xywh have changed.
+ * The layout_damage() flags must be on or it won't work.
  */
-void Window::layout() {
+void Window::system_layout() {
   if (i && (layout_damage()&LAYOUT_XYWH)) {
     // Fix the size/position we recorded for the X window if it is not
     // the same as the fltk window. If we received CONFIGURE_NOTIFY
@@ -2740,9 +2749,6 @@
        free_backbuffer();
     }
   }
-  // don't redraw if only the xy position changed:
-  if (layout_damage() & ~LAYOUT_XY) Group::layout();
-  else layout_damage(0);
 }
 
 //

Modified: trunk/test/fullscreen.cxx
===================================================================
--- trunk/test/fullscreen.cxx   2008-07-21 19:48:36 UTC (rev 6149)
+++ trunk/test/fullscreen.cxx   2008-08-04 22:53:30 UTC (rev 6150)
@@ -196,6 +196,11 @@
   }
 }
 
+void maximize_cb(fltk::Widget *o, void *p) {
+  fltk::Window *w = (fltk::Window *)p;
+  w->maximize();
+}
+
 void exit_cb(fltk::Widget *, void *) {
   // Turn fullscreen off when exit
   if(fullscreen)
@@ -203,7 +208,7 @@
   exit(0);
 }
 
-#define NUMB 4
+#define NUMB 5
 
 int twowindow = 0;
 int initfull = 0;
@@ -268,6 +273,10 @@
   b3.callback(fullscreen_cb,w);
   y+=30;
 
+  fltk::Button btnMaximize(50,y,window.w()-60,30,"Maximize me!");
+  btnMaximize.callback(maximize_cb,&window);
+  y+=30;
+
   fltk::Button eb(50,y,window.w()-60,30,"Exit");
   eb.callback(exit_cb);
   y+=30;

Deleted: trunk/test/makedepend

Deleted: trunk/themes/makedepend

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to