Chromium Code Reviews| Index: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc |
| diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc |
| index 38a416bb19ca7db7b8690c143237c1cf8435b6c9..c8ed877aed0b124af4eff2508e06c51831363c29 100644 |
| --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc |
| +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc |
| @@ -39,6 +39,7 @@ |
| #include "ui/events/devices/x11/device_list_cache_x11.h" |
| #include "ui/events/devices/x11/touch_factory_x11.h" |
| #include "ui/events/event_utils.h" |
| +#include "ui/events/null_event_targeter.h" |
| #include "ui/events/platform/platform_event_source.h" |
| #include "ui/events/platform/x11/x11_event_source.h" |
| #include "ui/gfx/geometry/insets.h" |
| @@ -177,6 +178,16 @@ int XI2ModeToXMode(int xi2_mode) { |
| } // namespace |
| +DesktopWindowTreeHostX11::ScopedHandle::ScopedHandle(const base::Closure& |
| + destroy_callback) |
| + : destroy_callback_(destroy_callback) { |
| +} |
| + |
| +DesktopWindowTreeHostX11::ScopedHandle::~ScopedHandle() { |
| + if (!destroy_callback_.is_null()) |
| + destroy_callback_.Run(); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // DesktopWindowTreeHostX11, public: |
| @@ -206,7 +217,10 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( |
| has_pointer_(false), |
| has_window_focus_(false), |
| has_pointer_focus_(false), |
| - close_widget_factory_(this) {} |
| + modal_dialog_xid_(0), |
| + scoped_handle_(NULL), |
| + close_widget_factory_(this), |
| + weak_factory_(this) {} |
| DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { |
| window()->ClearProperty(kHostForRootWindow); |
| @@ -1774,7 +1788,8 @@ void DesktopWindowTreeHostX11::DispatchTouchEvent(ui::TouchEvent* event) { |
| } |
| void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { |
| - GetInputMethod()->DispatchKeyEvent(event); |
| + if (native_widget_delegate_->AsWidget()->IsActive()) |
| + GetInputMethod()->DispatchKeyEvent(event); |
| } |
| void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( |
| @@ -2296,6 +2311,32 @@ gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( |
| return gfx::ToEnclosingRect(rect_in_pixels); |
| } |
| +XID DesktopWindowTreeHostX11::GetModalDialog() { |
| + return modal_dialog_xid_; |
| +} |
| + |
| +std::unique_ptr<DesktopWindowTreeHostX11::ScopedHandle> |
| + DesktopWindowTreeHostX11::DisableEventListening(XID dialog) { |
| + DCHECK(dialog); |
| + DCHECK(!modal_dialog_xid_); |
| + modal_dialog_xid_ = dialog; |
| + // ScopedWindowTargeter is used to temporarily replace the event-targeter |
| + // with NullEventTargeter to make |dialog| modal. |
| + targeter_for_modal_.reset(new aura::ScopedWindowTargeter(window(), |
| + std::unique_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); |
| + |
| + scoped_handle_ = new DesktopWindowTreeHostX11::ScopedHandle( |
| + base::Bind(&DesktopWindowTreeHostX11::EnableEventListening, |
| + weak_factory_.GetWeakPtr())); |
| + return base::WrapUnique(scoped_handle_); |
|
sadrul
2016/09/30 12:22:27
return base::MakeUnique<...>(base::Bind...)
joone
2016/10/01 00:03:16
Done.
|
| +} |
| + |
| +void DesktopWindowTreeHostX11::EnableEventListening() { |
| + DCHECK(modal_dialog_xid_); |
| + modal_dialog_xid_ = 0; |
| + targeter_for_modal_.reset(); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // DesktopWindowTreeHost, public: |