author | serb |
Tue, 01 Oct 2019 10:28:12 -0700 | |
changeset 58597 | 4ff14948c6a1 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
15983 | 1 |
/* |
37694
c064aefc5a2f
8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents:
30924
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
15983 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.lwawt.macosx; |
|
27 |
||
28 |
import java.awt.Font; |
|
29 |
import java.awt.FontMetrics; |
|
30 |
import java.awt.GraphicsDevice; |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
31 |
import java.awt.GraphicsEnvironment; |
15983 | 32 |
import java.awt.Insets; |
33 |
import java.awt.MenuBar; |
|
34 |
import java.awt.Point; |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
35 |
import java.awt.Rectangle; |
15983 | 36 |
import java.awt.Window; |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
37 |
import sun.awt.CGraphicsDevice; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
38 |
import sun.awt.CGraphicsEnvironment; |
37694
c064aefc5a2f
8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents:
30924
diff
changeset
|
39 |
import java.awt.event.FocusEvent; |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
40 |
import sun.awt.LightweightFrame; |
15983 | 41 |
import sun.java2d.SurfaceData; |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
42 |
import sun.lwawt.LWLightweightFramePeer; |
15983 | 43 |
import sun.lwawt.LWWindowPeer; |
44 |
import sun.lwawt.PlatformWindow; |
|
45 |
||
46 |
public class CPlatformLWWindow extends CPlatformWindow { |
|
47 |
||
48 |
@Override |
|
49 |
public void initialize(Window target, LWWindowPeer peer, PlatformWindow owner) { |
|
50 |
initializeBase(target, peer, owner, new CPlatformLWView()); |
|
51 |
} |
|
52 |
||
53 |
@Override |
|
54 |
public void toggleFullScreen() { |
|
55 |
} |
|
56 |
||
57 |
@Override |
|
58 |
public void setMenuBar(MenuBar mb) { |
|
59 |
} |
|
60 |
||
61 |
@Override |
|
62 |
public void dispose() { |
|
63 |
} |
|
64 |
||
65 |
@Override |
|
66 |
public FontMetrics getFontMetrics(Font f) { |
|
67 |
return null; |
|
68 |
} |
|
69 |
||
70 |
@Override |
|
71 |
public Insets getInsets() { |
|
72 |
return new Insets(0, 0, 0, 0); |
|
73 |
} |
|
74 |
||
75 |
@Override |
|
76 |
public Point getLocationOnScreen() { |
|
77 |
return null; |
|
78 |
} |
|
79 |
||
80 |
@Override |
|
81 |
public SurfaceData getScreenSurface() { |
|
82 |
return null; |
|
83 |
} |
|
84 |
||
85 |
@Override |
|
86 |
public SurfaceData replaceSurfaceData() { |
|
87 |
return null; |
|
88 |
} |
|
89 |
||
90 |
@Override |
|
91 |
public void setBounds(int x, int y, int w, int h) { |
|
92 |
if (getPeer() != null) { |
|
93 |
getPeer().notifyReshape(x, y, w, h); |
|
94 |
} |
|
95 |
} |
|
96 |
||
97 |
@Override |
|
98 |
public void setVisible(boolean visible) { |
|
99 |
} |
|
100 |
||
101 |
@Override |
|
102 |
public void setTitle(String title) { |
|
103 |
} |
|
104 |
||
105 |
@Override |
|
106 |
public void updateIconImages() { |
|
107 |
} |
|
108 |
||
109 |
@Override |
|
110 |
public SurfaceData getSurfaceData() { |
|
111 |
return null; |
|
112 |
} |
|
113 |
||
114 |
@Override |
|
115 |
public void toBack() { |
|
116 |
} |
|
117 |
||
118 |
@Override |
|
119 |
public void toFront() { |
|
120 |
} |
|
121 |
||
122 |
@Override |
|
123 |
public void setResizable(final boolean resizable) { |
|
124 |
} |
|
125 |
||
126 |
@Override |
|
127 |
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) { |
|
128 |
} |
|
129 |
||
130 |
@Override |
|
37694
c064aefc5a2f
8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents:
30924
diff
changeset
|
131 |
public boolean rejectFocusRequest(FocusEvent.Cause cause) { |
15983 | 132 |
return false; |
133 |
} |
|
134 |
||
135 |
@Override |
|
136 |
public boolean requestWindowFocus() { |
|
137 |
return true; |
|
138 |
} |
|
139 |
||
140 |
@Override |
|
141 |
public boolean isActive() { |
|
142 |
return true; |
|
143 |
} |
|
144 |
||
145 |
@Override |
|
146 |
public void updateFocusableWindowState() { |
|
147 |
} |
|
148 |
||
149 |
@Override |
|
150 |
public void setAlwaysOnTop(boolean isAlwaysOnTop) { |
|
151 |
} |
|
152 |
||
153 |
@Override |
|
154 |
public void setOpacity(float opacity) { |
|
155 |
} |
|
156 |
||
157 |
@Override |
|
158 |
public void setOpaque(boolean isOpaque) { |
|
159 |
} |
|
160 |
||
161 |
@Override |
|
162 |
public void enterFullScreenMode() { |
|
163 |
} |
|
164 |
||
165 |
@Override |
|
166 |
public void exitFullScreenMode() { |
|
167 |
} |
|
168 |
||
169 |
@Override |
|
170 |
public void setWindowState(int windowState) { |
|
171 |
} |
|
172 |
||
173 |
@Override |
|
174 |
public LWWindowPeer getPeer() { |
|
175 |
return super.getPeer(); |
|
176 |
} |
|
177 |
||
178 |
@Override |
|
179 |
public CPlatformView getContentView() { |
|
180 |
return super.getContentView(); |
|
181 |
} |
|
182 |
||
183 |
@Override |
|
184 |
public long getLayerPtr() { |
|
185 |
return 0; |
|
186 |
} |
|
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
187 |
|
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
188 |
@Override |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
189 |
public GraphicsDevice getGraphicsDevice() { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
190 |
CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment. |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
191 |
getLocalGraphicsEnvironment(); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
192 |
|
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
193 |
LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer(); |
42199
8c0e8e13d4d8
8153522: Update JLightweightFrame to allow non-integer (and X/Y) scales
ssadetsky
parents:
37700
diff
changeset
|
194 |
int scale =(int) Math.round(((LightweightFrame)peer.getTarget()) |
8c0e8e13d4d8
8153522: Update JLightweightFrame to allow non-integer (and X/Y) scales
ssadetsky
parents:
37700
diff
changeset
|
195 |
.getScaleFactorX()); |
25195
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
196 |
|
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
197 |
Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds(); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
198 |
for (GraphicsDevice d : ge.getScreenDevices()) { |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
199 |
if (d.getDefaultConfiguration().getBounds().intersects(bounds) && |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
200 |
((CGraphicsDevice)d).getScaleFactor() == scale) |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
201 |
{ |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
202 |
return d; |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
203 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
204 |
} |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
205 |
// We shouldn't be here... |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
206 |
return ge.getDefaultScreenDevice(); |
9de77f5b0df2
8029455: [JLightweightFrame] support scaled painting
serb
parents:
15983
diff
changeset
|
207 |
} |
15983 | 208 |
} |