| 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/desktop_aura/desktop_window_tree_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
| 6 | 6 |
| 7 #include <X11/extensions/shape.h> | 7 #include <X11/extensions/shape.h> |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
| 10 #include <X11/Xregion.h> | 10 #include <X11/Xregion.h> |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 desktop_native_widget_aura_(desktop_native_widget_aura), | 199 desktop_native_widget_aura_(desktop_native_widget_aura), |
| 200 content_window_(NULL), | 200 content_window_(NULL), |
| 201 window_parent_(NULL), | 201 window_parent_(NULL), |
| 202 custom_window_shape_(false), | 202 custom_window_shape_(false), |
| 203 urgency_hint_set_(false), | 203 urgency_hint_set_(false), |
| 204 has_pointer_grab_(false), | 204 has_pointer_grab_(false), |
| 205 activatable_(true), | 205 activatable_(true), |
| 206 has_pointer_(false), | 206 has_pointer_(false), |
| 207 has_window_focus_(false), | 207 has_window_focus_(false), |
| 208 has_pointer_focus_(false), | 208 has_pointer_focus_(false), |
| 209 modal_dialog_xid_(0), | 209 modal_dialog_counter_(0), |
| 210 close_widget_factory_(this), | 210 close_widget_factory_(this), |
| 211 weak_factory_(this) {} | 211 weak_factory_(this) {} |
| 212 | 212 |
| 213 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { | 213 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { |
| 214 window()->ClearProperty(kHostForRootWindow); | 214 window()->ClearProperty(kHostForRootWindow); |
| 215 aura::client::SetWindowMoveClient(window(), NULL); | 215 aura::client::SetWindowMoveClient(window(), NULL); |
| 216 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 216 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
| 217 DestroyDispatcher(); | 217 DestroyDispatcher(); |
| 218 } | 218 } |
| 219 | 219 |
| (...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2330 return gfx::ToEnclosingRect(rect_in_dip); | 2330 return gfx::ToEnclosingRect(rect_in_dip); |
| 2331 } | 2331 } |
| 2332 | 2332 |
| 2333 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( | 2333 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( |
| 2334 const gfx::Rect& rect_in_dip) const { | 2334 const gfx::Rect& rect_in_dip) const { |
| 2335 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); | 2335 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); |
| 2336 GetRootTransform().TransformRect(&rect_in_pixels); | 2336 GetRootTransform().TransformRect(&rect_in_pixels); |
| 2337 return gfx::ToEnclosingRect(rect_in_pixels); | 2337 return gfx::ToEnclosingRect(rect_in_pixels); |
| 2338 } | 2338 } |
| 2339 | 2339 |
| 2340 XID DesktopWindowTreeHostX11::GetModalDialog() { | |
| 2341 return modal_dialog_xid_; | |
| 2342 } | |
| 2343 | |
| 2344 std::unique_ptr<base::Closure> | 2340 std::unique_ptr<base::Closure> |
| 2345 DesktopWindowTreeHostX11::DisableEventListening(XID dialog) { | 2341 DesktopWindowTreeHostX11::DisableEventListening() { |
| 2346 DCHECK(dialog); | 2342 // Allows to open multiple file-pickers. See https://crbug.com/678982 |
| 2347 DCHECK(!modal_dialog_xid_); | 2343 modal_dialog_counter_++; |
| 2348 modal_dialog_xid_ = dialog; | 2344 if (modal_dialog_counter_ == 1) { |
| 2349 // ScopedWindowTargeter is used to temporarily replace the event-targeter | 2345 // ScopedWindowTargeter is used to temporarily replace the event-targeter |
| 2350 // with NullEventTargeter to make |dialog| modal. | 2346 // with NullEventTargeter to make |dialog| modal. |
| 2351 targeter_for_modal_.reset(new aura::ScopedWindowTargeter(window(), | 2347 targeter_for_modal_.reset(new aura::ScopedWindowTargeter( |
| 2352 std::unique_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); | 2348 window(), |
| 2349 std::unique_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); |
| 2350 } |
| 2353 | 2351 |
| 2354 return base::MakeUnique<base::Closure>(base::Bind( | 2352 return base::MakeUnique<base::Closure>(base::Bind( |
| 2355 &DesktopWindowTreeHostX11::EnableEventListening, | 2353 &DesktopWindowTreeHostX11::EnableEventListening, |
| 2356 weak_factory_.GetWeakPtr())); | 2354 weak_factory_.GetWeakPtr())); |
| 2357 } | 2355 } |
| 2358 | 2356 |
| 2359 void DesktopWindowTreeHostX11::EnableEventListening() { | 2357 void DesktopWindowTreeHostX11::EnableEventListening() { |
| 2360 DCHECK(modal_dialog_xid_); | 2358 DCHECK_GT(modal_dialog_counter_, 0UL); |
| 2361 modal_dialog_xid_ = 0; | 2359 if (!--modal_dialog_counter_) |
| 2362 targeter_for_modal_.reset(); | 2360 targeter_for_modal_.reset(); |
| 2363 } | 2361 } |
| 2364 | 2362 |
| 2365 //////////////////////////////////////////////////////////////////////////////// | 2363 //////////////////////////////////////////////////////////////////////////////// |
| 2366 // DesktopWindowTreeHost, public: | 2364 // DesktopWindowTreeHost, public: |
| 2367 | 2365 |
| 2368 // static | 2366 // static |
| 2369 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 2367 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
| 2370 internal::NativeWidgetDelegate* native_widget_delegate, | 2368 internal::NativeWidgetDelegate* native_widget_delegate, |
| 2371 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 2369 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
| 2372 return new DesktopWindowTreeHostX11(native_widget_delegate, | 2370 return new DesktopWindowTreeHostX11(native_widget_delegate, |
| 2373 desktop_native_widget_aura); | 2371 desktop_native_widget_aura); |
| 2374 } | 2372 } |
| 2375 | 2373 |
| 2376 } // namespace views | 2374 } // namespace views |
| OLD | NEW |