Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
0ca485cd
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0ca485cd
编写于
11月 15, 2013
作者:
P
pchelko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7124253: [macosx] Flavor change notification not coming
Reviewed-by: anthony, serb
上级
1899df4f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
58 deletion
+38
-58
src/macosx/classes/sun/lwawt/macosx/CClipboard.java
src/macosx/classes/sun/lwawt/macosx/CClipboard.java
+18
-8
src/macosx/native/sun/awt/CClipboard.h
src/macosx/native/sun/awt/CClipboard.h
+0
-2
src/macosx/native/sun/awt/CClipboard.m
src/macosx/native/sun/awt/CClipboard.m
+20
-48
未找到文件。
src/macosx/classes/sun/lwawt/macosx/CClipboard.java
浏览文件 @
0ca485cd
...
@@ -25,8 +25,10 @@
...
@@ -25,8 +25,10 @@
package
sun.lwawt.macosx
;
package
sun.lwawt.macosx
;
import
java.awt.*
;
import
java.awt.datatransfer.*
;
import
java.awt.datatransfer.*
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.NotSerializableException
;
import
java.util.*
;
import
java.util.*
;
import
sun.awt.datatransfer.*
;
import
sun.awt.datatransfer.*
;
...
@@ -65,12 +67,10 @@ public class CClipboard extends SunClipboard {
...
@@ -65,12 +67,10 @@ public class CClipboard extends SunClipboard {
long
[]
formatArray
=
dataTransferer
.
getFormatsForTransferableAsArray
(
contents
,
flavorMap
);
long
[]
formatArray
=
dataTransferer
.
getFormatsForTransferableAsArray
(
contents
,
flavorMap
);
declareTypes
(
formatArray
,
this
);
declareTypes
(
formatArray
,
this
);
Map
<
Long
,
DataFlavor
>
formatMap
=
DataTransferer
.
getInstance
().
getFormatsForTransferable
(
contents
,
flavorMap
);
Map
<
Long
,
DataFlavor
>
formatMap
=
dataTransferer
.
getFormatsForTransferable
(
contents
,
flavorMap
);
for
(
Map
.
Entry
<
Long
,
DataFlavor
>
entry
:
formatMap
.
entrySet
())
{
for
(
Iterator
<
Long
>
iter
=
formatMap
.
keySet
().
iterator
();
iter
.
hasNext
();
)
{
long
format
=
entry
.
getKey
();
Long
lFormat
=
iter
.
next
();
DataFlavor
flavor
=
entry
.
getValue
();
long
format
=
lFormat
.
longValue
();
DataFlavor
flavor
=
formatMap
.
get
(
lFormat
);
try
{
try
{
byte
[]
bytes
=
DataTransferer
.
getInstance
().
translateTransferable
(
contents
,
flavor
,
format
);
byte
[]
bytes
=
DataTransferer
.
getInstance
().
translateTransferable
(
contents
,
flavor
,
format
);
...
@@ -80,17 +80,27 @@ public class CClipboard extends SunClipboard {
...
@@ -80,17 +80,27 @@ public class CClipboard extends SunClipboard {
// javaJVMLocalObjectMimeType failed to serialize.
// javaJVMLocalObjectMimeType failed to serialize.
// May remove this if-check when 5078787 is fixed.
// May remove this if-check when 5078787 is fixed.
if
(!(
flavor
.
isMimeTypeEqual
(
DataFlavor
.
javaJVMLocalObjectMimeType
)
&&
if
(!(
flavor
.
isMimeTypeEqual
(
DataFlavor
.
javaJVMLocalObjectMimeType
)
&&
e
instanceof
java
.
io
.
NotSerializableException
))
{
e
instanceof
NotSerializableException
))
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
}
}
notifyChanged
();
}
}
private
void
lostSelectionOwnershipImpl
()
{
private
void
notifyLostOwnership
()
{
lostOwnershipImpl
();
lostOwnershipImpl
();
}
}
private
static
void
notifyChanged
()
{
CClipboard
clipboard
=
(
CClipboard
)
Toolkit
.
getDefaultToolkit
().
getSystemClipboard
();
if
(!
clipboard
.
areFlavorListenersRegistered
())
{
return
;
}
clipboard
.
checkChange
(
clipboard
.
getClipboardFormats
());
}
protected
native
long
[]
getClipboardFormats
();
protected
native
long
[]
getClipboardFormats
();
protected
native
byte
[]
getClipboardData
(
long
format
)
throws
IOException
;
protected
native
byte
[]
getClipboardData
(
long
format
)
throws
IOException
;
...
...
src/macosx/native/sun/awt/CClipboard.h
浏览文件 @
0ca485cd
...
@@ -43,6 +43,4 @@
...
@@ -43,6 +43,4 @@
-
(
NSArray
*
)
javaGetTypes
;
-
(
NSArray
*
)
javaGetTypes
;
-
(
NSData
*
)
javaGetDataForType
:(
NSString
*
)
inFormat
;
-
(
NSData
*
)
javaGetDataForType
:(
NSString
*
)
inFormat
;
-
(
void
)
pasteboardChangedOwner
:(
NSPasteboard
*
)
sender
;
@end
@end
src/macosx/native/sun/awt/CClipboard.m
浏览文件 @
0ca485cd
...
@@ -91,7 +91,9 @@ static CClipboard *sClipboard = nil;
...
@@ -91,7 +91,9 @@ static CClipboard *sClipboard = nil;
{
{
if
(
sClipboard
==
nil
)
{
if
(
sClipboard
==
nil
)
{
sClipboard
=
[[
CClipboard
alloc
]
init
];
sClipboard
=
[[
CClipboard
alloc
]
init
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
sClipboard
selector
:
@selector
(
checkPasteboard
:
)
name
:
NSApplicationDidBecomeActiveNotification
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
sClipboard
selector
:
@selector
(
checkPasteboard
:
)
name:
NSApplicationDidBecomeActiveNotification
object:
nil
];
}
}
return
sClipboard
;
return
sClipboard
;
...
@@ -110,8 +112,6 @@ static CClipboard *sClipboard = nil;
...
@@ -110,8 +112,6 @@ static CClipboard *sClipboard = nil;
-
(
void
)
javaDeclareTypes
:(
NSArray
*
)
inTypes
withOwner
:(
jobject
)
inClipboard
jniEnv
:(
JNIEnv
*
)
inEnv
{
-
(
void
)
javaDeclareTypes
:(
NSArray
*
)
inTypes
withOwner
:(
jobject
)
inClipboard
jniEnv
:(
JNIEnv
*
)
inEnv
{
//NSLog(@"CClipboard javaDeclareTypes %@ withOwner", inTypes);
@synchronized
(
self
)
{
@synchronized
(
self
)
{
if
(
inClipboard
!=
NULL
)
{
if
(
inClipboard
!=
NULL
)
{
if
(
fClipboardOwner
!=
NULL
)
{
if
(
fClipboardOwner
!=
NULL
)
{
...
@@ -126,8 +126,6 @@ static CClipboard *sClipboard = nil;
...
@@ -126,8 +126,6 @@ static CClipboard *sClipboard = nil;
-
(
void
)
_nativeDeclareTypes
:(
NSArray
*
)
inTypes
{
-
(
void
)
_nativeDeclareTypes
:(
NSArray
*
)
inTypes
{
AWT_ASSERT_APPKIT_THREAD
;
AWT_ASSERT_APPKIT_THREAD
;
//NSLog(@"CClipboard _nativeDeclareTypes %@ withOwner", inTypes);
fChangeCount
=
[[
NSPasteboard
generalPasteboard
]
declareTypes
:
inTypes
owner
:
self
];
fChangeCount
=
[[
NSPasteboard
generalPasteboard
]
declareTypes
:
inTypes
owner
:
self
];
}
}
...
@@ -136,8 +134,6 @@ static CClipboard *sClipboard = nil;
...
@@ -136,8 +134,6 @@ static CClipboard *sClipboard = nil;
NSMutableArray
*
args
=
[
NSMutableArray
arrayWithCapacity
:
1
];
NSMutableArray
*
args
=
[
NSMutableArray
arrayWithCapacity
:
1
];
[
ThreadUtilities
performOnMainThread
:
@selector
(
_nativeGetTypes
:)
on
:
self
withObject
:
args
waitUntilDone
:
YES
];
[
ThreadUtilities
performOnMainThread
:
@selector
(
_nativeGetTypes
:)
on
:
self
withObject
:
args
waitUntilDone
:
YES
];
//NSLog(@"CClipboard getTypes returns %@", [args lastObject]);
return
[
args
lastObject
];
return
[
args
lastObject
];
}
}
...
@@ -145,8 +141,6 @@ static CClipboard *sClipboard = nil;
...
@@ -145,8 +141,6 @@ static CClipboard *sClipboard = nil;
AWT_ASSERT_APPKIT_THREAD
;
AWT_ASSERT_APPKIT_THREAD
;
[
args
addObject
:[[
NSPasteboard
generalPasteboard
]
types
]];
[
args
addObject
:[[
NSPasteboard
generalPasteboard
]
types
]];
//NSLog(@"CClipboard getTypes returns %@", [args lastObject]);
}
}
-
(
void
)
javaSetData
:(
NSData
*
)
inData
forType
:(
NSString
*
)
inFormat
{
-
(
void
)
javaSetData
:(
NSData
*
)
inData
forType
:(
NSString
*
)
inFormat
{
...
@@ -154,25 +148,18 @@ static CClipboard *sClipboard = nil;
...
@@ -154,25 +148,18 @@ static CClipboard *sClipboard = nil;
CClipboardUpdate
*
newUpdate
=
[[
CClipboardUpdate
alloc
]
initWithData
:
inData
withFormat
:
inFormat
];
CClipboardUpdate
*
newUpdate
=
[[
CClipboardUpdate
alloc
]
initWithData
:
inData
withFormat
:
inFormat
];
[
ThreadUtilities
performOnMainThread
:
@selector
(
_nativeSetData
:)
on
:
self
withObject
:
newUpdate
waitUntilDone
:
YES
];
[
ThreadUtilities
performOnMainThread
:
@selector
(
_nativeSetData
:)
on
:
self
withObject
:
newUpdate
waitUntilDone
:
YES
];
[
newUpdate
release
];
[
newUpdate
release
];
//NSLog(@"CClipboard javaSetData forType %@", inFormat);
}
}
-
(
void
)
_nativeSetData
:(
CClipboardUpdate
*
)
newUpdate
{
-
(
void
)
_nativeSetData
:(
CClipboardUpdate
*
)
newUpdate
{
AWT_ASSERT_APPKIT_THREAD
;
AWT_ASSERT_APPKIT_THREAD
;
[[
NSPasteboard
generalPasteboard
]
setData
:[
newUpdate
data
]
forType
:[
newUpdate
format
]];
[[
NSPasteboard
generalPasteboard
]
setData
:[
newUpdate
data
]
forType
:[
newUpdate
format
]];
//NSLog(@"CClipboard _nativeSetData setData %@", [newUpdate data]);
//NSLog(@"CClipboard _nativeSetData forType %@", [newUpdate format]);
}
}
-
(
NSData
*
)
javaGetDataForType
:(
NSString
*
)
inFormat
{
-
(
NSData
*
)
javaGetDataForType
:(
NSString
*
)
inFormat
{
NSMutableArray
*
args
=
[
NSMutableArray
arrayWithObject
:
inFormat
];
NSMutableArray
*
args
=
[
NSMutableArray
arrayWithObject
:
inFormat
];
[
ThreadUtilities
performOnMainThread
:
@selector
(
_nativeGetDataForType
:)
on
:
self
withObject
:
args
waitUntilDone
:
YES
];
[
ThreadUtilities
performOnMainThread
:
@selector
(
_nativeGetDataForType
:)
on
:
self
withObject
:
args
waitUntilDone
:
YES
];
//NSLog(@"CClipboard javaGetDataForType %@ returns an NSData", inFormat);
return
[
args
lastObject
];
return
[
args
lastObject
];
}
}
...
@@ -183,15 +170,11 @@ static CClipboard *sClipboard = nil;
...
@@ -183,15 +170,11 @@ static CClipboard *sClipboard = nil;
if
(
returnValue
)
[
args
replaceObjectAtIndex
:
0
withObject
:
returnValue
];
if
(
returnValue
)
[
args
replaceObjectAtIndex
:
0
withObject
:
returnValue
];
else
[
args
removeLastObject
];
else
[
args
removeLastObject
];
//NSLog(@"CClipboard _nativeGetDataForType");
}
}
-
(
void
)
checkPasteboard
:(
id
)
application
{
-
(
void
)
checkPasteboard
:(
id
)
application
{
AWT_ASSERT_APPKIT_THREAD
;
AWT_ASSERT_APPKIT_THREAD
;
//NSLog(@"CClipboard checkPasteboard oldCount %d newCount %d newTypes %@", fChangeCount, [[NSPasteboard generalPasteboard] changeCount], [[NSPasteboard generalPasteboard] types]);
// This is called via NSApplicationDidBecomeActiveNotification.
// This is called via NSApplicationDidBecomeActiveNotification.
// If the change count on the general pasteboard is different than when we set it
// If the change count on the general pasteboard is different than when we set it
...
@@ -199,27 +182,23 @@ static CClipboard *sClipboard = nil;
...
@@ -199,27 +182,23 @@ static CClipboard *sClipboard = nil;
NSInteger
newChangeCount
=
[[
NSPasteboard
generalPasteboard
]
changeCount
];
NSInteger
newChangeCount
=
[[
NSPasteboard
generalPasteboard
]
changeCount
];
if
(
fChangeCount
!=
newChangeCount
)
{
if
(
fChangeCount
!=
newChangeCount
)
{
fChangeCount
=
newChangeCount
;
fChangeCount
=
newChangeCount
;
[
self
pasteboardChangedOwner
:[
NSPasteboard
generalPasteboard
]];
// Notify that the content might be changed
}
static
JNF_CLASS_CACHE
(
jc_CClipboard
,
"sun/lwawt/macosx/CClipboard"
);
}
static
JNF_STATIC_MEMBER_CACHE
(
jm_contentChanged
,
jc_CClipboard
,
"notifyChanged"
,
"()V"
);
JNIEnv
*
env
=
[
ThreadUtilities
getJNIEnv
];
-
(
void
)
pasteboardChangedOwner
:(
NSPasteboard
*
)
sender
;
{
JNFCallStaticVoidMethod
(
env
,
jm_contentChanged
);
AWT_ASSERT_APPKIT_THREAD
;
// If we have a Java pasteboard owner, tell it that it doesn't own the pasteboard anymore.
static
JNF_CLASS_CACHE
(
jc_CClipboard
,
"sun/lwawt/macosx/CClipboard"
);
static
JNF_MEMBER_CACHE
(
jm_lostOwnership
,
jc_CClipboard
,
"notifyLostOwnership"
,
"()V"
);
static
JNF_MEMBER_CACHE
(
jm_lostOwnership
,
jc_CClipboard
,
"lostSelectionOwnershipImpl"
,
"()V"
);
@synchronized
(
self
)
{
if
(
fClipboardOwner
)
{
//NSLog(@"CClipboard pasteboardChangedOwner");
JNIEnv
*
env
=
[
ThreadUtilities
getJNIEnv
];
JNFCallVoidMethod
(
env
,
fClipboardOwner
,
jm_lostOwnership
);
// AWT_THREADING Safe (event)
// If we have a Java pasteboard owner, tell it that it doesn't own the pasteboard anymore.
JNFDeleteGlobalRef
(
env
,
fClipboardOwner
);
@synchronized
(
self
)
{
fClipboardOwner
=
NULL
;
if
(
fClipboardOwner
)
{
}
JNIEnv
*
env
=
[
ThreadUtilities
getJNIEnv
];
JNFCallVoidMethod
(
env
,
fClipboardOwner
,
jm_lostOwnership
);
// AWT_THREADING Safe (event)
JNFDeleteGlobalRef
(
env
,
fClipboardOwner
);
fClipboardOwner
=
NULL
;
}
}
}
}
}
}
...
@@ -265,9 +244,6 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CClipboard_setData
...
@@ -265,9 +244,6 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CClipboard_setData
}
}
JNF_COCOA_ENTER
(
env
);
JNF_COCOA_ENTER
(
env
);
//NSLog(@"Java_sun_lwawt_macosx_CClipboard_setData");
jint
nBytes
=
(
*
env
)
->
GetArrayLength
(
env
,
inBytes
);
jint
nBytes
=
(
*
env
)
->
GetArrayLength
(
env
,
inBytes
);
jbyte
*
rawBytes
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
inBytes
,
NULL
);
jbyte
*
rawBytes
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
inBytes
,
NULL
);
NSData
*
bytesAsData
=
[
NSData
dataWithBytes
:
rawBytes
length
:
nBytes
];
NSData
*
bytesAsData
=
[
NSData
dataWithBytes
:
rawBytes
length
:
nBytes
];
...
@@ -288,8 +264,6 @@ JNIEXPORT jlongArray JNICALL Java_sun_lwawt_macosx_CClipboard_getClipboardFormat
...
@@ -288,8 +264,6 @@ JNIEXPORT jlongArray JNICALL Java_sun_lwawt_macosx_CClipboard_getClipboardFormat
jlongArray
returnValue
=
NULL
;
jlongArray
returnValue
=
NULL
;
JNF_COCOA_ENTER
(
env
);
JNF_COCOA_ENTER
(
env
);
//NSLog(@"Java_sun_lwawt_macosx_CClipboard_getClipboardFormats");
NSArray
*
dataTypes
=
[[
CClipboard
sharedClipboard
]
javaGetTypes
];
NSArray
*
dataTypes
=
[[
CClipboard
sharedClipboard
]
javaGetTypes
];
NSUInteger
nFormats
=
[
dataTypes
count
];
NSUInteger
nFormats
=
[
dataTypes
count
];
NSUInteger
knownFormats
=
0
;
NSUInteger
knownFormats
=
0
;
...
@@ -346,8 +320,6 @@ JNIEXPORT jbyteArray JNICALL Java_sun_lwawt_macosx_CClipboard_getClipboardData
...
@@ -346,8 +320,6 @@ JNIEXPORT jbyteArray JNICALL Java_sun_lwawt_macosx_CClipboard_getClipboardData
// a byte array back to Java. CDataTransferer will do that if necessary.
// a byte array back to Java. CDataTransferer will do that if necessary.
JNF_COCOA_ENTER
(
env
);
JNF_COCOA_ENTER
(
env
);
//NSLog(@"Java_sun_lwawt_macosx_CClipboard_getClipboardData");
NSString
*
formatAsString
=
formatForIndex
(
format
);
NSString
*
formatAsString
=
formatForIndex
(
format
);
NSData
*
clipData
=
[[
CClipboard
sharedClipboard
]
javaGetDataForType
:
formatAsString
];
NSData
*
clipData
=
[[
CClipboard
sharedClipboard
]
javaGetDataForType
:
formatAsString
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录