Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3701b59d
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
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看板
提交
3701b59d
编写于
11月 02, 2012
作者:
L
leonidr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7124310: [macosx] "opposite" seems always null in focus events
Reviewed-by: anthony
上级
69a9c9ee
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
68 addition
and
21 deletion
+68
-21
src/macosx/classes/sun/lwawt/LWWindowPeer.java
src/macosx/classes/sun/lwawt/LWWindowPeer.java
+12
-9
src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
+2
-2
src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java
src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java
+2
-2
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+4
-2
src/macosx/native/sun/awt/AWTWindow.h
src/macosx/native/sun/awt/AWTWindow.h
+3
-0
src/macosx/native/sun/awt/AWTWindow.m
src/macosx/native/sun/awt/AWTWindow.m
+45
-6
未找到文件。
src/macosx/classes/sun/lwawt/LWWindowPeer.java
浏览文件 @
3701b59d
...
...
@@ -675,8 +675,9 @@ public class LWWindowPeer
getLWToolkit
().
getCursorManager
().
updateCursorLater
(
this
);
}
public
void
notifyActivation
(
boolean
activation
)
{
changeFocusedWindow
(
activation
);
public
void
notifyActivation
(
boolean
activation
,
LWWindowPeer
opposite
)
{
Window
oppositeWindow
=
(
opposite
==
null
)?
null
:
opposite
.
getTarget
();
changeFocusedWindow
(
activation
,
oppositeWindow
);
}
// MouseDown in non-client area
...
...
@@ -1151,6 +1152,9 @@ public class LWWindowPeer
Window
currentActive
=
KeyboardFocusManager
.
getCurrentKeyboardFocusManager
().
getActiveWindow
();
Window
opposite
=
LWKeyboardFocusManagerPeer
.
getInstance
().
getCurrentFocusedWindow
();
// Make the owner active window.
if
(
isSimpleWindow
())
{
LWWindowPeer
owner
=
getOwnerFrameDialog
(
this
);
...
...
@@ -1177,16 +1181,17 @@ public class LWWindowPeer
}
// DKFM will synthesize all the focus/activation events correctly.
changeFocusedWindow
(
true
);
changeFocusedWindow
(
true
,
opposite
);
return
true
;
// In case the toplevel is active but not focused, change focus directly,
// as requesting native focus on it will not have effect.
}
else
if
(
getTarget
()
==
currentActive
&&
!
getTarget
().
hasFocus
())
{
changeFocusedWindow
(
true
);
changeFocusedWindow
(
true
,
opposite
);
return
true
;
}
return
platformWindow
.
requestWindowFocus
();
}
...
...
@@ -1216,7 +1221,7 @@ public class LWWindowPeer
/*
* Changes focused window on java level.
*/
private
void
changeFocusedWindow
(
boolean
becomesFocused
)
{
private
void
changeFocusedWindow
(
boolean
becomesFocused
,
Window
opposite
)
{
if
(
focusLog
.
isLoggable
(
PlatformLogger
.
FINE
))
{
focusLog
.
fine
((
becomesFocused
?
"gaining"
:
"loosing"
)
+
" focus window: "
+
this
);
}
...
...
@@ -1240,9 +1245,6 @@ public class LWWindowPeer
}
}
KeyboardFocusManagerPeer
kfmPeer
=
LWKeyboardFocusManagerPeer
.
getInstance
();
Window
oppositeWindow
=
becomesFocused
?
kfmPeer
.
getCurrentFocusedWindow
()
:
null
;
// Note, the method is not called:
// - when the opposite (gaining focus) window is an owned/owner window.
// - for a simple window in any case.
...
...
@@ -1254,10 +1256,11 @@ public class LWWindowPeer
grabbingWindow
.
ungrab
();
}
KeyboardFocusManagerPeer
kfmPeer
=
LWKeyboardFocusManagerPeer
.
getInstance
();
kfmPeer
.
setCurrentFocusedWindow
(
becomesFocused
?
getTarget
()
:
null
);
int
eventID
=
becomesFocused
?
WindowEvent
.
WINDOW_GAINED_FOCUS
:
WindowEvent
.
WINDOW_LOST_FOCUS
;
WindowEvent
windowEvent
=
new
TimedWindowEvent
(
getTarget
(),
eventID
,
opposite
Window
,
System
.
currentTimeMillis
());
WindowEvent
windowEvent
=
new
TimedWindowEvent
(
getTarget
(),
eventID
,
opposite
,
System
.
currentTimeMillis
());
// TODO: wrap in SequencedEvent
postEvent
(
windowEvent
);
...
...
src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
浏览文件 @
3701b59d
...
...
@@ -113,14 +113,14 @@ public class CEmbeddedFrame extends EmbeddedFrame {
public
void
handleFocusEvent
(
boolean
focused
)
{
this
.
focused
=
focused
;
if
(
parentWindowActive
)
{
responder
.
handleWindowFocusEvent
(
focused
);
responder
.
handleWindowFocusEvent
(
focused
,
null
);
}
}
public
void
handleWindowFocusEvent
(
boolean
parentWindowActive
)
{
this
.
parentWindowActive
=
parentWindowActive
;
if
(
focused
)
{
responder
.
handleWindowFocusEvent
(
parentWindowActive
);
responder
.
handleWindowFocusEvent
(
parentWindowActive
,
null
);
}
}
...
...
src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java
浏览文件 @
3701b59d
...
...
@@ -218,7 +218,7 @@ final class CPlatformResponder {
}
}
void
handleWindowFocusEvent
(
boolean
gained
)
{
peer
.
notifyActivation
(
gained
);
void
handleWindowFocusEvent
(
boolean
gained
,
LWWindowPeer
opposite
)
{
peer
.
notifyActivation
(
gained
,
opposite
);
}
}
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
浏览文件 @
3701b59d
...
...
@@ -878,13 +878,15 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor
/*************************************************************
* Callbacks from the AWTWindow and AWTView objc classes.
*************************************************************/
private
void
deliverWindowFocusEvent
(
boolean
gained
){
private
void
deliverWindowFocusEvent
(
boolean
gained
,
CPlatformWindow
opposite
){
// Fix for 7150349: ingore "gained" notifications when the app is inactive.
if
(
gained
&&
!((
LWCToolkit
)
Toolkit
.
getDefaultToolkit
()).
isApplicationActive
())
{
focusLogger
.
fine
(
"the app is inactive, so the notification is ignored"
);
return
;
}
responder
.
handleWindowFocusEvent
(
gained
);
LWWindowPeer
oppositePeer
=
(
opposite
==
null
)?
null
:
opposite
.
getPeer
();
responder
.
handleWindowFocusEvent
(
gained
,
oppositePeer
);
}
private
void
deliverMoveResizeEvent
(
int
x
,
int
y
,
int
width
,
int
height
)
{
...
...
src/macosx/native/sun/awt/AWTWindow.h
浏览文件 @
3701b59d
...
...
@@ -69,6 +69,9 @@
-
(
BOOL
)
worksWhenModal
;
-
(
void
)
sendEvent
:(
NSEvent
*
)
event
;
+
(
void
)
setLastKeyWindow
:(
AWTWindow
*
)
window
;
+
(
AWTWindow
*
)
lastKeyWindow
;
@end
@interface
AWTWindow_Normal
:
NSWindow
...
...
src/macosx/native/sun/awt/AWTWindow.m
浏览文件 @
3701b59d
...
...
@@ -51,6 +51,14 @@
static
JNF_CLASS_CACHE
(
jc_CPlatformWindow
,
"sun/lwawt/macosx/CPlatformWindow"
);
// Cocoa windowDidBecomeKey/windowDidResignKey notifications
// doesn't provide information about "opposite" window, so we
// have to do a bit of tracking. This variable points to a window
// which had been the key window just before a new key window
// was set. It would be nil if the new key window isn't an AWT
// window or the app currently has no key window.
static
AWTWindow
*
lastKeyWindow
=
nil
;
// --------------------------------------------------------------
// NSWindow/NSPanel descendants implementation
#define AWT_NS_WINDOW_IMPLEMENTATION \
...
...
@@ -505,15 +513,17 @@ AWT_ASSERT_APPKIT_THREAD;
[
self
_deliverIconify
:
JNI_FALSE
];
}
-
(
void
)
_deliverWindowFocusEvent
:(
BOOL
)
focused
{
-
(
void
)
_deliverWindowFocusEvent
:(
BOOL
)
focused
oppositeWindow
:(
AWTWindow
*
)
opposite
{
//AWT_ASSERT_APPKIT_THREAD;
JNIEnv
*
env
=
[
ThreadUtilities
getJNIEnvUncached
];
jobject
platformWindow
=
[
self
.
javaPlatformWindow
jObjectWithEnv
:
env
];
if
(
platformWindow
!=
NULL
)
{
static
JNF_MEMBER_CACHE
(
jm_deliverWindowFocusEvent
,
jc_CPlatformWindow
,
"deliverWindowFocusEvent"
,
"(Z)V"
);
JNFCallVoidMethod
(
env
,
platformWindow
,
jm_deliverWindowFocusEvent
,
(
jboolean
)
focused
);
jobject
oppositeWindow
=
[
opposite
.
javaPlatformWindow
jObjectWithEnv
:
env
];
static
JNF_MEMBER_CACHE
(
jm_deliverWindowFocusEvent
,
jc_CPlatformWindow
,
"deliverWindowFocusEvent"
,
"(ZLsun/lwawt/macosx/CPlatformWindow;)V"
);
JNFCallVoidMethod
(
env
,
platformWindow
,
jm_deliverWindowFocusEvent
,
(
jboolean
)
focused
,
oppositeWindow
);
(
*
env
)
->
DeleteLocalRef
(
env
,
platformWindow
);
(
*
env
)
->
DeleteLocalRef
(
env
,
oppositeWindow
);
}
}
...
...
@@ -522,7 +532,10 @@ AWT_ASSERT_APPKIT_THREAD;
AWT_ASSERT_APPKIT_THREAD
;
[
AWTToolkit
eventCountPlusPlus
];
[
CMenuBar
activate
:
self
.
javaMenuBar
modallyDisabled
:
NO
];
[
self
_deliverWindowFocusEvent
:
YES
];
AWTWindow
*
opposite
=
[
AWTWindow
lastKeyWindow
];
[
AWTWindow
setLastKeyWindow
:
nil
];
[
self
_deliverWindowFocusEvent
:
YES
oppositeWindow
:
opposite
];
}
-
(
void
)
windowDidResignKey
:
(
NSNotification
*
)
notification
{
...
...
@@ -530,7 +543,18 @@ AWT_ASSERT_APPKIT_THREAD;
AWT_ASSERT_APPKIT_THREAD
;
[
AWTToolkit
eventCountPlusPlus
];
[
self
.
javaMenuBar
deactivate
];
[
self
_deliverWindowFocusEvent
:
NO
];
// the new key window
NSWindow
*
keyWindow
=
[
NSApp
keyWindow
];
AWTWindow
*
opposite
=
nil
;
if
([
AWTWindow
isAWTWindow
:
keyWindow
])
{
opposite
=
(
AWTWindow
*
)[
keyWindow
delegate
];
[
AWTWindow
setLastKeyWindow
:
self
];
}
else
{
[
AWTWindow
setLastKeyWindow
:
nil
];
}
[
self
_deliverWindowFocusEvent
:
NO
oppositeWindow
:
opposite
];
}
-
(
void
)
windowDidBecomeMain
:
(
NSNotification
*
)
notification
{
...
...
@@ -684,6 +708,17 @@ AWT_ASSERT_APPKIT_THREAD;
}
}
+
(
void
)
setLastKeyWindow
:(
AWTWindow
*
)
window
{
[
window
retain
];
[
lastKeyWindow
release
];
lastKeyWindow
=
window
;
}
+
(
AWTWindow
*
)
lastKeyWindow
{
return
lastKeyWindow
;
}
@end
// AWTWindow
...
...
@@ -1208,6 +1243,10 @@ JNF_COCOA_ENTER(env);
[
JNFRunLoop
performOnMainThreadWaiting
:
NO
withBlock
:
^
(){
AWTWindow
*
window
=
(
AWTWindow
*
)[
nsWindow
delegate
];
if
([
AWTWindow
lastKeyWindow
]
==
window
)
{
[
AWTWindow
setLastKeyWindow
:
nil
];
}
// AWTWindow holds a reference to the NSWindow in its nsWindow
// property. Unsetting the delegate allows it to be deallocated
// which releases the reference. This, in turn, allows the window
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录