1 /* 2 * Copyright (c) 1996, 2018, 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.peer.TaskbarPeer; 29 import java.awt.*; 30 import java.awt.im.InputMethodHighlight; 31 import java.awt.im.spi.InputMethodDescriptor; 32 import java.awt.image.*; 33 import java.awt.peer.*; 34 import java.awt.event.FocusEvent; 35 import java.awt.event.KeyEvent; 36 import java.awt.event.MouseEvent; 37 import java.awt.datatransfer.Clipboard; 38 import java.awt.TextComponent; 39 import java.awt.TrayIcon; 40 import java.beans.PropertyChangeListener; 41 import java.lang.ref.WeakReference; 42 import java.security.AccessController; 43 import java.security.PrivilegedAction; 44 import javax.swing.text.JTextComponent; 45 46 import sun.awt.AWTAccessor; 47 import sun.awt.AppContext; 48 import sun.awt.AWTAutoShutdown; 49 import sun.awt.AWTPermissions; 50 import sun.awt.AppContext; 51 import sun.awt.DisplayChangedListener; 52 import sun.awt.LightweightFrame; 53 import sun.awt.SunToolkit; 54 import sun.awt.util.ThreadGroupUtils; 55 import sun.awt.Win32GraphicsDevice; 56 import sun.awt.Win32GraphicsEnvironment; 57 import sun.awt.datatransfer.DataTransferer; 58 import sun.java2d.d3d.D3DRenderQueue; 59 import sun.java2d.opengl.OGLRenderQueue; 60 61 import sun.print.PrintJob2D; 62 63 import java.awt.dnd.DragSource; 64 import java.awt.dnd.DragGestureListener; 65 import java.awt.dnd.DragGestureEvent; 66 import java.awt.dnd.DragGestureRecognizer; 67 import java.awt.dnd.MouseDragGestureRecognizer; 68 import java.awt.dnd.InvalidDnDOperationException; 69 import java.awt.dnd.peer.DragSourceContextPeer; 70 71 import java.util.Hashtable; 72 import java.util.Locale; 73 import java.util.Map; 74 import java.util.Properties; 75 import java.util.concurrent.ExecutorService; 76 import java.util.concurrent.Executors; 77 78 import sun.awt.util.PerformanceLogger; 79 import sun.font.FontManager; 80 import sun.font.FontManagerFactory; 81 import sun.font.SunFontManager; 82 import sun.util.logging.PlatformLogger; 83 84 public final class WToolkit extends SunToolkit implements Runnable { 85 86 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit"); 87 88 // Desktop property which specifies whether XP visual styles are in effect 89 public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive"; 90 91 // System clipboard. 92 WClipboard clipboard; 93 94 // cache of font peers 95 private Hashtable<String,FontPeer> cacheFontPeer; 96 97 // Windows properties 98 private WDesktopProperties wprops; 99 100 // Dynamic Layout Resize client code setting 101 protected boolean dynamicLayoutSetting = false; 116 @Override 117 public Void run() { 118 System.loadLibrary("awt"); 119 return null; 120 } 121 }); 122 loaded = true; 123 } 124 } 125 126 private static native String getWindowsVersion(); 127 128 static { 129 loadLibraries(); 130 initIDs(); 131 132 // Print out which version of Windows is running 133 if (log.isLoggable(PlatformLogger.Level.FINE)) { 134 log.fine("Win version: " + getWindowsVersion()); 135 } 136 137 AccessController.doPrivileged( 138 new PrivilegedAction <Void> () 139 { 140 @Override 141 public Void run() { 142 String browserProp = System.getProperty("browser"); 143 if (browserProp != null && browserProp.equals("sun.plugin")) { 144 disableCustomPalette(); 145 } 146 return null; 147 } 148 }); 149 } 150 151 private static native void disableCustomPalette(); 152 153 /* 154 * NOTE: The following embedded*() methods are non-public API intended 155 * for internal use only. The methods are unsupported and could go 156 * away in future releases. 157 * 158 * New hook functions for using the AWT as an embedded service. These 159 * functions replace the global C function AwtInit() which was previously 160 * exported by awt.dll. 161 * 162 * When used as an embedded service, the AWT does NOT have its own 163 * message pump. It instead relies on the parent application to provide 164 * this functionality. embeddedInit() assumes that the thread on which it 165 * is called is the message pumping thread. Violating this assumption 166 * will lead to undefined behavior. 167 * 168 * embeddedInit must be called before the WToolkit() constructor. 169 * embeddedDispose should be called before the applicaton terminates the 170 * Java VM. It is currently unsafe to reinitialize the toolkit again 171 * after it has been disposed. Instead, awt.dll must be reloaded and the | 1 /* 2 * Copyright (c) 1996, 2020, 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.AWTEvent; 29 import java.awt.AWTException; 30 import java.awt.Button; 31 import java.awt.Canvas; 32 import java.awt.Checkbox; 33 import java.awt.CheckboxMenuItem; 34 import java.awt.Choice; 35 import java.awt.Component; 36 import java.awt.Cursor; 37 import java.awt.Desktop; 38 import java.awt.Dialog; 39 import java.awt.Dimension; 40 import java.awt.EventQueue; 41 import java.awt.FileDialog; 42 import java.awt.Font; 43 import java.awt.FontMetrics; 44 import java.awt.Frame; 45 import java.awt.GraphicsConfiguration; 46 import java.awt.GraphicsDevice; 47 import java.awt.GraphicsEnvironment; 48 import java.awt.HeadlessException; 49 import java.awt.Image; 50 import java.awt.Insets; 51 import java.awt.JobAttributes; 52 import java.awt.Label; 53 import java.awt.List; 54 import java.awt.Menu; 55 import java.awt.MenuBar; 56 import java.awt.MenuItem; 57 import java.awt.PageAttributes; 58 import java.awt.Panel; 59 import java.awt.Point; 60 import java.awt.PopupMenu; 61 import java.awt.PrintJob; 62 import java.awt.RenderingHints; 63 import java.awt.Robot; 64 import java.awt.ScrollPane; 65 import java.awt.Scrollbar; 66 import java.awt.SystemTray; 67 import java.awt.Taskbar; 68 import java.awt.TextArea; 69 import java.awt.TextComponent; 70 import java.awt.TextField; 71 import java.awt.Toolkit; 72 import java.awt.TrayIcon; 73 import java.awt.Window; 74 import java.awt.datatransfer.Clipboard; 75 import java.awt.dnd.DragGestureEvent; 76 import java.awt.dnd.DragGestureListener; 77 import java.awt.dnd.DragGestureRecognizer; 78 import java.awt.dnd.DragSource; 79 import java.awt.dnd.InvalidDnDOperationException; 80 import java.awt.dnd.MouseDragGestureRecognizer; 81 import java.awt.dnd.peer.DragSourceContextPeer; 82 import java.awt.event.FocusEvent; 83 import java.awt.event.KeyEvent; 84 import java.awt.event.MouseEvent; 85 import java.awt.im.InputMethodHighlight; 86 import java.awt.im.spi.InputMethodDescriptor; 87 import java.awt.image.ColorModel; 88 import java.awt.peer.ButtonPeer; 89 import java.awt.peer.CanvasPeer; 90 import java.awt.peer.CheckboxMenuItemPeer; 91 import java.awt.peer.CheckboxPeer; 92 import java.awt.peer.ChoicePeer; 93 import java.awt.peer.DesktopPeer; 94 import java.awt.peer.DialogPeer; 95 import java.awt.peer.FileDialogPeer; 96 import java.awt.peer.FontPeer; 97 import java.awt.peer.FramePeer; 98 import java.awt.peer.KeyboardFocusManagerPeer; 99 import java.awt.peer.LabelPeer; 100 import java.awt.peer.ListPeer; 101 import java.awt.peer.MenuBarPeer; 102 import java.awt.peer.MenuItemPeer; 103 import java.awt.peer.MenuPeer; 104 import java.awt.peer.MouseInfoPeer; 105 import java.awt.peer.PanelPeer; 106 import java.awt.peer.PopupMenuPeer; 107 import java.awt.peer.RobotPeer; 108 import java.awt.peer.ScrollPanePeer; 109 import java.awt.peer.ScrollbarPeer; 110 import java.awt.peer.SystemTrayPeer; 111 import java.awt.peer.TaskbarPeer; 112 import java.awt.peer.TextAreaPeer; 113 import java.awt.peer.TextFieldPeer; 114 import java.awt.peer.TrayIconPeer; 115 import java.awt.peer.WindowPeer; 116 import java.beans.PropertyChangeListener; 117 import java.lang.ref.WeakReference; 118 import java.security.AccessController; 119 import java.security.PrivilegedAction; 120 import java.util.Hashtable; 121 import java.util.Locale; 122 import java.util.Map; 123 import java.util.Properties; 124 import java.util.concurrent.ExecutorService; 125 import java.util.concurrent.Executors; 126 127 import javax.swing.text.JTextComponent; 128 129 import sun.awt.AWTAccessor; 130 import sun.awt.AWTAutoShutdown; 131 import sun.awt.AWTPermissions; 132 import sun.awt.AppContext; 133 import sun.awt.DisplayChangedListener; 134 import sun.awt.LightweightFrame; 135 import sun.awt.SunToolkit; 136 import sun.awt.Win32GraphicsDevice; 137 import sun.awt.Win32GraphicsEnvironment; 138 import sun.awt.datatransfer.DataTransferer; 139 import sun.awt.util.PerformanceLogger; 140 import sun.awt.util.ThreadGroupUtils; 141 import sun.font.FontManager; 142 import sun.font.FontManagerFactory; 143 import sun.font.SunFontManager; 144 import sun.java2d.d3d.D3DRenderQueue; 145 import sun.java2d.opengl.OGLRenderQueue; 146 import sun.print.PrintJob2D; 147 import sun.util.logging.PlatformLogger; 148 149 public final class WToolkit extends SunToolkit implements Runnable { 150 151 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit"); 152 153 // Desktop property which specifies whether XP visual styles are in effect 154 public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive"; 155 156 // System clipboard. 157 WClipboard clipboard; 158 159 // cache of font peers 160 private Hashtable<String,FontPeer> cacheFontPeer; 161 162 // Windows properties 163 private WDesktopProperties wprops; 164 165 // Dynamic Layout Resize client code setting 166 protected boolean dynamicLayoutSetting = false; 181 @Override 182 public Void run() { 183 System.loadLibrary("awt"); 184 return null; 185 } 186 }); 187 loaded = true; 188 } 189 } 190 191 private static native String getWindowsVersion(); 192 193 static { 194 loadLibraries(); 195 initIDs(); 196 197 // Print out which version of Windows is running 198 if (log.isLoggable(PlatformLogger.Level.FINE)) { 199 log.fine("Win version: " + getWindowsVersion()); 200 } 201 } 202 203 /* 204 * NOTE: The following embedded*() methods are non-public API intended 205 * for internal use only. The methods are unsupported and could go 206 * away in future releases. 207 * 208 * New hook functions for using the AWT as an embedded service. These 209 * functions replace the global C function AwtInit() which was previously 210 * exported by awt.dll. 211 * 212 * When used as an embedded service, the AWT does NOT have its own 213 * message pump. It instead relies on the parent application to provide 214 * this functionality. embeddedInit() assumes that the thread on which it 215 * is called is the message pumping thread. Violating this assumption 216 * will lead to undefined behavior. 217 * 218 * embeddedInit must be called before the WToolkit() constructor. 219 * embeddedDispose should be called before the applicaton terminates the 220 * Java VM. It is currently unsafe to reinitialize the toolkit again 221 * after it has been disposed. Instead, awt.dll must be reloaded and the |