提交 7c0d3617 编写于 作者: D dav

Merge

...@@ -153,7 +153,6 @@ FILES_cpp = \ ...@@ -153,7 +153,6 @@ FILES_cpp = \
awt_Menu.cpp \ awt_Menu.cpp \
awt_MenuBar.cpp \ awt_MenuBar.cpp \
awt_MenuItem.cpp \ awt_MenuItem.cpp \
awt_MMStub.cpp \
awt_MouseEvent.cpp \ awt_MouseEvent.cpp \
awt_Object.cpp \ awt_Object.cpp \
awt_Palette.cpp \ awt_Palette.cpp \
...@@ -171,7 +170,6 @@ FILES_cpp = \ ...@@ -171,7 +170,6 @@ FILES_cpp = \
awt_TextComponent.cpp \ awt_TextComponent.cpp \
awt_TextField.cpp \ awt_TextField.cpp \
awt_Toolkit.cpp \ awt_Toolkit.cpp \
awt_Unicode.cpp \
awt_Window.cpp \ awt_Window.cpp \
awt_Win32GraphicsEnv.cpp \ awt_Win32GraphicsEnv.cpp \
awt_Win32GraphicsDevice.cpp \ awt_Win32GraphicsDevice.cpp \
...@@ -202,6 +200,4 @@ FILES_cpp = \ ...@@ -202,6 +200,4 @@ FILES_cpp = \
ThemeReader.cpp \ ThemeReader.cpp \
ComCtl32Util.cpp \ ComCtl32Util.cpp \
initIDs.cpp \ initIDs.cpp \
awt_dlls.cpp \
UnicowsLoader.cpp \
MouseInfo.cpp MouseInfo.cpp
...@@ -251,8 +251,14 @@ endif # PLATFORM ...@@ -251,8 +251,14 @@ endif # PLATFORM
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WINDOWS # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WINDOWS
OTHER_LDLIBS = kernel32.lib user32.lib gdi32.lib winspool.lib \ OTHER_LDLIBS = kernel32.lib user32.lib gdi32.lib winspool.lib \
imm32.lib ole32.lib uuid.lib $(JVMLIB) \ imm32.lib ole32.lib uuid.lib shell32.lib \
shell32.lib comdlg32.lib winmm.lib comctl32.lib delayimp.lib \
$(JVMLIB) \
/DELAYLOAD:user32.dll /DELAYLOAD:gdi32.dll \
/DELAYLOAD:shell32.dll /DELAYLOAD:winmm.dll \
/DELAYLOAD:winspool.drv /DELAYLOAD:imm32.dll \
/DELAYLOAD:ole32.dll /DELAYLOAD:comdlg32.dll \
/DELAYLOAD:comctl32.dll
clean:: awt.clean clean:: awt.clean
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
$(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/UnicowsLoader.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_MMStub.h ../../../src/windows/native/sun/windows/awt_Multimon.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Unicode.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/stdhdrs.h $(OBJDIR)/jawt.obj:: $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_AWTEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Component.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Dimension.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Event.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_Font.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_PlatformFont.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/../../awt/CClassHeaders/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jawt_md.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_DrawingSurface.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/stdhdrs.h
...@@ -67,7 +67,7 @@ ifneq ($(PLATFORM), windows) ...@@ -67,7 +67,7 @@ ifneq ($(PLATFORM), windows)
OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpthread OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpthread
else # PLATFORM else # PLATFORM
CFLAGS += -DWITH_WIN32 CFLAGS += -DWITH_WIN32
OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib /DELAYLOAD:user32.dll
#$(JVMLIB) $(OBJDIR)/../../jpeg/$(OBJDIRNAME)/jpeg$(SUFFIX).lib #$(JVMLIB) $(OBJDIR)/../../jpeg/$(OBJDIRNAME)/jpeg$(SUFFIX).lib
endif # PLATFORM endif # PLATFORM
......
/* /*
* Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -203,16 +203,18 @@ public class SystemTray { ...@@ -203,16 +203,18 @@ public class SystemTray {
* functionality is supported for the current platform * functionality is supported for the current platform
*/ */
public static boolean isSupported() { public static boolean isSupported() {
initializeSystemTrayIfNeeded();
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof SunToolkit) { if (toolkit instanceof SunToolkit) {
// connecting tray to native resource
initializeSystemTrayIfNeeded();
return ((SunToolkit)toolkit).isTraySupported(); return ((SunToolkit)toolkit).isTraySupported();
} else if (toolkit instanceof HeadlessToolkit) { } else if (toolkit instanceof HeadlessToolkit) {
// skip initialization as the init routine
// throws HeadlessException
return ((HeadlessToolkit)toolkit).isTraySupported(); return ((HeadlessToolkit)toolkit).isTraySupported();
} else {
return false;
} }
return false;
} }
/** /**
...@@ -476,7 +478,12 @@ public class SystemTray { ...@@ -476,7 +478,12 @@ public class SystemTray {
synchronized void addNotify() { synchronized void addNotify() {
if (peer == null) { if (peer == null) {
peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createSystemTray(this); Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof SunToolkit) {
peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createSystemTray(this);
} else if (toolkit instanceof HeadlessToolkit) {
peer = ((HeadlessToolkit)Toolkit.getDefaultToolkit()).createSystemTray(this);
}
} }
} }
......
/* /*
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -38,6 +38,7 @@ import java.util.EventListener; ...@@ -38,6 +38,7 @@ import java.util.EventListener;
import java.awt.peer.TrayIconPeer; import java.awt.peer.TrayIconPeer;
import sun.awt.AppContext; import sun.awt.AppContext;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import sun.awt.HeadlessToolkit;
import java.util.EventObject; import java.util.EventObject;
/** /**
...@@ -659,7 +660,12 @@ public class TrayIcon { ...@@ -659,7 +660,12 @@ public class TrayIcon {
{ {
synchronized (this) { synchronized (this) {
if (peer == null) { if (peer == null) {
peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createTrayIcon(this); Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof SunToolkit) {
peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createTrayIcon(this);
} else if (toolkit instanceof HeadlessToolkit) {
peer = ((HeadlessToolkit)Toolkit.getDefaultToolkit()).createTrayIcon(this);
}
} }
} }
peer.setToolTip(tooltip); peer.setToolTip(tooltip);
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
package javax.swing; package javax.swing;
import java.awt.*; import java.awt.*;
import sun.awt.ModalExclude; import sun.awt.ModalExclude;
import sun.awt.SunToolkit;
/** /**
* Popups are used to display a <code>Component</code> to the user, typically * Popups are used to display a <code>Component</code> to the user, typically
...@@ -225,7 +227,12 @@ public class Popup { ...@@ -225,7 +227,12 @@ public class Popup {
HeavyWeightWindow(Window parent) { HeavyWeightWindow(Window parent) {
super(parent); super(parent);
setFocusableWindowState(false); setFocusableWindowState(false);
setName("###overrideRedirect###"); Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
// all the short-lived windows like Popups should be
// OverrideRedirect on X11 platforms
((SunToolkit)tk).setOverrideRedirect(this);
}
// Popups are typically transient and most likely won't benefit // Popups are typically transient and most likely won't benefit
// from true double buffering. Turn it off here. // from true double buffering. Turn it off here.
getRootPane().setUseTrueDoubleBuffering(false); getRootPane().setUseTrueDoubleBuffering(false);
......
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -852,6 +852,15 @@ public abstract class SunToolkit extends Toolkit ...@@ -852,6 +852,15 @@ public abstract class SunToolkit extends Toolkit
return AccessController.doPrivileged(new GetBooleanAction("sun.awt.erasebackgroundonresize")); return AccessController.doPrivileged(new GetBooleanAction("sun.awt.erasebackgroundonresize"));
} }
/**
* Makes the window OverrideRedirect, on X11 platforms. See
* ICCCM specification for more details about OverrideRedirect
* windows. Implemented in XToolkit, no-op in WToolkit.
*/
public void setOverrideRedirect(Window target) {
}
static SoftCache imgCache = new SoftCache(); static SoftCache imgCache = new SoftCache();
static synchronized Image getImageFromHash(Toolkit tk, URL url) { static synchronized Image getImageFromHash(Toolkit tk, URL url) {
......
...@@ -97,6 +97,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -97,6 +97,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
static int awt_multiclick_time; static int awt_multiclick_time;
static boolean securityWarningEnabled; static boolean securityWarningEnabled;
// WeakSet should be used here, but there is no such class
// in JDK (at least in JDK6 and earlier versions)
private WeakHashMap<Window, Boolean> overrideRedirectWindows =
new WeakHashMap<Window, Boolean>();
private static int screenWidth = -1, screenHeight = -1; // Dimensions of default screen private static int screenWidth = -1, screenHeight = -1; // Dimensions of default screen
static long awt_defaultFg; // Pixel static long awt_defaultFg; // Pixel
private static XMouseInfoPeer xPeer; private static XMouseInfoPeer xPeer;
...@@ -1248,6 +1253,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -1248,6 +1253,19 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
} }
} }
@Override
public void setOverrideRedirect(Window target) {
synchronized (overrideRedirectWindows) {
overrideRedirectWindows.put(target, true);
}
}
public boolean isOverrideRedirect(Window target) {
synchronized (overrideRedirectWindows) {
return overrideRedirectWindows.containsKey(target);
}
}
static void dumpPeers() { static void dumpPeers() {
if (log.isLoggable(Level.FINE)) { if (log.isLoggable(Level.FINE)) {
log.fine("Mapped windows:"); log.fine("Mapped windows:");
......
...@@ -129,6 +129,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -129,6 +129,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
private static final int MAXIMUM_BUFFER_LENGTH_NET_WM_ICON = (2<<15) - 1; private static final int MAXIMUM_BUFFER_LENGTH_NET_WM_ICON = (2<<15) - 1;
void preInit(XCreateWindowParams params) { void preInit(XCreateWindowParams params) {
target = (Component)params.get(TARGET);
params.put(REPARENTED, params.put(REPARENTED,
Boolean.valueOf(isOverrideRedirect() || isSimpleWindow())); Boolean.valueOf(isOverrideRedirect() || isSimpleWindow()));
super.preInit(params); super.preInit(params);
...@@ -1117,6 +1118,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -1117,6 +1118,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
boolean isOverrideRedirect() { boolean isOverrideRedirect() {
return (XWM.getWMID() == XWM.OPENLOOK_WM ? true : false) || return (XWM.getWMID() == XWM.OPENLOOK_WM ? true : false) ||
((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target) ||
XTrayIconPeer.isTrayIconStuffWindow((Window)target); XTrayIconPeer.isTrayIconStuffWindow((Window)target);
} }
......
...@@ -68,13 +68,6 @@ public abstract class WComponentPeer extends WObjectPeer ...@@ -68,13 +68,6 @@ public abstract class WComponentPeer extends WObjectPeer
private static final Logger log = Logger.getLogger("sun.awt.windows.WComponentPeer"); private static final Logger log = Logger.getLogger("sun.awt.windows.WComponentPeer");
private static final Logger shapeLog = Logger.getLogger("sun.awt.windows.shape.WComponentPeer"); private static final Logger shapeLog = Logger.getLogger("sun.awt.windows.shape.WComponentPeer");
static {
wheelInit();
}
// Only actually does stuff if running on 95
native static void wheelInit();
// ComponentPeer implementation // ComponentPeer implementation
SurfaceData surfaceData; SurfaceData surfaceData;
......
...@@ -548,11 +548,15 @@ public class WInputMethod extends InputMethodAdapter ...@@ -548,11 +548,15 @@ public class WInputMethod extends InputMethodAdapter
public void inquireCandidatePosition() public void inquireCandidatePosition()
{ {
Component source = getClientComponent();
if (source == null) {
return;
}
// This call should return immediately just to cause // This call should return immediately just to cause
// InputMethodRequests.getTextLocation be called within // InputMethodRequests.getTextLocation be called within
// AWT Event thread. Otherwise, a potential deadlock // AWT Event thread. Otherwise, a potential deadlock
// could happen. // could happen.
java.awt.EventQueue.invokeLater(new Runnable() { Runnable r = new Runnable() {
public void run() { public void run() {
int x = 0; int x = 0;
int y = 0; int y = 0;
...@@ -573,7 +577,9 @@ public class WInputMethod extends InputMethodAdapter ...@@ -573,7 +577,9 @@ public class WInputMethod extends InputMethodAdapter
openCandidateWindow(awtFocussedComponentPeer, x, y); openCandidateWindow(awtFocussedComponentPeer, x, y);
} }
}); };
WToolkit.postEvent(WToolkit.targetToAppContext(source),
new InvocationEvent(source, r));
} }
// java.awt.Toolkit#getNativeContainer() is not available // java.awt.Toolkit#getNativeContainer() is not available
......
/* /*
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,24 +23,21 @@ ...@@ -23,24 +23,21 @@
* have any questions. * have any questions.
*/ */
// copy from awt.h
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#endif
// copy from awt.h
#ifndef _WIN32_IE
#define _WIN32_IE 0x0600
#endif
#include "splashscreen_impl.h" #include "splashscreen_impl.h"
#include <windowsx.h> #include <windowsx.h>
#include <windows.h> #include <windows.h>
#include <winuser.h> #include <winuser.h>
/* layered windows api prototypes. wouldn't be needed if we could use an updated version of the MS PSDK. */
typedef BOOL WINAPI UpdateLayeredWindowT(HWND hwnd, // handle to layered window
HDC hdcDst, // handle to screen DC
POINT * pptDst, // new screen position
SIZE * psize, // new size of the layered window
HDC hdcSrc, // handle to surface DC
POINT * pptSrc, // layer position
COLORREF crKey, // color key
BLENDFUNCTION * pblend, // blend function
DWORD dwFlags // options
);
#ifndef WS_EX_LAYERED #ifndef WS_EX_LAYERED
#define WS_EX_LAYERED 0x80000 #define WS_EX_LAYERED 0x80000
#endif #endif
...@@ -57,21 +54,6 @@ typedef BOOL WINAPI UpdateLayeredWindowT(HWND hwnd, // handle to layered win ...@@ -57,21 +54,6 @@ typedef BOOL WINAPI UpdateLayeredWindowT(HWND hwnd, // handle to layered win
#define AC_SRC_ALPHA 0x01 #define AC_SRC_ALPHA 0x01
#endif #endif
static UpdateLayeredWindowT *UpdateLayeredWindow = NULL;
/* Get/SetWindowLongPtr prototypes, for the case we're compiling with old headers for a 32-bit platform
copied from Component.cpp
FIXME: remove this as soon as the build process is using up-to-date headers */
#if !defined(__int3264)
#define GetWindowLongPtr GetWindowLong
#define SetWindowLongPtr SetWindowLong
#define GWLP_USERDATA GWL_USERDATA
#define GWLP_WNDPROC GWL_WNDPROC
typedef __int32 LONG_PTR;
typedef unsigned __int32 ULONG_PTR;
#endif // __int3264
#define WM_SPLASHUPDATE WM_USER+1 #define WM_SPLASHUPDATE WM_USER+1
#define WM_SPLASHRECONFIGURE WM_USER+2 #define WM_SPLASHRECONFIGURE WM_USER+2
...@@ -436,16 +418,11 @@ SplashUnlock(Splash * splash) ...@@ -436,16 +418,11 @@ SplashUnlock(Splash * splash)
void void
SplashInitPlatform(Splash * splash) SplashInitPlatform(Splash * splash)
{ {
HMODULE user32 = LoadLibrary("user32.dll");
HDC hdc; HDC hdc;
int paletteMode; int paletteMode;
InitializeCriticalSection(&splash->lock); InitializeCriticalSection(&splash->lock);
splash->isLayered = FALSE; splash->isLayered = FALSE;
if (user32) {
UpdateLayeredWindow = (UpdateLayeredWindowT *)
GetProcAddress(user32, "UpdateLayeredWindow");
}
hdc = GetDC(NULL); hdc = GetDC(NULL);
paletteMode = (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) != 0; paletteMode = (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) != 0;
if (UpdateLayeredWindow && !paletteMode) { if (UpdateLayeredWindow && !paletteMode) {
......
...@@ -184,7 +184,7 @@ void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter, ...@@ -184,7 +184,7 @@ void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter,
pMgr = D3DPipelineManager::GetInstance(); pMgr = D3DPipelineManager::GetInstance();
RETURN_IF_NULL(pMgr); RETURN_IF_NULL(pMgr);
hMon = pMgr->pd3d9->GetAdapterMonitor(adapter); hMon = pMgr->pd3d9->GetAdapterMonitor(adapter);
gdiScreen = AwtWin32GraphicsDevice::GetScreenFromMHND((MHND)hMon); gdiScreen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hMon);
JNU_CallStaticMethodByName(env, NULL, JNU_CallStaticMethodByName(env, NULL,
"sun/java2d/pipe/hw/AccelDeviceEventNotifier", "sun/java2d/pipe/hw/AccelDeviceEventNotifier",
...@@ -194,21 +194,21 @@ void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter, ...@@ -194,21 +194,21 @@ void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter,
UINT D3DPipelineManager::GetAdapterOrdinalForScreen(jint gdiScreen) UINT D3DPipelineManager::GetAdapterOrdinalForScreen(jint gdiScreen)
{ {
MHND mHnd = AwtWin32GraphicsDevice::GetMonitor(gdiScreen); HMONITOR mHnd = AwtWin32GraphicsDevice::GetMonitor(gdiScreen);
if (mHnd == (MHND)0) { if (mHnd == (HMONITOR)0) {
return D3DADAPTER_DEFAULT; return D3DADAPTER_DEFAULT;
} }
return GetAdapterOrdinalByHmon((HMONITOR)mHnd); return GetAdapterOrdinalByHmon((HMONITOR)mHnd);
} }
// static // static
HRESULT D3DPipelineManager::HandleAdaptersChange(HMONITOR *pMHNDs, UINT monNum) HRESULT D3DPipelineManager::HandleAdaptersChange(HMONITOR *pHMONITORs, UINT monNum)
{ {
HRESULT res = S_OK; HRESULT res = S_OK;
BOOL bResetD3D = FALSE, bFound; BOOL bResetD3D = FALSE, bFound;
D3DPipelineManager *pMgr = D3DPipelineManager::GetInstance(); D3DPipelineManager *pMgr = D3DPipelineManager::GetInstance();
RETURN_STATUS_IF_NULL(pMHNDs, E_FAIL); RETURN_STATUS_IF_NULL(pHMONITORs, E_FAIL);
if (pMgr == NULL) { if (pMgr == NULL) {
// NULL pMgr is valid when the pipeline is not enabled or if it hasn't // NULL pMgr is valid when the pipeline is not enabled or if it hasn't
// been created yet // been created yet
...@@ -234,7 +234,7 @@ HRESULT D3DPipelineManager::HandleAdaptersChange(HMONITOR *pMHNDs, UINT monNum) ...@@ -234,7 +234,7 @@ HRESULT D3DPipelineManager::HandleAdaptersChange(HMONITOR *pMHNDs, UINT monNum)
} }
bFound = FALSE; bFound = FALSE;
for (UINT mon = 0; mon < monNum; mon++) { for (UINT mon = 0; mon < monNum; mon++) {
if (pMHNDs[mon] == hMon) { if (pHMONITORs[mon] == hMon) {
J2dTraceLn3(J2D_TRACE_VERBOSE, J2dTraceLn3(J2D_TRACE_VERBOSE,
" adapter %d: found hmnd[%d]=0x%x", i, mon, hMon); " adapter %d: found hmnd[%d]=0x%x", i, mon, hMon);
bFound = TRUE; bFound = TRUE;
...@@ -364,8 +364,8 @@ D3DPipelineManager::CheckOSVersion() ...@@ -364,8 +364,8 @@ D3DPipelineManager::CheckOSVersion()
HRESULT HRESULT
D3DPipelineManager::GDICheckForBadHardware() D3DPipelineManager::GDICheckForBadHardware()
{ {
_DISPLAY_DEVICE dd; DISPLAY_DEVICE dd;
dd.dwSize = sizeof(DISPLAY_DEVICE); dd.cb = sizeof(DISPLAY_DEVICE);
int failedDevices = 0; int failedDevices = 0;
int attachedDevices = 0; int attachedDevices = 0;
...@@ -379,9 +379,9 @@ D3DPipelineManager::GDICheckForBadHardware() ...@@ -379,9 +379,9 @@ D3DPipelineManager::GDICheckForBadHardware()
// i<20 is to guard against buggy drivers // i<20 is to guard against buggy drivers
while (EnumDisplayDevices(NULL, i, &dd, 0) && i < 20) { while (EnumDisplayDevices(NULL, i, &dd, 0) && i < 20) {
if (dd.dwFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) { if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) {
attachedDevices++; attachedDevices++;
id = dd.deviceID; id = dd.DeviceID;
if (wcslen(id) > 21) { if (wcslen(id) > 21) {
// get vendor ID // get vendor ID
wcsncpy(vendorId, id+8, 4); wcsncpy(vendorId, id+8, 4);
...@@ -796,7 +796,7 @@ HWND D3DPipelineManager::CreateDefaultFocusWindow() ...@@ -796,7 +796,7 @@ HWND D3DPipelineManager::CreateDefaultFocusWindow()
ZeroMemory(&mi, sizeof(MONITORINFO)); ZeroMemory(&mi, sizeof(MONITORINFO));
mi.cbSize = sizeof(MONITORINFO); mi.cbSize = sizeof(MONITORINFO);
HMONITOR hMon = pd3d9->GetAdapterMonitor(adapterOrdinal); HMONITOR hMon = pd3d9->GetAdapterMonitor(adapterOrdinal);
if (hMon == 0 || !GetMonitorInfo(hMon, (PMONITOR_INFO)&mi)) { if (hMon == 0 || !GetMonitorInfo(hMon, (LPMONITORINFO)&mi)) {
J2dRlsTraceLn1(J2D_TRACE_ERROR, J2dRlsTraceLn1(J2D_TRACE_ERROR,
"D3DPPLM::CreateDefaultFocusWindow: "\ "D3DPPLM::CreateDefaultFocusWindow: "\
"error getting monitor info for adapter=%d", adapterOrdinal); "error getting monitor info for adapter=%d", adapterOrdinal);
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
* have any questions. * have any questions.
*/ */
#include "D3DPipeline.h"
#include <malloc.h> #include <malloc.h>
#include <jni.h>
#include "sun_java2d_pipe_BufferedOpCodes.h" #include "sun_java2d_pipe_BufferedOpCodes.h"
#include "jlong.h" #include "jlong.h"
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* have any questions. * have any questions.
*/ */
#include "D3DPipeline.h"
#include "sun_java2d_d3d_D3DRenderer.h" #include "sun_java2d_d3d_D3DRenderer.h"
#include "D3DContext.h" #include "D3DContext.h"
......
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
* have any questions. * have any questions.
*/ */
#include <jni.h> #include "D3DPipeline.h"
#include <jni_util.h>
#include <jlong.h> #include <jlong.h>
#include "D3DSurfaceData.h" #include "D3DSurfaceData.h"
#include "D3DPipelineManager.h" #include "D3DPipelineManager.h"
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include <sun_java2d_windows_GDIBlitLoops.h> #include <sun_java2d_windows_GDIBlitLoops.h>
#include "gdefs.h" #include "gdefs.h"
#include "Trace.h" #include "Trace.h"
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include "sun_java2d_windows_GDIRenderer.h" #include "sun_java2d_windows_GDIRenderer.h"
#include "java_awt_geom_PathIterator.h" #include "java_awt_geom_PathIterator.h"
...@@ -31,11 +32,8 @@ ...@@ -31,11 +32,8 @@
#include "awt_Pen.h" #include "awt_Pen.h"
#include "awt_Brush.h" #include "awt_Brush.h"
#include "jni.h"
#include "GraphicsPrimitiveMgr.h" #include "GraphicsPrimitiveMgr.h"
#include <windows.h>
#include <math.h> /* for cos(), sin(), etc */ #include <math.h> /* for cos(), sin(), etc */
#define MAX_CLAMP_BND (1<<26) #define MAX_CLAMP_BND (1<<26)
......
...@@ -246,7 +246,7 @@ static BOOL GDIWinSD_CheckMonitorArea(GDIWinSDOps *wsdo, ...@@ -246,7 +246,7 @@ static BOOL GDIWinSD_CheckMonitorArea(GDIWinSDOps *wsdo,
} }
if( numScreens > 1 ) { if( numScreens > 1 ) {
MONITOR_INFO *miInfo; LPMONITORINFO miInfo;
RECT rSect ={0,0,0,0}; RECT rSect ={0,0,0,0};
RECT rView ={bounds->x1, bounds->y1, bounds->x2, bounds->y2}; RECT rView ={bounds->x1, bounds->y1, bounds->x2, bounds->y2};
retCode = FALSE; retCode = FALSE;
...@@ -258,7 +258,7 @@ static BOOL GDIWinSD_CheckMonitorArea(GDIWinSDOps *wsdo, ...@@ -258,7 +258,7 @@ static BOOL GDIWinSD_CheckMonitorArea(GDIWinSDOps *wsdo,
::OffsetRect(&rView, ::OffsetRect(&rView,
(ptOrig.x), (ptOrig.y)); (ptOrig.x), (ptOrig.y));
::IntersectRect(&rSect,&rView,&(miInfo->rMonitor)); ::IntersectRect(&rSect,&rView,&(miInfo->rcMonitor));
if( FALSE == ::IsRectEmpty(&rSect) ) { if( FALSE == ::IsRectEmpty(&rSect) ) {
if( TRUE == ::EqualRect(&rSect,&rView) ) { if( TRUE == ::EqualRect(&rSect,&rView) ) {
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
* have any questions. * have any questions.
*/ */
#include <jni.h>
#include <awt.h> #include <awt.h>
#include "Trace.h" #include "Trace.h"
#include "WindowsFlags.h" #include "WindowsFlags.h"
......
/* /*
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,54 +23,26 @@ ...@@ -23,54 +23,26 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include "ComCtl32Util.h" #include "ComCtl32Util.h"
ComCtl32Util::ComCtl32Util() { ComCtl32Util::ComCtl32Util() {
hModComCtl32 = NULL;
m_bNewSubclassing = FALSE;
m_lpfnSetWindowSubclass = NULL;
m_lpfnRemoveWindowSubclass = NULL;
m_lpfnDefSubclassProc = NULL;
} }
ComCtl32Util::~ComCtl32Util() { ComCtl32Util::~ComCtl32Util() {
DASSERT(hModComCtl32 == NULL);
} }
void ComCtl32Util::InitLibraries() { void ComCtl32Util::InitLibraries() {
if (hModComCtl32 == NULL) { INITCOMMONCONTROLSEX iccex;
hModComCtl32 = ::LoadLibrary(TEXT("comctl32.dll")); memset(&iccex, 0, sizeof(INITCOMMONCONTROLSEX));
if (hModComCtl32 != NULL) { iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
m_lpfnSetWindowSubclass = (PFNSETWINDOWSUBCLASS)::GetProcAddress(hModComCtl32, "SetWindowSubclass"); ::InitCommonControlsEx(&iccex);
m_lpfnRemoveWindowSubclass = (PFNREMOVEWINDOWSUBCLASS)::GetProcAddress(hModComCtl32, "RemoveWindowSubclass");
m_lpfnDefSubclassProc = (PFNDEFSUBCLASSPROC)::GetProcAddress(hModComCtl32, "DefSubclassProc");
m_bNewSubclassing = (m_lpfnSetWindowSubclass != NULL) &&
(m_lpfnRemoveWindowSubclass != NULL) &&
(m_lpfnDefSubclassProc != NULL);
fn_InitCommonControlsEx = (ComCtl32Util::InitCommonControlsExType)::GetProcAddress(hModComCtl32, "InitCommonControlsEx");
InitCommonControls();
}
}
}
void ComCtl32Util::FreeLibraries() {
if (hModComCtl32 != NULL) {
m_lpfnSetWindowSubclass = NULL;
m_lpfnRemoveWindowSubclass = NULL;
m_lpfnDefSubclassProc = NULL;
::FreeLibrary(hModComCtl32);
hModComCtl32 = NULL;
}
} }
WNDPROC ComCtl32Util::SubclassHWND(HWND hwnd, WNDPROC _WindowProc) { WNDPROC ComCtl32Util::SubclassHWND(HWND hwnd, WNDPROC _WindowProc) {
if (m_bNewSubclassing) { if (IS_WINXP) {
DASSERT(hModComCtl32 != NULL);
const SUBCLASSPROC p = SharedWindowProc; // let compiler check type of SharedWindowProc const SUBCLASSPROC p = SharedWindowProc; // let compiler check type of SharedWindowProc
m_lpfnSetWindowSubclass(hwnd, p, (UINT_PTR)_WindowProc, NULL); // _WindowProc is used as subclass ID ::SetWindowSubclass(hwnd, p, (UINT_PTR)_WindowProc, NULL); // _WindowProc is used as subclass ID
return NULL; return NULL;
} else { } else {
return (WNDPROC)::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)_WindowProc); return (WNDPROC)::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)_WindowProc);
...@@ -78,21 +50,17 @@ WNDPROC ComCtl32Util::SubclassHWND(HWND hwnd, WNDPROC _WindowProc) { ...@@ -78,21 +50,17 @@ WNDPROC ComCtl32Util::SubclassHWND(HWND hwnd, WNDPROC _WindowProc) {
} }
void ComCtl32Util::UnsubclassHWND(HWND hwnd, WNDPROC _WindowProc, WNDPROC _DefWindowProc) { void ComCtl32Util::UnsubclassHWND(HWND hwnd, WNDPROC _WindowProc, WNDPROC _DefWindowProc) {
if (m_bNewSubclassing) { if (IS_WINXP) {
DASSERT(hModComCtl32 != NULL);
DASSERT(_DefWindowProc == NULL);
const SUBCLASSPROC p = SharedWindowProc; // let compiler check type of SharedWindowProc const SUBCLASSPROC p = SharedWindowProc; // let compiler check type of SharedWindowProc
m_lpfnRemoveWindowSubclass(hwnd, p, (UINT_PTR)_WindowProc); // _WindowProc is used as subclass ID ::RemoveWindowSubclass(hwnd, p, (UINT_PTR)_WindowProc); // _WindowProc is used as subclass ID
} else { } else {
::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)_DefWindowProc); ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)_DefWindowProc);
} }
} }
LRESULT ComCtl32Util::DefWindowProc(WNDPROC _DefWindowProc, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { LRESULT ComCtl32Util::DefWindowProc(WNDPROC _DefWindowProc, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
if (m_bNewSubclassing) { if (IS_WINXP) {
DASSERT(hModComCtl32 != NULL); return ::DefSubclassProc(hwnd, msg, wParam, lParam);
DASSERT(_DefWindowProc == NULL);
return m_lpfnDefSubclassProc(hwnd, msg, wParam, lParam);
} else if (_DefWindowProc != NULL) { } else if (_DefWindowProc != NULL) {
return ::CallWindowProc(_DefWindowProc, hwnd, msg, wParam, lParam); return ::CallWindowProc(_DefWindowProc, hwnd, msg, wParam, lParam);
} else { } else {
...@@ -111,15 +79,3 @@ LRESULT ComCtl32Util::SharedWindowProc(HWND hwnd, UINT msg, ...@@ -111,15 +79,3 @@ LRESULT ComCtl32Util::SharedWindowProc(HWND hwnd, UINT msg,
CATCH_BAD_ALLOC_RET(0); CATCH_BAD_ALLOC_RET(0);
} }
void ComCtl32Util::InitCommonControls()
{
if (fn_InitCommonControlsEx == NULL) {
return;
}
INITCOMMONCONTROLSEX iccex;
memset(&iccex, 0, sizeof(INITCOMMONCONTROLSEX));
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
fn_InitCommonControlsEx(&iccex);
}
/* /*
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -30,20 +30,6 @@ ...@@ -30,20 +30,6 @@
#ifndef _COMCTL32UTIL_H #ifndef _COMCTL32UTIL_H
#define _COMCTL32UTIL_H #define _COMCTL32UTIL_H
/*
* comctl32.dll version 6 subclassing - taken from PlatformSDK/Include/commctrl.h
*/
typedef LRESULT (CALLBACK *SUBCLASSPROC)(HWND hWnd, UINT uMsg, WPARAM wParam, \
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
typedef BOOL (WINAPI *PFNSETWINDOWSUBCLASS)(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIdSubclass, \
DWORD_PTR dwRefData);
typedef BOOL (WINAPI *PFNREMOVEWINDOWSUBCLASS)(HWND hWnd, SUBCLASSPROC pfnSubclass, \
UINT_PTR uIdSubclass);
typedef LRESULT (WINAPI *PFNDEFSUBCLASSPROC)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
class ComCtl32Util class ComCtl32Util
{ {
public: public:
...@@ -52,21 +38,8 @@ class ComCtl32Util ...@@ -52,21 +38,8 @@ class ComCtl32Util
return theInstance; return theInstance;
} }
// loads comctl32.dll and checks if required routines are available
// called from AwtToolkit::AwtToolkit()
void InitLibraries(); void InitLibraries();
// unloads comctl32.dll
// called from AwtToolkit::Dispose()
void FreeLibraries();
//-- comctl32.dll version 6 subclassing API --//
INLINE BOOL IsNewSubclassing() {
return m_bNewSubclassing;
}
// if comctl32.dll version 6 is used returns NULL, otherwise
// returns default window proc
WNDPROC SubclassHWND(HWND hwnd, WNDPROC _WindowProc); WNDPROC SubclassHWND(HWND hwnd, WNDPROC _WindowProc);
// DefWindowProc is the same as returned from SubclassHWND // DefWindowProc is the same as returned from SubclassHWND
void UnsubclassHWND(HWND hwnd, WNDPROC _WindowProc, WNDPROC _DefWindowProc); void UnsubclassHWND(HWND hwnd, WNDPROC _WindowProc, WNDPROC _DefWindowProc);
...@@ -77,19 +50,6 @@ class ComCtl32Util ...@@ -77,19 +50,6 @@ class ComCtl32Util
ComCtl32Util(); ComCtl32Util();
~ComCtl32Util(); ~ComCtl32Util();
HMODULE hModComCtl32;
PFNSETWINDOWSUBCLASS m_lpfnSetWindowSubclass;
PFNREMOVEWINDOWSUBCLASS m_lpfnRemoveWindowSubclass;
PFNDEFSUBCLASSPROC m_lpfnDefSubclassProc;
typedef BOOL (WINAPI * InitCommonControlsExType)(const LPINITCOMMONCONTROLSEX lpInitCtrls);
InitCommonControlsExType fn_InitCommonControlsEx;
void InitCommonControls();
BOOL m_bNewSubclassing;
// comctl32.dll version 6 window proc // comctl32.dll version 6 window proc
static LRESULT CALLBACK SharedWindowProc(HWND hwnd, UINT message, static LRESULT CALLBACK SharedWindowProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam, WPARAM wParam, LPARAM lParam,
......
...@@ -83,9 +83,83 @@ ...@@ -83,9 +83,83 @@
#include "Devices.h" #include "Devices.h"
#include "Trace.h" #include "Trace.h"
#include "awt_Multimon.h"
#include "D3DPipelineManager.h" #include "D3DPipelineManager.h"
/* Some helper functions (from awt_MMStub.h/cpp) */
int g_nMonitorCounter;
int g_nMonitorLimit;
HMONITOR* g_hmpMonitors;
// Callback for CountMonitors below
BOOL WINAPI clb_fCountMonitors(HMONITOR hMon, HDC hDC, LPRECT rRect, LPARAM lP)
{
g_nMonitorCounter ++;
return TRUE;
}
int WINAPI CountMonitors(void)
{
g_nMonitorCounter = 0;
::EnumDisplayMonitors(NULL, NULL, clb_fCountMonitors, 0L);
return g_nMonitorCounter;
}
// Callback for CollectMonitors below
BOOL WINAPI clb_fCollectMonitors(HMONITOR hMon, HDC hDC, LPRECT rRect, LPARAM lP)
{
if ((g_nMonitorCounter < g_nMonitorLimit) && (NULL != g_hmpMonitors)) {
g_hmpMonitors[g_nMonitorCounter] = hMon;
g_nMonitorCounter ++;
}
return TRUE;
}
int WINAPI CollectMonitors(HMONITOR* hmpMonitors, int nNum)
{
int retCode = 0;
if (NULL != hmpMonitors) {
g_nMonitorCounter = 0;
g_nMonitorLimit = nNum;
g_hmpMonitors = hmpMonitors;
::EnumDisplayMonitors(NULL, NULL, clb_fCollectMonitors, 0L);
retCode = g_nMonitorCounter;
g_nMonitorCounter = 0;
g_nMonitorLimit = 0;
g_hmpMonitors = NULL;
}
return retCode;
}
BOOL WINAPI MonitorBounds(HMONITOR hmMonitor, RECT* rpBounds)
{
BOOL retCode = FALSE;
if ((NULL != hmMonitor) && (NULL != rpBounds)) {
MONITORINFOEX miInfo;
memset((void*)(&miInfo), 0, sizeof(MONITORINFOEX));
miInfo.cbSize = sizeof(MONITORINFOEX);
if (TRUE == (retCode = ::GetMonitorInfo(hmMonitor, &miInfo))) {
(*rpBounds) = miInfo.rcMonitor;
}
}
return retCode;
}
/* End of helper functions */
Devices* Devices::theInstance = NULL; Devices* Devices::theInstance = NULL;
CriticalSection Devices::arrayLock; CriticalSection Devices::arrayLock;
...@@ -113,9 +187,9 @@ BOOL Devices::UpdateInstance(JNIEnv *env) ...@@ -113,9 +187,9 @@ BOOL Devices::UpdateInstance(JNIEnv *env)
{ {
J2dTraceLn(J2D_TRACE_INFO, "Devices::UpdateInstance"); J2dTraceLn(J2D_TRACE_INFO, "Devices::UpdateInstance");
int numScreens = ::CountMonitors(); int numScreens = CountMonitors();
MHND *monHds = (MHND *)safe_Malloc(numScreens * sizeof(MHND)); HMONITOR *monHds = (HMONITOR *)safe_Malloc(numScreens * sizeof(HMONITOR));
if (numScreens != ::CollectMonitors(monHds, numScreens)) { if (numScreens != CollectMonitors(monHds, numScreens)) {
J2dRlsTraceLn(J2D_TRACE_ERROR, J2dRlsTraceLn(J2D_TRACE_ERROR,
"Devices::UpdateInstance: Failed to get all "\ "Devices::UpdateInstance: Failed to get all "\
"monitor handles."); "monitor handles.");
......
/* /*
* Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -70,4 +70,8 @@ static CriticalSection arrayLock; ...@@ -70,4 +70,8 @@ static CriticalSection arrayLock;
}; };
// Some helper functions (from awt_MMStub.h/cpp)
BOOL WINAPI MonitorBounds (HMONITOR, RECT*);
#endif _DEVICES_H_ #endif _DEVICES_H_
/* /*
* Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "GDIHashtable.h" #include "GDIHashtable.h"
#include "awt_GDIObject.h" #include "awt_GDIObject.h"
#include "awt_dlls.h"
GDIHashtable::BatchDestructionManager GDIHashtable::manager; GDIHashtable::BatchDestructionManager GDIHashtable::manager;
...@@ -46,7 +45,6 @@ void GDIHashtable::release(void* key) { ...@@ -46,7 +45,6 @@ void GDIHashtable::release(void* key) {
DASSERT(value != NULL); DASSERT(value != NULL);
m_deleteProc(value); m_deleteProc(value);
} }
manager.update();
} }
void GDIHashtable::flush() { void GDIHashtable::flush() {
...@@ -128,9 +126,6 @@ void GDIHashtable::List::clear() { ...@@ -128,9 +126,6 @@ void GDIHashtable::List::clear() {
} }
} }
#undef GFSR_GDIRESOURCES
#define GFSR_GDIRESOURCES 0x0001
GDIHashtable::BatchDestructionManager::BatchDestructionManager(UINT nFirstThreshold, GDIHashtable::BatchDestructionManager::BatchDestructionManager(UINT nFirstThreshold,
UINT nSecondThreshold, UINT nSecondThreshold,
UINT nDestroyPeriod) : UINT nDestroyPeriod) :
...@@ -138,48 +133,6 @@ GDIHashtable::BatchDestructionManager::BatchDestructionManager(UINT nFirstThresh ...@@ -138,48 +133,6 @@ GDIHashtable::BatchDestructionManager::BatchDestructionManager(UINT nFirstThresh
m_nSecondThreshold(nSecondThreshold), m_nSecondThreshold(nSecondThreshold),
m_nDestroyPeriod(nDestroyPeriod), m_nDestroyPeriod(nDestroyPeriod),
m_nCounter(0), m_nCounter(0),
m_bBatchingEnabled(TRUE) { m_bBatchingEnabled(TRUE)
load_rsrc32_procs(); {
}
void GDIHashtable::BatchDestructionManager::update() {
if (get_free_system_resources != NULL) {
CriticalSection::Lock l(m_managerLock);
if (m_nCounter < 0) {
UINT nFreeResources = (*get_free_system_resources)(GFSR_GDIRESOURCES);
/*
* If m_bBatchingEnabled is FALSE there is no need
* to flush since we have been destroying all
* GDI resources as soon as they were released.
*/
if (m_bBatchingEnabled) {
if (nFreeResources < m_nFirstThreshold) {
flushAll();
nFreeResources = (*get_free_system_resources)(GFSR_GDIRESOURCES);
}
}
if (nFreeResources < m_nSecondThreshold) {
m_bBatchingEnabled = FALSE;
m_nCounter = m_nDestroyPeriod;
} else {
m_bBatchingEnabled = TRUE;
/*
* The frequency of checks must depend on the currect amount
* of free space in GDI heaps. Otherwise we can run into the
* Resource Meter warning dialog when GDI resources are low.
* This is a heuristic rule that provides this dependency.
* These numbers have been chosen because:
* Resource Meter posts a warning dialog when less than 10%
* of GDI resources are free.
* 5 pens/brushes take 1%. So 3 is the upper bound.
* When changing this rule you should check that performance
* isn't affected (with Caffeine Mark and JMark).
*/
m_nCounter = (nFreeResources - 10) * 3;
}
}
}
} }
/* /*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -151,12 +151,6 @@ class GDIHashtable : public Hashtable { ...@@ -151,12 +151,6 @@ class GDIHashtable : public Hashtable {
*/ */
INLINE void decrementCounter() { m_nCounter--; } INLINE void decrementCounter() { m_nCounter--; }
/**
* Depending on the amount of free space in GDI heaps flushes
* all GDIHashtables and sets the initial counter value.
*/
void update();
INLINE CriticalSection& getLock() { return m_managerLock; } INLINE CriticalSection& getLock() { return m_managerLock; }
}; };
......
/* /*
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,17 +31,27 @@ ...@@ -31,17 +31,27 @@
// This file should stand independent of AWT and should ultimately be // This file should stand independent of AWT and should ultimately be
// put into its own DLL. // put into its own DLL.
#include <awt.h> #include <awt.h>
#endif #else
// Include jni_util.h first, so JNU_* macros can be redefined
#include "jni_util.h"
// Borrow some macros from awt.h
#define JNU_NewStringPlatform(env, x) env->NewString(reinterpret_cast<jchar*>(x), static_cast<jsize>(_tcslen(x)))
#define JNU_GetStringPlatformChars(env, x, y) reinterpret_cast<LPCWSTR>(env->GetStringChars(x, y))
#define JNU_ReleaseStringPlatformChars(env, x, y) env->ReleaseStringChars(x, reinterpret_cast<const jchar*>(y))
#endif // DEBUG
#include <windows.h> #include <windows.h>
#include <shlobj.h> #include <shlobj.h>
#include <shellapi.h> #include <shellapi.h>
#include "jni_util.h"
#include "jlong.h" #include "jlong.h"
#include "alloc.h" #include "alloc.h"
#include "stdhdrs.h" #include "stdhdrs.h"
#include "UnicowsLoader.h"
// Copy from shlguid.h which is no longer in PlatformSDK
#ifndef DEFINE_SHLGUID
#define DEFINE_SHLGUID(name, l, w1, w2) DEFINE_GUID(name, l, w1, w2, 0xC0, 0, 0, 0, 0, 0, 0, 0x46)
#endif
// {93F2F68C-1D1B-11d3-A30E-00C04F79ABD1} // {93F2F68C-1D1B-11d3-A30E-00C04F79ABD1}
DEFINE_GUID(IID_IShellFolder2, 0x93f2f68c, 0x1d1b, 0x11d3, 0xa3, 0xe, 0x0, 0xc0, 0x4f, 0x79, 0xab, 0xd1); DEFINE_GUID(IID_IShellFolder2, 0x93f2f68c, 0x1d1b, 0x11d3, 0xa3, 0xe, 0x0, 0xc0, 0x4f, 0x79, 0xab, 0xd1);
...@@ -86,13 +96,15 @@ static jfieldID FID_folderType; ...@@ -86,13 +96,15 @@ static jfieldID FID_folderType;
static IMalloc* pMalloc; static IMalloc* pMalloc;
static IShellFolder* pDesktop; static IShellFolder* pDesktop;
static BOOL isXP; // Some macros from awt.h, because it is not included in release
#ifndef IS_WIN2000
// copied from awt.h, because it is not included in release #define IS_WIN2000 (LOBYTE(LOWORD(::GetVersion())) >= 5)
#if defined (WIN32) #endif
#define IS_WINVISTA (!(::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion())) >= 6) #ifndef IS_WINXP
#else #define IS_WINXP ((IS_WIN2000 && HIBYTE(LOWORD(::GetVersion())) >= 1) || LOBYTE(LOWORD(::GetVersion())) > 5)
#define IS_WINVISTA FALSE #endif
#ifndef IS_WINVISTA
#define IS_WINVISTA (!(::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion())) >= 6)
#endif #endif
...@@ -103,7 +115,6 @@ static BOOL initShellProcs() ...@@ -103,7 +115,6 @@ static BOOL initShellProcs()
static HMODULE libShell32 = NULL; static HMODULE libShell32 = NULL;
static HMODULE libUser32 = NULL; static HMODULE libUser32 = NULL;
static HMODULE libComCtl32 = NULL; static HMODULE libComCtl32 = NULL;
static HMODULE libUnicows = UnicowsLoader::GetModuleHandle();
// If already initialized, return TRUE // If already initialized, return TRUE
if (libShell32 != NULL && libUser32 != NULL) { if (libShell32 != NULL && libUser32 != NULL) {
return TRUE; return TRUE;
...@@ -130,7 +141,7 @@ static BOOL initShellProcs() ...@@ -130,7 +141,7 @@ static BOOL initShellProcs()
// Set up procs - libShell32 // Set up procs - libShell32
fn_FindExecutable = (FindExecutableType)GetProcAddress( fn_FindExecutable = (FindExecutableType)GetProcAddress(
(libUnicows ? libUnicows : libShell32), "FindExecutableW"); libShell32, "FindExecutableW");
if (fn_FindExecutable == NULL) { if (fn_FindExecutable == NULL) {
return FALSE; return FALSE;
} }
...@@ -140,7 +151,7 @@ static BOOL initShellProcs() ...@@ -140,7 +151,7 @@ static BOOL initShellProcs()
return FALSE; return FALSE;
} }
fn_SHGetFileInfo = (SHGetFileInfoType)GetProcAddress( fn_SHGetFileInfo = (SHGetFileInfoType)GetProcAddress(
(libUnicows ? libUnicows : libShell32), "SHGetFileInfoW"); libShell32, "SHGetFileInfoW");
if (fn_SHGetFileInfo == NULL) { if (fn_SHGetFileInfo == NULL) {
return FALSE; return FALSE;
} }
...@@ -154,7 +165,7 @@ static BOOL initShellProcs() ...@@ -154,7 +165,7 @@ static BOOL initShellProcs()
return FALSE; return FALSE;
} }
fn_SHGetPathFromIDList = (SHGetPathFromIDListType)GetProcAddress( fn_SHGetPathFromIDList = (SHGetPathFromIDListType)GetProcAddress(
(libUnicows ? libUnicows : libShell32), "SHGetPathFromIDListW"); libShell32, "SHGetPathFromIDListW");
if (fn_SHGetPathFromIDList == NULL) { if (fn_SHGetPathFromIDList == NULL) {
return FALSE; return FALSE;
} }
...@@ -181,19 +192,19 @@ static BOOL initShellProcs() ...@@ -181,19 +192,19 @@ static BOOL initShellProcs()
static jstring jstringFromSTRRET(JNIEnv* env, LPITEMIDLIST pidl, STRRET* pStrret) { static jstring jstringFromSTRRET(JNIEnv* env, LPITEMIDLIST pidl, STRRET* pStrret) {
switch (pStrret->uType) { switch (pStrret->uType) {
case STRRET_CSTR : case STRRET_CSTR :
return JNU_NewStringPlatform(env, pStrret->cStr); return JNU_NewStringPlatform(env, reinterpret_cast<const char*>(pStrret->cStr));
case STRRET_OFFSET : case STRRET_OFFSET :
// Note : this may need to be WCHAR instead // Note : this may need to be WCHAR instead
return JNU_NewStringPlatform(env, return JNU_NewStringPlatform(env,
(CHAR*)pidl + pStrret->uOffset); (CHAR*)pidl + pStrret->uOffset);
case STRRET_WSTR : case STRRET_WSTR :
return env->NewString(pStrret->pOleStr, return env->NewString(reinterpret_cast<const jchar*>(pStrret->pOleStr),
static_cast<jsize>(wcslen(pStrret->pOleStr))); static_cast<jsize>(wcslen(pStrret->pOleStr)));
} }
return NULL; return NULL;
} }
// restoring the original definition // restoring the original definition
#define JNU_NewStringPlatform(env, x) env->NewString(x, static_cast<jsize>(_tcslen(x))) #define JNU_NewStringPlatform(env, x) env->NewString(reinterpret_cast<jchar*>(x), static_cast<jsize>(_tcslen(x)))
/* /*
* Class: sun_awt_shell_Win32ShellFolder2 * Class: sun_awt_shell_Win32ShellFolder2
...@@ -212,13 +223,6 @@ JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_initIDs ...@@ -212,13 +223,6 @@ JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_initIDs
MID_relativePIDL = env->GetMethodID(cls, "setRelativePIDL", "(J)V"); MID_relativePIDL = env->GetMethodID(cls, "setRelativePIDL", "(J)V");
FID_displayName = env->GetFieldID(cls, "displayName", "Ljava/lang/String;"); FID_displayName = env->GetFieldID(cls, "displayName", "Ljava/lang/String;");
FID_folderType = env->GetFieldID(cls, "folderType", "Ljava/lang/String;"); FID_folderType = env->GetFieldID(cls, "folderType", "Ljava/lang/String;");
// Find out if we are on XP or later
long version = GetVersion();
isXP = (!(version & 0x80000000) &&
(LOBYTE(LOWORD(version)) == 5 &&
HIBYTE(LOWORD(version)) >= 1) ||
LOBYTE(LOWORD(version)) > 5);
} }
static IShellIcon* getIShellIcon(IShellFolder* pIShellFolder) { static IShellIcon* getIShellIcon(IShellFolder* pIShellFolder) {
...@@ -669,46 +673,24 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation ...@@ -669,46 +673,24 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
if (!CoInit(doCoUninit)) { if (!CoInit(doCoUninit)) {
return 0; return 0;
} }
if (IS_NT) { IShellLinkW* psl;
IShellLinkW* psl; hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&psl);
hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&psl); if (SUCCEEDED(hres)) {
if (SUCCEEDED(hres)) { IPersistFile* ppf;
IPersistFile* ppf; hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if (SUCCEEDED(hres)) {
hres = ppf->Load(wstr, STGM_READ);
if (SUCCEEDED(hres)) {
if (resolve) {
hres = psl->Resolve(NULL, 0);
// Ignore failure
}
pidl = (LPITEMIDLIST)NULL;
hres = psl->GetIDList(&pidl);
}
ppf->Release();
}
psl->Release();
}
} else {
IShellLinkA* psl;
hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkA, (LPVOID *)&psl);
if (SUCCEEDED(hres)) { if (SUCCEEDED(hres)) {
IPersistFile* ppf; hres = ppf->Load(wstr, STGM_READ);
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if (SUCCEEDED(hres)) { if (SUCCEEDED(hres)) {
hres = ppf->Load(wstr, STGM_READ); if (resolve) {
if (SUCCEEDED(hres)) { hres = psl->Resolve(NULL, 0);
if (resolve) { // Ignore failure
hres = psl->Resolve(NULL, 0);
// Ignore failure
}
pidl = (LPITEMIDLIST)NULL;
hres = psl->GetIDList(&pidl);
} }
ppf->Release(); pidl = (LPITEMIDLIST)NULL;
hres = psl->GetIDList(&pidl);
} }
psl->Release(); ppf->Release();
} }
psl->Release();
} }
if (doCoUninit) { if (doCoUninit) {
::CoUninitialize(); ::CoUninitialize();
...@@ -742,10 +724,10 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_parseDisplayName0 ...@@ -742,10 +724,10 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_parseDisplayName0
int nLength = env->GetStringLength(jname); int nLength = env->GetStringLength(jname);
jchar* wszPath = new jchar[nLength + 1]; jchar* wszPath = new jchar[nLength + 1];
const jchar* strPath = env->GetStringChars(jname, NULL); const jchar* strPath = env->GetStringChars(jname, NULL);
wcsncpy(wszPath, strPath, nLength); wcsncpy(reinterpret_cast<LPWSTR>(wszPath), reinterpret_cast<LPCWSTR>(strPath), nLength);
wszPath[nLength] = 0; wszPath[nLength] = 0;
HRESULT res = pIShellFolder->ParseDisplayName(NULL, NULL, HRESULT res = pIShellFolder->ParseDisplayName(NULL, NULL,
const_cast<jchar*>(wszPath), NULL, &pIDL, NULL); reinterpret_cast<LPWSTR>(wszPath), NULL, &pIDL, NULL);
if (res != S_OK) { if (res != S_OK) {
JNU_ThrowIOException(env, "Could not parse name"); JNU_ThrowIOException(env, "Could not parse name");
pIDL = 0; pIDL = 0;
...@@ -804,7 +786,7 @@ JNIEXPORT jstring JNICALL Java_sun_awt_shell_Win32ShellFolder2_getExecutableType ...@@ -804,7 +786,7 @@ JNIEXPORT jstring JNICALL Java_sun_awt_shell_Win32ShellFolder2_getExecutableType
(JNIEnv* env, jobject folder, jstring path) (JNIEnv* env, jobject folder, jstring path)
{ {
TCHAR szBuf[MAX_PATH]; TCHAR szBuf[MAX_PATH];
LPCTSTR szPath = (LPCTSTR)JNU_GetStringPlatformChars(env, path, NULL); LPCTSTR szPath = JNU_GetStringPlatformChars(env, path, NULL);
if (szPath == NULL) { if (szPath == NULL) {
return NULL; return NULL;
} }
...@@ -827,7 +809,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIcon ...@@ -827,7 +809,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIcon
{ {
HICON hIcon = NULL; HICON hIcon = NULL;
SHFILEINFO fileInfo; SHFILEINFO fileInfo;
LPCTSTR pathStr = (LPCTSTR)JNU_GetStringPlatformChars(env, absolutePath, NULL); LPCTSTR pathStr = JNU_GetStringPlatformChars(env, absolutePath, NULL);
if (fn_SHGetFileInfo(pathStr, 0L, &fileInfo, sizeof(fileInfo), if (fn_SHGetFileInfo(pathStr, 0L, &fileInfo, sizeof(fileInfo),
SHGFI_ICON | (getLargeIcon ? 0 : SHGFI_SMALLICON)) != 0) { SHGFI_ICON | (getLargeIcon ? 0 : SHGFI_SMALLICON)) != 0) {
hIcon = fileInfo.hIcon; hIcon = fileInfo.hIcon;
...@@ -890,52 +872,27 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_extractIcon ...@@ -890,52 +872,27 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_extractIcon
} }
HRESULT hres; HRESULT hres;
if (IS_NT) { IExtractIconW* pIcon;
IExtractIconW* pIcon; hres = pIShellFolder->GetUIObjectOf(NULL, 1, const_cast<LPCITEMIDLIST*>(&pidl),
hres = pIShellFolder->GetUIObjectOf(NULL, 1, const_cast<LPCITEMIDLIST*>(&pidl),
IID_IExtractIconW, NULL, (void**)&pIcon); IID_IExtractIconW, NULL, (void**)&pIcon);
if (SUCCEEDED(hres)) {
WCHAR szBuf[MAX_PATH];
INT index;
UINT flags;
hres = pIcon->GetIconLocation(GIL_FORSHELL, szBuf, MAX_PATH, &index, &flags);
if (SUCCEEDED(hres)) { if (SUCCEEDED(hres)) {
WCHAR szBuf[MAX_PATH]; HICON hIconLarge;
INT index; hres = pIcon->Extract(szBuf, index, &hIconLarge, &hIcon, (16 << 16) + 32);
UINT flags;
hres = pIcon->GetIconLocation(GIL_FORSHELL, szBuf, MAX_PATH, &index, &flags);
if (SUCCEEDED(hres)) {
HICON hIconLarge;
hres = pIcon->Extract(szBuf, index, &hIconLarge, &hIcon, (16 << 16) + 32);
if (SUCCEEDED(hres)) {
if (getLargeIcon) {
fn_DestroyIcon((HICON)hIcon);
hIcon = hIconLarge;
} else {
fn_DestroyIcon((HICON)hIconLarge);
}
}
}
pIcon->Release();
}
} else {
IExtractIconA* pIcon;
hres = pIShellFolder->GetUIObjectOf(NULL, 1, const_cast<LPCITEMIDLIST*>(&pidl),
IID_IExtractIconA, NULL, (void**)&pIcon);
if (SUCCEEDED(hres)) {
CHAR szBuf[MAX_PATH];
INT index;
UINT flags;
hres = pIcon->GetIconLocation(GIL_FORSHELL, szBuf, MAX_PATH, &index, &flags);
if (SUCCEEDED(hres)) { if (SUCCEEDED(hres)) {
HICON hIconLarge; if (getLargeIcon) {
hres = pIcon->Extract(szBuf, index, &hIconLarge, &hIcon, (16 << 16) + 32); fn_DestroyIcon((HICON)hIcon);
if (SUCCEEDED(hres)) { hIcon = hIconLarge;
if (getLargeIcon) { } else {
fn_DestroyIcon((HICON)hIcon); fn_DestroyIcon((HICON)hIconLarge);
hIcon = hIconLarge;
} else {
fn_DestroyIcon((HICON)hIconLarge);
}
} }
} }
pIcon->Release();
} }
pIcon->Release();
} }
if (doCoUninit) { if (doCoUninit) {
::CoUninitialize(); ::CoUninitialize();
...@@ -987,7 +944,7 @@ JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconBits ...@@ -987,7 +944,7 @@ JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconBits
// XP supports alpha in some icons, and depending on device. // XP supports alpha in some icons, and depending on device.
// This should take precedence over the icon mask bits. // This should take precedence over the icon mask bits.
BOOL hasAlpha = FALSE; BOOL hasAlpha = FALSE;
if (isXP) { if (IS_WINXP) {
for (int i = 0; i < nBits; i++) { for (int i = 0; i < nBits; i++) {
if ((colorBits[i] & 0xff000000) != 0) { if ((colorBits[i] & 0xff000000) != 0) {
hasAlpha = TRUE; hasAlpha = TRUE;
...@@ -1127,9 +1084,9 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource ...@@ -1127,9 +1084,9 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource
(JNIEnv* env, jclass cls, jstring libName, jint iconID, (JNIEnv* env, jclass cls, jstring libName, jint iconID,
jint cxDesired, jint cyDesired, jboolean useVGAColors) jint cxDesired, jint cyDesired, jboolean useVGAColors)
{ {
HINSTANCE libHandle = LoadLibrary(env->GetStringChars(libName, NULL)); HINSTANCE libHandle = LoadLibrary(JNU_GetStringPlatformChars(env, libName, NULL));
if (libHandle != NULL) { if (libHandle != NULL) {
UINT fuLoad = (useVGAColors && !isXP) ? LR_VGACOLOR : 0; UINT fuLoad = (useVGAColors && !IS_WINXP) ? LR_VGACOLOR : 0;
return ptr_to_jlong(LoadImage(libHandle, MAKEINTRESOURCE(iconID), return ptr_to_jlong(LoadImage(libHandle, MAKEINTRESOURCE(iconID),
IMAGE_ICON, cxDesired, cyDesired, IMAGE_ICON, cxDesired, cyDesired,
fuLoad)); fuLoad));
......
/*
* Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#include <float.h>
#include "alloc.h"
#include "UnicowsLoader.h"
/*
* Support functions for the Microsoft Layer for Unicode (MSLU).
*
* The MSLU maps the wide char version of Windows APIs with strings
* to their ANSI version equivalent on Win98/ME platforms.
*
* For more details on the MSLU, please refer to the MSDN webpage at:
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mslu/winprog/microsoft_layer_for_unicode_on_windows_95_98_me_systems.asp
*/
// The MSLU module handle. Only initialized on Win9x/ME.
HMODULE UnicowsLoader::hmodUnicows = NULL;
// MSLU loader entry point, which is called when the module
// is initialized.
extern "C" HMODULE (__stdcall *_PfnLoadUnicows)(void) =
&UnicowsLoader::LoadUnicows;
// Overriede APIs that are not supported by MSLU.
extern "C" FARPROC Unicows_GetPrinterW =
(FARPROC)&UnicowsLoader::GetPrinterWImpl;
extern "C" FARPROC Unicows_EnumPrintersW =
(FARPROC)&UnicowsLoader::EnumPrintersWImpl;
HMODULE __stdcall UnicowsLoader::LoadUnicows(void)
{
if (hmodUnicows != NULL) {
return hmodUnicows;
}
// Unfortunately, some DLLs that are loaded in conjunction with
// unicows.dll may blow the FPU's control word. So save it here.
unsigned int fpu_cw = _CW_DEFAULT;
fpu_cw = _control87(0, 0);
// Loads the DLL, assuming that the DLL resides in the same directory
// as the AWT(_G).DLL. We cannot use "sun.boot.library.path" system
// property since there is no way to issue JNI calls at this point
// (JNI_OnLoad is not yet called so it cannot obtain JavaVM structure)
//
// To obtain the AWT module handle, call GetModuleHandleA() directly,
// instead of AwtToolkit.GetModuleHandle(). Otherwise it could cause
// an infinite loop if some W call were made inside AwtToolkit class
// initialization.
HMODULE hmodAWT = GetModuleHandleA("awt");
LPSTR abspath = (LPSTR)safe_Malloc(MAX_PATH);
if (abspath != NULL) {
GetModuleFileNameA(hmodAWT, abspath, MAX_PATH);
*strrchr(abspath, '\\') = '\0';
strcat(abspath, "\\unicows.dll");
hmodUnicows = LoadLibraryA(abspath);
free(abspath);
}
// Restore the FPU control word if needed.
if ( _control87(0, 0) != fpu_cw) {
_control87(fpu_cw, 0xfffff);
}
return hmodUnicows;
}
HMODULE UnicowsLoader::GetModuleHandle(void)
{
return hmodUnicows;
}
// Convenient functions to convert DEVMODEA -> DEVMODEW
void UnicowsLoader::DevModeA2DevModeW(
const DEVMODEA * dma,
DEVMODEW * dmw)
{
// convert string portions
::MultiByteToWideChar(CP_ACP, 0, (CHAR *)dma->dmDeviceName, CCHDEVICENAME,
dmw->dmDeviceName, CCHDEVICENAME);
::MultiByteToWideChar(CP_ACP, 0, (CHAR *)dma->dmFormName, CCHDEVICENAME,
dmw->dmFormName, CCHDEVICENAME);
// copy driver specific data if exists
if (dma->dmDriverExtra != 0) {
PBYTE pExtraA = (PBYTE)(dma + 1);
PBYTE pExtraW = (PBYTE)(dmw + 1);
memcpy(pExtraW, pExtraA, dma->dmDriverExtra);
}
// copy normal struct members
dmw->dmSpecVersion = dma->dmSpecVersion;
dmw->dmDriverVersion = dma->dmDriverVersion;
dmw->dmSize = dma->dmSize;
dmw->dmDriverExtra = dma->dmDriverExtra;
dmw->dmFields = dma->dmFields;
dmw->dmPosition = dma->dmPosition;
dmw->dmScale = dma->dmScale;
dmw->dmCopies = dma->dmCopies;
dmw->dmDefaultSource = dma->dmDefaultSource;
dmw->dmPrintQuality = dma->dmPrintQuality;
dmw->dmColor = dma->dmColor;
dmw->dmDuplex = dma->dmDuplex;
dmw->dmYResolution = dma->dmYResolution;
dmw->dmTTOption = dma->dmTTOption;
dmw->dmCollate = dma->dmCollate;
dmw->dmLogPixels = dma->dmLogPixels;
dmw->dmBitsPerPel = dma->dmBitsPerPel;
dmw->dmPelsWidth = dma->dmPelsWidth;
dmw->dmPelsHeight = dma->dmPelsHeight;
dmw->dmDisplayFlags = dma->dmDisplayFlags;
dmw->dmDisplayFrequency = dma->dmDisplayFrequency;
#if(WINVER >= 0x0400)
dmw->dmICMMethod = dma->dmICMMethod;
dmw->dmICMIntent = dma->dmICMIntent;
dmw->dmMediaType = dma->dmMediaType;
dmw->dmDitherType = dma->dmDitherType;
dmw->dmReserved1 = dma->dmReserved1;
dmw->dmReserved2 = dma->dmReserved2;
#if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400)
dmw->dmPanningWidth = dma->dmPanningWidth;
dmw->dmPanningHeight = dma->dmPanningHeight;
#endif
#endif /* WINVER >= 0x0400 */
}
// PRINTER_INFO_1 struct converter
void UnicowsLoader::PrinterInfo1A2W(
const LPPRINTER_INFO_1A pi1A,
LPPRINTER_INFO_1W pi1W,
const DWORD num)
{
LPWSTR pwstrbuf = (LPWSTR)(pi1W + num);
DWORD current;
// loop through all structures
for (current = 0; current < num; current ++) {
LPPRINTER_INFO_1A curPi1A = pi1A + current;
LPPRINTER_INFO_1W curPi1W = pi1W + current;
// copy the structure itself
memcpy(curPi1W, curPi1A, sizeof(_PRINTER_INFO_1W));
// copy string members
StringA2W(curPi1A->pDescription, &(curPi1W->pDescription), &pwstrbuf);
StringA2W(curPi1A->pName, &(curPi1W->pName), &pwstrbuf);
StringA2W(curPi1A->pComment, &(curPi1W->pComment), &pwstrbuf);
}
}
// PRINTER_INFO_2 struct converter
void UnicowsLoader::PrinterInfo2A2W(
const LPPRINTER_INFO_2A pi2A,
LPPRINTER_INFO_2W pi2W,
const DWORD num)
{
PBYTE pbytebuf = (PBYTE)(pi2W + num);
DWORD current;
// loop through all structures
for (current = 0; current < num; current ++) {
LPPRINTER_INFO_2A curPi2A = pi2A + current;
LPPRINTER_INFO_2W curPi2W = pi2W + current;
// copy the structure itself
memcpy(curPi2W, curPi2A, sizeof(_PRINTER_INFO_2W));
// copy string members
StringA2W(curPi2A->pServerName, &(curPi2W->pServerName), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pPrinterName, &(curPi2W->pPrinterName), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pShareName, &(curPi2W->pShareName), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pPortName, &(curPi2W->pPortName), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pDriverName, &(curPi2W->pDriverName), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pComment, &(curPi2W->pComment), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pLocation, &(curPi2W->pLocation), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pSepFile, &(curPi2W->pSepFile), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pPrintProcessor, &(curPi2W->pPrintProcessor), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pDatatype, &(curPi2W->pDatatype), (LPWSTR *)&pbytebuf);
StringA2W(curPi2A->pParameters, &(curPi2W->pParameters), (LPWSTR *)&pbytebuf);
// copy DEVMODE structure
if (curPi2A->pDevMode != NULL) {
curPi2W->pDevMode = (LPDEVMODEW)pbytebuf;
DevModeA2DevModeW(curPi2A->pDevMode, curPi2W->pDevMode);
pbytebuf += sizeof(DEVMODEW) + curPi2A->pDevMode->dmDriverExtra;
}
}
}
// PRINTER_INFO_5 struct converter
void UnicowsLoader::PrinterInfo5A2W(
const LPPRINTER_INFO_5A pi5A,
LPPRINTER_INFO_5W pi5W,
const DWORD num)
{
LPWSTR pbuf = (LPWSTR)(pi5W + num);
DWORD current;
// loop through all structures
for (current = 0; current < num; current ++) {
LPPRINTER_INFO_5A curPi5A = pi5A + current;
LPPRINTER_INFO_5W curPi5W = pi5W + current;
// copy the structure itself
memcpy(curPi5W, curPi5A, sizeof(_PRINTER_INFO_5W));
// copy string members
StringA2W(curPi5A->pPrinterName, &(curPi5W->pPrinterName), &pbuf);
StringA2W(curPi5A->pPortName, &(curPi5W->pPortName), &pbuf);
}
}
// PRINTER_INFO_* struct converter. Supported levels are 1, 2, and 5.
void UnicowsLoader::PrinterInfoA2W(
const PVOID piA,
PVOID piW,
const DWORD Level,
const DWORD num)
{
switch (Level) {
case 1:
PrinterInfo1A2W((LPPRINTER_INFO_1A)piA, (LPPRINTER_INFO_1W)piW, num);
break;
case 2:
PrinterInfo2A2W((LPPRINTER_INFO_2A)piA, (LPPRINTER_INFO_2W)piW, num);
break;
case 5:
PrinterInfo5A2W((LPPRINTER_INFO_5A)piA, (LPPRINTER_INFO_5W)piW, num);
break;
}
}
// converts string members in PRINTER_INFO_* struct.
void UnicowsLoader::StringA2W(
LPCSTR pSrcA,
LPWSTR * ppwstrDest,
LPWSTR * ppwstrbuf)
{
if (pSrcA != NULL) {
DWORD cchWideChar = ::MultiByteToWideChar(CP_ACP, 0, pSrcA, -1, NULL, 0);
*ppwstrDest = *ppwstrbuf;
::MultiByteToWideChar(CP_ACP, 0, pSrcA, -1, *ppwstrbuf, cchWideChar);
*ppwstrbuf += cchWideChar;
} else {
*ppwstrDest = NULL;
}
}
// GetPrinterW implementation. Level 1, 2, and 5 are the only supported levels.
BOOL __stdcall UnicowsLoader::GetPrinterWImpl(
HANDLE hPrinter,
DWORD Level,
LPBYTE pPrinter,
DWORD cbBuf,
LPDWORD pcbNeeded)
{
if ((Level != 1) && (Level != 2) && (Level != 5)) {
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
DWORD cbBufA = (cbBuf != 0 ? cbBuf / 2 : 0); // dirty estimation...
LPBYTE pPrinterA = NULL;
DWORD cbNeededA = 0;
BOOL ret;
if (cbBufA != 0) {
pPrinterA = (LPBYTE)safe_Malloc(cbBufA);
memset(pPrinterA, 0, cbBufA);
}
ret = ::GetPrinterA(hPrinter, Level, pPrinterA, cbBufA, &cbNeededA);
*pcbNeeded = cbNeededA * 2; // dirty estimation...
if (pPrinterA != NULL) {
if (ret) {
PrinterInfoA2W(pPrinterA, pPrinter, Level, 1);
}
free(pPrinterA);
}
return ret;
}
// EnumPrintersW implementation. Level 1, 2, and 5 are the only supported levels.
BOOL __stdcall UnicowsLoader::EnumPrintersWImpl(
DWORD Flags,
LPWSTR Name,
DWORD Level,
LPBYTE pPrinterEnum,
DWORD cbBuf,
LPDWORD pcbNeeded,
LPDWORD pcReturned)
{
if ((Level != 1) && (Level != 2) && (Level != 5)) {
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
LPSTR pNameA = NULL;
DWORD cbBufA = (cbBuf != 0 ? cbBuf / 2 : 0); // dirty estimation...
LPBYTE pPrinterEnumA = NULL;
DWORD cbNeededA = 0;
BOOL ret;
if (Name != NULL) {
DWORD len = static_cast<DWORD>(wcslen(Name)) + 1;
pNameA = (LPSTR)safe_Malloc(len);
::WideCharToMultiByte(CP_ACP, 0, Name, -1, pNameA, len, NULL, NULL);
}
if (cbBufA != 0) {
pPrinterEnumA = (LPBYTE)safe_Malloc(cbBufA);
memset(pPrinterEnumA, 0, cbBufA);
}
ret = ::EnumPrintersA(Flags, pNameA, Level, pPrinterEnumA,
cbBufA, &cbNeededA, pcReturned);
*pcbNeeded = cbNeededA * 2; // dirty estimation...
if (pPrinterEnumA != NULL) {
if (ret) {
PrinterInfoA2W(pPrinterEnumA, pPrinterEnum, Level, *pcReturned);
}
free(pPrinterEnumA);
}
if (pNameA != NULL) {
free(pNameA);
}
return ret;
}
// wchar CRT implementations that VC6 does not support on Win9x.
// These implementations are used on both Win9x/ME *and* WinNT/2K/XP.
#undef _waccess
#undef _wchmod
#undef _wfullpath
#undef _wremove
#undef _wrename
#undef _wstat
#undef _wstati64
#undef _wstat64
#undef _wunlink
#undef _wfopen
#undef _wfreopen
#undef _wfsopen
#undef _wcreat
#undef _wopen
#undef _wsopen
#undef _wfindfirst
#undef _wfindfirst64
#undef _wfindnext
#undef _wfindnext64
#undef _wsystem
#undef _wexcel
#undef _wexcele
#undef _wexelp
#undef _wexelpe
#undef _wexecv
#undef _wexecve
#undef _wexecvp
#undef _wexecvpe
#undef _wpopen
#undef _wputenv
#undef _wspawnl
#undef _wspawnle
#undef _wspawnlp
#undef _wspawnlpe
#undef _wspawnv
#undef _wspawnve
#undef _wspawnvp
#undef _wspawnvpe
// _wfullpath implementation
wchar_t * __cdecl UnicowsLoader::_wfullpathImpl(
wchar_t * absPath,
const wchar_t * relPath,
size_t maxLength)
{
if (IS_NT) {
return _wfullpath(absPath, relPath, maxLength);
} else {
wchar_t * ret = NULL;
char * absPathA = (char *)safe_Malloc(maxLength);
char * relPathA = (char *)safe_Malloc(maxLength);
::WideCharToMultiByte(CP_ACP, 0, relPath, -1, relPathA,
static_cast<DWORD>(maxLength), NULL, NULL);
char * retA = _fullpath(absPathA, relPathA, maxLength);
if (retA != NULL) {
::MultiByteToWideChar(CP_ACP, 0, absPathA, -1,
absPath, static_cast<DWORD>(maxLength));
ret = absPath;
}
free(absPathA);
free(relPathA);
return ret;
}
}
/*
* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef UNICOWSLOADER_H
#define UNICOWSLOADER_H
#if !defined(UNICODE) || !defined(_UNICODE)
#error UnicowsLoader module needs UNICODE and _UNICODE flags to be set on compiling
#endif
#include <winspool.h>
// A class to load the Microsoft Layer for Unicode (unicows.dll)
class UnicowsLoader {
public:
// this is called when the client DLL (this case, AWT) is loaded
static HMODULE __stdcall LoadUnicows(void);
// this is provided to pass the MSLU module handle
static HMODULE GetModuleHandle(void);
// member functions that implements functions that MSLU does not support
static BOOL __stdcall GetPrinterWImpl(HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
static BOOL __stdcall EnumPrintersWImpl(DWORD, LPWSTR, DWORD, LPBYTE,
DWORD, LPDWORD, LPDWORD);
// member functions that implements functions that VC6 CRT does not support
// on Win9x
static wchar_t * __cdecl _wfullpathImpl(wchar_t *, const wchar_t *, size_t);
private:
// The module handle
static HMODULE hmodUnicows;
// utility member functions
static void DevModeA2DevModeW(const DEVMODEA *, DEVMODEW *);
static void PrinterInfo1A2W(const LPPRINTER_INFO_1A, LPPRINTER_INFO_1W, const DWORD);
static void PrinterInfo2A2W(const LPPRINTER_INFO_2A, LPPRINTER_INFO_2W, const DWORD);
static void PrinterInfo5A2W(const LPPRINTER_INFO_5A, LPPRINTER_INFO_5W, const DWORD);
static void PrinterInfoA2W(const PVOID, PVOID, DWORD, DWORD);
static void StringA2W(LPCSTR, LPWSTR *, LPWSTR *);
};
#ifndef AWT_H
// copied from awt.h
#if defined (WIN32)
#define IS_WIN32 TRUE
#else
#define IS_WIN32 FALSE
#endif
#define IS_NT (IS_WIN32 && !(::GetVersion() & 0x80000000))
#endif // AWT_H
// Now the platform encoding is Unicode (UTF-16), re-define JNU_ functions
// to proper JNI functions.
#define JNU_NewStringPlatform(env, x) env->NewString(x, static_cast<jsize>(_tcslen(x)))
#define JNU_GetStringPlatformChars(env, x, y) (LPWSTR)env->GetStringChars(x, y)
#define JNU_ReleaseStringPlatformChars(env, x, y) env->ReleaseStringChars(x, y)
// The following Windows W-APIs are not supported by the MSLU.
// You need to implement a stub to use these APIs. Or, if it is
// apparent that the API is used only on WindowsNT/2K/XP, wrap
// the call site with #undef - #define, e.g:
//
// #undef SomeFunctionW
// call SomeFunctionW
// #define SomeFunctionW NotSupportedByMSLU
#define AcquireCredentialsHandleW NotSupportedByMSLU
#define CreateNamedPipeW NotSupportedByMSLU
#define CryptAcquireContextW NotSupportedByMSLU
#define CryptEnumProvidersW NotSupportedByMSLU
#define CryptEnumProviderTypesW NotSupportedByMSLU
#define CryptGetDefaultProviderW NotSupportedByMSLU
#define CryptSetProviderW NotSupportedByMSLU
#define CryptSetProviderExW NotSupportedByMSLU
#define CryptSignHashW NotSupportedByMSLU
#define CryptVerifySignatureW NotSupportedByMSLU
#define EnumerateSecurityPackagesW NotSupportedByMSLU
#define EnumMonitorsW NotSupportedByMSLU
#define EnumPortsW NotSupportedByMSLU
#define EnumPrinterDriversW NotSupportedByMSLU
//#define EnumPrintersW NotSupportedByMSLU
#define EnumPrintProcessorDatatypesW NotSupportedByMSLU
#define EnumPrintProcessorsW NotSupportedByMSLU
#define FreeContextBufferW NotSupportedByMSLU
#define GetCharABCWidthsFloatW NotSupportedByMSLU
#define GetJobW NotSupportedByMSLU
#define GetOpenFileNamePreviewW NotSupportedByMSLU
//#define GetPrinterW NotSupportedByMSLU
#define GetPrinterDataW NotSupportedByMSLU
#define GetPrinterDriverW NotSupportedByMSLU
#define GetSaveFileNamePreviewW NotSupportedByMSLU
#define InitializeSecurityContextW NotSupportedByMSLU
#define mciSendCommandW NotSupportedByMSLU
#define mixerGetControlDetailsW NotSupportedByMSLU
#define mixerGetLineControlsW NotSupportedByMSLU
#define mixerGetLineInfoW NotSupportedByMSLU
#define mmioInstallIOProcW NotSupportedByMSLU
#define OleUIChangeSourceW NotSupportedByMSLU
#define OleUIConvertW NotSupportedByMSLU
#define OleUIEditLinksW NotSupportedByMSLU
#define OleUIInsertObjectW NotSupportedByMSLU
#define OleUIObjectPropertiesW NotSupportedByMSLU
#define OleUIPasteSpecialW NotSupportedByMSLU
#define OleUIPromptUserW NotSupportedByMSLU
#define OleUIUpdateLinksW NotSupportedByMSLU
#define PolyTextOutW NotSupportedByMSLU
#define QueryContextAttributesW NotSupportedByMSLU
#define QueryCredentialsAttributesW NotSupportedByMSLU
#define QuerySecurityPackageInfoW NotSupportedByMSLU
#define RasDeleteSubEntryW NotSupportedByMSLU
#define RasSetSubEntryPropertiesW NotSupportedByMSLU
#define ResetPrinterW NotSupportedByMSLU
// The following Shell COM interfaces are not supported by the MSLU.
// See ShellFolder2.cpp
#define IID_IFileViewerW NotSupportedByMSLU
#define IID_IShellLinkW NotSupportedByMSLU
#define IID_IExtractIconW NotSupportedByMSLU
#define IID_IShellCopyHookW NotSupportedByMSLU
#define IID_IShellExecuteHookW NotSupportedByMSLU
#define IID_INewShortcutHookW NotSupportedByMSLU
// The following CRT functions should fail on compiling, as it does not work on
// Win9x/ME platform. If you need these CRTs, write a wrapper for ANSI version
// equivalents, in which it converts to/from Unicode using WideCharToMultiByte.
//
// Or, if it is apparent that the function is used only on WindowsNT/2K/XP, wrap
// the call site with #undef - #define, e.g:
//
// #undef _wsomefunc
// call _wsomefunc
// #define _wsomefunc NotSupportedOnWin9X
#define _waccess NotSupportedOnWin9X
#define _wchmod NotSupportedOnWin9X
#define _wfullpath UnicowsLoader::_wfullpathImpl
#define _wremove NotSupportedOnWin9X
#define _wrename NotSupportedOnWin9X
#define _wstat NotSupportedOnWin9X
#define _wstati64 NotSupportedOnWin9X
#define _wstat64 NotSupportedOnWin9X
#define _wunlink NotSupportedOnWin9X
#define _wfopen NotSupportedOnWin9X
#define _wfreopen NotSupportedOnWin9X
#define _wfsopen NotSupportedOnWin9X
#define _wcreat NotSupportedOnWin9X
#define _wopen NotSupportedOnWin9X
#define _wsopen NotSupportedOnWin9X
#define _wfindfirst NotSupportedOnWin9X
#define _wfindfirst64 NotSupportedOnWin9X
#define _wfindnext NotSupportedOnWin9X
#define _wfindnext64 NotSupportedOnWin9X
#define _wsystem NotSupportedOnWin9X
#define _wexcel NotSupportedOnWin9X
#define _wexcele NotSupportedOnWin9X
#define _wexelp NotSupportedOnWin9X
#define _wexelpe NotSupportedOnWin9X
#define _wexecv NotSupportedOnWin9X
#define _wexecve NotSupportedOnWin9X
#define _wexecvp NotSupportedOnWin9X
#define _wexecvpe NotSupportedOnWin9X
#define _wpopen NotSupportedOnWin9X
#define _wputenv NotSupportedOnWin9X
#define _wspawnl NotSupportedOnWin9X
#define _wspawnle NotSupportedOnWin9X
#define _wspawnlp NotSupportedOnWin9X
#define _wspawnlpe NotSupportedOnWin9X
#define _wspawnv NotSupportedOnWin9X
#define _wspawnve NotSupportedOnWin9X
#define _wspawnvp NotSupportedOnWin9X
#define _wspawnvpe NotSupportedOnWin9X
#endif // UNICOWSLOADER_H
/* /*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include "stdhdrs.h" #include "stdhdrs.h"
#include <commdlg.h> #include <commdlg.h>
#include <winspool.h> #include <winspool.h>
#include <limits.h> #include <limits.h>
#include <float.h> #include <float.h>
#include "awt.h"
#include "awt_dlls.h"
#include "awt_Toolkit.h" #include "awt_Toolkit.h"
#include "awt_PrintControl.h" #include "awt_PrintControl.h"
...@@ -74,7 +74,6 @@ Java_sun_print_Win32PrintServiceLookup_getDefaultPrinterName(JNIEnv *env, ...@@ -74,7 +74,6 @@ Java_sun_print_Win32PrintServiceLookup_getDefaultPrinterName(JNIEnv *env,
TRY; TRY;
TCHAR cBuffer[250]; TCHAR cBuffer[250];
BOOL bFlag;
OSVERSIONINFO osv; OSVERSIONINFO osv;
PRINTER_INFO_2 *ppi2 = NULL; PRINTER_INFO_2 *ppi2 = NULL;
DWORD dwNeeded = 0; DWORD dwNeeded = 0;
...@@ -86,39 +85,8 @@ Java_sun_print_Win32PrintServiceLookup_getDefaultPrinterName(JNIEnv *env, ...@@ -86,39 +85,8 @@ Java_sun_print_Win32PrintServiceLookup_getDefaultPrinterName(JNIEnv *env,
osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osv); GetVersionEx(&osv);
// If Windows 95 or 98, use EnumPrinters... // If Windows 2000, XP, Vista
if (osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
// The first EnumPrinters() tells you how big our buffer should
// be in order to hold ALL of PRINTER_INFO_2. Note that this will
// usually return FALSE. This only means that the buffer (the 4th
// parameter) was not filled in. You don't want it filled in here...
EnumPrinters(PRINTER_ENUM_DEFAULT, NULL, 2,
NULL, 0, &dwNeeded, &dwReturned);
if (dwNeeded == 0) {
return NULL;
}
// Allocate enough space for PRINTER_INFO_2...
ppi2 = (PRINTER_INFO_2 *)GlobalAlloc(GPTR, dwNeeded);
if (!ppi2) {
return NULL;
}
// The second EnumPrinters() will fill in all the current information.
bFlag = EnumPrinters(PRINTER_ENUM_DEFAULT, NULL, 2,
(LPBYTE)ppi2, dwNeeded, &dwNeeded, &dwReturned);
if (!bFlag) {
GlobalFree(ppi2);
return NULL;
}
jPrinterName = JNU_NewStringPlatform(env, ppi2->pPrinterName);
GlobalFree(ppi2);
return jPrinterName;
} else if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
// Retrieve the default string from Win.ini (the registry). // Retrieve the default string from Win.ini (the registry).
// String will be in form "printername,drivername,portname". // String will be in form "printername,drivername,portname".
...@@ -165,62 +133,32 @@ Java_sun_print_Win32PrintServiceLookup_getAllPrinterNames(JNIEnv *env, ...@@ -165,62 +133,32 @@ Java_sun_print_Win32PrintServiceLookup_getAllPrinterNames(JNIEnv *env,
jobjectArray nameArray; jobjectArray nameArray;
try { try {
if (IS_NT) { ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, NULL, 0, &cbNeeded, &cReturned);
NULL, 4, NULL, 0, &cbNeeded, &cReturned); pPrinterEnum = new BYTE[cbNeeded];
pPrinterEnum = new BYTE[cbNeeded]; ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, pPrinterEnum, cbNeeded, &cbNeeded,
NULL, 4, pPrinterEnum, cbNeeded, &cbNeeded, &cReturned);
&cReturned);
if (cReturned > 0) {
if (cReturned > 0) { nameArray = env->NewObjectArray(cReturned, clazz, NULL);
nameArray = env->NewObjectArray(cReturned, clazz, NULL); if (nameArray == NULL) {
if (nameArray == NULL) { throw std::bad_alloc();
throw std::bad_alloc();
}
} else {
nameArray = NULL;
}
for (DWORD i = 0; i < cReturned; i++) {
PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *)
(pPrinterEnum + i * sizeof(PRINTER_INFO_4));
utf_str = JNU_NewStringPlatform(env, info4->pPrinterName);
if (utf_str == NULL) {
throw std::bad_alloc();
}
env->SetObjectArrayElement(nameArray, i, utf_str);
env->DeleteLocalRef(utf_str);
} }
} else { } else {
::EnumPrinters(PRINTER_ENUM_LOCAL, nameArray = NULL;
NULL, 5, NULL, 0, &cbNeeded, &cReturned); }
pPrinterEnum = new BYTE[cbNeeded];
::EnumPrinters(PRINTER_ENUM_LOCAL,
NULL, 5, pPrinterEnum, cbNeeded, &cbNeeded,
&cReturned);
if (cReturned > 0) {
nameArray = env->NewObjectArray(cReturned, clazz, NULL);
if (nameArray == NULL) {
throw std::bad_alloc();
}
} else {
nameArray = NULL;
}
for (DWORD i = 0; i < cReturned; i++) { for (DWORD i = 0; i < cReturned; i++) {
PRINTER_INFO_5 *info5 = (PRINTER_INFO_5 *) PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *)
(pPrinterEnum + i * sizeof(PRINTER_INFO_5)); (pPrinterEnum + i * sizeof(PRINTER_INFO_4));
utf_str = JNU_NewStringPlatform(env, info5->pPrinterName); utf_str = JNU_NewStringPlatform(env, info4->pPrinterName);
if (utf_str == NULL) { if (utf_str == NULL) {
throw std::bad_alloc(); throw std::bad_alloc();
}
env->SetObjectArrayElement(nameArray, i, utf_str);
env->DeleteLocalRef(utf_str);
} }
env->SetObjectArrayElement(nameArray, i, utf_str);
env->DeleteLocalRef(utf_str);
} }
} catch (std::bad_alloc&) { } catch (std::bad_alloc&) {
delete [] pPrinterEnum; delete [] pPrinterEnum;
...@@ -872,7 +810,7 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env, ...@@ -872,7 +810,7 @@ Java_sun_print_Win32PrintService_getDefaultSettings(JNIEnv *env,
int numSizes = ::DeviceCapabilities(printerName, printerPort, int numSizes = ::DeviceCapabilities(printerName, printerPort,
DC_PAPERS, NULL, NULL); DC_PAPERS, NULL, NULL);
if (numSizes > 0) { if (numSizes > 0) {
LPWORD papers = (LPWORD)safe_Malloc(numSizes * sizeof(WORD)); LPTSTR papers = (LPTSTR)safe_Malloc(numSizes * sizeof(WORD));
if (papers != NULL && if (papers != NULL &&
::DeviceCapabilities(printerName, printerPort, ::DeviceCapabilities(printerName, printerPort,
DC_PAPERS, papers, NULL) != -1) { DC_PAPERS, papers, NULL) != -1) {
......
...@@ -26,10 +26,21 @@ ...@@ -26,10 +26,21 @@
#ifndef _AWT_H_ #ifndef _AWT_H_
#define _AWT_H_ #define _AWT_H_
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#endif
#ifndef _WIN32_IE
#define _WIN32_IE 0x0600
#endif
//#ifndef NTDDI_VERSION
//#define NTDDI_VERSION NTDDI_LONGHORN
//#endif
#include "stdhdrs.h" #include "stdhdrs.h"
#include "alloc.h" #include "alloc.h"
#include "awt_Debug.h" #include "awt_Debug.h"
#include "UnicowsLoader.h"
extern COLORREF DesktopColor2RGB(int colorIndex); extern COLORREF DesktopColor2RGB(int colorIndex);
...@@ -129,40 +140,23 @@ typedef AwtObject* PDATA; ...@@ -129,40 +140,23 @@ typedef AwtObject* PDATA;
/* /NEW JNI */ /* /NEW JNI */
/* /*
* IS_NT returns TRUE on NT, 2000, XP
* IS_WIN2000 returns TRUE on 2000, XP
* IS_WINXP returns TRUE on XP
* IS_WIN95 returns TRUE on 95, 98, ME
* IS_WIN98 returns TRUE on 98, ME
* IS_WINME returns TRUE on ME
* IS_WIN32 returns TRUE on 32-bit Pentium and
* 64-bit Itanium.
* IS_WIN64 returns TRUE on 64-bit Itanium * IS_WIN64 returns TRUE on 64-bit Itanium
*
* uname -s returns Windows_95 on 95
* uname -s returns Windows_98 on 98 and ME
* uname -s returns Windows_NT on NT and 2000 and XP
*/ */
#if defined (WIN32)
#define IS_WIN32 TRUE
#else
#define IS_WIN32 FALSE
#endif
#if defined (_WIN64) #if defined (_WIN64)
#define IS_WIN64 TRUE #define IS_WIN64 TRUE
#else #else
#define IS_WIN64 FALSE #define IS_WIN64 FALSE
#endif #endif
#define IS_NT (IS_WIN32 && !(::GetVersion() & 0x80000000))
#define IS_WIN2000 (IS_NT && LOBYTE(LOWORD(::GetVersion())) >= 5) /*
#define IS_WIN2003 (IS_NT && LOBYTE(LOWORD(::GetVersion())) == 5 && HIBYTE(LOWORD(::GetVersion())) >= 2) * IS_WIN2000 returns TRUE on 2000, XP and Vista
#define IS_WINXP (IS_NT && (IS_WIN2000 && HIBYTE(LOWORD(::GetVersion())) >= 1) || LOBYTE(LOWORD(::GetVersion())) > 5) * IS_WINXP returns TRUE on XP and Vista
#define IS_WINVISTA (IS_NT && LOBYTE(LOWORD(::GetVersion())) >= 6) * IS_WINVISTA returns TRUE on Vista
#define IS_WIN32S (IS_WIN32 && !IS_NT && LOBYTE(LOWORD(::GetVersion())) < 4) */
#define IS_WIN95 (IS_WIN32 && !IS_NT && LOBYTE(LOWORD(::GetVersion())) >= 4) #define IS_WIN2000 (LOBYTE(LOWORD(::GetVersion())) >= 5)
#define IS_WIN98 (IS_WIN95 && HIBYTE(LOWORD(::GetVersion())) >= 10) #define IS_WINXP ((IS_WIN2000 && HIBYTE(LOWORD(::GetVersion())) >= 1) || LOBYTE(LOWORD(::GetVersion())) > 5)
#define IS_WINME (IS_WIN95 && HIBYTE(LOWORD(::GetVersion())) >= 90) #define IS_WINVISTA (LOBYTE(LOWORD(::GetVersion())) >= 6)
#define IS_WIN4X (IS_WIN32 && LOBYTE(::GetVersion()) >= 4)
#define IS_WINVER_ATLEAST(maj, min) \ #define IS_WINVER_ATLEAST(maj, min) \
((maj) < LOBYTE(LOWORD(::GetVersion())) || \ ((maj) < LOBYTE(LOWORD(::GetVersion())) || \
(maj) == LOBYTE(LOWORD(::GetVersion())) && \ (maj) == LOBYTE(LOWORD(::GetVersion())) && \
...@@ -177,6 +171,12 @@ typedef AwtObject* PDATA; ...@@ -177,6 +171,12 @@ typedef AwtObject* PDATA;
extern JavaVM *jvm; extern JavaVM *jvm;
// Platform encoding is Unicode (UTF-16), re-define JNU_ functions
// to proper JNI functions.
#define JNU_NewStringPlatform(env, x) env->NewString(reinterpret_cast<jchar*>(x), static_cast<jsize>(_tcslen(x)))
#define JNU_GetStringPlatformChars(env, x, y) reinterpret_cast<LPCWSTR>(env->GetStringChars(x, y))
#define JNU_ReleaseStringPlatformChars(env, x, y) env->ReleaseStringChars(x, reinterpret_cast<const jchar*>(y))
/* /*
* Itanium symbols needed for 64-bit compilation. * Itanium symbols needed for 64-bit compilation.
* These are defined in winuser.h in the August 2001 MSDN update. * These are defined in winuser.h in the August 2001 MSDN update.
...@@ -211,17 +211,12 @@ extern JavaVM *jvm; ...@@ -211,17 +211,12 @@ extern JavaVM *jvm;
* NOTE: float.h must be defined if using these macros * NOTE: float.h must be defined if using these macros
*/ */
#define SAVE_CONTROLWORD \ #define SAVE_CONTROLWORD \
unsigned int fpu_cw = _CW_DEFAULT; \ unsigned int fpu_cw = _control87(0, 0);
if (IS_WIN95) { \
fpu_cw = _control87(0, 0); \ #define RESTORE_CONTROLWORD \
} if (_control87(0, 0) != fpu_cw) { \
_control87(fpu_cw, 0xffffffff); \
#define RESTORE_CONTROLWORD \ }
if (IS_WIN95) { \
if ( _control87(0, 0) != fpu_cw) { \
_control87(fpu_cw, 0xfffff); \
} \
}
/* /*
* checks if the current thread is/isn't the toolkit thread * checks if the current thread is/isn't the toolkit thread
......
/* /*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* have any questions. * have any questions.
*/ */
#include <jni.h> #include "awt.h"
#include "awt_Object.h" /* wop_pDataID */ #include "awt_Object.h" /* wop_pDataID */
#include "awt_Toolkit.h" #include "awt_Toolkit.h"
...@@ -106,7 +106,7 @@ AwtButton* AwtButton::Create(jobject self, jobject parent) ...@@ -106,7 +106,7 @@ AwtButton* AwtButton::Create(jobject self, jobject parent)
if (label == NULL) { if (label == NULL) {
labelStr = L""; labelStr = L"";
} else { } else {
labelStr = env->GetStringChars(label, JNI_FALSE); labelStr = JNU_GetStringPlatformChars(env, label, JNI_FALSE);
} }
style = 0; style = 0;
...@@ -128,7 +128,7 @@ AwtButton* AwtButton::Create(jobject self, jobject parent) ...@@ -128,7 +128,7 @@ AwtButton* AwtButton::Create(jobject self, jobject parent)
c->m_backgroundColorSet = TRUE; // suppress inheriting parent's color c->m_backgroundColorSet = TRUE; // suppress inheriting parent's color
c->UpdateBackground(env, target); c->UpdateBackground(env, target);
if (label != NULL) if (label != NULL)
env->ReleaseStringChars(label, labelStr); JNU_ReleaseStringPlatformChars(env, label, labelStr);
} catch (...) { } catch (...) {
env->DeleteLocalRef(target); env->DeleteLocalRef(target);
if (label != NULL) if (label != NULL)
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include "awt_Toolkit.h" #include "awt_Toolkit.h"
#include "awt_Checkbox.h" #include "awt_Checkbox.h"
#include "awt_KeyboardFocusManager.h" #include "awt_KeyboardFocusManager.h"
...@@ -106,7 +107,7 @@ AwtCheckbox* AwtCheckbox::Create(jobject peer, jobject parent) ...@@ -106,7 +107,7 @@ AwtCheckbox* AwtCheckbox::Create(jobject peer, jobject parent)
label = (jstring)env->GetObjectField(target, AwtCheckbox::labelID); label = (jstring)env->GetObjectField(target, AwtCheckbox::labelID);
if (label != NULL) { if (label != NULL) {
labelStr = env->GetStringChars(label, 0); labelStr = JNU_GetStringPlatformChars(env, label, 0);
} }
if (labelStr != 0) { if (labelStr != 0) {
jint x = env->GetIntField(target, AwtComponent::xID); jint x = env->GetIntField(target, AwtComponent::xID);
...@@ -123,7 +124,7 @@ AwtCheckbox* AwtCheckbox::Create(jobject peer, jobject parent) ...@@ -123,7 +124,7 @@ AwtCheckbox* AwtCheckbox::Create(jobject peer, jobject parent)
peer); peer);
if (labelStr != defaultLabelStr) { if (labelStr != defaultLabelStr) {
env->ReleaseStringChars(label, labelStr); JNU_ReleaseStringPlatformChars(env, label, labelStr);
} }
} else { } else {
throw std::bad_alloc(); throw std::bad_alloc();
......
/* /*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -206,7 +206,7 @@ int AwtChoice::GetFieldHeight() ...@@ -206,7 +206,7 @@ int AwtChoice::GetFieldHeight()
fieldHeight =(int)::SendMessage(GetHWnd(), CB_GETITEMHEIGHT, (UINT)-1, 0); fieldHeight =(int)::SendMessage(GetHWnd(), CB_GETITEMHEIGHT, (UINT)-1, 0);
// add top and bottom border lines; border size is different for // add top and bottom border lines; border size is different for
// Win 4.x (3d edge) vs 3.x (1 pixel line) // Win 4.x (3d edge) vs 3.x (1 pixel line)
borderHeight = ::GetSystemMetrics(IS_WIN4X ? SM_CYEDGE : SM_CYBORDER); borderHeight = ::GetSystemMetrics(SM_CYEDGE);
fieldHeight += borderHeight*2; fieldHeight += borderHeight*2;
return fieldHeight; return fieldHeight;
} }
...@@ -424,6 +424,9 @@ AwtChoice::WmKillFocus(HWND hWndGotFocus) ...@@ -424,6 +424,9 @@ AwtChoice::WmKillFocus(HWND hWndGotFocus)
case mrPassAlong: case mrPassAlong:
return AwtComponent::WmKillFocus(hWndGotFocus); return AwtComponent::WmKillFocus(hWndGotFocus);
} }
DASSERT(false); // must never reach here
return mrDoDefault;
} }
MsgRouting MsgRouting
......
/* /*
* Copyright 1996-1999 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -97,7 +97,7 @@ Java_sun_awt_windows_WColor_getDefaultColor(JNIEnv *env, jclass cls, ...@@ -97,7 +97,7 @@ Java_sun_awt_windows_WColor_getDefaultColor(JNIEnv *env, jclass cls,
iColor = COLOR_MENUTEXT; iColor = COLOR_MENUTEXT;
break; break;
case sun_awt_windows_WColor_BUTTON_BKGND: case sun_awt_windows_WColor_BUTTON_BKGND:
iColor = (IS_NT) ? COLOR_BTNFACE : COLOR_3DFACE; iColor = COLOR_BTNFACE;
break; break;
case sun_awt_windows_WColor_BUTTON_TEXT: case sun_awt_windows_WColor_BUTTON_TEXT:
iColor = COLOR_BTNTEXT; iColor = COLOR_BTNTEXT;
......
...@@ -675,10 +675,6 @@ public: ...@@ -675,10 +675,6 @@ public:
static HWND sm_focusOwner; static HWND sm_focusOwner;
static HWND sm_focusedWindow; static HWND sm_focusedWindow;
static BOOL m_isWin95;
static BOOL m_isWin2000;
static BOOL m_isWinNT;
static BOOL sm_bMenuLoop; static BOOL sm_bMenuLoop;
static INLINE BOOL isMenuLoopActive() { static INLINE BOOL isMenuLoopActive() {
return sm_bMenuLoop; return sm_bMenuLoop;
......
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -79,10 +79,6 @@ AwtCursor::AwtCursor(JNIEnv *env, HCURSOR hCur, jobject jCur, int xH, int yH, ...@@ -79,10 +79,6 @@ AwtCursor::AwtCursor(JNIEnv *env, HCURSOR hCur, jobject jCur, int xH, int yH,
custom = TRUE; custom = TRUE;
dirty = FALSE; dirty = FALSE;
if (IsWin95Cursor()) {
customCursors.Add(this);
}
} }
AwtCursor::~AwtCursor() AwtCursor::~AwtCursor()
...@@ -96,9 +92,6 @@ void AwtCursor::Dispose() ...@@ -96,9 +92,6 @@ void AwtCursor::Dispose()
if (custom) { if (custom) {
::DestroyIcon(hCursor); ::DestroyIcon(hCursor);
if (IsWin95Cursor()) {
customCursors.Remove(this);
}
} }
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
...@@ -256,16 +249,6 @@ void AwtCursor::UpdateCursor(AwtComponent *comp) { ...@@ -256,16 +249,6 @@ void AwtCursor::UpdateCursor(AwtComponent *comp) {
env->DeleteLocalRef(jcomp); env->DeleteLocalRef(jcomp);
} }
void AwtCursor::DirtyAllCustomCursors() {
if (IsWin95Cursor()) {
AwtObjectListItem *cur = customCursors.m_head;
while (cur != NULL) {
((AwtCursor *)(cur->obj))->dirty = TRUE;
cur = cur->next;
}
}
}
void AwtCursor::Rebuild() { void AwtCursor::Rebuild() {
if (!dirty) { if (!dirty) {
return; return;
...@@ -294,23 +277,6 @@ void AwtCursor::Rebuild() { ...@@ -294,23 +277,6 @@ void AwtCursor::Rebuild() {
dirty = FALSE; dirty = FALSE;
} }
/* Bug fix for 4205805:
Custom cursor on WIN95 needs more effort, the same API works fine on NT
and WIN98. On Win95, DDB has to be passed in when calling createIconIndirect
Since DDB depends on the DISPLAY, we have to rebuild all the custom cursors
when user changes the display settings.
*/
BOOL AwtCursor::IsWin95Cursor() {
static BOOL val;
static BOOL known = FALSE;
if (!known) {
val = (IS_WIN32 && !IS_NT && LOBYTE(LOWORD(::GetVersion())) == 4 &&
HIBYTE(LOWORD(::GetVersion())) == 0);
known = TRUE;
}
return val;
}
extern "C" { extern "C" {
/************************************************************************ /************************************************************************
......
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -66,7 +66,6 @@ public: ...@@ -66,7 +66,6 @@ public:
} }
static AwtCursor * CreateSystemCursor(jobject jCursor); static AwtCursor * CreateSystemCursor(jobject jCursor);
static void UpdateCursor(AwtComponent *comp); static void UpdateCursor(AwtComponent *comp);
static void DirtyAllCustomCursors();
static HCURSOR GetCursor(JNIEnv *env, AwtComponent *comp); static HCURSOR GetCursor(JNIEnv *env, AwtComponent *comp);
static void setPData(jobject cursor, jlong pdata) { static void setPData(jobject cursor, jlong pdata) {
...@@ -76,7 +75,6 @@ public: ...@@ -76,7 +75,6 @@ public:
private: private:
void Rebuild(); void Rebuild();
static BOOL IsWin95Cursor();
HCURSOR hCursor; HCURSOR hCursor;
jweak jCursor; jweak jCursor;
......
/* /*
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,12 +24,11 @@ ...@@ -24,12 +24,11 @@
*/ */
#include "awt.h" #include "awt.h"
#include "awt_dlls.h"
#include "awt_DataTransferer.h" #include "awt_DataTransferer.h"
#include "awt_DnDDT.h" #include "awt_DnDDT.h"
#include "awt_TextComponent.h" #include "awt_TextComponent.h"
#include "awt_Unicode.h"
#include <shlobj.h> #include <shlobj.h>
#include <shellapi.h>
#include <sun_awt_datatransfer_DataTransferer.h> #include <sun_awt_datatransfer_DataTransferer.h>
#include <sun_awt_windows_WDataTransferer.h> #include <sun_awt_windows_WDataTransferer.h>
...@@ -271,9 +270,7 @@ Java_sun_awt_windows_WDataTransferer_dragQueryFile ...@@ -271,9 +270,7 @@ Java_sun_awt_windows_WDataTransferer_dragQueryFile
hdrop = (HDROP)bBytes; hdrop = (HDROP)bBytes;
load_shell_procs(); UINT nFilenames = ::DragQueryFile(hdrop, 0xFFFFFFFF, NULL, 0);
UINT nFilenames = (*do_drag_query_file)(hdrop, 0xFFFFFFFF, NULL, 0);
jclass str_clazz = env->FindClass("java/lang/String"); jclass str_clazz = env->FindClass("java/lang/String");
DASSERT(str_clazz != NULL); DASSERT(str_clazz != NULL);
...@@ -287,12 +284,12 @@ Java_sun_awt_windows_WDataTransferer_dragQueryFile ...@@ -287,12 +284,12 @@ Java_sun_awt_windows_WDataTransferer_dragQueryFile
buffer = (LPTSTR)safe_Malloc(bufsize*sizeof(TCHAR)); buffer = (LPTSTR)safe_Malloc(bufsize*sizeof(TCHAR));
for (UINT i = 0; i < nFilenames; i++) { for (UINT i = 0; i < nFilenames; i++) {
UINT size = (*do_drag_query_file)(hdrop, i, NULL, 0); UINT size = ::DragQueryFile(hdrop, i, NULL, 0);
if (size > bufsize) { if (size > bufsize) {
bufsize = size; bufsize = size;
buffer = (LPTSTR)safe_Realloc(buffer, bufsize*sizeof(TCHAR)); buffer = (LPTSTR)safe_Realloc(buffer, bufsize*sizeof(TCHAR));
} }
(*do_drag_query_file)(hdrop, i, buffer, bufsize); ::DragQueryFile(hdrop, i, buffer, bufsize);
jstring name = JNU_NewStringPlatform(env, buffer); jstring name = JNU_NewStringPlatform(env, buffer);
if (name == NULL) { if (name == NULL) {
...@@ -454,11 +451,6 @@ Java_sun_awt_windows_WDataTransferer_platformImageBytesToImageData( ...@@ -454,11 +451,6 @@ Java_sun_awt_windows_WDataTransferer_platformImageBytesToImageData(
width = p.x; width = p.x;
height = -p.y; height = -p.y;
// Win9X supports only 16-bit signed coordinates.
if (IS_WIN95) {
if (width > 0x7FFF) { width = 0x7FFF; }
if (height > 0x7FFF) { height = 0x7FFF; }
}
free(lpemh); free(lpemh);
} }
break; break;
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include <jni.h> #include <jni.h>
#include <Windows.h>
#include <shellapi.h> #include <shellapi.h>
#include <float.h> #include <float.h>
...@@ -40,32 +40,32 @@ extern "C" { ...@@ -40,32 +40,32 @@ extern "C" {
JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute
(JNIEnv *env, jclass cls, jstring uri_j, jstring verb_j) (JNIEnv *env, jclass cls, jstring uri_j, jstring verb_j)
{ {
const WCHAR* uri_c = env->GetStringChars(uri_j, JNI_FALSE); LPCWSTR uri_c = JNU_GetStringPlatformChars(env, uri_j, JNI_FALSE);
const WCHAR* verb_c = env->GetStringChars(verb_j, JNI_FALSE); LPCWSTR verb_c = JNU_GetStringPlatformChars(env, verb_j, JNI_FALSE);
// 6457572: ShellExecute possibly changes FPU control word - saving it here // 6457572: ShellExecute possibly changes FPU control word - saving it here
unsigned oldcontrol87 = _control87(0, 0); unsigned oldcontrol87 = _control87(0, 0);
HINSTANCE retval = ShellExecuteW(NULL, verb_c, uri_c, NULL, NULL, SW_SHOWNORMAL); HINSTANCE retval = ::ShellExecute(NULL, verb_c, uri_c, NULL, NULL, SW_SHOWNORMAL);
_control87(oldcontrol87, 0xffffffff); _control87(oldcontrol87, 0xffffffff);
env->ReleaseStringChars(uri_j, uri_c); JNU_ReleaseStringPlatformChars(env, uri_j, uri_c);
env->ReleaseStringChars(verb_j, verb_c); JNU_ReleaseStringPlatformChars(env, verb_j, verb_c);
if ((int)retval <= 32) { if ((int)retval <= 32) {
// ShellExecute failed. // ShellExecute failed.
LPVOID buffer; LPTSTR buffer = NULL;
int len = FormatMessageW( int len = ::FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, NULL,
GetLastError(), GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPWSTR) &buffer, (LPTSTR)&buffer,
0, 0,
NULL ); NULL );
jstring errmsg = env->NewString((LPCWSTR)buffer, len); jstring errmsg = JNU_NewStringPlatform(env, buffer, len);
LocalFree(buffer); LocalFree(buffer);
return errmsg; return errmsg;
} }
......
/* /*
* Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,17 +23,17 @@ ...@@ -23,17 +23,17 @@
* have any questions. * have any questions.
*/ */
#include "stdhdrs.h" #include "awt.h"
#include "mmsystem.h" #include "mmsystem.h"
#include "jlong.h" #include "jlong.h"
#include "awt.h"
#include "awt_DesktopProperties.h" #include "awt_DesktopProperties.h"
#include "awt_dlls.h" #include "awt_Toolkit.h"
#include "sun_awt_windows_WDesktopProperties.h" #include "sun_awt_windows_WDesktopProperties.h"
#include "java_awt_Font.h" #include "java_awt_Font.h"
#include "awtmsg.h" #include "awtmsg.h"
#include "Zmouse.h" #include "zmouse.h"
#include "shellapi.h" #include <shellapi.h>
#include <shlobj.h>
// WDesktopProperties fields // WDesktopProperties fields
jfieldID AwtDesktopProperties::pDataID = 0; jfieldID AwtDesktopProperties::pDataID = 0;
...@@ -44,10 +44,6 @@ jmethodID AwtDesktopProperties::setColorPropertyID = 0; ...@@ -44,10 +44,6 @@ jmethodID AwtDesktopProperties::setColorPropertyID = 0;
jmethodID AwtDesktopProperties::setFontPropertyID = 0; jmethodID AwtDesktopProperties::setFontPropertyID = 0;
jmethodID AwtDesktopProperties::setSoundPropertyID = 0; jmethodID AwtDesktopProperties::setSoundPropertyID = 0;
typedef VOID (WINAPI *SHGetSettingsType)(LPSHELLFLAGSTATE, DWORD);
static HMODULE libShell32 = NULL;
static SHGetSettingsType fn_SHGetSettings;
AwtDesktopProperties::AwtDesktopProperties(jobject self) { AwtDesktopProperties::AwtDesktopProperties(jobject self) {
this->self = GetEnv()->NewGlobalRef(self); this->self = GetEnv()->NewGlobalRef(self);
GetEnv()->SetLongField( self, AwtDesktopProperties::pDataID, GetEnv()->SetLongField( self, AwtDesktopProperties::pDataID,
...@@ -431,14 +427,12 @@ void CheckFontSmoothingSettings(HWND hWnd) { ...@@ -431,14 +427,12 @@ void CheckFontSmoothingSettings(HWND hWnd) {
void AwtDesktopProperties::GetColorParameters() { void AwtDesktopProperties::GetColorParameters() {
if (IS_WIN98 || IS_WIN2000) { SetColorProperty(TEXT("win.frame.activeCaptionGradientColor"),
SetColorProperty(TEXT("win.frame.activeCaptionGradientColor"), GetSysColor(COLOR_GRADIENTACTIVECAPTION));
GetSysColor(COLOR_GRADIENTACTIVECAPTION)); SetColorProperty(TEXT("win.frame.inactiveCaptionGradientColor"),
SetColorProperty(TEXT("win.frame.inactiveCaptionGradientColor"), GetSysColor(COLOR_GRADIENTINACTIVECAPTION));
GetSysColor(COLOR_GRADIENTINACTIVECAPTION)); SetColorProperty(TEXT("win.item.hotTrackedColor"),
SetColorProperty(TEXT("win.item.hotTrackedColor"), GetSysColor(COLOR_HOTLIGHT));
GetSysColor(COLOR_HOTLIGHT));
}
SetColorProperty(TEXT("win.3d.darkShadowColor"), GetSysColor(COLOR_3DDKSHADOW)); SetColorProperty(TEXT("win.3d.darkShadowColor"), GetSysColor(COLOR_3DDKSHADOW));
SetColorProperty(TEXT("win.3d.backgroundColor"), GetSysColor(COLOR_3DFACE)); SetColorProperty(TEXT("win.3d.backgroundColor"), GetSysColor(COLOR_3DFACE));
SetColorProperty(TEXT("win.3d.highlightColor"), GetSysColor(COLOR_3DHIGHLIGHT)); SetColorProperty(TEXT("win.3d.highlightColor"), GetSysColor(COLOR_3DHIGHLIGHT));
...@@ -510,40 +504,18 @@ void AwtDesktopProperties::GetOtherParameters() { ...@@ -510,40 +504,18 @@ void AwtDesktopProperties::GetOtherParameters() {
// This property is called "win.frame.fullWindowDragsOn" above // This property is called "win.frame.fullWindowDragsOn" above
// This is one of the properties that don't trigger WM_SETTINGCHANGE // This is one of the properties that don't trigger WM_SETTINGCHANGE
SetBooleanProperty(TEXT("awt.dynamicLayoutSupported"), GetBooleanParameter(SPI_GETDRAGFULLWINDOWS)); SetBooleanProperty(TEXT("awt.dynamicLayoutSupported"), GetBooleanParameter(SPI_GETDRAGFULLWINDOWS));
SetBooleanProperty(TEXT("awt.wheelMousePresent"),
// 95 MouseWheel support ::GetSystemMetrics(SM_MOUSEWHEELPRESENT));
// More or less copied from the MSH_MOUSEWHEEL MSDN entry
if (IS_WIN95 && !IS_WIN98) {
HWND hdlMSHWHEEL = NULL;
UINT msgMSHWheelSupported = NULL;
BOOL wheelSupported = FALSE;
msgMSHWheelSupported = RegisterWindowMessage(MSH_WHEELSUPPORT);
hdlMSHWHEEL = FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE);
if (hdlMSHWHEEL && msgMSHWheelSupported) {
wheelSupported = (BOOL)::SendMessage(hdlMSHWHEEL,
msgMSHWheelSupported, 0, 0);
}
SetBooleanProperty(TEXT("awt.wheelMousePresent"), wheelSupported);
}
else {
SetBooleanProperty(TEXT("awt.wheelMousePresent"),
::GetSystemMetrics(SM_MOUSEWHEELPRESENT));
}
// END cross-platform properties // END cross-platform properties
if (IS_WIN98 || IS_WIN2000) { //DWORD menuShowDelay;
//DWORD menuShowDelay; //SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &menuShowDelay, 0);
//SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &menuShowDelay, 0); // SetIntegerProperty(TEXT("win.menu.showDelay"), menuShowDelay);
// SetIntegerProperty(TEXT("win.menu.showDelay"), menuShowDelay); SetBooleanProperty(TEXT("win.frame.captionGradientsOn"), GetBooleanParameter(SPI_GETGRADIENTCAPTIONS));
SetBooleanProperty(TEXT("win.frame.captionGradientsOn"), GetBooleanParameter(SPI_GETGRADIENTCAPTIONS)); SetBooleanProperty(TEXT("win.item.hotTrackingOn"), GetBooleanParameter(SPI_GETHOTTRACKING));
SetBooleanProperty(TEXT("win.item.hotTrackingOn"), GetBooleanParameter(SPI_GETHOTTRACKING));
}
if (IS_WIN2000) { SetBooleanProperty(TEXT("win.menu.keyboardCuesOn"), GetBooleanParameter(SPI_GETKEYBOARDCUES));
SetBooleanProperty(TEXT("win.menu.keyboardCuesOn"), GetBooleanParameter(SPI_GETKEYBOARDCUES));
}
// High contrast accessibility property // High contrast accessibility property
HIGHCONTRAST contrast; HIGHCONTRAST contrast;
...@@ -557,21 +529,19 @@ void AwtDesktopProperties::GetOtherParameters() { ...@@ -557,21 +529,19 @@ void AwtDesktopProperties::GetOtherParameters() {
SetBooleanProperty(TEXT("win.highContrast.on"), FALSE); SetBooleanProperty(TEXT("win.highContrast.on"), FALSE);
} }
if (fn_SHGetSettings != NULL) { SHELLFLAGSTATE sfs;
SHELLFLAGSTATE sfs; ::SHGetSettings(&sfs, SSF_SHOWALLOBJECTS | SSF_SHOWATTRIBCOL);
fn_SHGetSettings(&sfs, SSF_SHOWALLOBJECTS | SSF_SHOWATTRIBCOL); if (sfs.fShowAllObjects) {
if (sfs.fShowAllObjects) { SetBooleanProperty(TEXT("awt.file.showHiddenFiles"), TRUE);
SetBooleanProperty(TEXT("awt.file.showHiddenFiles"), TRUE); }
} else {
else { SetBooleanProperty(TEXT("awt.file.showHiddenFiles"), FALSE);
SetBooleanProperty(TEXT("awt.file.showHiddenFiles"), FALSE); }
} if (sfs.fShowAttribCol) {
if (sfs.fShowAttribCol) { SetBooleanProperty(TEXT("awt.file.showAttribCol"), TRUE);
SetBooleanProperty(TEXT("awt.file.showAttribCol"), TRUE); }
} else {
else { SetBooleanProperty(TEXT("awt.file.showAttribCol"), FALSE);
SetBooleanProperty(TEXT("awt.file.showAttribCol"), FALSE);
}
} }
LPTSTR value; LPTSTR value;
...@@ -667,7 +637,7 @@ UINT AwtDesktopProperties::GetIntegerParameter(UINT spi) { ...@@ -667,7 +637,7 @@ UINT AwtDesktopProperties::GetIntegerParameter(UINT spi) {
} }
void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) { void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setStringPropertyID, AwtDesktopProperties::setStringPropertyID,
key, JNU_NewStringPlatform(GetEnv(), value)); key, JNU_NewStringPlatform(GetEnv(), value));
...@@ -675,7 +645,7 @@ void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) { ...@@ -675,7 +645,7 @@ void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) {
} }
void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) { void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setIntegerPropertyID, AwtDesktopProperties::setIntegerPropertyID,
key, (jint)value); key, (jint)value);
...@@ -683,7 +653,7 @@ void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) { ...@@ -683,7 +653,7 @@ void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
} }
void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) { void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setBooleanPropertyID, AwtDesktopProperties::setBooleanPropertyID,
key, value ? JNI_TRUE : JNI_FALSE); key, value ? JNI_TRUE : JNI_FALSE);
...@@ -691,7 +661,7 @@ void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) { ...@@ -691,7 +661,7 @@ void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) {
} }
void AwtDesktopProperties::SetColorProperty(LPCTSTR propName, DWORD value) { void AwtDesktopProperties::SetColorProperty(LPCTSTR propName, DWORD value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setColorPropertyID, AwtDesktopProperties::setColorPropertyID,
key, GetRValue(value), GetGValue(value), key, GetRValue(value), GetGValue(value),
...@@ -743,7 +713,7 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID, ...@@ -743,7 +713,7 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
style |= java_awt_Font_ITALIC; style |= java_awt_Font_ITALIC;
} }
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setFontPropertyID, AwtDesktopProperties::setFontPropertyID,
key, fontName, style, pointSize); key, fontName, style, pointSize);
...@@ -761,7 +731,7 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon ...@@ -761,7 +731,7 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
jint pointSize; jint pointSize;
jint style; jint style;
fontName = JNU_NewStringPlatform(GetEnv(), font.lfFaceName); fontName = JNU_NewStringPlatform(GetEnv(), const_cast<LPWSTR>(font.lfFaceName));
#if 0 #if 0
HDC hdc; HDC hdc;
...@@ -784,7 +754,7 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon ...@@ -784,7 +754,7 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
style |= java_awt_Font_ITALIC; style |= java_awt_Font_ITALIC;
} }
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
GetEnv()->CallVoidMethod(self, AwtDesktopProperties::setFontPropertyID, GetEnv()->CallVoidMethod(self, AwtDesktopProperties::setFontPropertyID,
key, fontName, style, pointSize); key, fontName, style, pointSize);
...@@ -793,8 +763,8 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon ...@@ -793,8 +763,8 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
} }
void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventName) { void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventName) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName); jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
jstring event = JNU_NewStringPlatform(GetEnv(), winEventName); jstring event = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(winEventName));
GetEnv()->CallVoidMethod(self, GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setSoundPropertyID, AwtDesktopProperties::setSoundPropertyID,
key, event); key, event);
...@@ -805,9 +775,9 @@ void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventNa ...@@ -805,9 +775,9 @@ void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventNa
void AwtDesktopProperties::PlayWindowsSound(LPCTSTR event) { void AwtDesktopProperties::PlayWindowsSound(LPCTSTR event) {
// stop any currently playing sounds // stop any currently playing sounds
AwtWinMM::PlaySoundWrapper(NULL, NULL, SND_PURGE); ::PlaySound(NULL, NULL, SND_PURGE);
// play the sound for the given event name // play the sound for the given event name
AwtWinMM::PlaySoundWrapper(event, NULL, SND_ASYNC|SND_ALIAS|SND_NODEFAULT); ::PlaySound(event, NULL, SND_ASYNC|SND_ALIAS|SND_NODEFAULT);
} }
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -852,16 +822,6 @@ JNIEXPORT void JNICALL ...@@ -852,16 +822,6 @@ JNIEXPORT void JNICALL
Java_sun_awt_windows_WDesktopProperties_init(JNIEnv *env, jobject self) { Java_sun_awt_windows_WDesktopProperties_init(JNIEnv *env, jobject self) {
TRY; TRY;
// Open shell32.dll, get the symbol for SHGetSettings
libShell32 = LoadLibrary(TEXT("shell32.dll"));
if (libShell32 == NULL) {
fn_SHGetSettings = NULL;
}
else {
fn_SHGetSettings = (SHGetSettingsType)GetProcAddress(
libShell32, "SHGetSettings");
}
new AwtDesktopProperties(self); new AwtDesktopProperties(self);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
......
...@@ -132,14 +132,13 @@ AwtDialog* AwtDialog::Create(jobject peer, jobject parent) ...@@ -132,14 +132,13 @@ AwtDialog* AwtDialog::Create(jobject peer, jobject parent)
dialog = new AwtDialog(); dialog = new AwtDialog();
{ {
int colorId = IS_WIN4X ? COLOR_3DFACE : COLOR_WINDOW; int colorId = COLOR_3DFACE;
DWORD style = WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN; DWORD style = WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN;
if (hwndParent != NULL) { if (hwndParent != NULL) {
style |= WS_POPUP; style |= WS_POPUP;
} }
style &= ~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX); style &= ~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX);
DWORD exStyle = IS_WIN4X ? WS_EX_WINDOWEDGE | WS_EX_DLGMODALFRAME DWORD exStyle = WS_EX_WINDOWEDGE | WS_EX_DLGMODALFRAME;
: 0;
if (GetRTL()) { if (GetRTL()) {
exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR; exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR;
...@@ -663,7 +662,7 @@ void AwtDialog::_SetIMMOption(void *param) ...@@ -663,7 +662,7 @@ void AwtDialog::_SetIMMOption(void *param)
int badAlloc = 0; int badAlloc = 0;
LPCTSTR coption; LPCTSTR coption;
LPTSTR empty = TEXT("InputMethod"); LPCTSTR empty = TEXT("InputMethod");
AwtDialog *d = NULL; AwtDialog *d = NULL;
PDATA pData; PDATA pData;
......
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include "jlong.h" #include "jlong.h"
#include "awt_DataTransferer.h" #include "awt_DataTransferer.h"
#include "awt_DnDDS.h" #include "awt_DnDDS.h"
...@@ -36,8 +37,6 @@ ...@@ -36,8 +37,6 @@
#include "sun_awt_dnd_SunDragSourceContextPeer.h" #include "sun_awt_dnd_SunDragSourceContextPeer.h"
#include "sun_awt_windows_WDragSourceContextPeer.h" #include "sun_awt_windows_WDragSourceContextPeer.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h> #include <memory.h>
#include <shlobj.h> #include <shlobj.h>
......
/* /*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -30,11 +30,8 @@ ...@@ -30,11 +30,8 @@
#include "awt_Toolkit.h" #include "awt_Toolkit.h"
#include "java_awt_dnd_DnDConstants.h" #include "java_awt_dnd_DnDConstants.h"
#include "sun_awt_windows_WDropTargetContextPeer.h" #include "sun_awt_windows_WDropTargetContextPeer.h"
#include "awt_dlls.h"
#include "awt_Container.h" #include "awt_Container.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h> #include <memory.h>
#include <shellapi.h> #include <shellapi.h>
...@@ -555,8 +552,7 @@ jobject AwtDropTarget::GetData(jlong fmt) { ...@@ -555,8 +552,7 @@ jobject AwtDropTarget::GetData(jlong fmt) {
break; break;
} }
case TYMED_FILE: { case TYMED_FILE: {
jobject local = JNU_NewStringPlatform(env, (LPCTSTR) jobject local = JNU_NewStringPlatform(env, stgmedium.lpszFileName);
stgmedium.lpszFileName);
jstring fileName = (jstring)env->NewGlobalRef(local); jstring fileName = (jstring)env->NewGlobalRef(local);
env->DeleteLocalRef(local); env->DeleteLocalRef(local);
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
*/ */
#define _JNI_IMPLEMENTATION_ #define _JNI_IMPLEMENTATION_
#include "awt.h"
#include "awt_DrawingSurface.h" #include "awt_DrawingSurface.h"
#include "awt_Component.h" #include "awt_Component.h"
......
/* /*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "awt_FileDialog.h" #include "awt_FileDialog.h"
#include "awt_Dialog.h" #include "awt_Dialog.h"
#include "awt_Toolkit.h" #include "awt_Toolkit.h"
#include "awt_dlls.h"
#include "ComCtl32Util.h" #include "ComCtl32Util.h"
#include <commdlg.h> #include <commdlg.h>
#include <cderr.h> #include <cderr.h>
...@@ -65,7 +64,7 @@ AwtFileDialog::Initialize(JNIEnv *env, jstring filterDescription) ...@@ -65,7 +64,7 @@ AwtFileDialog::Initialize(JNIEnv *env, jstring filterDescription)
{ {
int length = env->GetStringLength(filterDescription); int length = env->GetStringLength(filterDescription);
DASSERT(length + 1 < MAX_FILTER_STRING); DASSERT(length + 1 < MAX_FILTER_STRING);
LPCTSTR tmp = (LPTSTR)JNU_GetStringPlatformChars(env, filterDescription, NULL); LPCTSTR tmp = JNU_GetStringPlatformChars(env, filterDescription, NULL);
_tcscpy(s_fileFilterString, tmp); _tcscpy(s_fileFilterString, tmp);
JNU_ReleaseStringPlatformChars(env, filterDescription, tmp); JNU_ReleaseStringPlatformChars(env, filterDescription, tmp);
...@@ -156,7 +155,7 @@ FileDialogHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) ...@@ -156,7 +155,7 @@ FileDialogHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
LPITEMIDLIST pidl = (LPITEMIDLIST)notifyEx->pidl; LPITEMIDLIST pidl = (LPITEMIDLIST)notifyEx->pidl;
// Get the filename and directory // Get the filename and directory
TCHAR szPath[MAX_PATH]; TCHAR szPath[MAX_PATH];
if (!get_path_from_idlist(pidl,szPath)) { if (!::SHGetPathFromIDList(pidl, szPath)) {
return TRUE; return TRUE;
} }
jstring strPath = JNU_NewStringPlatform(env, szPath); jstring strPath = JNU_NewStringPlatform(env, szPath);
...@@ -190,7 +189,7 @@ AwtFileDialog::Show(void *p) ...@@ -190,7 +189,7 @@ AwtFileDialog::Show(void *p)
WCHAR unicodeChar = L' '; WCHAR unicodeChar = L' ';
LPTSTR fileBuffer = NULL; LPTSTR fileBuffer = NULL;
LPTSTR currentDirectory = NULL; LPTSTR currentDirectory = NULL;
AWTOPENFILENAME ofn; OPENFILENAME ofn;
jint mode = 0; jint mode = 0;
BOOL result = FALSE; BOOL result = FALSE;
DWORD dlgerr; DWORD dlgerr;
...@@ -222,7 +221,7 @@ AwtFileDialog::Show(void *p) ...@@ -222,7 +221,7 @@ AwtFileDialog::Show(void *p)
HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL; HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL;
if (title == NULL || env->GetStringLength(title)==0) { if (title == NULL || env->GetStringLength(title)==0) {
title = env->NewString(&unicodeChar, 1); title = JNU_NewStringPlatform(env, &unicodeChar);
} }
JavaStringBuffer titleBuffer(env, title); JavaStringBuffer titleBuffer(env, title);
...@@ -243,14 +242,7 @@ AwtFileDialog::Show(void *p) ...@@ -243,14 +242,7 @@ AwtFileDialog::Show(void *p)
memset(&ofn, 0, sizeof(ofn)); memset(&ofn, 0, sizeof(ofn));
// According to the MSDN docs, lStructSize must be set to
// OPENFILENAME_SIZE_VERSION_400 on NT4.0.
if (IS_NT && !(IS_WIN2000)) {
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
}
else {
ofn.lStructSize = sizeof(ofn); ofn.lStructSize = sizeof(ofn);
}
ofn.lpstrFilter = s_fileFilterString; ofn.lpstrFilter = s_fileFilterString;
ofn.nFilterIndex = 1; ofn.nFilterIndex = 1;
/* /*
...@@ -289,9 +281,6 @@ AwtFileDialog::Show(void *p) ...@@ -289,9 +281,6 @@ AwtFileDialog::Show(void *p)
mode = env->GetIntField(target, AwtFileDialog::modeID); mode = env->GetIntField(target, AwtFileDialog::modeID);
// Fix for 4364256 : call load_shell_procs()
load_shell_procs();
AwtDialog::CheckInstallModalHook(); AwtDialog::CheckInstallModalHook();
// show the Win32 file dialog // show the Win32 file dialog
...@@ -304,7 +293,7 @@ AwtFileDialog::Show(void *p) ...@@ -304,7 +293,7 @@ AwtFileDialog::Show(void *p)
// If the dialog is not shown because of invalid file name // If the dialog is not shown because of invalid file name
// replace the file name by empty string. // replace the file name by empty string.
if (!result) { if (!result) {
dlgerr = AwtCommDialog::CommDlgExtendedError(); dlgerr = ::CommDlgExtendedError();
if (dlgerr == FNERR_INVALIDFILENAME) { if (dlgerr == FNERR_INVALIDFILENAME) {
_tcscpy(fileBuffer, TEXT("")); _tcscpy(fileBuffer, TEXT(""));
if (mode == java_awt_FileDialog_LOAD) { if (mode == java_awt_FileDialog_LOAD) {
...@@ -326,7 +315,7 @@ AwtFileDialog::Show(void *p) ...@@ -326,7 +315,7 @@ AwtFileDialog::Show(void *p)
// Report result to peer. // Report result to peer.
if (result) { if (result) {
jstring tmpJString = (_tcslen(ofn.lpstrFile) == 0 ? jstring tmpJString = (_tcslen(ofn.lpstrFile) == 0 ?
env->NewStringUTF("") : JNU_NewStringPlatform(env, L"") :
JNU_NewStringPlatform(env, ofn.lpstrFile)); JNU_NewStringPlatform(env, ofn.lpstrFile));
env->CallVoidMethod(peer, AwtFileDialog::handleSelectedMID, tmpJString); env->CallVoidMethod(peer, AwtFileDialog::handleSelectedMID, tmpJString);
env->DeleteLocalRef(tmpJString); env->DeleteLocalRef(tmpJString);
...@@ -362,20 +351,18 @@ AwtFileDialog::Show(void *p) ...@@ -362,20 +351,18 @@ AwtFileDialog::Show(void *p)
} }
BOOL BOOL
AwtFileDialog::GetOpenFileName(LPAWTOPENFILENAME data) { AwtFileDialog::GetOpenFileName(LPOPENFILENAME data) {
AwtCommDialog::load_comdlg_procs();
return static_cast<BOOL>(reinterpret_cast<INT_PTR>( return static_cast<BOOL>(reinterpret_cast<INT_PTR>(
AwtToolkit::GetInstance().InvokeFunction((void*(*)(void*)) AwtToolkit::GetInstance().InvokeFunction((void*(*)(void*))
AwtCommDialog::GetOpenFileNameWrapper, data))); ::GetOpenFileName, data)));
} }
BOOL BOOL
AwtFileDialog::GetSaveFileName(LPAWTOPENFILENAME data) { AwtFileDialog::GetSaveFileName(LPOPENFILENAME data) {
AwtCommDialog::load_comdlg_procs();
return static_cast<BOOL>(reinterpret_cast<INT_PTR>( return static_cast<BOOL>(reinterpret_cast<INT_PTR>(
AwtToolkit::GetInstance().InvokeFunction((void *(*)(void *)) AwtToolkit::GetInstance().InvokeFunction((void *(*)(void *))
AwtCommDialog::GetSaveFileNameWrapper, data))); ::GetSaveFileName, data)));
} }
......
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -36,43 +36,6 @@ ...@@ -36,43 +36,6 @@
#include "java_awt_FileDialog.h" #include "java_awt_FileDialog.h"
#include "sun_awt_windows_WFileDialogPeer.h" #include "sun_awt_windows_WFileDialogPeer.h"
// The VC6 headers don't include this, but it's necessary for
// backward-compatibility with NT4.0, so we fake it.
#ifndef OPENFILENAME_SIZE_VERSION_400
// Determined via sizeof(OPENFILENAME)
#define OPENFILENAME_SIZE_VERSION_400 76
#endif
// 4859390
// For the Places Bar to show up, we need the "full" OPENFILENAME struct
typedef struct tagAWTOFN {
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCTSTR lpstrFilter;
LPTSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPTSTR lpstrFile;
DWORD nMaxFile;
LPTSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCTSTR lpstrInitialDir;
LPCTSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCTSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
//#if (_WIN32_WINNT >= 0x0500)
void * pvReserved;
DWORD dwReserved;
DWORD FlagsEx;
//#endif // (_WIN32_WINNT >= 0x0500)
} AWTOPENFILENAME, *LPAWTOPENFILENAME;
/************************************************************************ /************************************************************************
* AwtFileDialog class * AwtFileDialog class
*/ */
...@@ -96,8 +59,8 @@ public: ...@@ -96,8 +59,8 @@ public:
static void Initialize(JNIEnv *env, jstring filterDescription); static void Initialize(JNIEnv *env, jstring filterDescription);
static void Show(void *peer); static void Show(void *peer);
static BOOL GetOpenFileName(LPAWTOPENFILENAME); static BOOL GetOpenFileName(LPOPENFILENAME);
static BOOL GetSaveFileName(LPAWTOPENFILENAME); static BOOL GetSaveFileName(LPOPENFILENAME);
virtual BOOL InheritsNativeMouseWheelBehavior(); virtual BOOL InheritsNativeMouseWheelBehavior();
......
/* /*
* Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include <math.h> #include <math.h>
#include "jlong.h" #include "jlong.h"
#include "awt_Font.h" #include "awt_Font.h"
...@@ -195,7 +196,7 @@ AwtFont* AwtFont::GetFont(JNIEnv *env, jobject font, ...@@ -195,7 +196,7 @@ AwtFont* AwtFont::GetFont(JNIEnv *env, jobject font,
} }
// Get suitable CHARSET from charset string provided by font configuration. // Get suitable CHARSET from charset string provided by font configuration.
static int GetNativeCharset(WCHAR* name) static int GetNativeCharset(LPCWSTR name)
{ {
if (wcsstr(name, L"ANSI_CHARSET")) if (wcsstr(name, L"ANSI_CHARSET"))
return ANSI_CHARSET; return ANSI_CHARSET;
...@@ -259,7 +260,7 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) ...@@ -259,7 +260,7 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale)
cfnum = 0; cfnum = 0;
} }
WCHAR* wName; LPCWSTR wName;
awtFont = new AwtFont(cfnum, env, font); awtFont = new AwtFont(cfnum, env, font);
...@@ -269,9 +270,7 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) ...@@ -269,9 +270,7 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale)
if (cfnum > 0) { if (cfnum > 0) {
// Ask peer class for the text component font name // Ask peer class for the text component font name
jstring jTextComponentFontName = GetTextComponentFontName(env, font); jstring jTextComponentFontName = GetTextComponentFontName(env, font);
WCHAR* textComponentFontName = TO_WSTRING(jTextComponentFontName); LPCWSTR textComponentFontName = JNU_GetStringPlatformChars(env, jTextComponentFontName, NULL);
env->DeleteLocalRef(jTextComponentFontName);
awtFont->m_textInput = -1; awtFont->m_textInput = -1;
for (int i = 0; i < cfnum; i++) { for (int i = 0; i < cfnum; i++) {
...@@ -282,13 +281,13 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) ...@@ -282,13 +281,13 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale)
jstring nativeName = jstring nativeName =
(jstring)env->GetObjectField(fontDescriptor, (jstring)env->GetObjectField(fontDescriptor,
AwtFont::nativeNameID); AwtFont::nativeNameID);
wName = TO_WSTRING(nativeName); wName = JNU_GetStringPlatformChars(env, nativeName, NULL);
DASSERT(wName); DASSERT(wName);
//On NT platforms, if the font is not Symbol or Dingbats //On NT platforms, if the font is not Symbol or Dingbats
//use "W" version of Win32 APIs directly, info the FontDescription //use "W" version of Win32 APIs directly, info the FontDescription
//no need to convert characters from Unicode to locale encodings. //no need to convert characters from Unicode to locale encodings.
if (IS_NT && GetNativeCharset(wName) != SYMBOL_CHARSET) { if (GetNativeCharset(wName) != SYMBOL_CHARSET) {
env->SetBooleanField(fontDescriptor, AwtFont::useUnicodeID, TRUE); env->SetBooleanField(fontDescriptor, AwtFont::useUnicodeID, TRUE);
} }
...@@ -299,10 +298,12 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) ...@@ -299,10 +298,12 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale)
(wcscmp(wName, textComponentFontName) == 0)) { (wcscmp(wName, textComponentFontName) == 0)) {
awtFont->m_textInput = i; awtFont->m_textInput = i;
} }
HFONT hfonttmp = CreateHFont(wName, fontStyle, fontSize, HFONT hfonttmp = CreateHFont(const_cast<LPWSTR>(wName), fontStyle, fontSize,
angle, awScale); angle, awScale);
awtFont->m_hFont[i] = hfonttmp; awtFont->m_hFont[i] = hfonttmp;
JNU_ReleaseStringPlatformChars(env, nativeName, wName);
env->DeleteLocalRef(fontDescriptor); env->DeleteLocalRef(fontDescriptor);
env->DeleteLocalRef(nativeName); env->DeleteLocalRef(nativeName);
} }
...@@ -311,11 +312,14 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) ...@@ -311,11 +312,14 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale)
// to first component // to first component
awtFont->m_textInput = 0; awtFont->m_textInput = 0;
} }
JNU_ReleaseStringPlatformChars(env, jTextComponentFontName, textComponentFontName);
env->DeleteLocalRef(jTextComponentFontName);
} else { } else {
// Instantiation for English version. // Instantiation for English version.
jstring fontName = (jstring)env->GetObjectField(font, jstring fontName = (jstring)env->GetObjectField(font,
AwtFont::nameID); AwtFont::nameID);
wName = TO_WSTRING(fontName); wName = JNU_GetStringPlatformChars(env, fontName, NULL);
WCHAR* wEName; WCHAR* wEName;
if (!wcscmp(wName, L"Helvetica") || !wcscmp(wName, L"SansSerif")) { if (!wcscmp(wName, L"Helvetica") || !wcscmp(wName, L"SansSerif")) {
...@@ -338,6 +342,9 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale) ...@@ -338,6 +342,9 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale)
awtFont->m_textInput = 0; awtFont->m_textInput = 0;
awtFont->m_hFont[0] = CreateHFont(wEName, fontStyle, fontSize, awtFont->m_hFont[0] = CreateHFont(wEName, fontStyle, fontSize,
angle, awScale); angle, awScale);
JNU_ReleaseStringPlatformChars(env, fontName, wName);
env->DeleteLocalRef(fontName); env->DeleteLocalRef(fontName);
} }
/* The several callers of this method also set the pData field. /* The several callers of this method also set the pData field.
...@@ -381,7 +388,7 @@ static void strip_tail(wchar_t* text, wchar_t* tail) { // strips tail and any po ...@@ -381,7 +388,7 @@ static void strip_tail(wchar_t* text, wchar_t* tail) { // strips tail and any po
} }
static HFONT CreateHFont_sub(WCHAR* name, int style, int height, static HFONT CreateHFont_sub(LPCWSTR name, int style, int height,
int angle=0, float awScale=1.0f) int angle=0, float awScale=1.0f)
{ {
LOGFONTW logFont; LOGFONTW logFont;
...@@ -420,18 +427,7 @@ static HFONT CreateHFont_sub(WCHAR* name, int style, int height, ...@@ -420,18 +427,7 @@ static HFONT CreateHFont_sub(WCHAR* name, int style, int height,
strip_tail(tmpname,L"Italic"); strip_tail(tmpname,L"Italic");
strip_tail(tmpname,L"Bold"); strip_tail(tmpname,L"Bold");
wcscpy(&(logFont.lfFaceName[0]), tmpname); wcscpy(&(logFont.lfFaceName[0]), tmpname);
HFONT hFont; HFONT hFont = ::CreateFontIndirect(&logFont);
if (IS_WIN95) {
#ifdef WIN32
DASSERT(IS_WIN95);
#endif
HDC hdc = ::GetDC(NULL);
::EnumFontFamiliesEx(hdc, &logFont, (FONTENUMPROC)FindFamilyName,
(LPARAM)tmpname, 0L);
::ReleaseDC(NULL, hdc);
wcscpy(&logFont.lfFaceName[0], tmpname);
}
hFont = ::CreateFontIndirectW(&logFont);
DASSERT(hFont != NULL); DASSERT(hFont != NULL);
// get a expanded or condensed version if its specified. // get a expanded or condensed version if its specified.
if (awScale != 1.0f) { if (awScale != 1.0f) {
...@@ -446,7 +442,7 @@ static HFONT CreateHFont_sub(WCHAR* name, int style, int height, ...@@ -446,7 +442,7 @@ static HFONT CreateHFont_sub(WCHAR* name, int style, int height,
} }
avgWidth = tm.tmAveCharWidth; avgWidth = tm.tmAveCharWidth;
logFont.lfWidth = (LONG)((fabs)(avgWidth*awScale)); logFont.lfWidth = (LONG)((fabs)(avgWidth*awScale));
hFont = CreateFontIndirectW(&logFont); hFont = ::CreateFontIndirect(&logFont);
DASSERT(hFont != NULL); DASSERT(hFont != NULL);
VERIFY(::ReleaseDC(0, hDC)); VERIFY(::ReleaseDC(0, hDC));
} }
...@@ -460,15 +456,8 @@ HFONT AwtFont::CreateHFont(WCHAR* name, int style, int height, ...@@ -460,15 +456,8 @@ HFONT AwtFont::CreateHFont(WCHAR* name, int style, int height,
WCHAR longName[80]; WCHAR longName[80];
// 80 > (max face name(=30) + strlen("CHINESEBIG5_CHARSET")) // 80 > (max face name(=30) + strlen("CHINESEBIG5_CHARSET"))
// longName doesn't have to be printable. So, it is OK not to convert. // longName doesn't have to be printable. So, it is OK not to convert.
if (IS_NT) {
//wsprintfW only works on NT. See bugid 4123362 wsprintf(longName, L"%ls-%d-%d", name, style, height);
wsprintfW(longName, L"%ls-%d-%d", name, style, height);
} else {
#ifdef WIN32
DASSERT(IS_WIN95);
#endif
swprintf(longName, L"%ls-%d-%d", name, style, height);
}
HFONT hFont = NULL; HFONT hFont = NULL;
...@@ -682,28 +671,16 @@ SIZE AwtFont::DrawStringSize_sub(jstring str, HDC hDC, ...@@ -682,28 +671,16 @@ SIZE AwtFont::DrawStringSize_sub(jstring str, HDC hDC,
if (arrayLength == 0) { if (arrayLength == 0) {
int length = env->GetStringLength(str); int length = env->GetStringLength(str);
WCHAR* string = TO_WSTRING(str); LPCWSTR strW = JNU_GetStringPlatformChars(env, str, NULL);
VERIFY(::SelectObject(hDC, awtFont->GetHFont())); VERIFY(::SelectObject(hDC, awtFont->GetHFont()));
if (AwtComponent::GetRTLReadingOrder()){ if (AwtComponent::GetRTLReadingOrder()){
if (IS_WIN95) { VERIFY(!draw || ::ExtTextOut(hDC, x, y, ETO_RTLREADING, NULL,
// Start of conversion Code to fix arabic shaping problems strW, length, NULL));
// with unicode support in win 95
LPSTR buffer = (LPSTR) alloca((wcslen(string) + 1) * 2);
int count = ::WideCharToMultiByte(codePage, 0, string, length,
buffer,
static_cast<int>((wcslen(string) + 1) * 2),
NULL, NULL);
VERIFY(!draw || ::ExtTextOutA(hDC, x, y, ETO_RTLREADING, NULL,
buffer, count, NULL));
// End Of Conversion Code
} else {
VERIFY(!draw || ::ExtTextOutW(hDC, x, y, ETO_RTLREADING, NULL,
string, length, NULL));
}
} else { } else {
VERIFY(!draw || ::TextOutW(hDC, x, y, string, length)); VERIFY(!draw || ::TextOut(hDC, x, y, strW, length));
} }
VERIFY(::GetTextExtentPoint32W(hDC, string, length, &size)); VERIFY(::GetTextExtentPoint32(hDC, strW, length, &size));
JNU_ReleaseStringPlatformChars(env, str, strW);
} else { } else {
for (int i = 0; i < arrayLength; i = i + 2) { for (int i = 0; i < arrayLength; i = i + 2) {
jobject fontDescriptor = env->GetObjectArrayElement(array, i); jobject fontDescriptor = env->GetObjectArrayElement(array, i);
...@@ -732,7 +709,7 @@ SIZE AwtFont::DrawStringSize_sub(jstring str, HDC hDC, ...@@ -732,7 +709,7 @@ SIZE AwtFont::DrawStringSize_sub(jstring str, HDC hDC,
* extend buflen and bad things will happen. * extend buflen and bad things will happen.
*/ */
unsigned char* buffer = NULL; unsigned char* buffer = NULL;
jboolean unicodeUsed = env->GetBooleanField(fontDescriptor,AwtFont::useUnicodeID); jboolean unicodeUsed = env->GetBooleanField(fontDescriptor, AwtFont::useUnicodeID);
try { try {
buffer = (unsigned char *) buffer = (unsigned char *)
env->GetPrimitiveArrayCritical(convertedBytes, 0); env->GetPrimitiveArrayCritical(convertedBytes, 0);
...@@ -1231,7 +1208,7 @@ class CSegTableComponent ...@@ -1231,7 +1208,7 @@ class CSegTableComponent
public: public:
CSegTableComponent(); CSegTableComponent();
virtual ~CSegTableComponent(); virtual ~CSegTableComponent();
virtual void Create(LPWSTR name); virtual void Create(LPCWSTR name);
virtual BOOL In(USHORT iChar) { DASSERT(FALSE); return FALSE; }; virtual BOOL In(USHORT iChar) { DASSERT(FALSE); return FALSE; };
LPWSTR GetFontName(){ LPWSTR GetFontName(){
DASSERT(m_lpszFontName != NULL); return m_lpszFontName; DASSERT(m_lpszFontName != NULL); return m_lpszFontName;
...@@ -1254,7 +1231,7 @@ CSegTableComponent::~CSegTableComponent() ...@@ -1254,7 +1231,7 @@ CSegTableComponent::~CSegTableComponent()
} }
} }
void CSegTableComponent::Create(LPWSTR name) void CSegTableComponent::Create(LPCWSTR name)
{ {
if (m_lpszFontName != NULL) { if (m_lpszFontName != NULL) {
free(m_lpszFontName); free(m_lpszFontName);
...@@ -1453,7 +1430,7 @@ public: ...@@ -1453,7 +1430,7 @@ public:
CStdSegTable(); CStdSegTable();
virtual ~CStdSegTable(); virtual ~CStdSegTable();
BOOL IsEUDC() { return FALSE; }; BOOL IsEUDC() { return FALSE; };
virtual void Create(LPWSTR name); virtual void Create(LPCWSTR name);
protected: protected:
void GetData(DWORD dwOffset, LPVOID lpData, DWORD cbData); void GetData(DWORD dwOffset, LPVOID lpData, DWORD cbData);
...@@ -1481,7 +1458,7 @@ inline void CStdSegTable::GetData(DWORD dwOffset, ...@@ -1481,7 +1458,7 @@ inline void CStdSegTable::GetData(DWORD dwOffset,
DASSERT(nBytes != GDI_ERROR); DASSERT(nBytes != GDI_ERROR);
} }
void CStdSegTable::Create(LPWSTR name) void CStdSegTable::Create(LPCWSTR name)
{ {
CSegTableComponent::Create(name); CSegTableComponent::Create(name);
...@@ -1509,7 +1486,7 @@ public: ...@@ -1509,7 +1486,7 @@ public:
CEUDCSegTable(); CEUDCSegTable();
virtual ~CEUDCSegTable(); virtual ~CEUDCSegTable();
BOOL IsEUDC() { return TRUE; }; BOOL IsEUDC() { return TRUE; };
virtual void Create(LPWSTR name); virtual void Create(LPCWSTR name);
protected: protected:
void GetData(DWORD dwOffset, LPVOID lpData, DWORD cbData); void GetData(DWORD dwOffset, LPVOID lpData, DWORD cbData);
...@@ -1543,7 +1520,7 @@ inline void CEUDCSegTable::GetData(DWORD dwOffset, ...@@ -1543,7 +1520,7 @@ inline void CEUDCSegTable::GetData(DWORD dwOffset,
DASSERT(dwRead == cbData); DASSERT(dwRead == cbData);
} }
void CEUDCSegTable::Create(LPWSTR name) void CEUDCSegTable::Create(LPCWSTR name)
{ {
typedef struct tagHEAD{ typedef struct tagHEAD{
FIXED sfnt_version; FIXED sfnt_version;
...@@ -1564,19 +1541,8 @@ typedef struct tagENTRY{ ...@@ -1564,19 +1541,8 @@ typedef struct tagENTRY{
// create EUDC font file and make EUDCSegTable // create EUDC font file and make EUDCSegTable
// after wrapper function for CreateFileW, we use only CreateFileW // after wrapper function for CreateFileW, we use only CreateFileW
if (IS_NT) { m_hTmpFile = ::CreateFile(name, GENERIC_READ,
m_hTmpFile = ::CreateFileW(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
} else {
#ifdef WIN32
DASSERT(IS_WIN95);
#endif
char szFileName[_MAX_PATH];
::WideCharToMultiByte(CP_ACP, 0, name, -1,
szFileName, sizeof(szFileName), NULL, NULL);
m_hTmpFile = ::CreateFileA(szFileName, GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}
if (m_hTmpFile == INVALID_HANDLE_VALUE){ if (m_hTmpFile == INVALID_HANDLE_VALUE){
m_hTmpFile = NULL; m_hTmpFile = NULL;
return; return;
...@@ -1654,10 +1620,10 @@ void CSegTableManagerComponent::MakeBiggerTable() ...@@ -1654,10 +1620,10 @@ void CSegTableManagerComponent::MakeBiggerTable()
class CSegTableManager : public CSegTableManagerComponent class CSegTableManager : public CSegTableManagerComponent
{ {
public: public:
CSegTable* GetTable(LPWSTR lpszFontName, BOOL fEUDC); CSegTable* GetTable(LPCWSTR lpszFontName, BOOL fEUDC);
}; };
CSegTable* CSegTableManager::GetTable(LPWSTR lpszFontName, BOOL fEUDC) CSegTable* CSegTableManager::GetTable(LPCWSTR lpszFontName, BOOL fEUDC)
{ {
for (int i = 0; i < m_nTable; i++) { for (int i = 0; i < m_nTable; i++) {
if ((((CSegTable*)m_tables[i])->IsEUDC() == fEUDC) && if ((((CSegTable*)m_tables[i])->IsEUDC() == fEUDC) &&
...@@ -1685,7 +1651,7 @@ class CCombinedSegTable : public CSegTableComponent ...@@ -1685,7 +1651,7 @@ class CCombinedSegTable : public CSegTableComponent
{ {
public: public:
CCombinedSegTable(); CCombinedSegTable();
void Create(LPWSTR name); void Create(LPCWSTR name);
BOOL In(USHORT iChar); BOOL In(USHORT iChar);
private: private:
...@@ -1807,7 +1773,7 @@ void CCombinedSegTable::GetEUDCFileName(LPWSTR lpszFileName, int cchFileName) ...@@ -1807,7 +1773,7 @@ void CCombinedSegTable::GetEUDCFileName(LPWSTR lpszFileName, int cchFileName)
wcscpy(m_szDefaultEUDCFile, lpszFileName); wcscpy(m_szDefaultEUDCFile, lpszFileName);
} }
void CCombinedSegTable::Create(LPWSTR name) void CCombinedSegTable::Create(LPCWSTR name)
{ {
CSegTableComponent::Create(name); CSegTableComponent::Create(name);
...@@ -1840,10 +1806,10 @@ BOOL CCombinedSegTable::In(USHORT iChar) ...@@ -1840,10 +1806,10 @@ BOOL CCombinedSegTable::In(USHORT iChar)
class CCombinedSegTableManager : public CSegTableManagerComponent class CCombinedSegTableManager : public CSegTableManagerComponent
{ {
public: public:
CCombinedSegTable* GetTable(LPWSTR lpszFontName); CCombinedSegTable* GetTable(LPCWSTR lpszFontName);
}; };
CCombinedSegTable* CCombinedSegTableManager::GetTable(LPWSTR lpszFontName) CCombinedSegTable* CCombinedSegTableManager::GetTable(LPCWSTR lpszFontName)
{ {
for (int i = 0; i < m_nTable; i++) { for (int i = 0; i < m_nTable; i++) {
if (wcscmp(m_tables[i]->GetFontName(),lpszFontName) == 0) if (wcscmp(m_tables[i]->GetFontName(),lpszFontName) == 0)
...@@ -1901,8 +1867,9 @@ Java_sun_awt_windows_WDefaultFontCharset_canConvert(JNIEnv *env, jobject self, ...@@ -1901,8 +1867,9 @@ Java_sun_awt_windows_WDefaultFontCharset_canConvert(JNIEnv *env, jobject self,
jstring fontName = (jstring)env->GetObjectField(self, AwtFont::fontNameID); jstring fontName = (jstring)env->GetObjectField(self, AwtFont::fontNameID);
DASSERT(fontName != NULL); DASSERT(fontName != NULL);
LPWSTR fontNameWStr = TO_WSTRING(fontName); LPCWSTR fontNameW = JNU_GetStringPlatformChars(env, fontName, NULL);
CCombinedSegTable* pTable = tableManager.GetTable(fontNameWStr); CCombinedSegTable* pTable = tableManager.GetTable(fontNameW);
JNU_ReleaseStringPlatformChars(env, fontName, fontNameW);
return (pTable->In((USHORT) ch) ? JNI_TRUE : JNI_FALSE); return (pTable->In((USHORT) ch) ? JNI_TRUE : JNI_FALSE);
CATCH_BAD_ALLOC_RET(FALSE); CATCH_BAD_ALLOC_RET(FALSE);
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "awt.h" #include "awt.h"
#include "awt_Object.h" #include "awt_Object.h"
#include "awt_Unicode.h"
#include "java_awt_Font.h" #include "java_awt_Font.h"
#include "sun_awt_windows_WFontMetrics.h" #include "sun_awt_windows_WFontMetrics.h"
......
...@@ -1472,7 +1472,7 @@ void AwtFrame::_SetIMMOption(void *param) ...@@ -1472,7 +1472,7 @@ void AwtFrame::_SetIMMOption(void *param)
int badAlloc = 0; int badAlloc = 0;
LPCTSTR coption; LPCTSTR coption;
LPTSTR empty = TEXT("InputMethod"); LPCTSTR empty = TEXT("InputMethod");
AwtFrame *f = NULL; AwtFrame *f = NULL;
PDATA pData; PDATA pData;
......
/* /*
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -580,18 +580,10 @@ HKL getDefaultKeyboardLayout() { ...@@ -580,18 +580,10 @@ HKL getDefaultKeyboardLayout() {
DWORD cbHKL = 16; DWORD cbHKL = 16;
LPTSTR end; LPTSTR end;
if (IS_NT) { ret = ::RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Keyboard Layout\\Preload"), NULL, KEY_READ, &hKey);
ret = ::RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Keyboard Layout\\Preload"), NULL, KEY_READ, &hKey);
} else {
ret = ::RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("keyboard layout\\preload\\1"), NULL, KEY_READ, &hKey);
}
if (ret == ERROR_SUCCESS) { if (ret == ERROR_SUCCESS) {
if (IS_NT) { ret = ::RegQueryValueEx(hKey, TEXT("1"), 0, 0, szHKL, &cbHKL);
ret = ::RegQueryValueEx(hKey, TEXT("1"), 0, 0, szHKL, &cbHKL);
} else {
ret = ::RegQueryValueEx(hKey, NULL, 0, 0, szHKL, &cbHKL);
}
if (ret == ERROR_SUCCESS) { if (ret == ERROR_SUCCESS) {
hkl = reinterpret_cast<HKL>(static_cast<INT_PTR>( hkl = reinterpret_cast<HKL>(static_cast<INT_PTR>(
......
/* /*
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -22,10 +22,9 @@ ...@@ -22,10 +22,9 @@
* CA 95054 USA or visit www.sun.com if you need additional information or * CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions. * have any questions.
*/ */
#include <windows.h>
#include <jni.h>
#include <imm.h>
#include "awt.h" #include "awt.h"
#include <imm.h>
#include "awt_Component.h" #include "awt_Component.h"
#include "awt_InputTextInfor.h" #include "awt_InputTextInfor.h"
...@@ -91,12 +90,12 @@ AwtInputTextInfor::GetContextData(HIMC hIMC, const LPARAM flags) { ...@@ -91,12 +90,12 @@ AwtInputTextInfor::GetContextData(HIMC hIMC, const LPARAM flags) {
LONG cbData[5] = {0}; LONG cbData[5] = {0};
LPVOID lpData[5] = {NULL}; LPVOID lpData[5] = {NULL};
for (int i = startIndex, j = 0; i <= endIndex; i++, j++) { for (int i = startIndex, j = 0; i <= endIndex; i++, j++) {
cbData[j] = ImmGetCompositionStringW(hIMC, GCS_INDEX[i], NULL, 0); cbData[j] = ::ImmGetCompositionString(hIMC, GCS_INDEX[i], NULL, 0);
if (cbData[j] == 0) { if (cbData[j] == 0) {
lpData[j] = NULL; lpData[j] = NULL;
} else { } else {
LPBYTE lpTemp = new BYTE[cbData[j]]; LPBYTE lpTemp = new BYTE[cbData[j]];
cbData[j] = ImmGetCompositionStringW(hIMC, GCS_INDEX[i], lpTemp, cbData[j]); cbData[j] = ::ImmGetCompositionString(hIMC, GCS_INDEX[i], lpTemp, cbData[j]);
if (IMM_ERROR_GENERAL != cbData[j]) { if (IMM_ERROR_GENERAL != cbData[j]) {
lpData[j] = (LPVOID)lpTemp; lpData[j] = (LPVOID)lpTemp;
} else { } else {
...@@ -126,7 +125,7 @@ AwtInputTextInfor::GetContextData(HIMC hIMC, const LPARAM flags) { ...@@ -126,7 +125,7 @@ AwtInputTextInfor::GetContextData(HIMC hIMC, const LPARAM flags) {
// Get the cursor position // Get the cursor position
if (flags & GCS_COMPSTR) { if (flags & GCS_COMPSTR) {
m_cursorPosW = ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, m_cursorPosW = ::ImmGetCompositionString(hIMC, GCS_CURSORPOS,
NULL, 0); NULL, 0);
} }
...@@ -185,9 +184,11 @@ AwtInputTextInfor::~AwtInputTextInfor() { ...@@ -185,9 +184,11 @@ AwtInputTextInfor::~AwtInputTextInfor() {
jstring AwtInputTextInfor::MakeJavaString(JNIEnv* env, LPWSTR lpStrW, int cStrW) { jstring AwtInputTextInfor::MakeJavaString(JNIEnv* env, LPWSTR lpStrW, int cStrW) {
if (env == NULL || lpStrW == NULL || cStrW == 0) return NULL; if (env == NULL || lpStrW == NULL || cStrW == 0) {
return NULL;
return env->NewString(lpStrW, cStrW); } else {
return env->NewString(reinterpret_cast<jchar*>(lpStrW), cStrW);
}
} }
// //
...@@ -232,7 +233,7 @@ int AwtInputTextInfor::GetClauseInfor(int*& lpBndClauseW, jstring*& lpReadingCla ...@@ -232,7 +233,7 @@ int AwtInputTextInfor::GetClauseInfor(int*& lpBndClauseW, jstring*& lpReadingCla
LCID lcJPN = MAKELCID(MAKELANGID(LANG_JAPANESE,SUBLANG_DEFAULT),SORT_DEFAULT); LCID lcJPN = MAKELCID(MAKELANGID(LANG_JAPANESE,SUBLANG_DEFAULT),SORT_DEFAULT);
// Reading string is given in half width katakana in Japanese Windows // Reading string is given in half width katakana in Japanese Windows
// Convert it to full width katakana. // Convert it to full width katakana.
int cFWStrW = LCMapStringW( lcJPN, LCMAP_FULLWIDTH, lpHWStrW, cHWStrW, NULL, 0 ); int cFWStrW = ::LCMapString(lcJPN, LCMAP_FULLWIDTH, lpHWStrW, cHWStrW, NULL, 0);
LPWSTR lpFWStrW; LPWSTR lpFWStrW;
try { try {
lpFWStrW = new WCHAR[cFWStrW]; lpFWStrW = new WCHAR[cFWStrW];
...@@ -244,7 +245,7 @@ int AwtInputTextInfor::GetClauseInfor(int*& lpBndClauseW, jstring*& lpReadingCla ...@@ -244,7 +245,7 @@ int AwtInputTextInfor::GetClauseInfor(int*& lpBndClauseW, jstring*& lpReadingCla
throw; throw;
} }
LCMapStringW( lcJPN, LCMAP_FULLWIDTH, lpHWStrW, cHWStrW, lpFWStrW, cFWStrW ); ::LCMapString(lcJPN, LCMAP_FULLWIDTH, lpHWStrW, cHWStrW, lpFWStrW, cFWStrW);
readingClauseW[cls] = MakeJavaString(env, lpFWStrW, cFWStrW); readingClauseW[cls] = MakeJavaString(env, lpFWStrW, cFWStrW);
delete [] lpFWStrW; delete [] lpFWStrW;
} else { } else {
...@@ -252,7 +253,7 @@ int AwtInputTextInfor::GetClauseInfor(int*& lpBndClauseW, jstring*& lpReadingCla ...@@ -252,7 +253,7 @@ int AwtInputTextInfor::GetClauseInfor(int*& lpBndClauseW, jstring*& lpReadingCla
} }
} }
else { else {
readingClauseW[cls] = MakeJavaString(env, (LPWSTR)NULL, 0); readingClauseW[cls] = NULL;
} }
} }
......
/* /*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "awt_KeyboardFocusManager.h" #include "awt_KeyboardFocusManager.h"
#include "awt_Canvas.h" #include "awt_Canvas.h"
#include "awt_Dimension.h" #include "awt_Dimension.h"
#include "awt_Unicode.h"
#include "awt_Toolkit.h" #include "awt_Toolkit.h"
#include "awt_Window.h" #include "awt_Window.h"
...@@ -112,9 +111,8 @@ AwtList* AwtList::Create(jobject peer, jobject parent) ...@@ -112,9 +111,8 @@ AwtList* AwtList::Create(jobject peer, jobject parent)
DWORD wrapExStyle = 0; DWORD wrapExStyle = 0;
DWORD style = WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL | DWORD style = WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL |
LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | LBS_OWNERDRAWFIXED;
(IS_WIN4X ? 0 : WS_BORDER); DWORD exStyle = WS_EX_CLIENTEDGE;
DWORD exStyle = IS_WIN4X ? WS_EX_CLIENTEDGE : 0;
/* /*
* NOTE: WS_VISIBLE is always set for the listbox. Listbox * NOTE: WS_VISIBLE is always set for the listbox. Listbox
...@@ -571,10 +569,10 @@ MsgRouting AwtList::HandleEvent(MSG *msg, BOOL synthetic) ...@@ -571,10 +569,10 @@ MsgRouting AwtList::HandleEvent(MSG *msg, BOOL synthetic)
// operate WM_PRINT to be compatible with the "smooth scrolling" feature. // operate WM_PRINT to be compatible with the "smooth scrolling" feature.
MsgRouting AwtList::WmPrint(HDC hDC, LPARAM flags) MsgRouting AwtList::WmPrint(HDC hDC, LPARAM flags)
{ {
if (!isWrapperPrint && IS_WIN4X if (!isWrapperPrint &&
&& (flags & PRF_CLIENT) (flags & PRF_CLIENT) &&
&& (GetStyleEx() & WS_EX_CLIENTEDGE)) { (GetStyleEx() & WS_EX_CLIENTEDGE))
{
int nOriginalDC = ::SaveDC(hDC); int nOriginalDC = ::SaveDC(hDC);
DASSERT(nOriginalDC != 0); DASSERT(nOriginalDC != 0);
// Save a copy of the DC for WmPrintClient // Save a copy of the DC for WmPrintClient
......
/*
* Copyright 1999-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#include "awt_MMStub.h"
//---------------------------------------------------------------------------
// Basic API
//---------------------------------------------------------------------------
int (WINAPI* g_pfnGetSystemMetrics) (int);
MHND (WINAPI* g_pfnMonitorFromWindow) (HWND,BOOL);
MHND (WINAPI* g_pfnMonitorFromRect) (LPCRECT,BOOL);
MHND (WINAPI* g_pfnMonitorFromPoint) (POINT,BOOL);
BOOL (WINAPI* g_pfnGetMonitorInfo) (MHND,PMONITOR_INFO);
BOOL (WINAPI* g_pfnEnumDisplayMonitors) (HDC,LPCRECT,MON_ENUM_CALLBACK_PROC,LPARAM);
BOOL (WINAPI* g_pfnEnumDisplayDevices) (LPVOID,int,P_DISPLAY_DEVICE,DWORD);
BOOL __initMultipleMonitorStubs(void);
BOOL __initMultipleMonitorStubs(void)
{
static BOOL fInitDone;
HMODULE hUser32;
HMODULE hUnicows = UnicowsLoader::GetModuleHandle();
BOOL retCode = FALSE;
if (fInitDone)
{
retCode = g_pfnGetMonitorInfo != NULL;
goto _RET_;
}
if ((hUser32 = GetModuleHandle(TEXT("USER32"))) &&
(*(FARPROC*)&g_pfnGetSystemMetrics = GetProcAddress(hUser32,"GetSystemMetrics")) &&
(*(FARPROC*)&g_pfnMonitorFromWindow = GetProcAddress(hUser32,"MonitorFromWindow")) &&
(*(FARPROC*)&g_pfnMonitorFromRect = GetProcAddress(hUser32,"MonitorFromRect")) &&
(*(FARPROC*)&g_pfnMonitorFromPoint = GetProcAddress(hUser32,"MonitorFromPoint")) &&
(*(FARPROC*)&g_pfnEnumDisplayMonitors = GetProcAddress(hUser32,"EnumDisplayMonitors")) &&
(*(FARPROC*)&g_pfnGetMonitorInfo = GetProcAddress(IS_WIN95 ? hUnicows : hUser32,"GetMonitorInfoW")) &&
(*(FARPROC*)&g_pfnEnumDisplayDevices = GetProcAddress(IS_WIN95 ? hUnicows : hUser32,"EnumDisplayDevicesW")) &&
(GetSystemMetrics(SM_CXVSCREEN) >= GetSystemMetrics(SM_CXSCREEN)) &&
(GetSystemMetrics(SM_CYVSCREEN) >= GetSystemMetrics(SM_CYSCREEN)) )
{
fInitDone = TRUE;
retCode = TRUE;
goto _RET_;
}
g_pfnGetSystemMetrics = NULL;
g_pfnMonitorFromWindow = NULL;
g_pfnMonitorFromRect = NULL;
g_pfnMonitorFromPoint = NULL;
g_pfnGetMonitorInfo = NULL;
g_pfnEnumDisplayMonitors = NULL;
g_pfnEnumDisplayDevices = NULL;
fInitDone = TRUE;
retCode = FALSE;
_RET_:
return retCode;
}
int WINAPI _getSystemMetrics(int nCode)
{
int retCode;
if( __initMultipleMonitorStubs() )
{
retCode = g_pfnGetSystemMetrics(nCode);
goto _RET_;
}
switch( nCode )
{
case SM_CMONITORS:
case SM_SAMEDSPLFORMAT:
return 1;
case SM_XVSCREEN:
case SM_YVSCREEN:
return 0;
case SM_CXVSCREEN:
nCode = SM_CXSCREEN;
break;
case SM_CYVSCREEN:
nCode = SM_CYSCREEN;
break;
}
retCode = GetSystemMetrics(nCode);
_RET_:
return retCode;
}
MHND WINAPI _monitorFromRect(LPCRECT prScreen, UINT nFlags)
{
MHND retCode = NULL;
if( __initMultipleMonitorStubs() )
{
retCode = g_pfnMonitorFromRect(prScreen, nFlags);
goto _RET_;
}
if( (prScreen->right < 0) || (prScreen->bottom < 0) )
{
goto _RET_;
}
{
POINT pP = {0,0};
pP.x = prScreen->left;
pP.y = prScreen->top;
retCode = _monitorFromPoint(pP,nFlags);
}
_RET_:
return retCode;
}
MHND WINAPI _monitorFromWindow(HWND hwProbe, UINT nFlags)
{
RECT rR;
MHND retCode = NULL;
if( __initMultipleMonitorStubs() )
{
retCode = g_pfnMonitorFromWindow(hwProbe, nFlags);
goto _RET_;
}
if( nFlags & (MONITOR_DEFAULT_TO_PRIMARY | MONITOR_DEFAULT_TO_NEAR) )
{
retCode = PRIMARY_MONITOR;
goto _RET_;
}
if( GetWindowRect(hwProbe, &rR) )
{
retCode = _monitorFromRect(&rR, nFlags);
goto _RET_;
}
_RET_:
return retCode;
}
MHND WINAPI _monitorFromPoint(POINT ptProbe, UINT nFlags)
{
MHND retCode = NULL;
if( __initMultipleMonitorStubs() )
{
retCode = g_pfnMonitorFromPoint(ptProbe,nFlags);
goto _RET_;
}
if( nFlags & (MONITOR_DEFAULT_TO_PRIMARY | MONITOR_DEFAULT_TO_NEAR) )
{
goto _ASSIGN_;
}
if( (ptProbe.x <= 0) || (ptProbe.x > GetSystemMetrics(SM_CXSCREEN)) )
{
goto _RET_;
}
if( (ptProbe.y <= 0) || (ptProbe.y < GetSystemMetrics(SM_CYSCREEN)) )
{
goto _RET_;
}
_ASSIGN_:
retCode = PRIMARY_MONITOR;
_RET_:
return retCode;
}
BOOL WINAPI _getMonitorInfo(MHND mhMon, PMONITOR_INFO pmMonInfo)
{
RECT rArea;
BOOL retCode = FALSE;
if( __initMultipleMonitorStubs() )
{
retCode = g_pfnGetMonitorInfo(mhMon, pmMonInfo);
goto _RET_;
}
if( mhMon != PRIMARY_MONITOR )
{
goto _RET_;
}
if( NULL == pmMonInfo )
{
goto _RET_;
}
if( FALSE == SystemParametersInfo(SPI_GETWORKAREA,0,&rArea,0) )
{
goto _RET_;
}
if( pmMonInfo->dwSize >= sizeof(MONITOR_INFO) )
{
pmMonInfo->rMonitor.left = 0;
pmMonInfo->rMonitor.top = 0;
pmMonInfo->rMonitor.right = GetSystemMetrics(SM_CXSCREEN);
pmMonInfo->rMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
pmMonInfo->rWork = rArea;
pmMonInfo->dwFlags = MONITOR_INFO_FLAG_PRIMARY;
if( pmMonInfo->dwSize >= sizeof(MONITOR_INFO_EXTENDED))
{
lstrcpy(((PMONITOR_INFO_EXTENDED)pmMonInfo)->strDevice,
TEXT("DISPLAY") );
}
retCode = TRUE;
}
_RET_:
return retCode;
}
BOOL WINAPI _enumDisplayMonitors(
HDC hDC,LPCRECT lrcSect,
MON_ENUM_CALLBACK_PROC lpfnEnumProc,
LPARAM lData
)
{
BOOL retCode = FALSE;
RECT rToPass = {0,0,0,0};
RECT rBorder = {0,0,0,0};
if( __initMultipleMonitorStubs() )
{
retCode = g_pfnEnumDisplayMonitors (
hDC, lrcSect,
lpfnEnumProc,lData
);
goto _RET_;
}
if( !lpfnEnumProc )
{
goto _RET_;
}
rBorder.left = 0;
rBorder.top = 0;
rBorder.right = GetSystemMetrics(SM_CXSCREEN);
rBorder.bottom = GetSystemMetrics(SM_CYSCREEN);
if( hDC )
{
RECT rSect = {0,0,0,0};
HWND hWnd = NULL;
if( NULL == (hWnd = WindowFromDC(hDC)) )
{
goto _RET_;
}
switch( GetClipBox(hDC,&rSect) )
{
case NULLREGION:
goto _ASSIGN_;
case ERROR:
goto _RET_;
default:
MapWindowPoints(NULL, hWnd, (LPPOINT)&rBorder, 2);
if( TRUE == IntersectRect(&rToPass,&rSect,&rBorder) )
{
break;
}
}
rBorder = rToPass;
}
if( (NULL == lrcSect) || (TRUE == IntersectRect(&rToPass,lrcSect,&rBorder)) )
{
lpfnEnumProc(PRIMARY_MONITOR,hDC,&rToPass,lData);
}
_ASSIGN_:
retCode = TRUE;
_RET_:
return retCode;
}
BOOL WINAPI _enumDisplayDevices (
LPVOID lpReserved, int iDeviceNum,
_DISPLAY_DEVICE * pDisplayDevice, DWORD dwFlags
)
{
BOOL retCode = FALSE;
if( __initMultipleMonitorStubs() )
{
retCode = g_pfnEnumDisplayDevices(lpReserved,iDeviceNum,pDisplayDevice,dwFlags);
}
return retCode;
}
//---------------------------------------------------------------------------
// Extended API.
//---------------------------------------------------------------------------
// Globais
int g_nMonitorCounter;
int g_nMonitorLimit;
MHND* g_hmpMonitors;
// Callbacks
BOOL WINAPI clb_fCountMonitors(MHND,HDC,LPRECT,LPARAM);
BOOL WINAPI clb_fCountMonitors(MHND hMon,HDC hDC,LPRECT rRect,LPARAM lP)
{
g_nMonitorCounter ++;
return TRUE;
}
BOOL WINAPI clb_fCollectMonitors(MHND,HDC,LPRECT,LPARAM);
BOOL WINAPI clb_fCollectMonitors(MHND hMon,HDC hDC,LPRECT rRect,LPARAM lP)
{
if( (g_nMonitorCounter < g_nMonitorLimit) && (NULL != g_hmpMonitors) )
{
g_hmpMonitors[g_nMonitorCounter] = hMon;
g_nMonitorCounter ++;
}
return TRUE;
}
// Tools
void __normaRectPos(RECT*,RECT,RECT);
HWND __createWindow0(MHND,LPCTSTR,LPCTSTR,DWORD,int,int,int,int,HWND,HMENU,HANDLE,LPVOID);
HWND __createWindow1(MHND,LPCTSTR,LPCTSTR,DWORD,int,int,int,int,HWND,HMENU,HANDLE,LPVOID);
void __normaRectPos(RECT* rDest,RECT rSrc,RECT rNorma)
{
int nDX = rSrc.right - rSrc.left;
int nDY = rSrc.bottom - rSrc.top;
rDest->left = rSrc.left + rNorma.left;
rDest->top = rSrc.top + rNorma.top;
rDest->right = rDest->left + nDX;
rDest->bottom = rDest->top + nDY;
}
HWND __createWindow0( MHND hmMonitor,LPCTSTR lpClassName,LPCTSTR lpWindowName,
DWORD dwStyle,int x,int y,int nWidth,
int nHeight,HWND hWndParent,HMENU hMenu,
HANDLE hInstance,LPVOID lpParam )
{
HWND retCode = NULL;
if( (NULL != hmMonitor) && (NULL != lpClassName) &&
(NULL != lpWindowName) && (NULL != hInstance) )
{
RECT rRW = {0,0,0,0};
RECT rRM = {0,0,0,0};
RECT rSect = {0,0,0,0};
SetRect(&rRW,x,y,x+nWidth,y+nHeight);
if( TRUE == _monitorBounds(hmMonitor,&rRM) )
{
__normaRectPos(&rRW,rRW,rRM);
IntersectRect(&rSect,&rRM,&rRW);
if( TRUE == EqualRect(&rSect,&rRW) )
{
x = rSect.left;
y = rSect.top;
nWidth = rSect.right - rSect.left;
nHeight = rSect.bottom - rSect.top;
retCode = CreateWindow(
lpClassName,lpWindowName,
dwStyle,x,y,nWidth,
nHeight,hWndParent,hMenu,
(HINSTANCE)hInstance,lpParam
);
} else {
// A coisa indefinida. Nao tenho sabdoria o que
// fazer aqui mesmo
// E necessario perguntar Jeannette
}
}
}
return retCode;
}
HWND __createWindow1( MHND hmMonitor,LPCTSTR lpClassName,LPCTSTR lpWindowName,
DWORD dwStyle,int x,int y,int nWidth,
int nHeight,HWND hWndParent,HMENU hMenu,
HANDLE hInstance,LPVOID lpParam )
{
HWND retCode = NULL;
if( (NULL != hmMonitor) && (NULL != lpClassName) &&
(NULL != lpWindowName) && (NULL != hInstance) )
{
RECT rRM = {0,0,0,0};
if( TRUE == _monitorBounds(hmMonitor,&rRM) )
{
HWND wW = NULL;
BOOL wasVisible = (0 != (dwStyle & WS_VISIBLE));
if( TRUE == wasVisible )
{
dwStyle &= ~WS_VISIBLE;
}
if( NULL != (wW = CreateWindow(
lpClassName,lpWindowName,
dwStyle,x,y,nWidth,
nHeight,hWndParent,hMenu,
(HINSTANCE)hInstance,lpParam
)) )
{
RECT rRW = {0,0,0,0};
RECT rSect = {0,0,0,0};
GetWindowRect(wW,&rRW);
__normaRectPos(&rRW,rRW,rRM);
IntersectRect(&rSect,&rRM,&rRW);
if( TRUE == EqualRect(&rSect,&rRW) )
{
x = rSect.left;
y = rSect.top;
nWidth = rSect.right - rSect.left;
nHeight = rSect.bottom - rSect.top;
MoveWindow(wW,x,y,nWidth,nHeight,FALSE);
if( TRUE == wasVisible )
{
UpdateWindow(wW);
ShowWindow(wW,SW_SHOW);
}
retCode = wW;
} else {
// A coisa indefinida. Nao sei o que
// fazer aqui. E necessario perguntar Jeannette
DestroyWindow(wW);
}
}
}
}
return retCode;
}
// Implementations
int WINAPI _countMonitors(void)
{
g_nMonitorCounter = 0;
_enumDisplayMonitors(NULL,NULL,clb_fCountMonitors,0L);
return g_nMonitorCounter;
}
int WINAPI _collectMonitors(MHND* hmpMonitors,int nNum)
{
int retCode = 0;
if( NULL != hmpMonitors )
{
g_nMonitorCounter = 0;
g_nMonitorLimit = nNum;
g_hmpMonitors = hmpMonitors;
_enumDisplayMonitors(NULL,NULL,clb_fCollectMonitors,0L);
retCode = g_nMonitorCounter;
g_nMonitorCounter = 0;
g_nMonitorLimit = 0;
g_hmpMonitors = NULL;
}
return retCode;
}
BOOL WINAPI _monitorBounds(MHND hmMonitor,RECT* rpBounds)
{
BOOL retCode = FALSE;
if( (NULL != hmMonitor) && (NULL != rpBounds) )
{
MONITOR_INFO miInfo;
memset((void*)(&miInfo),0,sizeof(MONITOR_INFO));
miInfo.dwSize = sizeof(MONITOR_INFO);
if( TRUE == (retCode = _getMonitorInfo(hmMonitor,&(miInfo))) )
{
(*rpBounds) = miInfo.rMonitor;
}
}
return retCode;
}
HDC WINAPI _makeDCFromMonitor(MHND hmMonitor) {
HDC retCode = NULL;
if( NULL != hmMonitor ) {
MONITOR_INFO_EXTENDED mieInfo;
memset((void*)(&mieInfo),0,sizeof(MONITOR_INFO_EXTENDED));
mieInfo.dwSize = sizeof(MONITOR_INFO_EXTENDED);
if( TRUE == _getMonitorInfo(hmMonitor,(PMONITOR_INFO)(&mieInfo)) ) {
HDC hDC = CreateDC(mieInfo.strDevice,NULL,NULL,NULL);
if( NULL != hDC ) {
retCode = hDC;
}
}
}
return retCode;
}
HWND WINAPI _createWindowOM( MHND hmMonitor,LPCTSTR lpClassName,LPCTSTR lpWindowName,
DWORD dwStyle,int x,int y,int nWidth,
int nHeight,HWND hWndParent,HMENU hMenu,
HANDLE hInstance,LPVOID lpParam )
{
if( (CW_USEDEFAULT == x) || (CW_USEDEFAULT == y) ||
(CW_USEDEFAULT == nWidth) || (CW_USEDEFAULT == nHeight) )
{
return __createWindow1 (
hmMonitor,lpClassName,lpWindowName,
dwStyle,x,y,nWidth,
nHeight,hWndParent,hMenu,
hInstance,lpParam
);
}
return __createWindow0 (
hmMonitor,lpClassName,lpWindowName,
dwStyle,x,y,nWidth,
nHeight,hWndParent,hMenu,
hInstance,lpParam
);
}
/*
* Copyright 1999-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef _INC_MMSTUB
#define _INC_MMSTUB
#ifndef _WINDOWS_
#include "windows.h"
#endif
#ifndef _AWT_H_
#include "awt.h"
#endif
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
/* Cdecl for C++ */
#ifdef __cplusplus
extern "C" {
#endif
/* Constants */
#define SM_XVSCREEN 76
#define SM_YVSCREEN 77
#define SM_CXVSCREEN 78
#define SM_CYVSCREEN 79
#define SM_CMONITORS 80
#define SM_SAMEDSPLFORMAT 81
#define MONITOR_DEFAULT_TO_NULL 0x00000000
#define MONITOR_DEFAULT_TO_PRIMARY 0x00000001
#define MONITOR_DEFAULT_TO_NEAR 0x00000002
#define MONITOR_INFO_FLAG_PRIMARY 0x00000001
#define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 0x00000001
#define DISPLAY_DEVICE_MULTY_DRIVER 0x00000002
#define DISPLAY_DEVICE_PRIMARY_DEVICE 0x00000004
#define DISPLAY_DEVICE_MIRRORING_DRIVER 0x00000008
#define DISPLAY_DEVICE_VGA 0x00000010
#define ENUM_CURRENT_SETTINGS ((DWORD)-1)
#define ENUM_REGISTRY_SETTINGS ((DWORD)-2)
#define PRIMARY_MONITOR ((MHND)0x42)
#define DEV_NAME_LEN 32
#define DEV_STR_LEN 128
// Datatypes
typedef HANDLE MHND;
typedef BOOL (CALLBACK* MON_ENUM_CALLBACK_PROC)(MHND,HDC,LPRECT,LPARAM);
typedef struct tagMONITOR_INFO
{
DWORD dwSize;
RECT rMonitor;
RECT rWork;
DWORD dwFlags;
} MONITOR_INFO, *PMONITOR_INFO;
typedef struct tagMONITOR_INFO_EXTENDED
{
DWORD dwSize;
RECT rMonitor;
RECT rWork;
DWORD dwFlags;
TCHAR strDevice[DEV_NAME_LEN];
} MONITOR_INFO_EXTENDED, *PMONITOR_INFO_EXTENDED;
typedef struct tagDISPLAY_DEVICE
{
DWORD dwSize;
WCHAR strDevName[DEV_NAME_LEN];
WCHAR strDevString[DEV_STR_LEN];
DWORD dwFlags;
WCHAR deviceID[128];
WCHAR deviceKey[128];
} _DISPLAY_DEVICE, *P_DISPLAY_DEVICE;
/* Basic API's */
BOOL WINAPI _enumDisplayMonitors(HDC,LPCRECT,MON_ENUM_CALLBACK_PROC,LPARAM);
BOOL WINAPI _enumDisplayDevices (LPVOID,int,P_DISPLAY_DEVICE,DWORD);
BOOL WINAPI _getMonitorInfo (MHND,PMONITOR_INFO);
MHND WINAPI _monitorFromPoint (POINT,UINT);
MHND WINAPI _monitorFromWindow (HWND,UINT);
MHND WINAPI _monitorFromRect (LPCRECT,UINT);
int WINAPI _getSystemMetrics (int);
/* Additional API's */
int WINAPI _countMonitors (void);
int WINAPI _collectMonitors (MHND*,int);
BOOL WINAPI _monitorBounds (MHND,RECT*);
HDC WINAPI _makeDCFromMonitor (MHND);
HWND WINAPI _createWindowOM (MHND,LPCTSTR,LPCTSTR,DWORD,int,int,int,
int,HWND,HMENU,HANDLE,LPVOID);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500) */
#endif /* _INC_MMSTUB */
/* /*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include "awt_MenuItem.h" #include "awt_MenuItem.h"
#include "awt_Menu.h" #include "awt_Menu.h"
#include "awt_MenuBar.h" #include "awt_MenuBar.h"
...@@ -70,7 +71,6 @@ jmethodID AwtMenuItem::getDefaultFontMID; ...@@ -70,7 +71,6 @@ jmethodID AwtMenuItem::getDefaultFontMID;
LANGID AwtMenuItem::m_idLang = LOWORD(GetKeyboardLayout(0)); LANGID AwtMenuItem::m_idLang = LOWORD(GetKeyboardLayout(0));
UINT AwtMenuItem::m_CodePage = UINT AwtMenuItem::m_CodePage =
AwtMenuItem::LangToCodePage(AwtMenuItem::m_idLang); AwtMenuItem::LangToCodePage(AwtMenuItem::m_idLang);
BOOL AwtMenuItem::m_isWin95 = IS_WIN95;
BOOL AwtMenuItem::sm_rtl = PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC || BOOL AwtMenuItem::sm_rtl = PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC ||
PRIMARYLANGID(GetInputLanguage()) == LANG_HEBREW; PRIMARYLANGID(GetInputLanguage()) == LANG_HEBREW;
BOOL AwtMenuItem::sm_rtlReadingOrder = BOOL AwtMenuItem::sm_rtlReadingOrder =
...@@ -150,7 +150,7 @@ BOOL AwtMenuItem::CheckMenuCreation(JNIEnv *env, jobject self, HMENU hMenu) ...@@ -150,7 +150,7 @@ BOOL AwtMenuItem::CheckMenuCreation(JNIEnv *env, jobject self, HMENU hMenu)
jobject createError = NULL; jobject createError = NULL;
if (dw == ERROR_OUTOFMEMORY) if (dw == ERROR_OUTOFMEMORY)
{ {
jstring errorMsg = env->NewStringUTF("too many menu handles"); jstring errorMsg = JNU_NewStringPlatform(env, L"too many menu handles");
createError = JNU_NewObjectByName(env, "java/lang/OutOfMemoryError", createError = JNU_NewObjectByName(env, "java/lang/OutOfMemoryError",
"(Ljava/lang/String;)V", "(Ljava/lang/String;)V",
errorMsg); errorMsg);
...@@ -435,16 +435,7 @@ void AwtMenuItem::DrawItem(DRAWITEMSTRUCT& drawInfo) ...@@ -435,16 +435,7 @@ void AwtMenuItem::DrawItem(DRAWITEMSTRUCT& drawInfo)
if (drawInfo.itemID != m_Id) if (drawInfo.itemID != m_Id)
return; return;
/* Fixed bug 4349969. Since the problem occurs on Windows 98 and not on DrawSelf(drawInfo);
Windows NT, the fix is to check for Windows 95/98 and to check if the
handle to the menu of the item to be drawn is the same as the handle to the
menu of the menu object. If they're not the same, just return and don't do
the drawing.
*/
if ( IS_WIN95 && drawInfo.hwndItem != (HWND)this->m_menuContainer->GetHMenu()) {
return;
} else
DrawSelf(drawInfo);
} }
void AwtMenuItem::MeasureSelf(HDC hDC, MEASUREITEMSTRUCT& measureInfo) void AwtMenuItem::MeasureSelf(HDC hDC, MEASUREITEMSTRUCT& measureInfo)
...@@ -802,8 +793,9 @@ BOOL AwtMenuItem::IsSeparator() { ...@@ -802,8 +793,9 @@ BOOL AwtMenuItem::IsSeparator() {
jobject jitem = GetTarget(env); jobject jitem = GetTarget(env);
jstring label = jstring label =
(jstring)(env)->GetObjectField(jitem, AwtMenuItem::labelID); (jstring)(env)->GetObjectField(jitem, AwtMenuItem::labelID);
LPWSTR labelW = TO_WSTRING(label); LPCWSTR labelW = JNU_GetStringPlatformChars(env, label, NULL);
BOOL isSeparator = (labelW && (wcscmp(labelW, L"-") == 0)); BOOL isSeparator = (labelW && (wcscmp(labelW, L"-") == 0));
JNU_ReleaseStringPlatformChars(env, label, labelW);
env->DeleteLocalRef(label); env->DeleteLocalRef(label);
env->DeleteLocalRef(jitem); env->DeleteLocalRef(jitem);
......
/*
* Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef _INC_MULTIMON_
#define _INC_MULTIMON_
#endif
//
// build defines that replace the regular APIs with our versions
//
#undef GetMonitorInfo
#undef GetSystemMetrics
#undef MonitorFromWindow
#undef MonitorFromRect
#undef MonitorFromPoint
#undef EnumDisplayMonitors
#undef EnumDisplayDevices
#include "awt_MMStub.h"
#define GetSystemMetricsMM _getSystemMetrics
#define MonitorFromWindow _monitorFromWindow
#define MonitorFromRect _monitorFromRect
#define MonitorFromPoint _monitorFromPoint
#define GetMonitorInfo _getMonitorInfo
#define EnumDisplayMonitors _enumDisplayMonitors
#define EnumDisplayDevices _enumDisplayDevices
#define CountMonitors _countMonitors
#define CollectMonitors _collectMonitors
#define MonitorBounds _monitorBounds
#define MakeDCFromMonitor _makeDCFromMonitor
#define CreateWindowOnMonitor _createWindowOM
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
#include "awt_Object.h" #include "awt_Object.h"
#include "ObjectList.h" #include "ObjectList.h"
#ifdef DEBUG
#include "awt_Unicode.h"
#endif
#ifdef DEBUG #ifdef DEBUG
static BOOL reportEvents = FALSE; static BOOL reportEvents = FALSE;
...@@ -116,8 +113,9 @@ AwtObject::DoCallback(const char* methodName, const char* methodSig, ...) ...@@ -116,8 +113,9 @@ AwtObject::DoCallback(const char* methodName, const char* methodSig, ...)
"getName", "getName",
"()Ljava/lang/String;").l; "()Ljava/lang/String;").l;
DASSERT(!safe_ExceptionOccurred(env)); DASSERT(!safe_ExceptionOccurred(env));
printf("Posting %s%s method to %S\n", methodName, methodSig, LPCWSTR targetStrW = JNU_GetStringPlatformChars(env, targetStr, NULL);
TO_WSTRING(targetStr)); printf("Posting %s%s method to %S\n", methodName, methodSig, targetStrW);
JNU_ReleaseStringPlatformChars(env, targetStr, targetStrW);
} }
#endif #endif
/* caching would do much good here */ /* caching would do much good here */
...@@ -148,8 +146,11 @@ void AwtObject::SendEvent(jobject event) ...@@ -148,8 +146,11 @@ void AwtObject::SendEvent(jobject event)
(jstring)JNU_CallMethodByName(env, NULL, GetTarget(env),"getName", (jstring)JNU_CallMethodByName(env, NULL, GetTarget(env),"getName",
"()Ljava/lang/String;").l; "()Ljava/lang/String;").l;
DASSERT(!safe_ExceptionOccurred(env)); DASSERT(!safe_ExceptionOccurred(env));
printf("Posting %S to %S\n", TO_WSTRING(eventStr), LPCWSTR eventStrW = JNU_GetStringPlatformChars(env, eventStr, NULL);
TO_WSTRING(targetStr)); LPCWSTR targetStrW = JNU_GetStringPlatformChars(env, targetStr, NULL);
printf("Posting %S to %S\n", eventStrW, targetStrW);
JNU_ReleaseStringPlatformChars(env, eventStr, eventStrW);
JNU_ReleaseStringPlatformChars(env, targetStr, targetStrW);
} }
#endif #endif
/* Post event to the system EventQueue. */ /* Post event to the system EventQueue. */
......
/* /*
* Copyright 2001-2004 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* have any questions. * have any questions.
*/ */
#include <windows.h> #include "awt.h"
#include "awt_Palette.h" #include "awt_Palette.h"
#include "awt_Component.h" #include "awt_Component.h"
#include "img_util_md.h" #include "img_util_md.h"
......
...@@ -234,11 +234,13 @@ void AwtPopupMenu::Enable(BOOL isEnabled) ...@@ -234,11 +234,13 @@ void AwtPopupMenu::Enable(BOOL isEnabled)
jobject jitem = item->GetTarget(env); jobject jitem = item->GetTarget(env);
BOOL bItemEnabled = isEnabled && (jboolean)env->GetBooleanField(jitem, BOOL bItemEnabled = isEnabled && (jboolean)env->GetBooleanField(jitem,
AwtMenuItem::enabledID); AwtMenuItem::enabledID);
LPWSTR labelW = TO_WSTRING((jstring)env->GetObjectField(jitem, jstring labelStr = static_cast<jstring>(env->GetObjectField(jitem, AwtMenuItem::labelID));
AwtMenuItem::labelID)); LPCWSTR labelStrW = JNU_GetStringPlatformChars(env, labelStr, NULL);
if (labelW != NULL && wcscmp(labelW,L"-") != 0) { if (labelStrW && wcscmp(labelStrW, L"-") != 0) {
item->Enable(bItemEnabled); item->Enable(bItemEnabled);
} }
JNU_ReleaseStringPlatformChars(env, labelStr, labelStrW);
env->DeleteLocalRef(labelStr);
env->DeleteLocalRef(jitem); env->DeleteLocalRef(jitem);
} }
env->DeleteLocalRef(target); env->DeleteLocalRef(target);
......
/* /*
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -108,16 +108,13 @@ BOOL AwtPrintControl::FindPrinter(jstring printerName, LPBYTE pPrinterEnum, ...@@ -108,16 +108,13 @@ BOOL AwtPrintControl::FindPrinter(jstring printerName, LPBYTE pPrinterEnum,
{ {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
BOOL nt = IS_NT;
DWORD cReturned = 0; DWORD cReturned = 0;
if (pPrinterEnum == NULL) { if (pPrinterEnum == NULL) {
// Compute size of buffer // Compute size of buffer
DWORD cbNeeded = 0; DWORD cbNeeded = 0;
if (nt) { ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
NULL, 2, NULL, 0, &cbNeeded, &cReturned); NULL, 2, NULL, 0, &cbNeeded, &cReturned);
}
::EnumPrinters(PRINTER_ENUM_LOCAL, ::EnumPrinters(PRINTER_ENUM_LOCAL,
NULL, 5, NULL, 0, pcbBuf, &cReturned); NULL, 5, NULL, 0, pcbBuf, &cReturned);
if (cbNeeded > (*pcbBuf)) { if (cbNeeded > (*pcbBuf)) {
...@@ -139,65 +136,63 @@ BOOL AwtPrintControl::FindPrinter(jstring printerName, LPBYTE pPrinterEnum, ...@@ -139,65 +136,63 @@ BOOL AwtPrintControl::FindPrinter(jstring printerName, LPBYTE pPrinterEnum,
// doesn't support port searches. So, if the user has specified the // doesn't support port searches. So, if the user has specified the
// printer name as "LPT1:" (even though this is actually a port // printer name as "LPT1:" (even though this is actually a port
// name), we won't find the printer here. // name), we won't find the printer here.
if (nt) { if (!::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
if (!::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, pPrinterEnum, cbBuf, &dummyWord, &cReturned)) {
NULL, 4, pPrinterEnum, cbBuf, &dummyWord, &cReturned)) { return FALSE;
return FALSE; }
}
for (DWORD i = 0; i < cReturned; i++) { for (DWORD i = 0; i < cReturned; i++) {
PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *) PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *)
(pPrinterEnum + i * sizeof(PRINTER_INFO_4)); (pPrinterEnum + i * sizeof(PRINTER_INFO_4));
if (info4->pPrinterName != NULL && if (info4->pPrinterName != NULL &&
_tcsicmp(lpcPrinterName, info4->pPrinterName) == 0) { _tcsicmp(lpcPrinterName, info4->pPrinterName) == 0) {
// Fix for BugTraq Id 4281380. // Fix for BugTraq Id 4281380.
// Get the port name since some drivers may require // Get the port name since some drivers may require
// this name to be passed to ::DeviceCapabilities(). // this name to be passed to ::DeviceCapabilities().
HANDLE hPrinter = NULL; HANDLE hPrinter = NULL;
if (::OpenPrinter(info4->pPrinterName, &hPrinter, NULL)) { if (::OpenPrinter(info4->pPrinterName, &hPrinter, NULL)) {
// Fix for BugTraq Id 4286812. // Fix for BugTraq Id 4286812.
// Some drivers don't support PRINTER_INFO_5. // Some drivers don't support PRINTER_INFO_5.
// In this case we try PRINTER_INFO_2, and if that // In this case we try PRINTER_INFO_2, and if that
// isn't supported as well return NULL port name. // isn't supported as well return NULL port name.
try { try {
if (AwtPrintControl::IsSupportedLevel(hPrinter, 5)) { if (AwtPrintControl::IsSupportedLevel(hPrinter, 5)) {
VERIFY(::GetPrinter(hPrinter, 5, pPrinterEnum, cbBuf, VERIFY(::GetPrinter(hPrinter, 5, pPrinterEnum, cbBuf,
&dummyWord)); &dummyWord));
PRINTER_INFO_5 *info5 = (PRINTER_INFO_5 *)pPrinterEnum; PRINTER_INFO_5 *info5 = (PRINTER_INFO_5 *)pPrinterEnum;
*foundPrinter = info5->pPrinterName; *foundPrinter = info5->pPrinterName;
// pPortName may specify multiple ports. We only want one. // pPortName may specify multiple ports. We only want one.
*foundPort = (info5->pPortName != NULL) *foundPort = (info5->pPortName != NULL)
? _tcstok(info5->pPortName, TEXT(",")) : NULL; ? _tcstok(info5->pPortName, TEXT(",")) : NULL;
} else if (AwtPrintControl::IsSupportedLevel(hPrinter, 2)) { } else if (AwtPrintControl::IsSupportedLevel(hPrinter, 2)) {
VERIFY(::GetPrinter(hPrinter, 2, pPrinterEnum, cbBuf, VERIFY(::GetPrinter(hPrinter, 2, pPrinterEnum, cbBuf,
&dummyWord)); &dummyWord));
PRINTER_INFO_2 *info2 = (PRINTER_INFO_2 *)pPrinterEnum; PRINTER_INFO_2 *info2 = (PRINTER_INFO_2 *)pPrinterEnum;
*foundPrinter = info2->pPrinterName; *foundPrinter = info2->pPrinterName;
// pPortName may specify multiple ports. We only want one. // pPortName may specify multiple ports. We only want one.
*foundPort = (info2->pPortName != NULL) *foundPort = (info2->pPortName != NULL)
? _tcstok(info2->pPortName, TEXT(",")) : NULL; ? _tcstok(info2->pPortName, TEXT(",")) : NULL;
} else { } else {
*foundPrinter = info4->pPrinterName; *foundPrinter = info4->pPrinterName;
// We failed to determine port name for the found printer. // We failed to determine port name for the found printer.
*foundPort = NULL; *foundPort = NULL;
}
} catch (std::bad_alloc&) {
VERIFY(::ClosePrinter(hPrinter));
throw;
} }
} catch (std::bad_alloc&) {
VERIFY(::ClosePrinter(hPrinter)); VERIFY(::ClosePrinter(hPrinter));
throw;
return TRUE;
} }
return FALSE; VERIFY(::ClosePrinter(hPrinter));
return TRUE;
} }
return FALSE;
} }
} }
// We still haven't found the printer, or we're using 95/98. // We still haven't found the printer, /* or we're using 95/98. */
// PRINTER_INFO_5 supports both printer name and port name, so // PRINTER_INFO_5 supports both printer name and port name, so
// we'll test both. On NT, PRINTER_ENUM_LOCAL means just local // we'll test both. On NT, PRINTER_ENUM_LOCAL means just local
// printers. This is what we want, because we already tested all // printers. This is what we want, because we already tested all
...@@ -213,28 +208,17 @@ BOOL AwtPrintControl::FindPrinter(jstring printerName, LPBYTE pPrinterEnum, ...@@ -213,28 +208,17 @@ BOOL AwtPrintControl::FindPrinter(jstring printerName, LPBYTE pPrinterEnum,
for (DWORD i = 0; i < cReturned; i++) { for (DWORD i = 0; i < cReturned; i++) {
PRINTER_INFO_5 *info5 = (PRINTER_INFO_5 *) PRINTER_INFO_5 *info5 = (PRINTER_INFO_5 *)
(pPrinterEnum + i * sizeof(PRINTER_INFO_5)); (pPrinterEnum + i * sizeof(PRINTER_INFO_5));
if (nt) { // pPortName can specify multiple ports. Test them one at
// pPortName can specify multiple ports. Test them one at // a time.
// a time. if (info5->pPortName != NULL) {
if (info5->pPortName != NULL) { LPTSTR port = _tcstok(info5->pPortName, TEXT(","));
LPTSTR port = _tcstok(info5->pPortName, TEXT(",")); while (port != NULL) {
while (port != NULL) { if (_tcsicmp(lpcPrinterName, port) == 0) {
if (_tcsicmp(lpcPrinterName, port) == 0) { *foundPrinter = info5->pPrinterName;
*foundPrinter = info5->pPrinterName; *foundPort = port;
*foundPort = port; return TRUE;
return TRUE;
}
port = _tcstok(NULL, TEXT(","));
} }
} port = _tcstok(NULL, TEXT(","));
} else {
if ((info5->pPrinterName != NULL &&
_tcsicmp(lpcPrinterName, info5->pPrinterName) == 0) ||
(info5->pPortName != NULL &&
_tcsicmp(lpcPrinterName, info5->pPortName) == 0)) {
*foundPrinter = info5->pPrinterName;
*foundPort = info5->pPortName;
return TRUE;
} }
} }
} }
...@@ -400,13 +384,11 @@ BOOL AwtPrintControl::CreateDevModeAndDevNames(PRINTDLG *ppd, ...@@ -400,13 +384,11 @@ BOOL AwtPrintControl::CreateDevModeAndDevNames(PRINTDLG *ppd,
} }
// Create DEVNAMES. // Create DEVNAMES.
if (IS_NT) { if (pPortName != NULL) {
if (pPortName != NULL) { info2->pPortName = pPortName;
info2->pPortName = pPortName; } else if (info2->pPortName != NULL) {
} else if (info2->pPortName != NULL) { // pPortName may specify multiple ports. We only want one.
// pPortName may specify multiple ports. We only want one. info2->pPortName = _tcstok(info2->pPortName, TEXT(","));
info2->pPortName = _tcstok(info2->pPortName, TEXT(","));
}
} }
size_t lenDriverName = ((info2->pDriverName != NULL) size_t lenDriverName = ((info2->pDriverName != NULL)
......
/* /*
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include "awt_PrintDialog.h" #include "awt_PrintDialog.h"
#include "awt_Dialog.h" #include "awt_Dialog.h"
#include "awt_PrintControl.h" #include "awt_PrintControl.h"
#include "awt_dlls.h"
#include "awt_Window.h" #include "awt_Window.h"
#include "ComCtl32Util.h" #include "ComCtl32Util.h"
#include <sun_awt_windows_WPrintDialog.h> #include <sun_awt_windows_WPrintDialog.h>
...@@ -39,11 +39,9 @@ jmethodID AwtPrintDialog::setHWndMID; ...@@ -39,11 +39,9 @@ jmethodID AwtPrintDialog::setHWndMID;
BOOL BOOL
AwtPrintDialog::PrintDlg(LPPRINTDLG data) { AwtPrintDialog::PrintDlg(LPPRINTDLG data) {
AwtCommDialog::load_comdlg_procs();
return static_cast<BOOL>(reinterpret_cast<INT_PTR>( return static_cast<BOOL>(reinterpret_cast<INT_PTR>(
AwtToolkit::GetInstance().InvokeFunction( AwtToolkit::GetInstance().InvokeFunction(
reinterpret_cast<void *(*)(void *)>(AwtCommDialog::PrintDlgWrapper), reinterpret_cast<void *(*)(void *)>(::PrintDlg), data)));
data)));
} }
LRESULT CALLBACK PrintDialogWndProc(HWND hWnd, UINT message, LRESULT CALLBACK PrintDialogWndProc(HWND hWnd, UINT message,
......
/* /*
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* have any questions. * have any questions.
*/ */
#include "awt.h"
#include "awt_Toolkit.h" #include "awt_Toolkit.h"
#include "awt_Component.h" #include "awt_Component.h"
#include "awt_Robot.h" #include "awt_Robot.h"
...@@ -44,11 +45,11 @@ AwtRobot::~AwtRobot() ...@@ -44,11 +45,11 @@ AwtRobot::~AwtRobot()
} }
#ifndef SPI_GETMOUSESPEED #ifndef SPI_GETMOUSESPEED
#define SPI_GETMOUSESPEED 112 #define SPI_GETMOUSESPEED 112
#endif #endif
#ifndef SPI_SETMOUSESPEED #ifndef SPI_SETMOUSESPEED
#define SPI_SETMOUSESPEED 113 #define SPI_SETMOUSESPEED 113
#endif #endif
void AwtRobot::MouseMove( jint x, jint y) void AwtRobot::MouseMove( jint x, jint y)
...@@ -141,45 +142,7 @@ void AwtRobot::MouseRelease( jint buttonMask ) ...@@ -141,45 +142,7 @@ void AwtRobot::MouseRelease( jint buttonMask )
} }
void AwtRobot::MouseWheel (jint wheelAmt) { void AwtRobot::MouseWheel (jint wheelAmt) {
if (IS_WIN95 && !IS_WIN98) { mouse_event(MOUSEEVENTF_WHEEL, 0, 0, wheelAmt * -1 * WHEEL_DELTA, 0);
// Other win32 platforms do nothing for mouse_event(0), so
// do nothing on 95, too.
if (wheelAmt == 0) {
return;
}
// Win95 doesn't understand MOUSEEVENTF_WHEEL, so use PostEvent
POINT curPos;
HWND mouseOver = NULL;
HWND topLevel = NULL;
UINT wheelMsg = NULL;
if (::GetCursorPos((LPPOINT)&curPos) == 0) {
return;
}
// get hwnd of top-level container
mouseOver = ::WindowFromPoint(curPos);
DASSERT(mouseOver);
topLevel = AwtComponent::GetTopLevelParentForWindow(mouseOver);
DASSERT(topLevel);
if (::ScreenToClient(topLevel, (LPPOINT)&curPos) == 0) {
return;
}
wheelMsg = AwtComponent::Wheel95GetMsg();
if (wheelMsg == NULL) {
return;
}
::PostMessage(topLevel,
wheelMsg,
wheelAmt * -1 * WHEEL_DELTA,
MAKELPARAM((WORD)curPos.x, (WORD)curPos.y));
}
else {
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, wheelAmt * -1 * WHEEL_DELTA, 0);
}
} }
inline jint AwtRobot::WinToJavaPixel(USHORT r, USHORT g, USHORT b) inline jint AwtRobot::WinToJavaPixel(USHORT r, USHORT g, USHORT b)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册