From c02b509b7b9232413dba46f36081d91df9ed9d6d Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Thu, 12 Feb 2009 18:26:02 -0800 Subject: [PATCH] b=477727; windows widget nsWindow WinCE/Windows Mobile separation fixes; r=dougt --- widget/src/windows/nsWindow.cpp | 89 +++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 32 deletions(-) diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 09fcc4cb2f05..e27e282477c6 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -78,9 +78,20 @@ #include "gfxImageSurface.h" #ifdef WINCE + #include "aygshell.h" #include "imm.h" + +#define PAINT_USE_IMAGE_SURFACE + +#ifdef WINCE_WINDOWS_MOBILE +#define WINCE_HAVE_SOFTKB #include "tpcshell.h" +#else +#undef WINCE_HAVE_SOFTKB +#include "winuserm.h" +#endif + #else #include "nsUXThemeData.h" @@ -150,13 +161,16 @@ #include "prprf.h" #include "prmem.h" - #ifdef NS_ENABLE_TSF #include "nsTextStore.h" #endif //NS_ENABLE_TSF +/* + * WinCE helpers + */ #ifdef WINCE +#ifdef WINCE_HAVE_SOFTKB static PRBool gSoftKeyMenuBar = PR_FALSE; static void CreateSoftKeyMenuBar(HWND wnd) @@ -201,6 +215,7 @@ static void CreateSoftKeyMenuBar(HWND wnd) gSoftKeyMenuBar = mbi.hwndMB; } +#endif //defined(WINCE_HAVE_SOFTKB) #define IDI_APPLICATION MAKEINTRESOURCE(32512) @@ -251,7 +266,7 @@ inline BOOL EnumThreadWindows(DWORD inThreadID, WNDENUMPROC inFunc, LPARAM inPar return FALSE; } -#endif +#endif //defined(WINCE) @@ -1402,7 +1417,7 @@ nsWindow::StandardWindowCreate(nsIWidget *aParent, } } } -#ifdef WINCE +#if defined(WINCE) && defined(WINCE_HAVE_SOFTKB) if (mWindowType == eWindowType_dialog || mWindowType == eWindowType_toplevel ) CreateSoftKeyMenuBar(mWnd); #endif @@ -4732,11 +4747,9 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT if (WA_INACTIVE == fActive) { gJustGotDeactivate = PR_TRUE; - if (mIsTopWidgetWindow) #ifndef WINCE + if (mIsTopWidgetWindow) mLastKeyboardLayout = gKbdLayout.GetLayout(); -#else - ; #endif } else { gJustGotActivate = PR_TRUE; @@ -4806,7 +4819,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT } #endif -#ifdef WINCE +#if defined(WINCE) && defined(WINCE_HAVE_SOFTKB) // On Windows CE, we have a window that overlaps // the ISP button. In this case, we should always // try to hide it when we are activated @@ -4834,7 +4847,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT break; case WM_KILLFOCUS: -#ifdef WINCE +#if defined(WINCE) && defined(WINCE_HAVE_SOFTKB) { // Get current input context HIMC hC = ImmGetContext(mWnd); @@ -5350,7 +5363,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT #endif } - //*aRetValue = result; if (mWnd) { return result; @@ -6063,8 +6075,7 @@ PRBool nsWindow::OnPaint(HDC aDC) (PRInt32) mWnd); #endif // NS_DEBUG -#ifndef WINCE -#ifdef MOZ_XUL +#if defined(MOZ_XUL) && !defined(PAINT_USE_IMAGE_SURFACE) nsRefPtr targetSurface; if (eTransparencyTransparent == mTransparencyMode) { if (mTransparentSurface == nsnull) @@ -6073,24 +6084,25 @@ PRBool nsWindow::OnPaint(HDC aDC) } else { targetSurface = new gfxWindowsSurface(hDC); } -#else - nsRefPtr targetSurface = new gfxWindowsSurface(hDC); -#endif -#else - nsRefPtr targetSurface = new gfxImageSurface(gfxIntSize(ps.rcPaint.right - ps.rcPaint.left, - ps.rcPaint.bottom - ps.rcPaint.top), +#elif defined(PAINT_USE_IMAGE_SURFACE) + gfxIntSize surfaceSize(ps.rcPaint.right - ps.rcPaint.left, + ps.rcPaint.bottom - ps.rcPaint.top); + nsRefPtr targetSurface = new gfxImageSurface(surfaceSize, gfxASurface::ImageFormatRGB24); if (targetSurface && !targetSurface->CairoStatus()) { targetSurface->SetDeviceOffset(gfxPoint(-ps.rcPaint.left, -ps.rcPaint.top)); } +#else + nsRefPtr targetSurface = new gfxWindowsSurface(hDC); #endif - nsRefPtr thebesContext = new gfxContext(targetSurface); thebesContext->SetFlag(gfxContext::FLAG_DESTINED_FOR_SCREEN); -#ifndef WINCE -#if defined(MOZ_XUL) + // don't need to double buffer with PAINT_USE_IMAGE_SURFACE; + // it's implicitly double buffered +#if !defined(PAINT_USE_IMAGE_SURFACE) +# if defined(MOZ_XUL) if (eTransparencyGlass == mTransparencyMode && nsUXThemeData::sHaveCompositor) { thebesContext->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA); } else if (eTransparencyTransparent == mTransparencyMode) { @@ -6103,11 +6115,11 @@ PRBool nsWindow::OnPaint(HDC aDC) // If we're not doing translucency, then double buffer thebesContext->PushGroup(gfxASurface::CONTENT_COLOR); } -#else +# else // If we're not doing translucency, then double buffer thebesContext->PushGroup(gfxASurface::CONTENT_COLOR); +# endif #endif -#endif /* ifndef WINCE */ nsCOMPtr rc; nsresult rv = mContext->CreateRenderingContextInstance (*getter_AddRefs(rc)); @@ -6132,24 +6144,37 @@ PRBool nsWindow::OnPaint(HDC aDC) // bitmap. Now it can be read from memory bitmap to apply alpha channel and after // that displayed on the screen. UpdateTranslucentWindow(); - } else if (result) { - -#ifndef WINCE + } else +#endif + if (result) { +#ifndef PAINT_USE_IMAGE_SURFACE // Only update if DispatchWindowEvent returned TRUE; otherwise, nothing handled // this, and we'll just end up painting with black. thebesContext->PopGroupToSource(); thebesContext->SetOperator(gfxContext::OPERATOR_SOURCE); thebesContext->Paint(); #else - nsRefPtr winSurface = new gfxWindowsSurface(hDC); - nsRefPtr winCtx = new gfxContext(winSurface); + // Just blit this directly + BITMAPINFOHEADER bi; + memset(&bi, 0, sizeof(BITMAPINFOHEADER)); + bi.biSize = sizeof(BITMAPINFOHEADER); + bi.biWidth = surfaceSize.width; + bi.biHeight = - surfaceSize.height; + bi.biPlanes = 1; + bi.biBitCount = 32; + bi.biCompression = BI_RGB; - winCtx->SetOperator(gfxContext::OPERATOR_SOURCE); - winCtx->SetSource(targetSurface); - winCtx->Paint(); + StretchDIBits(hDC, + ps.rcPaint.left, ps.rcPaint.top, + surfaceSize.width, surfaceSize.height, + 0, 0, + surfaceSize.width, surfaceSize.height, + targetSurface->Data(), + (BITMAPINFO*) &bi, + DIB_RGB_COLORS, + SRCCOPY); #endif } -#endif } } @@ -6937,7 +6962,7 @@ nsWindow::GetTextRangeList(PRUint32* aListLength, // iterate over the attributes int lastOffset = 0; - for (int i = 0; i < *aListLength; i++) { + for (unsigned int i = 0; i < *aListLength; i++) { long current = sIMECompClauseArray[i + 1]; NS_ASSERTION(current <= maxlen, "wrong offset"); if(current > maxlen)