author | darcy |
Thu, 13 Mar 2014 12:40:27 -0700 | |
changeset 23647 | 41d22f2dbeb5 |
parent 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
21270
diff
changeset
|
2 |
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
package sun.awt.X11; |
|
26 |
||
27 |
import java.awt.*; |
|
28 |
import java.awt.peer.*; |
|
29 |
||
30 |
import sun.awt.SunToolkit; |
|
31 |
||
32 |
import sun.awt.X11GraphicsConfig; |
|
33 |
import sun.awt.X11GraphicsDevice; |
|
34 |
||
35 |
class XCanvasPeer extends XComponentPeer implements CanvasPeer { |
|
36 |
||
37 |
private boolean eraseBackgroundDisabled; |
|
38 |
||
39 |
XCanvasPeer() {} |
|
40 |
||
41 |
XCanvasPeer(XCreateWindowParams params) { |
|
42 |
super(params); |
|
43 |
} |
|
44 |
||
45 |
XCanvasPeer(Component target) { |
|
46 |
super(target); |
|
47 |
} |
|
48 |
||
49 |
void preInit(XCreateWindowParams params) { |
|
50 |
super.preInit(params); |
|
51 |
if (SunToolkit.getSunAwtNoerasebackground()) { |
|
52 |
disableBackgroundErase(); |
|
53 |
} |
|
54 |
} |
|
55 |
||
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
56 |
/* Get a GraphicsConfig with the same visual on the new |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
57 |
* screen, which should be easy in Xinerama mode. |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
58 |
*/ |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
59 |
public GraphicsConfiguration getAppropriateGraphicsConfiguration( |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
60 |
GraphicsConfiguration gc) |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
61 |
{ |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
62 |
if (graphicsConfig == null || gc == null) { |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
63 |
return gc; |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
64 |
} |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
65 |
// Opt: Only need to do if we're not using the default GC |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
66 |
|
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
67 |
int screenNum = ((X11GraphicsDevice)gc.getDevice()).getScreen(); |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
68 |
|
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
69 |
X11GraphicsConfig parentgc; |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
70 |
// save vis id of current gc |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
71 |
int visual = graphicsConfig.getVisual(); |
2 | 72 |
|
2459
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
73 |
X11GraphicsDevice newDev = (X11GraphicsDevice) GraphicsEnvironment. |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
74 |
getLocalGraphicsEnvironment(). |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
75 |
getScreenDevices()[screenNum]; |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
76 |
|
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
77 |
for (int i = 0; i < newDev.getNumConfigs(screenNum); i++) { |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
78 |
if (visual == newDev.getConfigVisualId(i, screenNum)) { |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
79 |
// use that |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
80 |
graphicsConfig = (X11GraphicsConfig)newDev.getConfigurations()[i]; |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
81 |
break; |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
82 |
} |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
83 |
} |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
84 |
// just in case... |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
85 |
if (graphicsConfig == null) { |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
86 |
graphicsConfig = (X11GraphicsConfig) GraphicsEnvironment. |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
87 |
getLocalGraphicsEnvironment(). |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
88 |
getScreenDevices()[screenNum]. |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
89 |
getDefaultConfiguration(); |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
90 |
} |
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
91 |
|
08f3416ff334
6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents:
2
diff
changeset
|
92 |
return graphicsConfig; |
2 | 93 |
} |
94 |
||
95 |
protected boolean shouldFocusOnClick() { |
|
96 |
// Canvas should always be able to be focused by mouse clicks. |
|
97 |
return true; |
|
98 |
} |
|
99 |
||
100 |
public void disableBackgroundErase() { |
|
101 |
eraseBackgroundDisabled = true; |
|
102 |
} |
|
103 |
protected boolean doEraseBackground() { |
|
104 |
return !eraseBackgroundDisabled; |
|
105 |
} |
|
106 |
} |