GDK W32: Use Vista+ clipboard API
Use RemoveClipboardFormatListener() and AddClipboardFormatListener(). These APIs remove the need for us to maintain the integrity of the clipboard chain, which turned out to be problematic for some reason that is yet to be identified. Fixes #2215 Fixes #442
This commit is contained in:
@ -523,8 +523,6 @@ gdk_win32_display_supports_selection_notification (GdkDisplay *display)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HWND _hwnd_next_viewer = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* maybe this should be integrated with the default message loop - or maybe not ;-)
|
* maybe this should be integrated with the default message loop - or maybe not ;-)
|
||||||
*/
|
*/
|
||||||
@ -538,24 +536,11 @@ inner_clipboard_window_procedure (HWND hwnd,
|
|||||||
{
|
{
|
||||||
case WM_DESTROY: /* remove us from chain */
|
case WM_DESTROY: /* remove us from chain */
|
||||||
{
|
{
|
||||||
ChangeClipboardChain (hwnd, _hwnd_next_viewer);
|
RemoveClipboardFormatListener (hwnd);
|
||||||
PostQuitMessage (0);
|
PostQuitMessage (0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_CHANGECBCHAIN:
|
|
||||||
{
|
|
||||||
HWND hwndRemove = (HWND) wparam; /* handle of window being removed */
|
|
||||||
HWND hwndNext = (HWND) lparam; /* handle of next window in chain */
|
|
||||||
|
|
||||||
if (hwndRemove == _hwnd_next_viewer)
|
|
||||||
_hwnd_next_viewer = hwndNext == hwnd ? NULL : hwndNext;
|
|
||||||
else if (_hwnd_next_viewer != NULL)
|
|
||||||
return SendMessage (_hwnd_next_viewer, message, wparam, lparam);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
case WM_CLIPBOARDUPDATE:
|
case WM_CLIPBOARDUPDATE:
|
||||||
case WM_DRAWCLIPBOARD:
|
|
||||||
{
|
{
|
||||||
HWND hwnd_owner;
|
HWND hwnd_owner;
|
||||||
HWND stored_hwnd_owner;
|
HWND stored_hwnd_owner;
|
||||||
@ -632,9 +617,6 @@ inner_clipboard_window_procedure (HWND hwnd,
|
|||||||
event->owner_change.selection_time = GDK_CURRENT_TIME;
|
event->owner_change.selection_time = GDK_CURRENT_TIME;
|
||||||
_gdk_win32_append_event (event);
|
_gdk_win32_append_event (event);
|
||||||
|
|
||||||
if (_hwnd_next_viewer != NULL)
|
|
||||||
return SendMessage (_hwnd_next_viewer, message, wparam, lparam);
|
|
||||||
|
|
||||||
/* clear error to avoid confusing SetClipboardViewer() return */
|
/* clear error to avoid confusing SetClipboardViewer() return */
|
||||||
SetLastError (0);
|
SetLastError (0);
|
||||||
return 0;
|
return 0;
|
||||||
@ -694,16 +676,10 @@ register_clipboard_notification (GdkDisplay *display)
|
|||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
SetLastError (0);
|
SetLastError (0);
|
||||||
_hwnd_next_viewer = SetClipboardViewer (display_win32->clipboard_hwnd);
|
|
||||||
|
|
||||||
if (_hwnd_next_viewer == NULL && GetLastError() != 0)
|
if (AddClipboardFormatListener (display_win32->clipboard_hwnd) == FALSE)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
/* 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; */
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
@ -850,7 +826,6 @@ gdk_win32_display_dispose (GObject *object)
|
|||||||
{
|
{
|
||||||
DestroyWindow (display_win32->clipboard_hwnd);
|
DestroyWindow (display_win32->clipboard_hwnd);
|
||||||
display_win32->clipboard_hwnd = NULL;
|
display_win32->clipboard_hwnd = NULL;
|
||||||
_hwnd_next_viewer = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display_win32->have_at_least_win81)
|
if (display_win32->have_at_least_win81)
|
||||||
|
Reference in New Issue
Block a user