]> Pileus Git - ~andy/gtk/commitdiff
Implement the conditional use of FlashWindowEx() properly for MSVC
authorTor Lillqvist <tml@novell.com>
Mon, 28 Nov 2005 08:40:56 +0000 (08:40 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Mon, 28 Nov 2005 08:40:56 +0000 (08:40 +0000)
2005-11-28  Tor Lillqvist  <tml@novell.com>

* gdk/win32/gdkwindow-win32.c (gdk_window_set_urgency_hint):
Implement the conditional use of FlashWindowEx() properly for MSVC
compilations. The code was confusingly assuming that if compiled
with a "new" compiler, it will only be run on "new" Windows
versions. We want it to run on "old" versions, too, even if
compiled with a "new" compiler. There are two orthogonal issues:
whether the compiler defines the necessary API in its headers, and
whether it is present at run-time. (#318077)

ChangeLog
ChangeLog.pre-2-10
gdk/win32/gdkwindow-win32.c

index e537933dfdab3c0b6337c40e21bde4ed37270696..7106a9fecf176ab45ecb64a45ca7268c3297b370 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2005-11-28  Tor Lillqvist  <tml@novell.com>
 
+       * gdk/win32/gdkwindow-win32.c (gdk_window_set_urgency_hint):
+       Implement the conditional use of FlashWindowEx() properly for MSVC
+       compilations. The code was confusingly assuming that if compiled
+       with a "new" compiler, it will only be run on "new" Windows
+       versions. We want it to run on "old" versions, too, even if
+       compiled with a "new" compiler. There are two orthogonal issues:
+       whether the compiler defines the necessary API in its headers, and
+       whether it is present at run-time. (#318077)
+
        * gtk/gtkcalendar.c (gtk_calendar_init): Use GetLocaleInfo() on
        Windows to get the localized weekday and month names. strftime()
        in the Microsoft C library returns strings in the default codepage
index e537933dfdab3c0b6337c40e21bde4ed37270696..7106a9fecf176ab45ecb64a45ca7268c3297b370 100644 (file)
@@ -1,5 +1,14 @@
 2005-11-28  Tor Lillqvist  <tml@novell.com>
 
+       * gdk/win32/gdkwindow-win32.c (gdk_window_set_urgency_hint):
+       Implement the conditional use of FlashWindowEx() properly for MSVC
+       compilations. The code was confusingly assuming that if compiled
+       with a "new" compiler, it will only be run on "new" Windows
+       versions. We want it to run on "old" versions, too, even if
+       compiled with a "new" compiler. There are two orthogonal issues:
+       whether the compiler defines the necessary API in its headers, and
+       whether it is present at run-time. (#318077)
+
        * gtk/gtkcalendar.c (gtk_calendar_init): Use GetLocaleInfo() on
        Windows to get the localized weekday and month names. strftime()
        in the Microsoft C library returns strings in the default codepage
index 799ab68373a214505bfdb3f66f4f68b4b6f87d6e..580ac1c3f4e0f595b23147021f6d7351f498a380 100644 (file)
 #include <config.h>
 #include <stdlib.h>
 
+#ifndef _MSC_VER
+#define _WIN32_WINNT 0x0500
+#define WINVER _WIN32_WINNT
+#endif
+
 #include "gdk.h"
 #include "gdkprivate-win32.h"
 #include "gdkinput-win32.h"
 
 #if defined(_MSC_VER) && (WINVER < 0x0500)
+
+typedef struct
+{
+  UINT cbSize;
+  HWND hwnd;
+  DWORD dwFlags;
+  UINT uCount;
+  DWORD dwTimeout;
+} FLASHWINFO;
+
+#define FLASHW_STOP 0
+#define FLASHW_CAPTION 1
+#define FLASHW_TRAY 2
+#define FLASHW_ALL (FLASHW_CAPTION|FLASHW_TRAY)
+#define FLASHW_TIMER 4
+
 #define GetAncestor(hwnd,what) _gdk_win32_get_ancestor_parent (hwnd)
 
 static HWND
@@ -1539,38 +1560,9 @@ void
 gdk_window_set_urgency_hint (GdkWindow *window,
                             gboolean   urgent)
 {
-#if (WINVER >= 0x0500)
-
   FLASHWINFO flashwinfo;
-
-  g_return_if_fail (GDK_IS_WINDOW (window));
-  g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
-  
-  if (GDK_WINDOW_DESTROYED (window))
-    return;
-
-  flashwinfo.cbSize = sizeof (flashwinfo);
-  flashwinfo.hwnd = GDK_WINDOW_HWND (window);
-  if (urgent)
-    flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER;
-  else
-    flashwinfo.dwFlags = FLASHW_STOP;
-  flashwinfo.uCount = 0;
-  flashwinfo.dwTimeout = 0;
-
-  FlashWindowEx (&flashwinfo);
-#else
-  struct _FLASHWINDOW
-  {
-    UINT cbSize;
-    HWND hwnd;
-    DWORD dwFlags;
-    UINT uCount;
-    DWORD dwTimeout;
-  } flashwindow = { sizeof (flashwindow), GDK_WINDOW_HWND (window), urgent ? 0x07 : 0x0, 0, 0 };
-  typedef BOOL (*PFN_FlashWindowEx) (struct _FLASHWINDOW);
+  typedef BOOL (*PFN_FlashWindowEx) (FLASHWINFO*);
   PFN_FlashWindowEx flashWindowEx = NULL;
-  gboolean once = TRUE;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
   g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
@@ -1578,16 +1570,25 @@ gdk_window_set_urgency_hint (GdkWindow *window,
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
-  if (once)
+  flashWindowEx = (PFN_FlashWindowEx) GetProcAddress (GetModuleHandle ("user32.dll"), "FlashWindowEx");
+
+  if (flashWindowEx)
     {
-      flashWindowEx = (PFN_FlashWindowEx)GetProcAddress (GetModuleHandle ("user32.dll"), "FlashWindowEx");
-      once = FALSE;
+      flashwinfo.cbSize = sizeof (flashwinfo);
+      flashwinfo.hwnd = GDK_WINDOW_HWND (window);
+      if (urgent)
+       flashwinfo.dwFlags = FLASHW_ALL | FLASHW_TIMER;
+      else
+       flashwinfo.dwFlags = FLASHW_STOP;
+      flashwinfo.uCount = 0;
+      flashwinfo.dwTimeout = 0;
+      
+      flashWindowEx (&flashwinfo);
     }
-  if (flashWindowEx)
-    flashWindowEx(flashwindow);
   else
-    FlashWindow (GDK_WINDOW_HWND (window), urgent);
-#endif
+    {
+      FlashWindow (GDK_WINDOW_HWND (window), urgent);
+    }
 }
 
 static void