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