Mercurial > pidgin.yaz
diff pidgin/plugins/win32/transparency/win2ktrans.c @ 29803:c3cd8f9fe4b1
Avoid looking up functions by name that will be present on all supported Windows versions.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 19 Feb 2010 19:27:23 +0000 |
parents | 4aa5400b1b99 |
children |
line wrap: on
line diff
--- a/pidgin/plugins/win32/transparency/win2ktrans.c Fri Feb 19 08:54:11 2010 +0000 +++ b/pidgin/plugins/win32/transparency/win2ktrans.c Fri Feb 19 19:27:23 2010 +0000 @@ -72,8 +72,6 @@ static const char *OPT_WINTRANS_BL_ONTOP = "/plugins/gtk/win32/wintrans/bl_always_on_top"; static GSList *window_list = NULL; -static BOOL (*MySetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags) = NULL; - /* * CODE */ @@ -81,31 +79,31 @@ /* Set window transparency level */ static void set_wintrans(GtkWidget *window, int alpha, gboolean enabled, gboolean always_on_top) { - if (MySetLayeredWindowAttributes) { - HWND hWnd = GDK_WINDOW_HWND(window->window); - LONG style = GetWindowLong(hWnd, GWL_EXSTYLE); - if (enabled) { - style |= WS_EX_LAYERED; - } else { - style &= ~WS_EX_LAYERED; - } - SetWindowLong(hWnd, GWL_EXSTYLE, style); + + HWND hWnd = GDK_WINDOW_HWND(window->window); + LONG style = GetWindowLong(hWnd, GWL_EXSTYLE); + if (enabled) { + style |= WS_EX_LAYERED; + } else { + style &= ~WS_EX_LAYERED; + } + SetWindowLong(hWnd, GWL_EXSTYLE, style); - if (enabled) { - SetWindowPos(hWnd, - always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, - 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - MySetLayeredWindowAttributes(hWnd, 0, alpha, LWA_ALPHA); - } else { - /* Ask the window and its children to repaint */ - SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + if (enabled) { + SetWindowPos(hWnd, + always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, + 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + SetLayeredWindowAttributes(hWnd, 0, alpha, LWA_ALPHA); + } else { + /* Ask the window and its children to repaint */ + SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - RedrawWindow(hWnd, NULL, NULL, - RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); - } + RedrawWindow(hWnd, NULL, NULL, + RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } + } /* When a conv window is focused, if we're only transparent when unfocused, @@ -491,14 +489,6 @@ * EXPORTED FUNCTIONS */ static gboolean plugin_load(PurplePlugin *plugin) { - MySetLayeredWindowAttributes = (void*) wpurple_find_and_loadproc( - "user32.dll", "SetLayeredWindowAttributes"); - - if (!MySetLayeredWindowAttributes) { - purple_debug_error(WINTRANS_PLUGIN_ID, - "SetLayeredWindowAttributes API not found (Required W2K+)\n"); - return FALSE; - } purple_signal_connect(purple_conversations_get_handle(), "conversation-created", plugin,