# HG changeset patch # User Herman Bloggs # Date 1037659866 0 # Node ID a1245dcf7b310d7934dd5c247bf4959d8ecde370 # Parent 156d2c2fc3d5c2c18978b348753151335647ef6f [gaim-migrate @ 4174] Flashing window fixed to work with all Windows vers committer: Tailor Script diff -r 156d2c2fc3d5 -r a1245dcf7b31 src/win32/win32dep.c --- a/src/win32/win32dep.c Mon Nov 18 22:22:30 2002 +0000 +++ b/src/win32/win32dep.c Mon Nov 18 22:51:06 2002 +0000 @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include "gaim.h" @@ -24,6 +25,15 @@ */ /* + * DATA STRUCTS + */ +struct _WGAIM_FLASH_INFO { + guint t_handle; + guint sig_handler; +}; +typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO; + +/* * LOCALS */ static char install_dir[MAXPATHLEN]; @@ -39,9 +49,66 @@ HINSTANCE gaimdll_hInstance = 0; /* + * PROTOS + */ +BOOL (*MyFlashWindowEx)(PFLASHWINFO pfwi)=NULL; + + +/* * STATIC CODE */ +/* Window flasher */ +static gboolean flash_window_cb(gpointer data) { + FlashWindow((HWND)data, TRUE); + return TRUE; +} + +static void halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, WGAIM_FLASH_INFO *finfo) { + /* Stop flashing and remove filter */ + debug_printf("Removing timeout\n"); + gtk_timeout_remove(finfo->t_handle); + debug_printf("Disconnecting signal handler\n"); + g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler); + debug_printf("done\n"); +} + +/* Determine whether the specified dll contains the specified procedure. + If so, load it (if not already loaded). */ +static FARPROC find_and_loadproc( char* dllname, char* procedure ) { + HMODULE hmod; + int did_load=0; + FARPROC proc = 0; + + if(!(hmod=GetModuleHandle(dllname))) { + debug_printf("%s not found. Loading it..\n", dllname); + if(!(hmod = LoadLibrary(dllname))) { + debug_printf("Could not load: %s\n", dllname); + return NULL; + } + else + did_load = 1; + } + + if((proc=GetProcAddress(hmod, procedure))) { + debug_printf("This version of %s contains %s\n", dllname, procedure); + return proc; + } + else { + debug_printf("Function: %s not found in dll: %s\n", procedure, dllname); + if(did_load) { + /* unload dll */ + FreeLibrary(hmod); + } + return NULL; + } +} + + +void load_winver_specific_procs(void) { + /* Used for Win98+ and WinNT5+ */ + MyFlashWindowEx = (void*)find_and_loadproc("user32.dll", "FlashWindowEx" ); +} /* @@ -93,15 +160,25 @@ /* Miscellaneous */ -/* FlashWindowEx is only supported by Win98+ and WinNT5+ */ +/* FlashWindowEx is only supported by Win98+ and WinNT5+. If its + not supported we do it our own way */ void wgaim_im_blink(GtkWidget *window) { - FLASHWINFO info; + if(MyFlashWindowEx) { + FLASHWINFO info; - info.cbSize = sizeof(FLASHWINFO); - info.hwnd = GDK_WINDOW_HWND(window->window); - info.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG; - info.dwTimeout = 0; - FlashWindowEx(&info); + info.cbSize = sizeof(FLASHWINFO); + info.hwnd = GDK_WINDOW_HWND(window->window); + info.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG; + info.dwTimeout = 0; + MyFlashWindowEx(&info); + } + else { + WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1); + + /* Start Flashing window */ + finfo->t_handle = gtk_timeout_add(1000, flash_window_cb, GDK_WINDOW_HWND(window->window)); + finfo->sig_handler = g_signal_connect(G_OBJECT(window), "focus-in-event", G_CALLBACK(halt_flash_filter), finfo); + } } /* Windows Initializations */ @@ -115,6 +192,8 @@ debug_printf("wgaim_init\n"); + load_winver_specific_procs(); + /* Initialize Wingaim systray icon */ wgaim_systray_init();