Commit 2aadb2df authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist
Browse files

Implement the conditional use of FlashWindowEx() properly for MSVC

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)
parent 954deb7b
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
......
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
......
......@@ -29,11 +29,32 @@
#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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment