Changeset 84990 in webkit
- Timestamp:
- Apr 26, 2011 5:29:28 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/win/ChangeLog
r84578 r84990 1 2011-04-26 Brent Fulgham <bfulgham@webkit.org> 2 3 Reviewed by Adam Roben. 4 5 Implement a transparent WebView under Windows. This feature 6 allows the user to create small web-based applications, similar 7 to the dashboard on Mac OS X. 8 https://bugs.webkit.org/show_bug.cgi?id=58300 9 10 * Interfaces/IWebViewPrivate.idl: Add new set/get accessors to 11 change the state of a WebView into a Layered Window, or back 12 into a standard window. 13 * Interfaces/WebKit.idl: touch to force clean build 14 * WebView.cpp: 15 (WebView::WebView): Set layered window state in constructor. 16 (WebView::updateBackingStore): Cleanup old bitmap when finished. 17 (WebView::performLayeredWindowUpdate): New method to do the work 18 of calling ::UpdateLayeredWindow for the WebView with proper 19 alpha blending. 20 (WebView::paint): Small change to prevent accelerated compositing 21 when using a layered window. DirectX is not compatible with 22 ::UpdateLayeredWindow (at least currently). 23 (WebView::WebViewWndProc): Adjust main window procedure to avoid 24 painting a default background on a layered window (this is handled 25 by Windows during compositing), and to deal with paint messages 26 properly in the layered window case. 27 (WebView::active): The layered window is not a child window, 28 so the active state logic is slightly different. 29 (WebView::setUsesLayeredWindow): New set method for layered stated. 30 When called, it will convert a WebView into a Layered Window. 31 (WebView::usesLayeredWindow): Accessor 32 * WebView.h: 33 (WebView::setUsesLayeredWindow): Declare new accessor 34 (WebView::usesLayeredWindow): Declare new accessor 35 1 36 2011-04-21 Ryosuke Niwa <rniwa@webkit.org> 2 37 -
trunk/Source/WebKit/win/Interfaces/IWebViewPrivate.idl
r78620 r84990 154 154 HRESULT transparent([out, retval] BOOL* transparent); 155 155 156 HRESULT setUsesLayeredWindow([in] BOOL usesLayeredWindow); 157 HRESULT usesLayeredWindow([out, retval] BOOL* usesLayeredWindow); 158 156 159 HRESULT setAlwaysUsesComplexTextCodePath([in] BOOL complex); 157 160 HRESULT alwaysUsesComplexTextCodePath([out, retval] BOOL* complex); -
trunk/Source/WebKit/win/Interfaces/WebKit.idl
r83628 r84990 302 302 } 303 303 } 304 -
trunk/Source/WebKit/win/WebView.cpp
r84101 r84990 1 1 /* 2 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple, Inc. All rights reserved. 3 * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved. 4 * Copyright (C) 2011 Brent Fulgham. All rights reserved. 3 5 * 4 6 * Redistribution and use in source and binary forms, with or without … … 359 361 , m_nextDisplayIsSynchronous(false) 360 362 , m_lastSetCursor(0) 363 , m_usesLayeredWindow(false) 361 364 { 362 365 JSC::initializeThreading(); … … 950 953 HDC windowDC = 0; 951 954 HDC bitmapDC = dc; 955 HGDIOBJ oldBitmap = 0; 952 956 if (!dc) { 953 957 windowDC = ::GetDC(m_viewWindow); 954 958 bitmapDC = ::CreateCompatibleDC(windowDC); 955 ::SelectObject(bitmapDC, m_backingStoreBitmap->handle());959 oldBitmap = ::SelectObject(bitmapDC, m_backingStoreBitmap->handle()); 956 960 } 957 961 … … 983 987 984 988 if (!dc) { 989 ::SelectObject(bitmapDC, oldBitmap); 985 990 ::DeleteDC(bitmapDC); 986 991 ::ReleaseDC(m_viewWindow, windowDC); … … 990 995 } 991 996 997 void WebView::performLayeredWindowUpdate() 998 { 999 HDC hdcScreen = ::GetDC(m_viewWindow); 1000 OwnPtr<HDC> hdcMem = adoptPtr(::CreateCompatibleDC(hdcScreen)); 1001 HBITMAP hbmOld = static_cast<HBITMAP>(::SelectObject(hdcMem.get(), m_backingStoreBitmap->handle())); 1002 1003 BITMAP bmpInfo; 1004 ::GetObject(m_backingStoreBitmap->handle(), sizeof(bmpInfo), &bmpInfo); 1005 SIZE windowSize = { bmpInfo.bmWidth, bmpInfo.bmHeight }; 1006 1007 BLENDFUNCTION blendFunction; 1008 blendFunction.BlendOp = AC_SRC_OVER; 1009 blendFunction.BlendFlags = 0; 1010 blendFunction.SourceConstantAlpha = 0xFF; 1011 blendFunction.AlphaFormat = AC_SRC_ALPHA; 1012 1013 POINT layerPos = { 0, 0 }; 1014 ::UpdateLayeredWindow(m_viewWindow, hdcScreen, 0, &windowSize, hdcMem.get(), &layerPos, 0, &blendFunction, ULW_ALPHA); 1015 1016 ::SelectObject(hdcMem.get(), hbmOld); 1017 ::ReleaseDC(0, hdcScreen); 1018 } 1019 992 1020 void WebView::paint(HDC dc, LPARAM options) 993 1021 { … … 995 1023 996 1024 #if USE(ACCELERATED_COMPOSITING) 997 if (isAcceleratedCompositing() ) {1025 if (isAcceleratedCompositing() && !usesLayeredWindow()) { 998 1026 m_layerTreeHost->flushPendingLayerChangesNow(); 999 1027 // Flushing might have taken us out of compositing mode. … … 2098 2126 case WM_PAINT: { 2099 2127 webView->paint(0, 0); 2128 if (webView->usesLayeredWindow()) 2129 webView->performLayeredWindowUpdate(); 2100 2130 break; 2101 2131 } 2132 case WM_ERASEBKGND: 2133 if (webView->usesLayeredWindow()) { 2134 // Don't perform a background erase for transparent views. 2135 handled = true; 2136 lResult = 1; 2137 } 2138 break; 2102 2139 case WM_PRINTCLIENT: 2103 2140 webView->paint((HDC)wParam, lParam); … … 3315 3352 { 3316 3353 HWND activeWindow = GetActiveWindow(); 3354 if (usesLayeredWindow() && activeWindow == m_viewWindow) 3355 return true; 3356 3317 3357 return (activeWindow && m_topLevelParent == findTopLevelParent(activeWindow)); 3318 3358 } … … 5789 5829 } 5790 5830 5831 static bool setWindowStyle(HWND window, int index, LONG_PTR newValue) 5832 { 5833 // According to MSDN, if the last value of the flag we are setting was zero, 5834 // then SetWindowLongPtr returns zero, even though the call succeeded. So, 5835 // we have to clear the error state, then check the last error after 5836 // setting the value to see if it actually was a failure. 5837 ::SetLastError(0); 5838 return ::SetWindowLongPtr(window, index, newValue) || !::GetLastError(); 5839 } 5840 5841 HRESULT WebView::setUsesLayeredWindow(BOOL usesLayeredWindow) 5842 { 5843 if (m_usesLayeredWindow == !!usesLayeredWindow) 5844 return S_OK; 5845 5846 if (!m_viewWindow) 5847 return E_FAIL; 5848 5849 RECT rect; 5850 ::GetWindowRect(m_viewWindow, &rect); 5851 5852 LONG_PTR origExStyle = ::GetWindowLongPtr(m_viewWindow, GWL_EXSTYLE); 5853 LONG_PTR origStyle = ::GetWindowLongPtr(m_viewWindow, GWL_STYLE); 5854 5855 // The logic here has to account for the way SetParent works. 5856 // According to MSDN, to go from a child window to a popup window, 5857 // you must clear the child bit after setting the parent to 0. 5858 // On the other hand, to go from a popup window to a child, you 5859 // must clear the popup state before setting the parent. 5860 if (usesLayeredWindow) { 5861 LONG_PTR newExStyle = origExStyle | WS_EX_LAYERED; 5862 LONG_PTR newStyle = (origStyle & ~(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)) | WS_POPUP; 5863 5864 HWND origParent = ::SetParent(m_viewWindow, 0); 5865 5866 if (!setWindowStyle(m_viewWindow, GWL_STYLE, newStyle)) { 5867 ::SetParent(m_viewWindow, origParent); 5868 return E_FAIL; 5869 } 5870 5871 if (!setWindowStyle(m_viewWindow, GWL_EXSTYLE, newExStyle)) { 5872 setWindowStyle(m_viewWindow, GWL_STYLE, origStyle); 5873 ::SetParent(m_viewWindow, origParent); 5874 return E_FAIL; 5875 } 5876 } else { 5877 LONG_PTR newExStyle = origExStyle & ~WS_EX_LAYERED; 5878 LONG_PTR newStyle = (origStyle & ~WS_POPUP) | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; 5879 5880 if (!setWindowStyle(m_viewWindow, GWL_EXSTYLE, newExStyle)) 5881 return E_FAIL; 5882 5883 if (!setWindowStyle(m_viewWindow, GWL_STYLE, newStyle)) { 5884 setWindowStyle(m_viewWindow, GWL_EXSTYLE, origExStyle); 5885 return E_FAIL; 5886 } 5887 5888 ::SetParent(m_viewWindow, m_hostWindow ? m_hostWindow : HWND_MESSAGE); 5889 } 5890 5891 // MSDN indicates that SetWindowLongPtr doesn't take effect for some settings until a 5892 // SetWindowPos is called. 5893 ::SetWindowPos(m_viewWindow, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 5894 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); 5895 5896 m_usesLayeredWindow = usesLayeredWindow; 5897 return S_OK; 5898 } 5899 5900 HRESULT WebView::usesLayeredWindow(BOOL* usesLayeredWindow) 5901 { 5902 if (!usesLayeredWindow) 5903 return E_POINTER; 5904 5905 *usesLayeredWindow = this->usesLayeredWindow() ? TRUE : FALSE; 5906 return S_OK; 5907 } 5908 5791 5909 HRESULT STDMETHODCALLTYPE WebView::setCookieEnabled(BOOL enable) 5792 5910 { -
trunk/Source/WebKit/win/WebView.h
r84146 r84990 1 1 /* 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved. 4 * Copyright (C) 2011 Brent Fulgham. All rights reserved. 3 5 * 4 6 * Redistribution and use in source and binary forms, with or without … … 124 126 /* [in] */ BSTR frameName, 125 127 /* [in] */ BSTR groupName); 126 128 127 129 virtual HRESULT STDMETHODCALLTYPE setUIDelegate( 128 130 /* [in] */ IWebUIDelegate *d); … … 823 825 virtual HRESULT STDMETHODCALLTYPE setMinimumTimerInterval( 824 826 /* [in] */ double); 827 828 virtual HRESULT STDMETHODCALLTYPE setUsesLayeredWindow(BOOL); 829 virtual HRESULT STDMETHODCALLTYPE usesLayeredWindow(BOOL*); 825 830 826 831 // WebView … … 860 865 861 866 bool transparent() const { return m_transparent; } 867 bool usesLayeredWindow() const { return m_usesLayeredWindow; } 862 868 863 869 bool onIMEStartComposition(); … … 947 953 void paintIntoBackingStore(WebCore::FrameView*, HDC bitmapDC, const WebCore::IntRect& dirtyRect, WindowsToPaint); 948 954 void updateBackingStore(WebCore::FrameView*, HDC = 0, bool backingStoreCompletelyDirty = false, WindowsToPaint = PaintWebViewOnly); 955 956 void performLayeredWindowUpdate(); 949 957 950 958 WebCore::DragOperation keyStateToDragOperation(DWORD grfKeyState) const; … … 1078 1086 1079 1087 bool m_nextDisplayIsSynchronous; 1088 bool m_usesLayeredWindow; 1080 1089 1081 1090 HCURSOR m_lastSetCursor; -
trunk/Tools/ChangeLog
r84985 r84990 1 2011-04-26 Brent Fulgham <bfulgham@webkit.org> 2 3 Reviewed by Adam Roben. 4 5 Update WinLauncher with command-line arguments to allow the 6 transparency to be tested. Use --transparent to create a 7 transparent view. Use --desktop to have the view fill the 8 desktop area of the screen. 9 https://bugs.webkit.org/show_bug.cgi?id=58300 10 11 * WinLauncher/WinLauncher.cpp: 12 (usesLayeredWebView): New method to indicate that the 13 program is running with layered windows (alpha-blended 14 transparent windows). 15 (shouldUseFullDesktop): New method to indicate that the 16 program is running across the full desktop (less any 17 task bars.) 18 (resizeSubViews): Layered window mode doesn't have any 19 winapi child windows, so this routine is exited early 20 for that case. 21 (subclassForLayeredWindow): Subclass the window so we can 22 override its defaut message loop. 23 (computeFullDesktopFrame): Convenience function to get the 24 desktop region and update the frame dimensions appropriately. 25 (_tWinMain): Updated to accept the new '--transparent' and 26 '--desktop' arguments. 27 (InitInstance): Modified to exit early for the transparent 28 background case. WebKit will construct our primary window (with 29 appropriate settings) so we don't need to create one ourselves. 30 (WndProc): 31 (TransparentWndProc): New message loop for transparent windows, 32 since they need special handling to support dragging. 33 1 34 2011-04-26 Alexandre MAzari <amazari@igalia.com> 2 35 -
trunk/Tools/WinLauncher/WinLauncher.cpp
r84154 r84990 1 1 /* 2 2 * Copyright (C) 2006, 2008 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2009 Brent Fulgha. All rights reserved. 3 * Copyright (C) 2009, 2011 Brent Fulgham. All rights reserved. 4 * Copyright (C) 2009, 2010, 2011 Appcelerator, Inc. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 29 30 #include <WebKit/WebKitCOMAPI.h> 30 31 32 #include <string> 33 31 34 #include <commctrl.h> 32 35 #include <commdlg.h> 33 36 #include <objbase.h> 37 #include <shellapi.h> 34 38 #include <shlwapi.h> 35 39 #include <wininet.h> … … 44 48 HWND hMainWnd; 45 49 HWND hURLBarWnd; 46 long DefEditProc; 50 WNDPROC DefEditProc = 0; 51 WNDPROC DefWebKitProc = 0; 47 52 IWebView* gWebView = 0; 53 IWebViewPrivate* gWebViewPrivate = 0; 48 54 HWND gViewWindow = 0; 49 55 WinLauncherWebHost* gWebHost = 0; … … 51 57 TCHAR szTitle[MAX_LOADSTRING]; // The title bar text 52 58 TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name 59 60 // Support moving the transparent window 61 POINT s_windowPosition = { 100, 100 }; 62 SIZE s_windowSize = { 800, 400 }; 63 bool s_usesLayeredWebView = false; 64 bool s_fullDesktop = false; 53 65 54 66 // Forward declarations of functions included in this code module: … … 60 72 61 73 static void loadURL(BSTR urlBStr); 74 75 static bool usesLayeredWebView() 76 { 77 return s_usesLayeredWebView; 78 } 79 80 static bool shouldUseFullDesktop() 81 { 82 return s_fullDesktop; 83 } 62 84 63 85 HRESULT WinLauncherWebHost::updateAddressBar(IWebView* webView) … … 131 153 static void resizeSubViews() 132 154 { 155 if (usesLayeredWebView() || !gViewWindow) 156 return; 157 133 158 RECT rcClient; 134 159 GetClientRect(hMainWnd, &rcClient); … … 137 162 } 138 163 164 static void subclassForLayeredWindow() 165 { 166 hMainWnd = gViewWindow; 167 DefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hMainWnd, GWL_WNDPROC)); 168 ::SetWindowLongPtr(hMainWnd, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(WndProc)); 169 } 170 171 static void computeFullDesktopFrame() 172 { 173 RECT desktop; 174 if (!::SystemParametersInfo(SPI_GETWORKAREA, 0, static_cast<void*>(&desktop), 0)) 175 return; 176 177 s_windowPosition.x = 0; 178 s_windowPosition.y = 0; 179 s_windowSize.cx = desktop.right - desktop.left; 180 s_windowSize.cy = desktop.bottom - desktop.top; 181 } 182 139 183 int APIENTRY _tWinMain(HINSTANCE hInstance, 140 184 HINSTANCE hPrevInstance, … … 160 204 InitCommonControlsEx(&InitCtrlEx); 161 205 206 int argc = 0; 207 WCHAR** argv = CommandLineToArgvW(GetCommandLineW(), &argc); 208 for (int i = 1; i < argc; ++i) { 209 if (!wcsicmp(argv[i], L"--transparent")) 210 s_usesLayeredWebView = true; 211 else if (!wcsicmp(argv[i], L"--desktop")) 212 s_fullDesktop = true; 213 } 214 162 215 // Initialize global strings 163 216 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); … … 165 218 MyRegisterClass(hInstance); 166 219 220 if (shouldUseFullDesktop()) 221 computeFullDesktopFrame(); 222 167 223 // Perform application initialization: 168 224 if (!InitInstance (hInstance, nCmdShow)) … … 172 228 OleInitialize(NULL); 173 229 174 hURLBarWnd = CreateWindow(L"EDIT", 0, 175 WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, 176 0, 0, 0, 0, 177 hMainWnd, 178 0, 179 hInstance, 0); 180 181 DefEditProc = GetWindowLong(hURLBarWnd, GWL_WNDPROC); 182 SetWindowLong(hURLBarWnd, GWL_WNDPROC,(long)MyEditProc); 230 if (usesLayeredWebView()) { 231 hURLBarWnd = CreateWindow(L"EDIT", L"Type URL Here", 232 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, 233 s_windowPosition.x, s_windowPosition.y + s_windowSize.cy, s_windowSize.cx, URLBAR_HEIGHT, 234 0, 235 0, 236 hInstance, 0); 237 } else { 238 hURLBarWnd = CreateWindow(L"EDIT", 0, 239 WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, 240 0, 0, 0, 0, 241 hMainWnd, 242 0, 243 hInstance, 0); 244 } 245 246 DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hURLBarWnd, GWL_WNDPROC)); 247 SetWindowLongPtr(hURLBarWnd, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(MyEditProc)); 183 248 SetFocus(hURLBarWnd); 184 249 185 HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, (void**)&gWebView); 250 RECT clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy }; 251 252 IWebPreferences* tmpPreferences = 0; 253 IWebPreferences* standardPreferences = 0; 254 if (FAILED(WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences, reinterpret_cast<void**>(&tmpPreferences)))) 255 goto exit; 256 257 if (FAILED(tmpPreferences->standardPreferences(&standardPreferences))) 258 goto exit; 259 260 standardPreferences->setAcceleratedCompositingEnabled(TRUE); 261 262 HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&gWebView)); 263 if (FAILED(hr)) 264 goto exit; 265 266 hr = gWebView->QueryInterface(IID_IWebViewPrivate, reinterpret_cast<void**>(&gWebViewPrivate)); 186 267 if (FAILED(hr)) 187 268 goto exit; … … 199 280 goto exit; 200 281 201 hr = gWebView->setHostWindow((OLE_HANDLE) hMainWnd); 202 if (FAILED(hr)) 203 goto exit; 204 205 RECT clientRect; 206 GetClientRect(hMainWnd, &clientRect); 282 hr = gWebView->setHostWindow(reinterpret_cast<OLE_HANDLE>(hMainWnd)); 283 if (FAILED(hr)) 284 goto exit; 285 207 286 hr = gWebView->initWithFrame(clientRect, 0, 0); 208 287 if (FAILED(hr)) … … 214 293 goto exit; 215 294 216 static BSTR defaultHTML = SysAllocString(TEXT("<p style=\"background-color: #00FF00\">Testing</p><img src=\"http://webkit.org/images/icon-gold.png\" alt=\"Face\"><div style=\"border: solid blue \" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>"));295 static BSTR defaultHTML = SysAllocString(TEXT("<p style=\"background-color: #00FF00\">Testing</p><img src=\"http://webkit.org/images/icon-gold.png\" alt=\"Face\"><div style=\"border: solid blue; background: white;\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>")); 217 296 frame->loadHTMLString(defaultHTML, 0); 218 297 frame->Release(); 219 298 220 IWebViewPrivate* viewExt; 221 hr = gWebView->QueryInterface(IID_IWebViewPrivate, (void**)&viewExt); 222 if (FAILED(hr)) 223 goto exit; 224 225 hr = viewExt->viewWindow((OLE_HANDLE*) &gViewWindow); 226 viewExt->Release(); 299 hr = gWebViewPrivate->setTransparent(usesLayeredWebView()); 300 if (FAILED(hr)) 301 goto exit; 302 303 hr = gWebViewPrivate->setUsesLayeredWindow(usesLayeredWebView()); 304 if (FAILED(hr)) 305 goto exit; 306 307 hr = gWebViewPrivate->viewWindow(reinterpret_cast<OLE_HANDLE*>(&gViewWindow)); 227 308 if (FAILED(hr) || !gViewWindow) 228 309 goto exit; 310 311 if (usesLayeredWebView()) 312 subclassForLayeredWindow(); 229 313 230 314 resizeSubViews(); … … 245 329 exit: 246 330 gPrintDelegate->Release(); 331 if (gWebViewPrivate) 332 gWebViewPrivate->Release(); 247 333 gWebView->Release(); 334 if (standardPreferences) 335 standardPreferences->Release(); 336 tmpPreferences->Release(); 337 248 338 shutDownWebKit(); 249 339 #ifdef _CRTDBG_MAP_ALLOC … … 280 370 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) 281 371 { 282 hInst = hInstance; // Store instance handle in our global variable 283 284 hMainWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 285 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); 286 287 if (!hMainWnd) 288 return FALSE; 289 290 ShowWindow(hMainWnd, nCmdShow); 291 UpdateWindow(hMainWnd); 292 293 return TRUE; 372 hInst = hInstance; // Store instance handle in our global variable 373 374 if (usesLayeredWebView()) 375 return TRUE; 376 377 hMainWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 378 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInstance, 0); 379 380 if (!hMainWnd) 381 return FALSE; 382 383 ShowWindow(hMainWnd, nCmdShow); 384 UpdateWindow(hMainWnd); 385 386 return TRUE; 294 387 } 295 388 … … 374 467 } 375 468 469 static const int dragBarHeight = 30; 470 376 471 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 377 472 { 378 int wmId, wmEvent;473 WNDPROC parentProc = usesLayeredWebView() ? DefWebKitProc : DefWindowProc; 379 474 380 475 switch (message) { 381 case WM_COMMAND: 382 wmId = LOWORD(wParam); 383 wmEvent = HIWORD(wParam); 476 case WM_NCHITTEST: 477 if (usesLayeredWebView()) { 478 RECT window; 479 ::GetWindowRect(hWnd, &window); 480 // For testing our transparent window, we need a region to use as a handle for 481 // dragging. The right way to do this would be to query the web view to see what's 482 // under the mouse. However, for testing purposes we just use an arbitrary 483 // 30 pixel band at the top of the view as an arbitrary gripping location. 484 // 485 // When we are within this bad, return HT_CAPTION to tell Windows we want to 486 // treat this region as if it were the title bar on a normal window. 487 int y = HIWORD(lParam); 488 489 if ((y > window.top) && (y < window.top + dragBarHeight)) 490 return HTCAPTION; 491 492 return CallWindowProc(parentProc, hWnd, message, wParam, lParam); 493 } 494 break; 495 case WM_COMMAND: { 496 int wmId = LOWORD(wParam); 497 int wmEvent = HIWORD(wParam); 384 498 // Parse the menu selections: 385 499 switch (wmId) { 386 case IDM_ABOUT: 387 DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); 388 break; 389 case IDM_EXIT: 390 DestroyWindow(hWnd); 391 break; 392 case IDM_PRINT: 393 PrintView(hWnd, message, wParam, lParam); 394 break; 395 default: 396 return DefWindowProc(hWnd, message, wParam, lParam); 500 case IDM_ABOUT: 501 DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); 502 break; 503 case IDM_EXIT: 504 DestroyWindow(hWnd); 505 break; 506 case IDM_PRINT: 507 PrintView(hWnd, message, wParam, lParam); 508 break; 509 default: 510 return CallWindowProc(parentProc, hWnd, message, wParam, lParam); 511 } 397 512 } 398 513 break; … … 401 516 break; 402 517 case WM_SIZE: 403 if (!gWebView) 404 break; 518 if (!gWebView || usesLayeredWebView()) 519 return CallWindowProc(parentProc, hWnd, message, wParam, lParam); 520 405 521 resizeSubViews(); 406 break; 522 break; 407 523 default: 408 return DefWindowProc(hWnd, message, wParam, lParam); 409 } 524 return CallWindowProc(parentProc, hWnd, message, wParam, lParam); 525 break; 526 } 527 410 528 return 0; 411 529 } 412 413 530 414 531 #define MAX_URL_LENGTH 1024
Note: See TracChangeset
for help on using the changeset viewer.