forked from chromiumembedded/java-cef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCefBrowserWindowMac.java
More file actions
45 lines (40 loc) · 1.53 KB
/
CefBrowserWindowMac.java
File metadata and controls
45 lines (40 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
package org.cef.browser.mac;
import org.cef.browser.CefBrowserWindow;
import java.awt.Component;
import java.awt.peer.ComponentPeer;
import sun.awt.AWTAccessor;
import sun.lwawt.LWComponentPeer;
import sun.lwawt.PlatformWindow;
import sun.lwawt.macosx.CFRetainedResource;
import sun.lwawt.macosx.CPlatformWindow;
public class CefBrowserWindowMac implements CefBrowserWindow {
@Override
public long getWindowHandle(Component comp) {
final long[] result = new long[1];
while (comp != null) {
if (comp.isLightweight()) {
comp = comp.getParent();
continue;
}
ComponentPeer peer = AWTAccessor.getComponentAccessor().getPeer(comp);
if (peer instanceof LWComponentPeer) {
@SuppressWarnings("rawtypes")
PlatformWindow pWindow = ((LWComponentPeer) peer).getPlatformWindow();
if (pWindow instanceof CPlatformWindow) {
((CPlatformWindow) pWindow).execute(new CFRetainedResource.CFNativeAction() {
@Override
public void run(long l) {
result[0] = l;
}
});
break;
}
}
comp = comp.getParent();
}
return result[0];
}
}