1 /*
2 * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
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.awt.windows;
27
28 import java.awt.*;
29 import java.awt.im.InputMethodHighlight;
30 import java.awt.im.spi.InputMethodDescriptor;
31 import java.awt.image.*;
32 import java.awt.peer.*;
33 import java.awt.event.KeyEvent;
34 import java.awt.datatransfer.Clipboard;
35 import java.awt.TrayIcon;
36 import java.beans.PropertyChangeListener;
37 import java.security.AccessController;
38 import java.security.PrivilegedAction;
39 import sun.awt.AppContext;
40 import sun.awt.AWTAutoShutdown;
41 import sun.awt.AWTPermissions;
42 import sun.awt.AppContext;
43 import sun.awt.LightweightFrame;
44 import sun.awt.SunToolkit;
45 import sun.awt.util.ThreadGroupUtils;
46 import sun.awt.Win32GraphicsDevice;
47 import sun.awt.Win32GraphicsEnvironment;
48 import sun.awt.datatransfer.DataTransferer;
49 import sun.java2d.d3d.D3DRenderQueue;
50 import sun.java2d.opengl.OGLRenderQueue;
51
52 import sun.print.PrintJob2D;
53
54 import java.awt.dnd.DragSource;
55 import java.awt.dnd.DragGestureListener;
56 import java.awt.dnd.DragGestureEvent;
57 import java.awt.dnd.DragGestureRecognizer;
58 import java.awt.dnd.MouseDragGestureRecognizer;
409 FramePeer peer = new WFramePeer(target);
410 targetCreatedPeer(target, peer);
411 return peer;
412 }
413
414 @Override
415 public FramePeer createLightweightFrame(LightweightFrame target) {
416 FramePeer peer = new WLightweightFramePeer(target);
417 targetCreatedPeer(target, peer);
418 return peer;
419 }
420
421 @Override
422 public CanvasPeer createCanvas(Canvas target) {
423 CanvasPeer peer = new WCanvasPeer(target);
424 targetCreatedPeer(target, peer);
425 return peer;
426 }
427
428 @Override
429 @SuppressWarnings("deprecation")
430 public void disableBackgroundErase(Canvas canvas) {
431 WCanvasPeer peer = (WCanvasPeer)canvas.getPeer();
432 if (peer == null) {
433 throw new IllegalStateException("Canvas must have a valid peer");
434 }
435 peer.disableBackgroundErase();
436 }
437
438 @Override
439 public PanelPeer createPanel(Panel target) {
440 PanelPeer peer = new WPanelPeer(target);
441 targetCreatedPeer(target, peer);
442 return peer;
443 }
444
445 @Override
446 public WindowPeer createWindow(Window target) {
447 WindowPeer peer = new WWindowPeer(target);
448 targetCreatedPeer(target, peer);
449 return peer;
450 }
451
1071 * paint manager to redirect rendering to the screen for some operations
1072 * (like copyArea), and since bpw uses its own BufferStrategy the
1073 * d3d onscreen rendering support is disabled and rendering goes through
1074 * GDI. This doesn't work well with Vista's DWM since one
1075 * can not perform GDI and D3D operations on the same surface
1076 * (see 6630702 for more info)
1077 *
1078 * Note: even though DWM composition state can change during the lifetime
1079 * of the application it is a rare event, and it is more often that it
1080 * is temporarily disabled (because of some app) than it is getting
1081 * permanently enabled so we can live with this approach without the
1082 * complexity of dwm state listeners and such. This can be revisited if
1083 * proved otherwise.
1084 */
1085 @Override
1086 public boolean useBufferPerWindow() {
1087 return !Win32GraphicsEnvironment.isDWMCompositionEnabled();
1088 }
1089
1090 @Override
1091 @SuppressWarnings("deprecation")
1092 public void grab(Window w) {
1093 if (w.getPeer() != null) {
1094 ((WWindowPeer)w.getPeer()).grab();
1095 }
1096 }
1097
1098 @Override
1099 @SuppressWarnings("deprecation")
1100 public void ungrab(Window w) {
1101 if (w.getPeer() != null) {
1102 ((WWindowPeer)w.getPeer()).ungrab();
1103 }
1104 }
1105
1106 @Override
1107 public native boolean syncNativeQueue(final long timeout);
1108 @Override
1109 public boolean isDesktopSupported() {
1110 return true;
1111 }
1112
1113 @Override
1114 public DesktopPeer createDesktopPeer(Desktop target) {
1115 return new WDesktopPeer();
1116 }
1117
1118 private static native void setExtraMouseButtonsEnabledNative(boolean enable);
1119
1120 @Override
1121 public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
1122 return areExtraMouseButtonsEnabled;
|
1 /*
2 * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
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.awt.windows;
27
28 import java.awt.*;
29 import java.awt.im.InputMethodHighlight;
30 import java.awt.im.spi.InputMethodDescriptor;
31 import java.awt.image.*;
32 import java.awt.peer.*;
33 import java.awt.event.KeyEvent;
34 import java.awt.datatransfer.Clipboard;
35 import java.awt.TrayIcon;
36 import java.beans.PropertyChangeListener;
37 import java.security.AccessController;
38 import java.security.PrivilegedAction;
39
40 import sun.awt.AWTAccessor;
41 import sun.awt.AppContext;
42 import sun.awt.AWTAutoShutdown;
43 import sun.awt.AWTPermissions;
44 import sun.awt.AppContext;
45 import sun.awt.LightweightFrame;
46 import sun.awt.SunToolkit;
47 import sun.awt.util.ThreadGroupUtils;
48 import sun.awt.Win32GraphicsDevice;
49 import sun.awt.Win32GraphicsEnvironment;
50 import sun.awt.datatransfer.DataTransferer;
51 import sun.java2d.d3d.D3DRenderQueue;
52 import sun.java2d.opengl.OGLRenderQueue;
53
54 import sun.print.PrintJob2D;
55
56 import java.awt.dnd.DragSource;
57 import java.awt.dnd.DragGestureListener;
58 import java.awt.dnd.DragGestureEvent;
59 import java.awt.dnd.DragGestureRecognizer;
60 import java.awt.dnd.MouseDragGestureRecognizer;
411 FramePeer peer = new WFramePeer(target);
412 targetCreatedPeer(target, peer);
413 return peer;
414 }
415
416 @Override
417 public FramePeer createLightweightFrame(LightweightFrame target) {
418 FramePeer peer = new WLightweightFramePeer(target);
419 targetCreatedPeer(target, peer);
420 return peer;
421 }
422
423 @Override
424 public CanvasPeer createCanvas(Canvas target) {
425 CanvasPeer peer = new WCanvasPeer(target);
426 targetCreatedPeer(target, peer);
427 return peer;
428 }
429
430 @Override
431 public void disableBackgroundErase(Canvas canvas) {
432 WCanvasPeer peer = AWTAccessor.getComponentAccessor().getPeer(canvas);
433 if (peer == null) {
434 throw new IllegalStateException("Canvas must have a valid peer");
435 }
436 peer.disableBackgroundErase();
437 }
438
439 @Override
440 public PanelPeer createPanel(Panel target) {
441 PanelPeer peer = new WPanelPeer(target);
442 targetCreatedPeer(target, peer);
443 return peer;
444 }
445
446 @Override
447 public WindowPeer createWindow(Window target) {
448 WindowPeer peer = new WWindowPeer(target);
449 targetCreatedPeer(target, peer);
450 return peer;
451 }
452
1072 * paint manager to redirect rendering to the screen for some operations
1073 * (like copyArea), and since bpw uses its own BufferStrategy the
1074 * d3d onscreen rendering support is disabled and rendering goes through
1075 * GDI. This doesn't work well with Vista's DWM since one
1076 * can not perform GDI and D3D operations on the same surface
1077 * (see 6630702 for more info)
1078 *
1079 * Note: even though DWM composition state can change during the lifetime
1080 * of the application it is a rare event, and it is more often that it
1081 * is temporarily disabled (because of some app) than it is getting
1082 * permanently enabled so we can live with this approach without the
1083 * complexity of dwm state listeners and such. This can be revisited if
1084 * proved otherwise.
1085 */
1086 @Override
1087 public boolean useBufferPerWindow() {
1088 return !Win32GraphicsEnvironment.isDWMCompositionEnabled();
1089 }
1090
1091 @Override
1092 public void grab(Window w) {
1093 final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
1094 if (peer != null) {
1095 ((WWindowPeer) peer).grab();
1096 }
1097 }
1098
1099 @Override
1100 public void ungrab(Window w) {
1101 final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
1102 if (peer != null) {
1103 ((WWindowPeer) peer).ungrab();
1104 }
1105 }
1106
1107 @Override
1108 public native boolean syncNativeQueue(final long timeout);
1109 @Override
1110 public boolean isDesktopSupported() {
1111 return true;
1112 }
1113
1114 @Override
1115 public DesktopPeer createDesktopPeer(Desktop target) {
1116 return new WDesktopPeer();
1117 }
1118
1119 private static native void setExtraMouseButtonsEnabledNative(boolean enable);
1120
1121 @Override
1122 public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
1123 return areExtraMouseButtonsEnabled;
|