[gtk+/2.24: 4/7] win32: use AddClipboardFormatListener when available
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/2.24: 4/7] win32: use AddClipboardFormatListener when available
- Date: Thu, 24 Apr 2014 14:05:25 +0000 (UTC)
commit 45786a691fb0485e3028cafe76f3cfed87ba60df
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Thu Aug 22 18:20:32 2013 +0200
win32: use AddClipboardFormatListener when available
Clipboard viewer method has design issues, they can be easily broken by
misbehaving applications. AddClipboardFormatListener is the recommended
method, although it was added only since Vista.
https://bugzilla.gnome.org/show_bug.cgi?id=706609
gdk/win32/gdkdisplay-win32.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c
index cef6072..bc90c3a 100644
--- a/gdk/win32/gdkdisplay-win32.c
+++ b/gdk/win32/gdkdisplay-win32.c
@@ -363,9 +363,10 @@ inner_clipboard_window_procedure (HWND hwnd,
return 0;
}
-#ifdef WM_CLIPBOARDUPDATE
- case WM_CLIPBOARDUPDATE:
+#ifndef WM_CLIPBOARDUPDATE
+#define WM_CLIPBOARDUPDATE 0x031D
#endif
+ case WM_CLIPBOARDUPDATE:
case WM_DRAWCLIPBOARD:
{
int success;
@@ -451,6 +452,8 @@ _gdk_win32_register_clipboard_notification (void)
WNDCLASS wclass = { 0, };
HWND hwnd;
ATOM klass;
+ typedef BOOL (WINAPI *PFN_AddClipboardFormatListener) (HWND);
+ PFN_AddClipboardFormatListener addClipboardFormatListener = NULL;
wclass.lpszClassName = "GdkClipboardNotification";
wclass.lpfnWndProc = _clipboard_window_procedure;
@@ -467,16 +470,20 @@ _gdk_win32_register_clipboard_notification (void)
if (!hwnd)
goto failed;
- SetLastError (0);
- _hwnd_next_viewer = SetClipboardViewer (hwnd);
+ addClipboardFormatListener = (PFN_AddClipboardFormatListener) GetProcAddress (GetModuleHandle
("user32.dll"), "AddClipboardFormatListener");
- if (_hwnd_next_viewer == NULL && GetLastError() != 0)
- goto failed;
+ if (addClipboardFormatListener != NULL && addClipboardFormatListener (hwnd))
+ {
+ GDK_NOTE (DND, g_print ("registered clipboard listener\n"));
+ }
+ else
+ {
+ SetLastError (0);
+ _hwnd_next_viewer = SetClipboardViewer (hwnd);
- /* FIXME: http://msdn.microsoft.com/en-us/library/ms649033(v=VS.85).aspx */
- /* This is only supported by Vista, and not yet by mingw64 */
- /* if (AddClipboardFormatListener (hwnd) == FALSE) */
- /* goto failed; */
+ if (_hwnd_next_viewer == NULL && GetLastError() != 0)
+ goto failed;
+ }
return hwnd;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]