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
51 import sun.awt.Win32GraphicsDevice;
52 import sun.awt.Win32GraphicsEnvironment;
53 import sun.awt.datatransfer.DataTransferer;
54 import sun.java2d.d3d.D3DRenderQueue;
55 import sun.java2d.opengl.OGLRenderQueue;
56
57 import sun.print.PrintJob2D;
58
59 import java.awt.dnd.DragSource;
60 import java.awt.dnd.DragGestureListener;
61 import java.awt.dnd.DragGestureEvent;
62 import java.awt.dnd.DragGestureRecognizer;
63 import java.awt.dnd.MouseDragGestureRecognizer;
64 import java.awt.dnd.InvalidDnDOperationException;
65 import java.awt.dnd.peer.DragSourceContextPeer;
66
67 import java.util.Hashtable;
68 import java.util.Locale;
69 import java.util.Map;
70 import java.util.Properties;
71
72 import sun.font.FontManager;
73 import sun.font.FontManagerFactory;
74 import sun.font.SunFontManager;
75 import sun.misc.PerformanceLogger;
76 import sun.util.logging.PlatformLogger;
77 import sun.security.util.SecurityConstants;
78
79 public final class WToolkit extends SunToolkit implements Runnable {
80
81 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit");
82
83 // Desktop property which specifies whether XP visual styles are in effect
84 public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive";
85
86 static GraphicsConfiguration config;
87
88 // System clipboard.
89 WClipboard clipboard;
90
811 }
812
813 /**
814 * Returns the supported cursor size (Win32 only has one).
815 */
816 @Override
817 public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
818 return new Dimension(WCustomCursor.getCursorWidth(),
819 WCustomCursor.getCursorHeight());
820 }
821
822 @Override
823 public native int getMaximumCursorColors();
824
825 static void paletteChanged() {
826 ((Win32GraphicsEnvironment)GraphicsEnvironment
827 .getLocalGraphicsEnvironment())
828 .paletteChanged();
829 }
830
831 /*
832 * Called from Toolkit native code when a WM_DISPLAYCHANGE occurs.
833 * Have Win32GraphicsEnvironment execute the display change code on the
834 * Event thread.
835 */
836 static public void displayChanged() {
837 EventQueue.invokeLater(new Runnable() {
838 @Override
839 public void run() {
840 ((Win32GraphicsEnvironment)GraphicsEnvironment
841 .getLocalGraphicsEnvironment())
842 .displayChanged();
843 }
844 });
845 }
846
847 /**
848 * create the peer for a DragSourceContext
849 */
850
851 @Override
852 public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
853 final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
854 if (f != null) {
855 return f.createDragSourceContextPeer(dge);
856 }
857
858 return WDragSourceContextPeer.createDragSourceContextPeer(dge);
859 }
860
861 @Override
862 public <T extends DragGestureRecognizer> T
863 createDragGestureRecognizer(Class<T> abstractRecognizerClass,
864 DragSource ds, Component c, int srcActions,
865 DragGestureListener dgl)
|
1 /*
2 * Copyright (c) 1996, 2019, 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
51 import sun.awt.Win32GraphicsDevice;
52 import sun.awt.Win32GraphicsEnvironment;
53 import sun.awt.datatransfer.DataTransferer;
54 import sun.java2d.d3d.D3DRenderQueue;
55 import sun.java2d.opengl.OGLRenderQueue;
56
57 import sun.print.PrintJob2D;
58
59 import java.awt.dnd.DragSource;
60 import java.awt.dnd.DragGestureListener;
61 import java.awt.dnd.DragGestureEvent;
62 import java.awt.dnd.DragGestureRecognizer;
63 import java.awt.dnd.MouseDragGestureRecognizer;
64 import java.awt.dnd.InvalidDnDOperationException;
65 import java.awt.dnd.peer.DragSourceContextPeer;
66
67 import java.util.Hashtable;
68 import java.util.Locale;
69 import java.util.Map;
70 import java.util.Properties;
71 import java.util.concurrent.ExecutorService;
72 import java.util.concurrent.Executors;
73
74 import sun.font.FontManager;
75 import sun.font.FontManagerFactory;
76 import sun.font.SunFontManager;
77 import sun.misc.PerformanceLogger;
78 import sun.util.logging.PlatformLogger;
79 import sun.security.util.SecurityConstants;
80
81 public final class WToolkit extends SunToolkit implements Runnable {
82
83 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit");
84
85 // Desktop property which specifies whether XP visual styles are in effect
86 public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive";
87
88 static GraphicsConfiguration config;
89
90 // System clipboard.
91 WClipboard clipboard;
92
813 }
814
815 /**
816 * Returns the supported cursor size (Win32 only has one).
817 */
818 @Override
819 public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
820 return new Dimension(WCustomCursor.getCursorWidth(),
821 WCustomCursor.getCursorHeight());
822 }
823
824 @Override
825 public native int getMaximumCursorColors();
826
827 static void paletteChanged() {
828 ((Win32GraphicsEnvironment)GraphicsEnvironment
829 .getLocalGraphicsEnvironment())
830 .paletteChanged();
831 }
832
833 private static ExecutorService displayChangeExecutor;
834
835 /*
836 * Called from Toolkit native code when a WM_DISPLAYCHANGE occurs.
837 * Have Win32GraphicsEnvironment execute the display change code on the
838 * Event thread.
839 */
840 static public void displayChanged() {
841 final Runnable runnable = () -> {
842 Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
843 if (lge instanceof DisplayChangedListener) {
844 ((DisplayChangedListener) lge).displayChanged();
845 }
846 };
847 if (AppContext.getAppContext() != null) {
848 // Common case, standalone application
849 EventQueue.invokeLater(runnable);
850 } else {
851 if (displayChangeExecutor == null) {
852 // No synchronization, called on the Toolkit thread only
853 displayChangeExecutor = Executors.newFixedThreadPool(1, r -> {
854 Thread t = Executors.defaultThreadFactory().newThread(r);
855 t.setDaemon(true);
856 return t;
857 });
858 }
859 displayChangeExecutor.submit(runnable);
860 }
861 }
862
863 /**
864 * create the peer for a DragSourceContext
865 */
866
867 @Override
868 public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
869 final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
870 if (f != null) {
871 return f.createDragSourceContextPeer(dge);
872 }
873
874 return WDragSourceContextPeer.createDragSourceContextPeer(dge);
875 }
876
877 @Override
878 public <T extends DragGestureRecognizer> T
879 createDragGestureRecognizer(Class<T> abstractRecognizerClass,
880 DragSource ds, Component c, int srcActions,
881 DragGestureListener dgl)
|