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/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/Xregion.h> | 8 #include <X11/Xregion.h> |
9 #include <X11/Xutil.h> | 9 #include <X11/Xutil.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ui/aura/window_property.h" | 23 #include "ui/aura/window_property.h" |
24 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" | 24 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" |
25 #include "ui/base/hit_test.h" | 25 #include "ui/base/hit_test.h" |
26 #include "ui/base/ime/input_method.h" | 26 #include "ui/base/ime/input_method.h" |
27 #include "ui/base/x/x11_util.h" | 27 #include "ui/base/x/x11_util.h" |
28 #include "ui/base/x/x11_util_internal.h" | 28 #include "ui/base/x/x11_util_internal.h" |
29 #include "ui/events/devices/x11/device_data_manager_x11.h" | 29 #include "ui/events/devices/x11/device_data_manager_x11.h" |
30 #include "ui/events/devices/x11/device_list_cache_x11.h" | 30 #include "ui/events/devices/x11/device_list_cache_x11.h" |
31 #include "ui/events/devices/x11/touch_factory_x11.h" | 31 #include "ui/events/devices/x11/touch_factory_x11.h" |
32 #include "ui/events/event_utils.h" | 32 #include "ui/events/event_utils.h" |
| 33 #include "ui/events/null_event_targeter.h" |
33 #include "ui/events/platform/platform_event_source.h" | 34 #include "ui/events/platform/platform_event_source.h" |
34 #include "ui/events/platform/x11/x11_event_source.h" | 35 #include "ui/events/platform/x11/x11_event_source.h" |
35 #include "ui/gfx/display.h" | 36 #include "ui/gfx/display.h" |
36 #include "ui/gfx/geometry/insets.h" | 37 #include "ui/gfx/geometry/insets.h" |
37 #include "ui/gfx/geometry/size_conversions.h" | 38 #include "ui/gfx/geometry/size_conversions.h" |
38 #include "ui/gfx/image/image_skia.h" | 39 #include "ui/gfx/image/image_skia.h" |
39 #include "ui/gfx/image/image_skia_rep.h" | 40 #include "ui/gfx/image/image_skia_rep.h" |
40 #include "ui/gfx/path.h" | 41 #include "ui/gfx/path.h" |
41 #include "ui/gfx/path_x11.h" | 42 #include "ui/gfx/path_x11.h" |
42 #include "ui/gfx/screen.h" | 43 #include "ui/gfx/screen.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 should_maximize_after_map_(false), | 169 should_maximize_after_map_(false), |
169 use_argb_visual_(false), | 170 use_argb_visual_(false), |
170 drag_drop_client_(NULL), | 171 drag_drop_client_(NULL), |
171 native_widget_delegate_(native_widget_delegate), | 172 native_widget_delegate_(native_widget_delegate), |
172 desktop_native_widget_aura_(desktop_native_widget_aura), | 173 desktop_native_widget_aura_(desktop_native_widget_aura), |
173 content_window_(NULL), | 174 content_window_(NULL), |
174 window_parent_(NULL), | 175 window_parent_(NULL), |
175 custom_window_shape_(false), | 176 custom_window_shape_(false), |
176 urgency_hint_set_(false), | 177 urgency_hint_set_(false), |
177 activatable_(true), | 178 activatable_(true), |
| 179 modal_dialog_xid_(0), |
178 close_widget_factory_(this) { | 180 close_widget_factory_(this) { |
179 } | 181 } |
180 | 182 |
181 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { | 183 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { |
182 window()->ClearProperty(kHostForRootWindow); | 184 window()->ClearProperty(kHostForRootWindow); |
183 aura::client::SetWindowMoveClient(window(), NULL); | 185 aura::client::SetWindowMoveClient(window(), NULL); |
184 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 186 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
185 DestroyDispatcher(); | 187 DestroyDispatcher(); |
186 } | 188 } |
187 | 189 |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 if (g_current_capture && g_current_capture != this && | 1520 if (g_current_capture && g_current_capture != this && |
1519 event->type() == ui::ET_TOUCH_PRESSED) { | 1521 event->type() == ui::ET_TOUCH_PRESSED) { |
1520 ConvertEventToDifferentHost(event, g_current_capture); | 1522 ConvertEventToDifferentHost(event, g_current_capture); |
1521 g_current_capture->SendEventToProcessor(event); | 1523 g_current_capture->SendEventToProcessor(event); |
1522 } else { | 1524 } else { |
1523 SendEventToProcessor(event); | 1525 SendEventToProcessor(event); |
1524 } | 1526 } |
1525 } | 1527 } |
1526 | 1528 |
1527 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { | 1529 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { |
1528 GetInputMethod()->DispatchKeyEvent(event); | 1530 if (native_widget_delegate_->AsWidget()->IsActive()) |
| 1531 GetInputMethod()->DispatchKeyEvent(event); |
1529 } | 1532 } |
1530 | 1533 |
1531 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( | 1534 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( |
1532 ui::LocatedEvent* located_event, | 1535 ui::LocatedEvent* located_event, |
1533 DesktopWindowTreeHostX11* host) { | 1536 DesktopWindowTreeHostX11* host) { |
1534 DCHECK_NE(this, host); | 1537 DCHECK_NE(this, host); |
1535 const gfx::Display display_src = | 1538 const gfx::Display display_src = |
1536 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); | 1539 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); |
1537 const gfx::Display display_dest = | 1540 const gfx::Display display_dest = |
1538 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); | 1541 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2011 return gfx::ToEnclosingRect(rect_in_dip); | 2014 return gfx::ToEnclosingRect(rect_in_dip); |
2012 } | 2015 } |
2013 | 2016 |
2014 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( | 2017 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( |
2015 const gfx::Rect& rect_in_dip) const { | 2018 const gfx::Rect& rect_in_dip) const { |
2016 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); | 2019 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); |
2017 GetRootTransform().TransformRect(&rect_in_pixels); | 2020 GetRootTransform().TransformRect(&rect_in_pixels); |
2018 return gfx::ToEnclosingRect(rect_in_pixels); | 2021 return gfx::ToEnclosingRect(rect_in_pixels); |
2019 } | 2022 } |
2020 | 2023 |
| 2024 const XID DesktopWindowTreeHostX11::GetModalDialog() { |
| 2025 return modal_dialog_xid_; |
| 2026 } |
| 2027 |
| 2028 void DesktopWindowTreeHostX11::DisableEventListening(XID dialog) { |
| 2029 DCHECK(dialog); |
| 2030 DCHECK(!modal_dialog_xid_); |
| 2031 modal_dialog_xid_ = dialog; |
| 2032 // ScopedWindowTargeter is used to temporarily replace the event-targeter |
| 2033 // with NullEventTargeter to make |dialog| modal. |
| 2034 targeter_for_modal_.reset(new aura::ScopedWindowTargeter(window(), |
| 2035 scoped_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); |
| 2036 } |
| 2037 |
| 2038 void DesktopWindowTreeHostX11::EnableEventListening() { |
| 2039 DCHECK(modal_dialog_xid_); |
| 2040 modal_dialog_xid_ = 0; |
| 2041 targeter_for_modal_.reset(); |
| 2042 } |
| 2043 |
2021 //////////////////////////////////////////////////////////////////////////////// | 2044 //////////////////////////////////////////////////////////////////////////////// |
2022 // DesktopWindowTreeHost, public: | 2045 // DesktopWindowTreeHost, public: |
2023 | 2046 |
2024 // static | 2047 // static |
2025 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 2048 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
2026 internal::NativeWidgetDelegate* native_widget_delegate, | 2049 internal::NativeWidgetDelegate* native_widget_delegate, |
2027 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 2050 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
2028 return new DesktopWindowTreeHostX11(native_widget_delegate, | 2051 return new DesktopWindowTreeHostX11(native_widget_delegate, |
2029 desktop_native_widget_aura); | 2052 desktop_native_widget_aura); |
2030 } | 2053 } |
2031 | 2054 |
2032 // static | 2055 // static |
2033 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { | 2056 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { |
2034 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); | 2057 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
2035 if (linux_ui) { | 2058 if (linux_ui) { |
2036 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2059 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2037 if (native_theme) | 2060 if (native_theme) |
2038 return native_theme; | 2061 return native_theme; |
2039 } | 2062 } |
2040 | 2063 |
2041 return ui::NativeThemeAura::instance(); | 2064 return ui::NativeThemeAura::instance(); |
2042 } | 2065 } |
2043 | 2066 |
2044 } // namespace views | 2067 } // namespace views |
OLD | NEW |