mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 422792 - reduce narrow Windows API calls in widget/, original patch by Brad Lassey <blassey@mozilla.com>, r=roc
This commit is contained in:
parent
e62d0391bf
commit
c0a7e081e1
@ -93,13 +93,13 @@ nsresult
|
||||
nsAppShell::Init()
|
||||
{
|
||||
if (!sMsgId)
|
||||
sMsgId = RegisterWindowMessage("nsAppShell:EventID");
|
||||
sMsgId = RegisterWindowMessageW(L"nsAppShell:EventID");
|
||||
|
||||
WNDCLASS wc;
|
||||
WNDCLASSW wc;
|
||||
HINSTANCE module = GetModuleHandle(NULL);
|
||||
|
||||
const char *const kWindowClass = "nsAppShell:EventWindowClass";
|
||||
if (!GetClassInfo(module, kWindowClass, &wc)) {
|
||||
const PRUnichar *const kWindowClass = L"nsAppShell:EventWindowClass";
|
||||
if (!GetClassInfoW(module, kWindowClass, &wc)) {
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = EventWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
@ -108,12 +108,12 @@ nsAppShell::Init()
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = NULL;
|
||||
wc.hbrBackground = (HBRUSH) NULL;
|
||||
wc.lpszMenuName = (LPCSTR) NULL;
|
||||
wc.lpszMenuName = (LPCWSTR) NULL;
|
||||
wc.lpszClassName = kWindowClass;
|
||||
RegisterClass(&wc);
|
||||
RegisterClassW(&wc);
|
||||
}
|
||||
|
||||
mEventWnd = CreateWindow(kWindowClass, "nsAppShell:EventWindow",
|
||||
mEventWnd = CreateWindowW(kWindowClass, L"nsAppShell:EventWindow",
|
||||
0, 0, 0, 10, 10, NULL, NULL, module, NULL);
|
||||
NS_ENSURE_STATE(mEventWnd);
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <stdio.h>
|
||||
#include "nsBidiKeyboard.h"
|
||||
#include "prmem.h"
|
||||
#include <tchar.h>
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
|
||||
|
||||
@ -63,8 +64,8 @@ NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel)
|
||||
return result;
|
||||
|
||||
// call LoadKeyboardLayout() only if the target keyboard layout is different from the current
|
||||
char currentLocaleName[KL_NAMELENGTH];
|
||||
strncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH);
|
||||
PRUnichar currentLocaleName[KL_NAMELENGTH];
|
||||
wcsncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH);
|
||||
currentLocaleName[KL_NAMELENGTH-1] = '\0'; // null terminate
|
||||
|
||||
NS_ASSERTION(*currentLocaleName,
|
||||
@ -96,26 +97,26 @@ NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
|
||||
currentLocale = ::GetKeyboardLayout(0);
|
||||
*aIsRTL = IsRTLLanguage(currentLocale);
|
||||
|
||||
if (!::GetKeyboardLayoutName(mCurrentLocaleName))
|
||||
if (!::GetKeyboardLayoutNameW(mCurrentLocaleName))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ASSERTION(*mCurrentLocaleName,
|
||||
"GetKeyboardLayoutName return string length == 0");
|
||||
NS_ASSERTION((strlen(mCurrentLocaleName) < KL_NAMELENGTH),
|
||||
NS_ASSERTION((wcslen(mCurrentLocaleName) < KL_NAMELENGTH),
|
||||
"GetKeyboardLayoutName return string length >= KL_NAMELENGTH");
|
||||
|
||||
// The language set by the user overrides the default language for that direction
|
||||
if (*aIsRTL) {
|
||||
strncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
|
||||
wcsncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
|
||||
mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
|
||||
} else {
|
||||
strncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
|
||||
wcsncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
|
||||
mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
|
||||
}
|
||||
|
||||
NS_ASSERTION((strlen(mRTLKeyboard) < KL_NAMELENGTH),
|
||||
NS_ASSERTION((wcslen(mRTLKeyboard) < KL_NAMELENGTH),
|
||||
"mLTRKeyboard has string length >= KL_NAMELENGTH");
|
||||
NS_ASSERTION((strlen(mLTRKeyboard) < KL_NAMELENGTH),
|
||||
NS_ASSERTION((wcslen(mLTRKeyboard) < KL_NAMELENGTH),
|
||||
"mRTLKeyboard has string length >= KL_NAMELENGTH");
|
||||
return NS_OK;
|
||||
}
|
||||
@ -132,7 +133,7 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards()
|
||||
int keyboards;
|
||||
HKL far* buf;
|
||||
HKL locale;
|
||||
char localeName[KL_NAMELENGTH];
|
||||
PRUnichar localeName[KL_NAMELENGTH];
|
||||
PRBool isLTRKeyboardSet = PR_FALSE;
|
||||
PRBool isRTLKeyboardSet = PR_FALSE;
|
||||
|
||||
@ -156,11 +157,13 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards()
|
||||
while (keyboards--) {
|
||||
locale = buf[keyboards];
|
||||
if (IsRTLLanguage(locale)) {
|
||||
sprintf(mRTLKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID((DWORD)locale));
|
||||
swprintf(mRTLKeyboard, KL_NAMELENGTH, L"%.*x", KL_NAMELENGTH - 1,
|
||||
LANGIDFROMLCID((DWORD)locale));
|
||||
isRTLKeyboardSet = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
sprintf(mLTRKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID((DWORD)locale));
|
||||
swprintf(mLTRKeyboard, KL_NAMELENGTH, L"%.*x", KL_NAMELENGTH - 1,
|
||||
LANGIDFROMLCID((DWORD)locale));
|
||||
isLTRKeyboardSet = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@ -178,20 +181,20 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards()
|
||||
// installed this prevents us from arbitrarily resetting the current
|
||||
// layout (bug 80274)
|
||||
locale = ::GetKeyboardLayout(0);
|
||||
if (!::GetKeyboardLayoutName(localeName))
|
||||
if (!::GetKeyboardLayoutNameW(localeName))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ASSERTION(*localeName,
|
||||
"GetKeyboardLayoutName return string length == 0");
|
||||
NS_ASSERTION((strlen(localeName) < KL_NAMELENGTH),
|
||||
NS_ASSERTION((wcslen(localeName) < KL_NAMELENGTH),
|
||||
"GetKeyboardLayout return string length >= KL_NAMELENGTH");
|
||||
|
||||
if (IsRTLLanguage(locale)) {
|
||||
strncpy(mRTLKeyboard, localeName, KL_NAMELENGTH);
|
||||
wcsncpy(mRTLKeyboard, localeName, KL_NAMELENGTH);
|
||||
mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
|
||||
}
|
||||
else {
|
||||
strncpy(mLTRKeyboard, localeName, KL_NAMELENGTH);
|
||||
wcsncpy(mLTRKeyboard, localeName, KL_NAMELENGTH);
|
||||
mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,9 @@ protected:
|
||||
|
||||
PRPackedBool mInitialized;
|
||||
PRPackedBool mHaveBidiKeyboards;
|
||||
char mLTRKeyboard[KL_NAMELENGTH];
|
||||
char mRTLKeyboard[KL_NAMELENGTH];
|
||||
char mCurrentLocaleName[KL_NAMELENGTH];
|
||||
PRUnichar mLTRKeyboard[KL_NAMELENGTH];
|
||||
PRUnichar mRTLKeyboard[KL_NAMELENGTH];
|
||||
PRUnichar mCurrentLocaleName[KL_NAMELENGTH];
|
||||
};
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
||||
|
||||
|
||||
// oddly, this isn't in the MSVC headers anywhere.
|
||||
UINT nsClipboard::CF_HTML = ::RegisterClipboardFormat("HTML Format");
|
||||
UINT nsClipboard::CF_HTML = ::RegisterClipboardFormatW(L"HTML Format");
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -111,7 +111,9 @@ UINT nsClipboard::GetFormat(const char* aMimeStr)
|
||||
else if (strcmp(aMimeStr, kNativeHTMLMime) == 0)
|
||||
format = CF_HTML;
|
||||
else
|
||||
format = ::RegisterClipboardFormat(aMimeStr);
|
||||
format = ::RegisterClipboardFormatW(NS_ConvertASCIItoUTF16(aMimeStr).get());
|
||||
|
||||
|
||||
|
||||
return format;
|
||||
}
|
||||
@ -306,18 +308,18 @@ nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void ** aData, PRUint32 * aLe
|
||||
*aLen = 0;
|
||||
LPVOID lpMsgBuf;
|
||||
|
||||
FormatMessage(
|
||||
FormatMessageW(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
(LPWSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
// Display the string.
|
||||
MessageBox( NULL, (const char *)lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );
|
||||
MessageBoxW( NULL, (LPCWSTR) lpMsgBuf, L"GetLastError", MB_OK|MB_ICONINFORMATION );
|
||||
|
||||
// Free the buffer.
|
||||
LocalFree( lpMsgBuf );
|
||||
|
@ -82,10 +82,10 @@ IAsyncOperation : public IUnknown
|
||||
* See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/transferring/clipboard.asp
|
||||
*/
|
||||
#ifndef CFSTR_INETURLA
|
||||
#define CFSTR_INETURLA "UniformResourceLocator"
|
||||
#define CFSTR_INETURLA L"UniformResourceLocator"
|
||||
#endif
|
||||
#ifndef CFSTR_INETURLW
|
||||
#define CFSTR_INETURLW "UniformResourceLocatorW"
|
||||
#define CFSTR_INETURLW L"UniformResourceLocatorW"
|
||||
#endif
|
||||
|
||||
// For support of MinGW w32api v2.4.
|
||||
@ -93,10 +93,10 @@ IAsyncOperation : public IUnknown
|
||||
// http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/shlobj.h?cvsroot=src
|
||||
// then that can be made the base required version and this code should be removed.
|
||||
#ifndef CFSTR_FILEDESCRIPTORA
|
||||
# define CFSTR_FILEDESCRIPTORA "FileGroupDescriptor"
|
||||
# define CFSTR_FILEDESCRIPTORA L"FileGroupDescriptor"
|
||||
#endif
|
||||
#ifndef CFSTR_FILEDESCRIPTORW
|
||||
# define CFSTR_FILEDESCRIPTORW "FileGroupDescriptorW"
|
||||
# define CFSTR_FILEDESCRIPTORW L"FileGroupDescriptorW"
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
@ -280,10 +280,10 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
|
||||
#ifndef WINCE
|
||||
}
|
||||
catch(...) {
|
||||
MessageBox(ofn.hwndOwner,
|
||||
0,
|
||||
"The filepicker was unexpectedly closed by Windows.",
|
||||
MB_ICONERROR);
|
||||
MessageBoxW(ofn.hwndOwner,
|
||||
0,
|
||||
L"The filepicker was unexpectedly closed by Windows.",
|
||||
MB_ICONERROR);
|
||||
result = PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
@ -83,7 +83,7 @@ static PRInt32 GetSystemParam(long flag, PRInt32 def)
|
||||
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
||||
{
|
||||
#ifndef WINCE
|
||||
gShell32DLLInst = LoadLibrary("Shell32.dll");
|
||||
gShell32DLLInst = LoadLibraryW(L"Shell32.dll");
|
||||
if (gShell32DLLInst)
|
||||
{
|
||||
gSHAppBarMessage = (SHAppBarMessagePtr) GetProcAddress(gShell32DLLInst,
|
||||
@ -531,7 +531,7 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
|
||||
if (gSHAppBarMessage)
|
||||
{
|
||||
// Get task bar window handle
|
||||
HWND shellWindow = FindWindow("Shell_TrayWnd", NULL);
|
||||
HWND shellWindow = FindWindowW(L"Shell_TrayWnd", NULL);
|
||||
|
||||
if (shellWindow != NULL)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include "nscore.h"
|
||||
#include "plstr.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nsString.h"
|
||||
#include <windows.h>
|
||||
|
||||
// mmsystem.h is needed to build with WIN32_LEAN_AND_MEAN
|
||||
@ -124,8 +124,7 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
|
||||
data = mLastSound;
|
||||
flags |= SND_ASYNC;
|
||||
}
|
||||
|
||||
::PlaySound(reinterpret_cast<const char*>(data), 0, flags);
|
||||
::PlaySoundW(reinterpret_cast<LPCWSTR>(data), 0, flags);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -166,12 +165,10 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
|
||||
PurgeLastSound();
|
||||
|
||||
if (aSoundAlias.EqualsLiteral("_moz_mailbeep")) {
|
||||
::PlaySound("MailBeep", nsnull, SND_ALIAS | SND_ASYNC);
|
||||
::PlaySoundW(L"MailBeep", nsnull, SND_ALIAS | SND_ASYNC);
|
||||
}
|
||||
else {
|
||||
nsCAutoString nativeSoundAlias;
|
||||
NS_CopyUnicodeToNative(aSoundAlias, nativeSoundAlias);
|
||||
::PlaySound(nativeSoundAlias.get(), nsnull, SND_ALIAS | SND_ASYNC);
|
||||
::PlaySoundW(PromiseFlatString(aSoundAlias).get(), nsnull, SND_ALIAS | SND_ASYNC);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -265,8 +265,7 @@ nsToolkit::Startup(HMODULE hModule)
|
||||
typedef BOOL (*SetProcessDPIAwareFunc)(VOID);
|
||||
|
||||
SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)
|
||||
GetProcAddress(LoadLibrary("user32.dll"),
|
||||
"SetProcessDPIAware");
|
||||
GetProcAddress(LoadLibraryW(L"user32.dll"), "SetProcessDPIAware");
|
||||
|
||||
if (setDPIAware)
|
||||
setDPIAware();
|
||||
@ -300,8 +299,8 @@ void nsToolkit::CreateInternalWindow(PRThread *aThread)
|
||||
// create the internal window
|
||||
//
|
||||
|
||||
mDispatchWnd = ::CreateWindow("nsToolkitClass",
|
||||
"NetscapeDispatchWnd",
|
||||
mDispatchWnd = ::CreateWindowW(L"nsToolkitClass",
|
||||
L"NetscapeDispatchWnd",
|
||||
WS_DISABLED,
|
||||
-50, -50,
|
||||
10, 10,
|
||||
|
@ -158,7 +158,7 @@
|
||||
PRLogModuleInfo* sWindowsLog = nsnull;
|
||||
#endif
|
||||
|
||||
static const char kMozHeapDumpMessageString[] = "MOZ_HeapDump";
|
||||
static const PRUnichar kMozHeapDumpMessageString[] = L"MOZ_HeapDump";
|
||||
|
||||
#define kWindowPositionSlop 20
|
||||
|
||||
@ -678,7 +678,7 @@ nsWindow::nsWindow() : nsBaseWidget()
|
||||
|
||||
// Heap dump
|
||||
#ifndef WINCE
|
||||
nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessage(kMozHeapDumpMessageString);
|
||||
nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessageW(kMozHeapDumpMessageString);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1096,26 +1096,26 @@ nsWindow::EventIsInsideWindow(UINT Msg, nsWindow* aWindow)
|
||||
return (PRBool) PtInRect(&r, mp);
|
||||
}
|
||||
|
||||
static char sPropName[40] = "";
|
||||
static char* GetNSWindowPropName() {
|
||||
static PRUnichar sPropName[40] = L"";
|
||||
static PRUnichar* GetNSWindowPropName() {
|
||||
if (!*sPropName)
|
||||
{
|
||||
_snprintf(sPropName, 39, "MozillansIWidgetPtr%p", _getpid());
|
||||
_snwprintf(sPropName, 39, L"MozillansIWidgetPtr%p", _getpid());
|
||||
sPropName[39] = '\0';
|
||||
}
|
||||
return sPropName;
|
||||
}
|
||||
|
||||
nsWindow * nsWindow::GetNSWindowPtr(HWND aWnd) {
|
||||
return (nsWindow *) ::GetPropA(aWnd, GetNSWindowPropName());
|
||||
return (nsWindow *) ::GetPropW(aWnd, GetNSWindowPropName());
|
||||
}
|
||||
|
||||
BOOL nsWindow::SetNSWindowPtr(HWND aWnd, nsWindow * ptr) {
|
||||
if (ptr == NULL) {
|
||||
::RemovePropA(aWnd, GetNSWindowPropName());
|
||||
::RemovePropW(aWnd, GetNSWindowPropName());
|
||||
return TRUE;
|
||||
} else {
|
||||
return ::SetPropA(aWnd, GetNSWindowPropName(), (HANDLE)ptr);
|
||||
return ::SetPropW(aWnd, GetNSWindowPropName(), (HANDLE)ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1766,7 +1766,7 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode) {
|
||||
|
||||
// Play the minimize sound while we're here, since that is also
|
||||
// forgotten when we use SW_SHOWMINIMIZED.
|
||||
::PlaySound("Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC);
|
||||
::PlaySoundW(L"Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -5397,7 +5397,7 @@ LPCWSTR nsWindow::WindowPopupClassW()
|
||||
return className;
|
||||
}
|
||||
|
||||
LPCSTR nsWindow::WindowClass()
|
||||
LPCTSTR nsWindow::WindowClass()
|
||||
{
|
||||
// Call into the wide version to make sure things get
|
||||
// registered properly.
|
||||
@ -5405,7 +5405,9 @@ LPCSTR nsWindow::WindowClass()
|
||||
|
||||
// XXX: The class name used here must be kept in sync with
|
||||
// the classname used in WindowClassW();
|
||||
|
||||
#ifdef UNICODE
|
||||
return classNameW;
|
||||
#else
|
||||
if (classNameW == kWClassNameHidden) {
|
||||
return kClassNameHidden;
|
||||
}
|
||||
@ -5422,17 +5424,21 @@ LPCSTR nsWindow::WindowClass()
|
||||
return kClassNameContentFrame;
|
||||
}
|
||||
return kClassNameGeneral;
|
||||
#endif
|
||||
}
|
||||
|
||||
LPCSTR nsWindow::WindowPopupClass()
|
||||
LPCTSTR nsWindow::WindowPopupClass()
|
||||
{
|
||||
// Call into the wide version to make sure things get
|
||||
// registered properly.
|
||||
WindowPopupClassW();
|
||||
#ifdef UNICODE
|
||||
return WindowPopupClassW();
|
||||
#else
|
||||
|
||||
// XXX: The class name used here must be kept in sync with
|
||||
// the classname used in WindowPopupClassW();
|
||||
return "MozillaDropShadowWindowClass";
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -7926,7 +7932,7 @@ STDMETHODIMP_(LRESULT) nsWindow::LresultFromObject(REFIID riid, WPARAM wParam, L
|
||||
{
|
||||
// open the dll dynamically
|
||||
if (!gmAccLib)
|
||||
gmAccLib =::LoadLibrary("OLEACC.DLL");
|
||||
gmAccLib =::LoadLibraryW(L"OLEACC.DLL");
|
||||
|
||||
if (gmAccLib) {
|
||||
if (!gmLresultFromObject)
|
||||
|
Loading…
Reference in New Issue
Block a user