Added window iconification callback.
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index fd6d43b..2de5b40 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -386,6 +386,7 @@
 typedef int  (* GLFWwindowclosefun)(GLFWwindow);
 typedef void (* GLFWwindowrefreshfun)(GLFWwindow);
 typedef void (* GLFWwindowfocusfun)(GLFWwindow,int);
+typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
 typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
 typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
 typedef void (* GLFWmousewheelfun)(GLFWwindow,int);
@@ -431,6 +432,7 @@
 GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun);
 GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun);
 GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cbfun);
+GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun);
 
 /* Event handling */
 GLFWAPI void glfwPollEvents(void);
diff --git a/readme.html b/readme.html
index 2389d89..4107639 100644
--- a/readme.html
+++ b/readme.html
@@ -269,6 +269,7 @@
   <li>Added <code>glfwGetVersionString</code> function for determining which code paths were enabled at compile time</li>
   <li>Added <code>glfwGetWindowPos</code> function for querying the position of the specified window</li>
   <li>Added <code>glfwSetWindowFocusCallback</code> function and GLFWwindowfocusfun type for receiving window focus events</li>
+  <li>Added <code>glfwSetWindowIconifyCallback</code> function and GLFWwindowiconifyfun type for receiving window iconification events</li>
   <li>Added <code>windows</code> simple multi-window test program</li>
   <li>Added initial window title parameter to <code>glfwOpenWindow</code></li>
   <li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li>
diff --git a/src/cocoa/cocoa_window.m b/src/cocoa/cocoa_window.m
index e391eba..6bb5571 100644
--- a/src/cocoa/cocoa_window.m
+++ b/src/cocoa/cocoa_window.m
@@ -94,11 +94,17 @@
 - (void)windowDidMiniaturize:(NSNotification *)notification
 {
     window->iconified = GL_TRUE;
+
+    if (window->windowIconifyCallback)
+        window->windowIconifyCallback(window, window->iconified);
 }
 
 - (void)windowDidDeminiaturize:(NSNotification *)notification
 {
     window->iconified = GL_FALSE;
+
+    if (window->windowIconifyCallback)
+        window->windowIconifyCallback(window, window->iconified);
 }
 
 - (void)windowDidBecomeKey:(NSNotification *)notification
diff --git a/src/internal.h b/src/internal.h
index d7bb5d0..7c3d018 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -149,6 +149,7 @@
     GLFWwindowclosefun   windowCloseCallback;
     GLFWwindowrefreshfun windowRefreshCallback;
     GLFWwindowfocusfun   windowFocusCallback;
+    GLFWwindowiconifyfun windowIconifyCallback;
     GLFWmousebuttonfun   mouseButtonCallback;
     GLFWmouseposfun      mousePosCallback;
     GLFWmousewheelfun    mouseWheelCallback;
diff --git a/src/win32/win32_window.c b/src/win32/win32_window.c
index 7ba50a0..c5e3ca5 100644
--- a/src/win32/win32_window.c
+++ b/src/win32/win32_window.c
@@ -697,7 +697,14 @@
 
             _glfwInputWindowFocus(window, active);
 
-            window->iconified = iconified;
+            if (iconified != window->iconified)
+            {
+                window->iconified = iconified;
+
+                if (window->windowIconifyCallback)
+                    window->windowIconifyCallback(window, window->iconified);
+            }
+
             return 0;
         }
 
diff --git a/src/window.c b/src/window.c
index 12f0b86..62622d8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1123,6 +1123,22 @@
 
 
 //========================================================================
+// Set callback function for window iconification events
+//========================================================================
+
+GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun)
+{
+    if (!_glfwInitialized)
+    {
+        _glfwSetError(GLFW_NOT_INITIALIZED);
+        return;
+    }
+
+    window->windowIconifyCallback = cbfun;
+}
+
+
+//========================================================================
 // Poll for new window and input events and close any flagged windows
 //========================================================================
 
diff --git a/src/x11/x11_window.c b/src/x11/x11_window.c
index c847bf5..2205493 100644
--- a/src/x11/x11_window.c
+++ b/src/x11/x11_window.c
@@ -1272,6 +1272,10 @@
             }
 
             window->iconified = GL_FALSE;
+
+            if (window->windowIconifyCallback)
+                window->windowIconifyCallback(window, window->iconified);
+
             break;
         }
 
@@ -1286,6 +1290,10 @@
             }
 
             window->iconified = GL_TRUE;
+
+            if (window->windowIconifyCallback)
+                window->windowIconifyCallback(window, window->iconified);
+
             break;
         }
 
diff --git a/tests/events.c b/tests/events.c
index e4f5610..26c1dfe 100644
--- a/tests/events.c
+++ b/tests/events.c
@@ -193,6 +193,14 @@
            activated ? "activated" : "deactivated");
 }
 
+static void window_iconify_callback(GLFWwindow window, int iconified)
+{
+    printf("%08x at %0.3f: Window was %s\n",
+           counter++,
+           glfwGetTime(),
+           iconified ? "iconified" : "restored");
+}
+
 static void mouse_button_callback(GLFWwindow window, int button, int action)
 {
     const char* name = get_button_name(button);
@@ -299,6 +307,7 @@
     glfwSetWindowCloseCallback(window, window_close_callback);
     glfwSetWindowRefreshCallback(window, window_refresh_callback);
     glfwSetWindowFocusCallback(window, window_focus_callback);
+    glfwSetWindowIconifyCallback(window, window_iconify_callback);
     glfwSetMouseButtonCallback(window, mouse_button_callback);
     glfwSetMousePosCallback(window, mouse_position_callback);
     glfwSetMouseWheelCallback(window, mouse_wheel_callback);