1
1
/*
2
- * Copyright (c) 1996, 2011 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 1996, 2020 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -42,9 +42,7 @@ jobject AwtClipboard::theCurrentClipboard;
42
42
BOOL AwtClipboard::isGettingOwnership = FALSE ;
43
43
44
44
volatile jmethodID AwtClipboard::handleContentsChangedMID;
45
- volatile BOOL AwtClipboard::skipInitialWmDrawClipboardMsg = TRUE ;
46
45
volatile BOOL AwtClipboard::isClipboardViewerRegistered = FALSE ;
47
- volatile HWND AwtClipboard::hwndNextViewer = NULL ;
48
46
49
47
#define GALLOCFLG (GMEM_DDESHARE | GMEM_MOVEABLE | GMEM_ZEROINIT)
50
48
@@ -59,27 +57,11 @@ void AwtClipboard::LostOwnership(JNIEnv *env) {
59
57
}
60
58
}
61
59
62
- void AwtClipboard::WmChangeCbChain (WPARAM wParam, LPARAM lParam) {
63
- if ((HWND)wParam == hwndNextViewer) {
64
- hwndNextViewer = (HWND)lParam;
65
- } else if (hwndNextViewer != NULL ) {
66
- ::SendMessage (hwndNextViewer, WM_CHANGECBCHAIN, wParam, lParam);
67
- }
68
- }
69
-
70
- void AwtClipboard::WmDrawClipboard (JNIEnv *env, WPARAM wParam, LPARAM lParam) {
71
- if (skipInitialWmDrawClipboardMsg) {
72
- // skipping the first contents change notification as it comes
73
- // immediately after registering the clipboard viewer window
74
- // and it is not caused by an actual contents change.
75
- skipInitialWmDrawClipboardMsg = FALSE ;
76
- return ;
77
- }
60
+ void AwtClipboard::WmClipboardUpdate (JNIEnv *env) {
78
61
if (theCurrentClipboard != NULL ) {
79
62
env->CallVoidMethod (theCurrentClipboard, handleContentsChangedMID);
80
63
DASSERT (!safe_ExceptionOccurred (env));
81
64
}
82
- ::SendMessage (hwndNextViewer, WM_DRAWCLIPBOARD, wParam, lParam);
83
65
}
84
66
85
67
void AwtClipboard::RegisterClipboardViewer (JNIEnv *env, jobject jclipboard) {
@@ -96,18 +78,16 @@ void AwtClipboard::RegisterClipboardViewer(JNIEnv *env, jobject jclipboard) {
96
78
env->GetMethodID (cls, " handleContentsChanged" , " ()V" );
97
79
DASSERT (AwtClipboard::handleContentsChangedMID != NULL );
98
80
99
- hwndNextViewer = :: SetClipboardViewer (AwtToolkit::GetInstance ().GetHWnd ());
81
+ ::AddClipboardFormatListener (AwtToolkit::GetInstance().GetHWnd());
100
82
isClipboardViewerRegistered = TRUE ;
101
83
}
102
84
103
85
void AwtClipboard::UnregisterClipboardViewer (JNIEnv *env) {
104
86
TRY;
105
87
106
88
if (isClipboardViewerRegistered) {
107
- ::ChangeClipboardChain (AwtToolkit::GetInstance().GetHWnd(), AwtClipboard::hwndNextViewer);
108
- AwtClipboard::hwndNextViewer = NULL ;
89
+ ::RemoveClipboardFormatListener (AwtToolkit::GetInstance().GetHWnd());
109
90
isClipboardViewerRegistered = FALSE ;
110
- skipInitialWmDrawClipboardMsg = TRUE ;
111
91
}
112
92
113
93
CATCH_BAD_ALLOC;
0 commit comments