Chromium Code Reviews| 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/win/hwnd_message_handler.h" | 5 #include "ui/views/win/hwnd_message_handler.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <oleacc.h> | 8 #include <oleacc.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <tchar.h> | 10 #include <tchar.h> |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 | 369 |
| 370 // Direct Manipulation is enabled on Windows 10+. The CreateInstance function | 370 // Direct Manipulation is enabled on Windows 10+. The CreateInstance function |
| 371 // returns NULL if Direct Manipulation is not available. | 371 // returns NULL if Direct Manipulation is not available. |
| 372 direct_manipulation_helper_ = | 372 direct_manipulation_helper_ = |
| 373 gfx::win::DirectManipulationHelper::CreateInstance(); | 373 gfx::win::DirectManipulationHelper::CreateInstance(); |
| 374 if (direct_manipulation_helper_) | 374 if (direct_manipulation_helper_) |
| 375 direct_manipulation_helper_->Initialize(hwnd()); | 375 direct_manipulation_helper_->Initialize(hwnd()); |
| 376 | 376 |
| 377 // Disable pen flicks (http://crbug.com/506977) | 377 // Disable pen flicks (http://crbug.com/506977) |
| 378 base::win::DisableFlicks(hwnd()); | 378 base::win::DisableFlicks(hwnd()); |
| 379 | |
| 380 // Register for fullscreen window notifications from the shell. | |
| 381 APPBARDATA appbar = {}; | |
| 382 appbar.cbSize = sizeof(APPBARDATA); | |
| 383 appbar.hWnd = hwnd(); | |
| 384 appbar.uCallbackMessage = WM_APPBAR_NOTIFICATION_MESSAGE; | |
| 385 ::SHAppBarMessage(ABM_NEW, &appbar); | |
| 379 } | 386 } |
| 380 | 387 |
| 381 void HWNDMessageHandler::InitModalType(ui::ModalType modal_type) { | 388 void HWNDMessageHandler::InitModalType(ui::ModalType modal_type) { |
| 382 if (modal_type == ui::MODAL_TYPE_NONE) | 389 if (modal_type == ui::MODAL_TYPE_NONE) |
| 383 return; | 390 return; |
| 384 // We implement modality by crawling up the hierarchy of windows starting | 391 // We implement modality by crawling up the hierarchy of windows starting |
| 385 // at the owner, disabling all of them so that they don't receive input | 392 // at the owner, disabling all of them so that they don't receive input |
| 386 // messages. | 393 // messages. |
| 387 HWND start = ::GetWindow(hwnd(), GW_OWNER); | 394 HWND start = ::GetWindow(hwnd(), GW_OWNER); |
| 388 while (start) { | 395 while (start) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 411 // may delete ourselves on destroy and the ATL callback would still | 418 // may delete ourselves on destroy and the ATL callback would still |
| 412 // dereference us when the callback returns). | 419 // dereference us when the callback returns). |
| 413 waiting_for_close_now_ = true; | 420 waiting_for_close_now_ = true; |
| 414 base::ThreadTaskRunnerHandle::Get()->PostTask( | 421 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 415 FROM_HERE, | 422 FROM_HERE, |
| 416 base::Bind(&HWNDMessageHandler::CloseNow, weak_factory_.GetWeakPtr())); | 423 base::Bind(&HWNDMessageHandler::CloseNow, weak_factory_.GetWeakPtr())); |
| 417 } | 424 } |
| 418 } | 425 } |
| 419 | 426 |
| 420 void HWNDMessageHandler::CloseNow() { | 427 void HWNDMessageHandler::CloseNow() { |
| 428 // Unregister fullscreen notifications from the shell. | |
| 429 APPBARDATA appbar = {}; | |
| 430 appbar.cbSize = sizeof(APPBARDATA); | |
| 431 appbar.hWnd = hwnd(); | |
| 432 ::SHAppBarMessage(ABM_REMOVE, &appbar); | |
| 433 | |
| 421 // We may already have been destroyed if the selection resulted in a tab | 434 // We may already have been destroyed if the selection resulted in a tab |
| 422 // switch which will have reactivated the browser window and closed us, so | 435 // switch which will have reactivated the browser window and closed us, so |
| 423 // we need to check to see if we're still a window before trying to destroy | 436 // we need to check to see if we're still a window before trying to destroy |
| 424 // ourself. | 437 // ourself. |
| 425 waiting_for_close_now_ = false; | 438 waiting_for_close_now_ = false; |
| 426 if (IsWindow(hwnd())) | 439 if (IsWindow(hwnd())) |
| 427 DestroyWindow(hwnd()); | 440 DestroyWindow(hwnd()); |
| 428 } | 441 } |
| 429 | 442 |
| 430 gfx::Rect HWNDMessageHandler::GetWindowBoundsInScreen() const { | 443 gfx::Rect HWNDMessageHandler::GetWindowBoundsInScreen() const { |
| (...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2380 // received after this message was posted. | 2393 // received after this message was posted. |
| 2381 if (current_window_size_message_ != w_param) | 2394 if (current_window_size_message_ != w_param) |
| 2382 return 0; | 2395 return 0; |
| 2383 | 2396 |
| 2384 delegate_->HandleWindowSizeUnchanged(); | 2397 delegate_->HandleWindowSizeUnchanged(); |
| 2385 sent_window_size_changing_ = false; | 2398 sent_window_size_changing_ = false; |
| 2386 | 2399 |
| 2387 return 0; | 2400 return 0; |
| 2388 } | 2401 } |
| 2389 | 2402 |
| 2403 LRESULT HWNDMessageHandler::OnAppBarMessage(UINT message, | |
| 2404 WPARAM w_param, | |
| 2405 LPARAM l_param) { | |
| 2406 // Please refer to the ChromeViewsDelegate::GetAppbarAutohideEdges() function | |
| 2407 // for some context on how we handle autohide taskbars. | |
| 2408 | |
| 2409 // We receive this notification when a window changes from fullscreen to | |
| 2410 // non fullscreen. Sadly we don't get the window handle. The problem we | |
| 2411 // are trying to address is the case where our window switched away to | |
| 2412 // maximized from fullscreen mode and the autohide taskbar is around. | |
| 2413 // We want to leave a pixel space at the place where the taskbar shows up | |
| 2414 // to ensure that the taskbar shows up when the mouse is moved there. | |
| 2415 // The SendFrameChanged() call below achieves that. | |
| 2416 if (w_param == ABN_FULLSCREENAPP && (l_param == 0) && IsMaximized()) | |
| 2417 SendFrameChanged(); | |
|
Peter Kasting
2016/12/02 01:56:41
Now that we removed the TOPMOST check, does this s
ananta
2016/12/02 06:09:14
I added this mostly for correctness sake, i.e quer
| |
| 2418 return 0; | |
| 2419 } | |
| 2420 | |
| 2390 void HWNDMessageHandler::OnSessionChange(WPARAM status_code) { | 2421 void HWNDMessageHandler::OnSessionChange(WPARAM status_code) { |
| 2391 // Direct3D presents are ignored while the screen is locked, so force the | 2422 // Direct3D presents are ignored while the screen is locked, so force the |
| 2392 // window to be redrawn on unlock. | 2423 // window to be redrawn on unlock. |
| 2393 if (status_code == WTS_SESSION_UNLOCK) | 2424 if (status_code == WTS_SESSION_UNLOCK) |
| 2394 ForceRedrawWindow(10); | 2425 ForceRedrawWindow(10); |
| 2395 } | 2426 } |
| 2396 | 2427 |
| 2397 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { | 2428 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { |
| 2398 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); | 2429 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); |
| 2399 for (size_t i = 0; i < touch_events.size() && ref; ++i) | 2430 for (size_t i = 0; i < touch_events.size() && ref; ++i) |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2749 MONITORINFO monitor_info = {sizeof(monitor_info)}; | 2780 MONITORINFO monitor_info = {sizeof(monitor_info)}; |
| 2750 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), | 2781 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), |
| 2751 &monitor_info); | 2782 &monitor_info); |
| 2752 gfx::Rect shrunk_rect(monitor_info.rcMonitor); | 2783 gfx::Rect shrunk_rect(monitor_info.rcMonitor); |
| 2753 shrunk_rect.set_height(shrunk_rect.height() - 1); | 2784 shrunk_rect.set_height(shrunk_rect.height() - 1); |
| 2754 background_fullscreen_hack_ = true; | 2785 background_fullscreen_hack_ = true; |
| 2755 SetBoundsInternal(shrunk_rect, false); | 2786 SetBoundsInternal(shrunk_rect, false); |
| 2756 } | 2787 } |
| 2757 | 2788 |
| 2758 } // namespace views | 2789 } // namespace views |
| OLD | NEW |