| 38 #include <purple.h> |
38 #include <purple.h> |
| 39 |
39 |
| 40 #include "resource.h" |
40 #include "resource.h" |
| 41 |
41 |
| 42 #include "gtkwin32dep.h" |
42 #include "gtkwin32dep.h" |
| 43 #include "pidgindisplaywindow.h" |
|
| 44 |
|
| 45 /* |
|
| 46 * GLOBALS |
|
| 47 */ |
|
| 48 HINSTANCE exe_hInstance = 0; |
|
| 49 HINSTANCE dll_hInstance = 0; |
|
| 50 HWND messagewin_hwnd; |
|
| 51 |
43 |
| 52 /* |
44 /* |
| 53 * PUBLIC CODE |
45 * PUBLIC CODE |
| 54 */ |
46 */ |
| 55 |
47 |
| 56 HINSTANCE winpidgin_exe_hinstance(void) { |
|
| 57 return exe_hInstance; |
|
| 58 } |
|
| 59 |
|
| 60 void winpidgin_set_exe_hinstance(HINSTANCE hint) |
|
| 61 { |
|
| 62 exe_hInstance = hint; |
|
| 63 } |
|
| 64 |
|
| 65 HINSTANCE winpidgin_dll_hinstance(void) { |
|
| 66 return dll_hInstance; |
|
| 67 } |
|
| 68 |
|
| 69 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14) |
|
| 70 |
|
| 71 static LRESULT CALLBACK |
|
| 72 message_window_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { |
|
| 73 if (msg == PIDGIN_WM_PROTOCOL_HANDLE) { |
|
| 74 char *proto_msg = (char *) lparam; |
|
| 75 purple_debug_info("winpidgin", "Got protocol handler request: %s\n", proto_msg ? proto_msg : ""); |
|
| 76 purple_got_protocol_handler_uri(proto_msg); |
|
| 77 return TRUE; |
|
| 78 } |
|
| 79 |
|
| 80 return DefWindowProc(hwnd, msg, wparam, lparam); |
|
| 81 } |
|
| 82 |
|
| 83 static HWND winpidgin_message_window_init(void) { |
|
| 84 HWND win_hwnd; |
|
| 85 WNDCLASSEX wcx; |
|
| 86 LPCTSTR wname; |
|
| 87 |
|
| 88 wname = TEXT("WinpidginMsgWinCls"); |
|
| 89 |
|
| 90 wcx.cbSize = sizeof(wcx); |
|
| 91 wcx.style = 0; |
|
| 92 wcx.lpfnWndProc = message_window_handler; |
|
| 93 wcx.cbClsExtra = 0; |
|
| 94 wcx.cbWndExtra = 0; |
|
| 95 wcx.hInstance = winpidgin_exe_hinstance(); |
|
| 96 wcx.hIcon = NULL; |
|
| 97 wcx.hCursor = NULL; |
|
| 98 wcx.hbrBackground = NULL; |
|
| 99 wcx.lpszMenuName = NULL; |
|
| 100 wcx.lpszClassName = wname; |
|
| 101 wcx.hIconSm = NULL; |
|
| 102 |
|
| 103 RegisterClassEx(&wcx); |
|
| 104 |
|
| 105 /* Create the window */ |
|
| 106 if(!(win_hwnd = CreateWindow(wname, TEXT("WinpidginMsgWin"), 0, 0, 0, 0, 0, |
|
| 107 NULL, NULL, winpidgin_exe_hinstance(), 0))) { |
|
| 108 purple_debug_error("winpidgin", |
|
| 109 "Unable to create message window.\n"); |
|
| 110 return NULL; |
|
| 111 } |
|
| 112 |
|
| 113 return win_hwnd; |
|
| 114 } |
|
| 115 |
|
| 116 void winpidgin_init(void) { |
|
| 117 if (purple_debug_is_verbose()) |
|
| 118 purple_debug_misc("winpidgin", "winpidgin_init start\n"); |
|
| 119 |
|
| 120 messagewin_hwnd = winpidgin_message_window_init(); |
|
| 121 |
|
| 122 if (purple_debug_is_verbose()) |
|
| 123 purple_debug_misc("winpidgin", "winpidgin_init end\n"); |
|
| 124 } |
|
| 125 |
|
| 126 /* Windows Cleanup */ |
|
| 127 |
|
| 128 void winpidgin_cleanup(void) { |
|
| 129 purple_debug_info("winpidgin", "winpidgin_cleanup\n"); |
|
| 130 |
|
| 131 if(messagewin_hwnd) |
|
| 132 DestroyWindow(messagewin_hwnd); |
|
| 133 |
|
| 134 } |
|
| 135 |
|
| 136 /* DLL initializer */ |
48 /* DLL initializer */ |
| 137 /* suppress gcc "no previous prototype" warning */ |
49 /* suppress gcc "no previous prototype" warning */ |
| 138 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); |
50 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); |
| 139 BOOL WINAPI DllMain(HINSTANCE hinstDLL, G_GNUC_UNUSED DWORD fdwReason, G_GNUC_UNUSED LPVOID lpvReserved) { |
51 BOOL WINAPI |
| 140 dll_hInstance = hinstDLL; |
52 DllMain(G_GNUC_UNUSED HINSTANCE hinstDLL, G_GNUC_UNUSED DWORD fdwReason, |
| |
53 G_GNUC_UNUSED LPVOID lpvReserved) |
| |
54 { |
| 141 return TRUE; |
55 return TRUE; |
| 142 } |
56 } |
| 143 |
|
| 144 typedef HRESULT (WINAPI* DwmIsCompositionEnabledFunction)(BOOL*); |
|
| 145 typedef HRESULT (WINAPI* DwmGetWindowAttributeFunction)(HWND, DWORD, PVOID, DWORD); |
|
| 146 #ifndef DWMWA_EXTENDED_FRAME_BOUNDS |
|
| 147 # define DWMWA_EXTENDED_FRAME_BOUNDS 9 |
|
| 148 #endif |
|
| 149 |
|
| 150 DWORD winpidgin_get_lastactive() { |
|
| 151 DWORD result = 0; |
|
| 152 |
|
| 153 LASTINPUTINFO lii; |
|
| 154 memset(&lii, 0, sizeof(lii)); |
|
| 155 lii.cbSize = sizeof(lii); |
|
| 156 if (GetLastInputInfo(&lii)) |
|
| 157 result = lii.dwTime; |
|
| 158 |
|
| 159 return result; |
|
| 160 } |
|
| 161 |
|