| 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> |
| 11 #include <tpcshrd.h> | |
| 12 | 11 |
| 13 #include <utility> | 12 #include <utility> |
| 14 | 13 |
| 15 #include "base/bind.h" | 14 #include "base/bind.h" |
| 16 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 17 #include "base/debug/alias.h" | 16 #include "base/debug/alias.h" |
| 18 #include "base/macros.h" | 17 #include "base/macros.h" |
| 19 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 20 #include "base/win/scoped_gdi_object.h" | 19 #include "base/win/scoped_gdi_object.h" |
| 21 #include "base/win/windows_version.h" | 20 #include "base/win/windows_version.h" |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 static_cast<ui::WindowEventTarget*>(this))); | 377 static_cast<ui::WindowEventTarget*>(this))); |
| 379 | 378 |
| 380 // Direct Manipulation is enabled on Windows 10+. The CreateInstance function | 379 // Direct Manipulation is enabled on Windows 10+. The CreateInstance function |
| 381 // returns NULL if Direct Manipulation is not available. | 380 // returns NULL if Direct Manipulation is not available. |
| 382 direct_manipulation_helper_ = | 381 direct_manipulation_helper_ = |
| 383 gfx::win::DirectManipulationHelper::CreateInstance(); | 382 gfx::win::DirectManipulationHelper::CreateInstance(); |
| 384 if (direct_manipulation_helper_) | 383 if (direct_manipulation_helper_) |
| 385 direct_manipulation_helper_->Initialize(hwnd()); | 384 direct_manipulation_helper_->Initialize(hwnd()); |
| 386 | 385 |
| 387 // Disable pen flicks (http://crbug.com/506977) | 386 // Disable pen flicks (http://crbug.com/506977) |
| 388 ::SetProp(hwnd(), MICROSOFT_TABLETPENSERVICE_PROPERTY, | 387 base::win::DisableFlicks(hwnd()); |
| 389 reinterpret_cast<HANDLE>(TABLET_DISABLE_FLICKS | | |
| 390 TABLET_DISABLE_FLICKFALLBACKKEYS)); | |
| 391 } | 388 } |
| 392 | 389 |
| 393 void HWNDMessageHandler::InitModalType(ui::ModalType modal_type) { | 390 void HWNDMessageHandler::InitModalType(ui::ModalType modal_type) { |
| 394 if (modal_type == ui::MODAL_TYPE_NONE) | 391 if (modal_type == ui::MODAL_TYPE_NONE) |
| 395 return; | 392 return; |
| 396 // We implement modality by crawling up the hierarchy of windows starting | 393 // We implement modality by crawling up the hierarchy of windows starting |
| 397 // at the owner, disabling all of them so that they don't receive input | 394 // at the owner, disabling all of them so that they don't receive input |
| 398 // messages. | 395 // messages. |
| 399 HWND start = ::GetWindow(hwnd(), GW_OWNER); | 396 HWND start = ::GetWindow(hwnd(), GW_OWNER); |
| 400 while (start) { | 397 while (start) { |
| 401 ::EnableWindow(start, FALSE); | 398 ::EnableWindow(start, FALSE); |
| 402 start = ::GetParent(start); | 399 start = ::GetParent(start); |
| 403 } | 400 } |
| 404 } | 401 } |
| 405 | 402 |
| 406 void HWNDMessageHandler::Close() { | 403 void HWNDMessageHandler::Close() { |
| 407 if (!IsWindow(hwnd())) | 404 if (!IsWindow(hwnd())) |
| 408 return; // No need to do anything. | 405 return; // No need to do anything. |
| 409 | 406 |
| 410 // Let's hide ourselves right away. | 407 // Let's hide ourselves right away. |
| 411 Hide(); | 408 Hide(); |
| 412 | 409 |
| 413 // Modal dialog windows disable their owner windows; re-enable them now so | 410 // Modal dialog windows disable their owner windows; re-enable them now so |
| 414 // they can activate as foreground windows upon this window's destruction. | 411 // they can activate as foreground windows upon this window's destruction. |
| 415 RestoreEnabledIfNecessary(); | 412 RestoreEnabledIfNecessary(); |
| 416 | 413 |
| 417 // Remove the property which disables pen flicks (http://crbug.com/506977) | 414 // Re-enable flicks which removes the window property. |
| 418 // for this window. | 415 base::win::EnableFlicks(hwnd()); |
| 419 ::RemoveProp(hwnd(), MICROSOFT_TABLETPENSERVICE_PROPERTY); | |
| 420 | 416 |
| 421 if (!waiting_for_close_now_) { | 417 if (!waiting_for_close_now_) { |
| 422 // And we delay the close so that if we are called from an ATL callback, | 418 // And we delay the close so that if we are called from an ATL callback, |
| 423 // we don't destroy the window before the callback returned (as the caller | 419 // we don't destroy the window before the callback returned (as the caller |
| 424 // may delete ourselves on destroy and the ATL callback would still | 420 // may delete ourselves on destroy and the ATL callback would still |
| 425 // dereference us when the callback returns). | 421 // dereference us when the callback returns). |
| 426 waiting_for_close_now_ = true; | 422 waiting_for_close_now_ = true; |
| 427 base::MessageLoop::current()->PostTask( | 423 base::MessageLoop::current()->PostTask( |
| 428 FROM_HERE, | 424 FROM_HERE, |
| 429 base::Bind(&HWNDMessageHandler::CloseNow, weak_factory_.GetWeakPtr())); | 425 base::Bind(&HWNDMessageHandler::CloseNow, weak_factory_.GetWeakPtr())); |
| (...skipping 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 delegate_->HandleClientSizeChanged(GetClientAreaBounds().size()); | 2625 delegate_->HandleClientSizeChanged(GetClientAreaBounds().size()); |
| 2630 ResetWindowRegion(false, true); | 2626 ResetWindowRegion(false, true); |
| 2631 } | 2627 } |
| 2632 | 2628 |
| 2633 if (direct_manipulation_helper_) | 2629 if (direct_manipulation_helper_) |
| 2634 direct_manipulation_helper_->SetBounds(bounds_in_pixels); | 2630 direct_manipulation_helper_->SetBounds(bounds_in_pixels); |
| 2635 } | 2631 } |
| 2636 | 2632 |
| 2637 | 2633 |
| 2638 } // namespace views | 2634 } // namespace views |
| OLD | NEW |