OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/widget/native_widget_win.h" | 5 #include "ui/views/widget/native_widget_win.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "ui/views/controls/textfield/native_textfield_views.h" | 38 #include "ui/views/controls/textfield/native_textfield_views.h" |
39 #include "ui/views/drag_utils.h" | 39 #include "ui/views/drag_utils.h" |
40 #include "ui/views/focus/accelerator_handler.h" | 40 #include "ui/views/focus/accelerator_handler.h" |
41 #include "ui/views/focus/view_storage.h" | 41 #include "ui/views/focus/view_storage.h" |
42 #include "ui/views/focus/widget_focus_manager.h" | 42 #include "ui/views/focus/widget_focus_manager.h" |
43 #include "ui/views/ime/input_method_win.h" | 43 #include "ui/views/ime/input_method_win.h" |
44 #include "ui/views/views_delegate.h" | 44 #include "ui/views/views_delegate.h" |
45 #include "ui/views/widget/aero_tooltip_manager.h" | 45 #include "ui/views/widget/aero_tooltip_manager.h" |
46 #include "ui/views/widget/child_window_message_processor.h" | 46 #include "ui/views/widget/child_window_message_processor.h" |
47 #include "ui/views/widget/drop_target_win.h" | 47 #include "ui/views/widget/drop_target_win.h" |
| 48 #include "ui/views/widget/hwnd_message_handler.h" |
48 #include "ui/views/widget/monitor_win.h" | 49 #include "ui/views/widget/monitor_win.h" |
49 #include "ui/views/widget/native_widget_delegate.h" | 50 #include "ui/views/widget/native_widget_delegate.h" |
50 #include "ui/views/widget/root_view.h" | 51 #include "ui/views/widget/root_view.h" |
51 #include "ui/views/widget/widget_delegate.h" | 52 #include "ui/views/widget/widget_delegate.h" |
52 #include "ui/views/widget/widget_hwnd_utils.h" | 53 #include "ui/views/widget/widget_hwnd_utils.h" |
53 #include "ui/views/window/native_frame_view.h" | 54 #include "ui/views/window/native_frame_view.h" |
54 | 55 |
55 #if !defined(USE_AURA) | 56 #if !defined(USE_AURA) |
56 #include "base/command_line.h" | 57 #include "base/command_line.h" |
57 #include "ui/base/ui_base_switches.h" | 58 #include "ui/base/ui_base_switches.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 fullscreen_(false), | 423 fullscreen_(false), |
423 metro_snap_(false), | 424 metro_snap_(false), |
424 force_hidden_count_(0), | 425 force_hidden_count_(0), |
425 lock_updates_count_(0), | 426 lock_updates_count_(0), |
426 ignore_window_pos_changes_(false), | 427 ignore_window_pos_changes_(false), |
427 ALLOW_THIS_IN_INITIALIZER_LIST(ignore_pos_changes_factory_(this)), | 428 ALLOW_THIS_IN_INITIALIZER_LIST(ignore_pos_changes_factory_(this)), |
428 last_monitor_(NULL), | 429 last_monitor_(NULL), |
429 is_right_mouse_pressed_on_caption_(false), | 430 is_right_mouse_pressed_on_caption_(false), |
430 restored_enabled_(false), | 431 restored_enabled_(false), |
431 destroyed_(NULL), | 432 destroyed_(NULL), |
432 has_non_client_view_(false) { | 433 has_non_client_view_(false), |
| 434 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 435 message_handler_(new HWNDMessageHandler(this))) { |
433 } | 436 } |
434 | 437 |
435 NativeWidgetWin::~NativeWidgetWin() { | 438 NativeWidgetWin::~NativeWidgetWin() { |
436 if (destroyed_ != NULL) | 439 if (destroyed_ != NULL) |
437 *destroyed_ = true; | 440 *destroyed_ = true; |
438 | 441 |
439 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 442 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
440 delete delegate_; | 443 delete delegate_; |
441 else | 444 else |
442 CloseNow(); | 445 CloseNow(); |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 } | 1253 } |
1251 return result; | 1254 return result; |
1252 } | 1255 } |
1253 | 1256 |
1254 //////////////////////////////////////////////////////////////////////////////// | 1257 //////////////////////////////////////////////////////////////////////////////// |
1255 // NativeWidgetWin, protected: | 1258 // NativeWidgetWin, protected: |
1256 | 1259 |
1257 // Message handlers ------------------------------------------------------------ | 1260 // Message handlers ------------------------------------------------------------ |
1258 | 1261 |
1259 void NativeWidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) { | 1262 void NativeWidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) { |
1260 SetMsgHandled(FALSE); | 1263 message_handler_->OnActivate(action, minimized, window); |
1261 } | 1264 } |
1262 | 1265 |
1263 void NativeWidgetWin::OnActivateApp(BOOL active, DWORD thread_id) { | 1266 void NativeWidgetWin::OnActivateApp(BOOL active, DWORD thread_id) { |
1264 if (GetWidget()->non_client_view() && !active && | 1267 message_handler_->OnActivateApp(active, thread_id); |
1265 thread_id != GetCurrentThreadId()) { | |
1266 // Another application was activated, we should reset any state that | |
1267 // disables inactive rendering now. | |
1268 delegate_->EnableInactiveRendering(); | |
1269 // Also update the native frame if it is rendering the non-client area. | |
1270 if (!remove_standard_frame_ && GetWidget()->ShouldUseNativeFrame()) | |
1271 DefWindowProcWithRedrawLock(WM_NCACTIVATE, FALSE, 0); | |
1272 } | |
1273 } | 1268 } |
1274 | 1269 |
1275 LRESULT NativeWidgetWin::OnAppCommand(HWND window, | 1270 LRESULT NativeWidgetWin::OnAppCommand(HWND window, |
1276 short app_command, | 1271 short app_command, |
1277 WORD device, | 1272 WORD device, |
1278 int keystate) { | 1273 int keystate) { |
1279 // We treat APPCOMMAND ids as an extension of our command namespace, and just | 1274 return message_handler_->OnAppCommand(window, app_command, device, keystate); |
1280 // let the delegate figure out what to do... | |
1281 BOOL is_handled = (GetWidget()->widget_delegate() && | |
1282 GetWidget()->widget_delegate()->ExecuteWindowsCommand(app_command)) ? | |
1283 TRUE : FALSE; | |
1284 SetMsgHandled(is_handled); | |
1285 // Make sure to return TRUE if the event was handled or in some cases the | |
1286 // system will execute the default handler which can cause bugs like going | |
1287 // forward or back two pages instead of one. | |
1288 return is_handled; | |
1289 } | 1275 } |
1290 | 1276 |
1291 void NativeWidgetWin::OnCancelMode() { | 1277 void NativeWidgetWin::OnCancelMode() { |
1292 SetMsgHandled(FALSE); | 1278 message_handler_->OnCancelMode(); |
1293 } | 1279 } |
1294 | 1280 |
1295 void NativeWidgetWin::OnCaptureChanged(HWND hwnd) { | 1281 void NativeWidgetWin::OnCaptureChanged(HWND hwnd) { |
1296 delegate_->OnMouseCaptureLost(); | 1282 message_handler_->OnCaptureChanged(hwnd); |
1297 } | 1283 } |
1298 | 1284 |
1299 void NativeWidgetWin::OnClose() { | 1285 void NativeWidgetWin::OnClose() { |
1300 GetWidget()->Close(); | 1286 message_handler_->OnClose(); |
1301 } | 1287 } |
1302 | 1288 |
1303 void NativeWidgetWin::OnCommand(UINT notification_code, | 1289 void NativeWidgetWin::OnCommand(UINT notification_code, |
1304 int command_id, | 1290 int command_id, |
1305 HWND window) { | 1291 HWND window) { |
1306 // If the notification code is > 1 it means it is control specific and we | 1292 message_handler_->OnCommand(notification_code, command_id, window); |
1307 // should ignore it. | |
1308 if (notification_code > 1 || | |
1309 GetWidget()->widget_delegate()->ExecuteWindowsCommand(command_id)) { | |
1310 SetMsgHandled(FALSE); | |
1311 } | |
1312 } | 1293 } |
1313 | 1294 |
1314 LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) { | 1295 LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) { |
1315 SetNativeWindowProperty(kNativeWidgetKey, this); | 1296 SetNativeWindowProperty(kNativeWidgetKey, this); |
1316 CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd())); | 1297 CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd())); |
1317 | 1298 |
1318 use_layered_buffer_ = !!(window_ex_style() & WS_EX_LAYERED); | 1299 use_layered_buffer_ = !!(window_ex_style() & WS_EX_LAYERED); |
1319 | 1300 |
1320 // Attempt to detect screen readers by sending an event with our custom id. | 1301 // Attempt to detect screen readers by sending an event with our custom id. |
1321 if (!IsAccessibleWidget()) | 1302 if (!IsAccessibleWidget()) |
(...skipping 28 matching lines...) Expand all Loading... |
1350 | 1331 |
1351 // This message initializes the window so that focus border are shown for | 1332 // This message initializes the window so that focus border are shown for |
1352 // windows. | 1333 // windows. |
1353 SendMessage( | 1334 SendMessage( |
1354 hwnd(), WM_CHANGEUISTATE, MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0); | 1335 hwnd(), WM_CHANGEUISTATE, MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0); |
1355 | 1336 |
1356 // Bug 964884: detach the IME attached to this window. | 1337 // Bug 964884: detach the IME attached to this window. |
1357 // We should attach IMEs only when we need to input CJK strings. | 1338 // We should attach IMEs only when we need to input CJK strings. |
1358 ImmAssociateContextEx(hwnd(), NULL, 0); | 1339 ImmAssociateContextEx(hwnd(), NULL, 0); |
1359 | 1340 |
1360 if (remove_standard_frame_) { | 1341 if (message_handler_->remove_standard_frame()) { |
1361 SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) & ~WS_CAPTION); | 1342 SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) & ~WS_CAPTION); |
1362 SendFrameChanged(GetNativeView()); | 1343 SendFrameChanged(GetNativeView()); |
1363 } | 1344 } |
1364 | 1345 |
1365 // We need to allow the delegate to size its contents since the window may not | 1346 // We need to allow the delegate to size its contents since the window may not |
1366 // receive a size notification when its initial bounds are specified at window | 1347 // receive a size notification when its initial bounds are specified at window |
1367 // creation time. | 1348 // creation time. |
1368 ClientAreaSizeChanged(); | 1349 ClientAreaSizeChanged(); |
1369 | 1350 |
1370 delegate_->OnNativeWidgetCreated(); | 1351 delegate_->OnNativeWidgetCreated(); |
1371 | 1352 |
1372 // Get access to a modifiable copy of the system menu. | 1353 // Get access to a modifiable copy of the system menu. |
1373 GetSystemMenu(hwnd(), false); | 1354 GetSystemMenu(hwnd(), false); |
1374 | 1355 |
1375 if (base::win::GetVersion() >= base::win::VERSION_WIN7) | 1356 if (base::win::GetVersion() >= base::win::VERSION_WIN7) |
1376 RegisterTouchWindow(hwnd(), 0); | 1357 RegisterTouchWindow(hwnd(), 0); |
1377 | 1358 |
1378 return 0; | 1359 return 0; |
1379 } | 1360 } |
1380 | 1361 |
1381 void NativeWidgetWin::OnDestroy() { | 1362 void NativeWidgetWin::OnDestroy() { |
1382 delegate_->OnNativeWidgetDestroying(); | 1363 message_handler_->OnDestroy(); |
1383 if (drop_target_.get()) { | |
1384 RevokeDragDrop(hwnd()); | |
1385 drop_target_ = NULL; | |
1386 } | |
1387 } | 1364 } |
1388 | 1365 |
1389 void NativeWidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) { | 1366 void NativeWidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) { |
1390 GetWidget()->widget_delegate()->OnDisplayChanged(); | 1367 message_handler_->OnDisplayChange(bits_per_pixel, screen_size); |
1391 } | 1368 } |
1392 | 1369 |
1393 LRESULT NativeWidgetWin::OnDwmCompositionChanged(UINT msg, | 1370 LRESULT NativeWidgetWin::OnDwmCompositionChanged(UINT msg, |
1394 WPARAM w_param, | 1371 WPARAM w_param, |
1395 LPARAM l_param) { | 1372 LPARAM l_param) { |
1396 if (!GetWidget()->non_client_view()) { | 1373 message_handler_->OnDwmCompositionChanged(msg, w_param, l_param); |
1397 SetMsgHandled(FALSE); | |
1398 return 0; | |
1399 } | |
1400 | |
1401 // For some reason, we need to hide the window while we're changing the frame | |
1402 // type only when we're changing it in response to WM_DWMCOMPOSITIONCHANGED. | |
1403 // If we don't, the client area will be filled with black. I'm suspecting | |
1404 // something skia-ey. | |
1405 // Frame type toggling caused by the user (e.g. switching theme) doesn't seem | |
1406 // to have this requirement. | |
1407 FrameTypeChanged(); | |
1408 return 0; | 1374 return 0; |
1409 } | 1375 } |
1410 | 1376 |
1411 void NativeWidgetWin::OnEndSession(BOOL ending, UINT logoff) { | 1377 void NativeWidgetWin::OnEndSession(BOOL ending, UINT logoff) { |
1412 SetMsgHandled(FALSE); | 1378 message_handler_->OnEndSession(ending, logoff); |
1413 } | 1379 } |
1414 | 1380 |
1415 void NativeWidgetWin::OnEnterSizeMove() { | 1381 void NativeWidgetWin::OnEnterSizeMove() { |
1416 delegate_->OnNativeWidgetBeginUserBoundsChange(); | 1382 message_handler_->OnEnterSizeMove(); |
1417 SetMsgHandled(FALSE); | |
1418 } | 1383 } |
1419 | 1384 |
1420 LRESULT NativeWidgetWin::OnEraseBkgnd(HDC dc) { | 1385 LRESULT NativeWidgetWin::OnEraseBkgnd(HDC dc) { |
1421 // This is needed for magical win32 flicker ju-ju. | 1386 return message_handler_->OnEraseBkgnd(dc); |
1422 return 1; | |
1423 } | 1387 } |
1424 | 1388 |
1425 void NativeWidgetWin::OnExitMenuLoop(BOOL is_track_popup_menu) { | 1389 void NativeWidgetWin::OnExitMenuLoop(BOOL is_track_popup_menu) { |
1426 SetMsgHandled(FALSE); | 1390 message_handler_->OnExitMenuLoop(is_track_popup_menu); |
1427 } | 1391 } |
1428 | 1392 |
1429 void NativeWidgetWin::OnExitSizeMove() { | 1393 void NativeWidgetWin::OnExitSizeMove() { |
1430 delegate_->OnNativeWidgetEndUserBoundsChange(); | 1394 message_handler_->OnExitSizeMove(); |
1431 SetMsgHandled(FALSE); | |
1432 } | 1395 } |
1433 | 1396 |
1434 LRESULT NativeWidgetWin::OnGetObject(UINT uMsg, | 1397 LRESULT NativeWidgetWin::OnGetObject(UINT uMsg, |
1435 WPARAM w_param, | 1398 WPARAM w_param, |
1436 LPARAM l_param) { | 1399 LPARAM l_param) { |
1437 LRESULT reference_result = static_cast<LRESULT>(0L); | 1400 LRESULT reference_result = static_cast<LRESULT>(0L); |
1438 | 1401 |
1439 // Accessibility readers will send an OBJID_CLIENT message | 1402 // Accessibility readers will send an OBJID_CLIENT message |
1440 if (OBJID_CLIENT == l_param) { | 1403 if (OBJID_CLIENT == l_param) { |
1441 // Retrieve MSAA dispatch object for the root view. | 1404 // Retrieve MSAA dispatch object for the root view. |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 WM_NCACTIVATE, inactive_rendering_disabled || active, 0); | 1688 WM_NCACTIVATE, inactive_rendering_disabled || active, 0); |
1726 } | 1689 } |
1727 | 1690 |
1728 LRESULT NativeWidgetWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { | 1691 LRESULT NativeWidgetWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { |
1729 // We only override the default handling if we need to specify a custom | 1692 // We only override the default handling if we need to specify a custom |
1730 // non-client edge width. Note that in most cases "no insets" means no | 1693 // non-client edge width. Note that in most cases "no insets" means no |
1731 // custom width, but in fullscreen mode or when the NonClientFrameView | 1694 // custom width, but in fullscreen mode or when the NonClientFrameView |
1732 // requests it, we want a custom width of 0. | 1695 // requests it, we want a custom width of 0. |
1733 gfx::Insets insets = GetClientAreaInsets(); | 1696 gfx::Insets insets = GetClientAreaInsets(); |
1734 if (insets.empty() && !IsFullscreen() && | 1697 if (insets.empty() && !IsFullscreen() && |
1735 !(mode && remove_standard_frame_)) { | 1698 !(mode && message_handler_->remove_standard_frame())) { |
1736 SetMsgHandled(FALSE); | 1699 SetMsgHandled(FALSE); |
1737 return 0; | 1700 return 0; |
1738 } | 1701 } |
1739 | 1702 |
1740 RECT* client_rect = mode ? | 1703 RECT* client_rect = mode ? |
1741 &(reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0]) : | 1704 &(reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0]) : |
1742 reinterpret_cast<RECT*>(l_param); | 1705 reinterpret_cast<RECT*>(l_param); |
1743 client_rect->left += insets.left(); | 1706 client_rect->left += insets.left(); |
1744 client_rect->top += insets.top(); | 1707 client_rect->top += insets.top(); |
1745 client_rect->bottom -= insets.bottom(); | 1708 client_rect->bottom -= insets.bottom(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 } | 1773 } |
1811 | 1774 |
1812 LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) { | 1775 LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) { |
1813 if (!GetWidget()->non_client_view()) { | 1776 if (!GetWidget()->non_client_view()) { |
1814 SetMsgHandled(FALSE); | 1777 SetMsgHandled(FALSE); |
1815 return 0; | 1778 return 0; |
1816 } | 1779 } |
1817 | 1780 |
1818 // If the DWM is rendering the window controls, we need to give the DWM's | 1781 // If the DWM is rendering the window controls, we need to give the DWM's |
1819 // default window procedure first chance to handle hit testing. | 1782 // default window procedure first chance to handle hit testing. |
1820 if (!remove_standard_frame_ && GetWidget()->ShouldUseNativeFrame()) { | 1783 if (!message_handler_->remove_standard_frame() && |
| 1784 GetWidget()->ShouldUseNativeFrame()) { |
1821 LRESULT result; | 1785 LRESULT result; |
1822 if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, | 1786 if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, |
1823 MAKELPARAM(point.x, point.y), &result)) { | 1787 MAKELPARAM(point.x, point.y), &result)) { |
1824 return result; | 1788 return result; |
1825 } | 1789 } |
1826 } | 1790 } |
1827 | 1791 |
1828 // First, give the NonClientView a chance to test the point to see if it | 1792 // First, give the NonClientView a chance to test the point to see if it |
1829 // provides any of the non-client area. | 1793 // provides any of the non-client area. |
1830 POINT temp = point; | 1794 POINT temp = point; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2204 SetMsgHandled(TRUE); | 2168 SetMsgHandled(TRUE); |
2205 return; | 2169 return; |
2206 } | 2170 } |
2207 | 2171 |
2208 SetMsgHandled(FALSE); | 2172 SetMsgHandled(FALSE); |
2209 } | 2173 } |
2210 | 2174 |
2211 void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) { | 2175 void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) { |
2212 if (DidClientAreaSizeChange(window_pos)) | 2176 if (DidClientAreaSizeChange(window_pos)) |
2213 ClientAreaSizeChanged(); | 2177 ClientAreaSizeChanged(); |
2214 if (remove_standard_frame_ && window_pos->flags & SWP_FRAMECHANGED && | 2178 if (message_handler_->remove_standard_frame() && |
2215 IsAeroGlassEnabled()) | 2179 window_pos->flags & SWP_FRAMECHANGED && |
| 2180 IsAeroGlassEnabled()) { |
2216 UpdateDWMFrame(); | 2181 UpdateDWMFrame(); |
| 2182 } |
2217 if (window_pos->flags & SWP_SHOWWINDOW) | 2183 if (window_pos->flags & SWP_SHOWWINDOW) |
2218 delegate_->OnNativeWidgetVisibilityChanged(true); | 2184 delegate_->OnNativeWidgetVisibilityChanged(true); |
2219 else if (window_pos->flags & SWP_HIDEWINDOW) | 2185 else if (window_pos->flags & SWP_HIDEWINDOW) |
2220 delegate_->OnNativeWidgetVisibilityChanged(false); | 2186 delegate_->OnNativeWidgetVisibilityChanged(false); |
2221 SetMsgHandled(FALSE); | 2187 SetMsgHandled(FALSE); |
2222 } | 2188 } |
2223 | 2189 |
2224 void NativeWidgetWin::OnFinalMessage(HWND window) { | 2190 void NativeWidgetWin::OnFinalMessage(HWND window) { |
2225 // We don't destroy props in WM_DESTROY as we may still get messages after | 2191 // We don't destroy props in WM_DESTROY as we may still get messages after |
2226 // WM_DESTROY that assume the properties are still valid (such as WM_CLOSE). | 2192 // WM_DESTROY that assume the properties are still valid (such as WM_CLOSE). |
2227 props_.clear(); | 2193 props_.clear(); |
2228 delegate_->OnNativeWidgetDestroyed(); | 2194 delegate_->OnNativeWidgetDestroyed(); |
2229 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 2195 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
2230 delete this; | 2196 delete this; |
2231 } | 2197 } |
2232 | 2198 |
2233 //////////////////////////////////////////////////////////////////////////////// | 2199 //////////////////////////////////////////////////////////////////////////////// |
2234 // NativeWidgetWin, protected: | 2200 // NativeWidgetWin, protected: |
2235 | 2201 |
2236 int NativeWidgetWin::GetShowState() const { | 2202 int NativeWidgetWin::GetShowState() const { |
2237 return SW_SHOWNORMAL; | 2203 return SW_SHOWNORMAL; |
2238 } | 2204 } |
2239 | 2205 |
2240 gfx::Insets NativeWidgetWin::GetClientAreaInsets() const { | 2206 gfx::Insets NativeWidgetWin::GetClientAreaInsets() const { |
2241 // Returning an empty Insets object causes the default handling in | 2207 // Returning an empty Insets object causes the default handling in |
2242 // NativeWidgetWin::OnNCCalcSize() to be invoked. | 2208 // NativeWidgetWin::OnNCCalcSize() to be invoked. |
2243 if (!has_non_client_view_ || | 2209 if (!has_non_client_view_ || |
2244 (GetWidget()->ShouldUseNativeFrame() && !remove_standard_frame_)) | 2210 (GetWidget()->ShouldUseNativeFrame() && |
| 2211 !message_handler_->remove_standard_frame())) |
2245 return gfx::Insets(); | 2212 return gfx::Insets(); |
2246 | 2213 |
2247 if (IsMaximized()) { | 2214 if (IsMaximized()) { |
2248 // Windows automatically adds a standard width border to all sides when a | 2215 // Windows automatically adds a standard width border to all sides when a |
2249 // window is maximized. | 2216 // window is maximized. |
2250 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); | 2217 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); |
2251 return gfx::Insets(border_thickness, border_thickness, border_thickness, | 2218 return gfx::Insets(border_thickness, border_thickness, border_thickness, |
2252 border_thickness); | 2219 border_thickness); |
2253 } | 2220 } |
2254 | 2221 |
2255 // The hack below doesn't seem to be necessary when the standard frame is | 2222 // The hack below doesn't seem to be necessary when the standard frame is |
2256 // removed. | 2223 // removed. |
2257 if (remove_standard_frame_) | 2224 if (message_handler_->remove_standard_frame()) |
2258 return gfx::Insets(); | 2225 return gfx::Insets(); |
2259 // This is weird, but highly essential. If we don't offset the bottom edge | 2226 // This is weird, but highly essential. If we don't offset the bottom edge |
2260 // of the client rect, the window client area and window area will match, | 2227 // of the client rect, the window client area and window area will match, |
2261 // and when returning to glass rendering mode from non-glass, the client | 2228 // and when returning to glass rendering mode from non-glass, the client |
2262 // area will not paint black as transparent. This is because (and I don't | 2229 // area will not paint black as transparent. This is because (and I don't |
2263 // know why) the client area goes from matching the window rect to being | 2230 // know why) the client area goes from matching the window rect to being |
2264 // something else. If the client area is not the window rect in both | 2231 // something else. If the client area is not the window rect in both |
2265 // modes, the blackness doesn't occur. Because of this, we need to tell | 2232 // modes, the blackness doesn't occur. Because of this, we need to tell |
2266 // the RootView to lay out to fit the window rect, rather than the client | 2233 // the RootView to lay out to fit the window rect, rather than the client |
2267 // rect when using the opaque frame. | 2234 // rect when using the opaque frame. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2306 SetFocus(GetNativeView()); | 2273 SetFocus(GetNativeView()); |
2307 } | 2274 } |
2308 } | 2275 } |
2309 | 2276 |
2310 void NativeWidgetWin::ExecuteSystemMenuCommand(int command) { | 2277 void NativeWidgetWin::ExecuteSystemMenuCommand(int command) { |
2311 if (command) | 2278 if (command) |
2312 SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0); | 2279 SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0); |
2313 } | 2280 } |
2314 | 2281 |
2315 //////////////////////////////////////////////////////////////////////////////// | 2282 //////////////////////////////////////////////////////////////////////////////// |
| 2283 // NativeWidgetWin, HWNDMessageHandlerDelegate implementation: |
| 2284 |
| 2285 bool NativeWidgetWin::IsWidgetWindow() const { |
| 2286 return !!GetWidget()->non_client_view(); |
| 2287 } |
| 2288 |
| 2289 bool NativeWidgetWin::IsUsingCustomFrame() const { |
| 2290 return GetWidget()->ShouldUseNativeFrame(); |
| 2291 } |
| 2292 |
| 2293 void NativeWidgetWin::HandleAppDeactivated() { |
| 2294 // Another application was activated, we should reset any state that |
| 2295 // disables inactive rendering now. |
| 2296 delegate_->EnableInactiveRendering(); |
| 2297 } |
| 2298 |
| 2299 bool NativeWidgetWin::HandleAppCommand(short command) { |
| 2300 // We treat APPCOMMAND ids as an extension of our command namespace, and just |
| 2301 // let the delegate figure out what to do... |
| 2302 return GetWidget()->widget_delegate() && |
| 2303 GetWidget()->widget_delegate()->ExecuteWindowsCommand(command); |
| 2304 } |
| 2305 |
| 2306 void NativeWidgetWin::HandleCaptureLost() { |
| 2307 delegate_->OnMouseCaptureLost(); |
| 2308 } |
| 2309 |
| 2310 void NativeWidgetWin::HandleClose() { |
| 2311 GetWidget()->Close(); |
| 2312 } |
| 2313 |
| 2314 bool NativeWidgetWin::HandleCommand(int command) { |
| 2315 return GetWidget()->widget_delegate()->ExecuteWindowsCommand(command); |
| 2316 } |
| 2317 |
| 2318 void NativeWidgetWin::HandleDestroy() { |
| 2319 delegate_->OnNativeWidgetDestroying(); |
| 2320 if (drop_target_.get()) { |
| 2321 RevokeDragDrop(hwnd()); |
| 2322 drop_target_ = NULL; |
| 2323 } |
| 2324 } |
| 2325 |
| 2326 void NativeWidgetWin::HandleDisplayChange() { |
| 2327 GetWidget()->widget_delegate()->OnDisplayChanged(); |
| 2328 } |
| 2329 |
| 2330 void NativeWidgetWin::HandleGlassModeChange() { |
| 2331 // For some reason, we need to hide the window while we're changing the frame |
| 2332 // type only when we're changing it in response to WM_DWMCOMPOSITIONCHANGED. |
| 2333 // If we don't, the client area will be filled with black. I'm suspecting |
| 2334 // something skia-ey. |
| 2335 // Frame type toggling caused by the user (e.g. switching theme) doesn't seem |
| 2336 // to have this requirement. |
| 2337 FrameTypeChanged(); |
| 2338 } |
| 2339 |
| 2340 void NativeWidgetWin::HandleBeginWMSizeMove() { |
| 2341 delegate_->OnNativeWidgetBeginUserBoundsChange(); |
| 2342 } |
| 2343 |
| 2344 void NativeWidgetWin::HandleEndWMSizeMove() { |
| 2345 delegate_->OnNativeWidgetEndUserBoundsChange(); |
| 2346 } |
| 2347 |
| 2348 NativeWidgetWin* NativeWidgetWin::AsNativeWidgetWin() { |
| 2349 return this; |
| 2350 } |
| 2351 |
| 2352 //////////////////////////////////////////////////////////////////////////////// |
2316 // NativeWidgetWin, private: | 2353 // NativeWidgetWin, private: |
2317 | 2354 |
2318 // static | 2355 // static |
2319 void NativeWidgetWin::PostProcessActivateMessage(NativeWidgetWin* widget, | 2356 void NativeWidgetWin::PostProcessActivateMessage(NativeWidgetWin* widget, |
2320 int activation_state) { | 2357 int activation_state) { |
2321 DCHECK(widget->GetWidget()->is_top_level()); | 2358 DCHECK(widget->GetWidget()->is_top_level()); |
2322 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager(); | 2359 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager(); |
2323 if (WA_INACTIVE == activation_state) { | 2360 if (WA_INACTIVE == activation_state) { |
2324 // We might get activated/inactivated without being enabled, so we need to | 2361 // We might get activated/inactivated without being enabled, so we need to |
2325 // clear restore_focus_when_enabled_. | 2362 // clear restore_focus_when_enabled_. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2434 break; | 2471 break; |
2435 default: | 2472 default: |
2436 NOTREACHED(); | 2473 NOTREACHED(); |
2437 } | 2474 } |
2438 | 2475 |
2439 set_initial_class_style(class_style); | 2476 set_initial_class_style(class_style); |
2440 set_window_style(window_style() | style); | 2477 set_window_style(window_style() | style); |
2441 set_window_ex_style(window_ex_style() | ex_style); | 2478 set_window_ex_style(window_ex_style() | ex_style); |
2442 | 2479 |
2443 has_non_client_view_ = Widget::RequiresNonClientView(params.type); | 2480 has_non_client_view_ = Widget::RequiresNonClientView(params.type); |
2444 remove_standard_frame_ = params.remove_standard_frame; | 2481 message_handler_->set_remove_standard_frame(params.remove_standard_frame); |
2445 } | 2482 } |
2446 | 2483 |
2447 void NativeWidgetWin::RedrawInvalidRect() { | 2484 void NativeWidgetWin::RedrawInvalidRect() { |
2448 if (!use_layered_buffer_) { | 2485 if (!use_layered_buffer_) { |
2449 RECT r = { 0, 0, 0, 0 }; | 2486 RECT r = { 0, 0, 0, 0 }; |
2450 if (GetUpdateRect(hwnd(), &r, FALSE) && !IsRectEmpty(&r)) { | 2487 if (GetUpdateRect(hwnd(), &r, FALSE) && !IsRectEmpty(&r)) { |
2451 RedrawWindow(hwnd(), &r, NULL, | 2488 RedrawWindow(hwnd(), &r, NULL, |
2452 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); | 2489 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); |
2453 } | 2490 } |
2454 } | 2491 } |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2770 // static | 2807 // static |
2771 bool NativeWidgetPrivate::IsTouchDown() { | 2808 bool NativeWidgetPrivate::IsTouchDown() { |
2772 // This currently isn't necessary because we're not generating touch events on | 2809 // This currently isn't necessary because we're not generating touch events on |
2773 // windows. When we do, this will need to be updated. | 2810 // windows. When we do, this will need to be updated. |
2774 return false; | 2811 return false; |
2775 } | 2812 } |
2776 | 2813 |
2777 } // namespace internal | 2814 } // namespace internal |
2778 | 2815 |
2779 } // namespace views | 2816 } // namespace views |
OLD | NEW |