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 11 matching lines...) Expand all Loading... |
22 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
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/events/devices/x11/device_data_manager_x11.h" | 28 #include "ui/events/devices/x11/device_data_manager_x11.h" |
29 #include "ui/events/devices/x11/device_list_cache_x11.h" | 29 #include "ui/events/devices/x11/device_list_cache_x11.h" |
30 #include "ui/events/devices/x11/touch_factory_x11.h" | 30 #include "ui/events/devices/x11/touch_factory_x11.h" |
31 #include "ui/events/event_utils.h" | 31 #include "ui/events/event_utils.h" |
| 32 #include "ui/events/null_event_targeter.h" |
32 #include "ui/events/platform/platform_event_source.h" | 33 #include "ui/events/platform/platform_event_source.h" |
33 #include "ui/events/platform/x11/x11_event_source.h" | 34 #include "ui/events/platform/x11/x11_event_source.h" |
34 #include "ui/gfx/display.h" | 35 #include "ui/gfx/display.h" |
35 #include "ui/gfx/geometry/insets.h" | 36 #include "ui/gfx/geometry/insets.h" |
36 #include "ui/gfx/geometry/size_conversions.h" | 37 #include "ui/gfx/geometry/size_conversions.h" |
37 #include "ui/gfx/image/image_skia.h" | 38 #include "ui/gfx/image/image_skia.h" |
38 #include "ui/gfx/image/image_skia_rep.h" | 39 #include "ui/gfx/image/image_skia_rep.h" |
39 #include "ui/gfx/path.h" | 40 #include "ui/gfx/path.h" |
40 #include "ui/gfx/path_x11.h" | 41 #include "ui/gfx/path_x11.h" |
41 #include "ui/gfx/screen.h" | 42 #include "ui/gfx/screen.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 should_maximize_after_map_(false), | 167 should_maximize_after_map_(false), |
167 use_argb_visual_(false), | 168 use_argb_visual_(false), |
168 drag_drop_client_(NULL), | 169 drag_drop_client_(NULL), |
169 native_widget_delegate_(native_widget_delegate), | 170 native_widget_delegate_(native_widget_delegate), |
170 desktop_native_widget_aura_(desktop_native_widget_aura), | 171 desktop_native_widget_aura_(desktop_native_widget_aura), |
171 content_window_(NULL), | 172 content_window_(NULL), |
172 window_parent_(NULL), | 173 window_parent_(NULL), |
173 custom_window_shape_(false), | 174 custom_window_shape_(false), |
174 urgency_hint_set_(false), | 175 urgency_hint_set_(false), |
175 activatable_(true), | 176 activatable_(true), |
| 177 modal_dialog_xid_(0), |
176 close_widget_factory_(this) { | 178 close_widget_factory_(this) { |
177 } | 179 } |
178 | 180 |
179 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { | 181 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { |
180 window()->ClearProperty(kHostForRootWindow); | 182 window()->ClearProperty(kHostForRootWindow); |
181 aura::client::SetWindowMoveClient(window(), NULL); | 183 aura::client::SetWindowMoveClient(window(), NULL); |
182 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 184 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
183 DestroyDispatcher(); | 185 DestroyDispatcher(); |
184 } | 186 } |
185 | 187 |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 if (g_current_capture && g_current_capture != this && | 1524 if (g_current_capture && g_current_capture != this && |
1523 event->type() == ui::ET_TOUCH_PRESSED) { | 1525 event->type() == ui::ET_TOUCH_PRESSED) { |
1524 ConvertEventToDifferentHost(event, g_current_capture); | 1526 ConvertEventToDifferentHost(event, g_current_capture); |
1525 g_current_capture->SendEventToProcessor(event); | 1527 g_current_capture->SendEventToProcessor(event); |
1526 } else { | 1528 } else { |
1527 SendEventToProcessor(event); | 1529 SendEventToProcessor(event); |
1528 } | 1530 } |
1529 } | 1531 } |
1530 | 1532 |
1531 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { | 1533 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { |
1532 GetInputMethod()->DispatchKeyEvent(event); | 1534 if (native_widget_delegate_->AsWidget()->IsActive()) |
| 1535 GetInputMethod()->DispatchKeyEvent(event); |
1533 } | 1536 } |
1534 | 1537 |
1535 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( | 1538 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( |
1536 ui::LocatedEvent* located_event, | 1539 ui::LocatedEvent* located_event, |
1537 DesktopWindowTreeHostX11* host) { | 1540 DesktopWindowTreeHostX11* host) { |
1538 DCHECK_NE(this, host); | 1541 DCHECK_NE(this, host); |
1539 const gfx::Display display_src = | 1542 const gfx::Display display_src = |
1540 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); | 1543 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); |
1541 const gfx::Display display_dest = | 1544 const gfx::Display display_dest = |
1542 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); | 1545 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2042 return gfx::ToEnclosingRect(rect_in_dip); | 2045 return gfx::ToEnclosingRect(rect_in_dip); |
2043 } | 2046 } |
2044 | 2047 |
2045 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( | 2048 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( |
2046 const gfx::Rect& rect_in_dip) const { | 2049 const gfx::Rect& rect_in_dip) const { |
2047 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); | 2050 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); |
2048 GetRootTransform().TransformRect(&rect_in_pixels); | 2051 GetRootTransform().TransformRect(&rect_in_pixels); |
2049 return gfx::ToEnclosingRect(rect_in_pixels); | 2052 return gfx::ToEnclosingRect(rect_in_pixels); |
2050 } | 2053 } |
2051 | 2054 |
| 2055 const XID DesktopWindowTreeHostX11::GetModalDialog() { |
| 2056 return modal_dialog_xid_; |
| 2057 } |
| 2058 |
| 2059 void DesktopWindowTreeHostX11::DisableEventListening(XID dialog) { |
| 2060 DCHECK(dialog); |
| 2061 DCHECK(!modal_dialog_xid_); |
| 2062 modal_dialog_xid_ = dialog; |
| 2063 // ScopedWindowTargeter is used to temporarily replace the event-targeter |
| 2064 // with NullEventTargeter to make |dialog| modal. |
| 2065 targeter_for_modal_.reset(new aura::ScopedWindowTargeter(window(), |
| 2066 scoped_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); |
| 2067 } |
| 2068 |
| 2069 void DesktopWindowTreeHostX11::EnableEventListening() { |
| 2070 DCHECK(modal_dialog_xid_); |
| 2071 modal_dialog_xid_ = 0; |
| 2072 targeter_for_modal_.reset(); |
| 2073 } |
| 2074 |
2052 //////////////////////////////////////////////////////////////////////////////// | 2075 //////////////////////////////////////////////////////////////////////////////// |
2053 // DesktopWindowTreeHost, public: | 2076 // DesktopWindowTreeHost, public: |
2054 | 2077 |
2055 // static | 2078 // static |
2056 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 2079 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
2057 internal::NativeWidgetDelegate* native_widget_delegate, | 2080 internal::NativeWidgetDelegate* native_widget_delegate, |
2058 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 2081 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
2059 return new DesktopWindowTreeHostX11(native_widget_delegate, | 2082 return new DesktopWindowTreeHostX11(native_widget_delegate, |
2060 desktop_native_widget_aura); | 2083 desktop_native_widget_aura); |
2061 } | 2084 } |
2062 | 2085 |
2063 // static | 2086 // static |
2064 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { | 2087 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { |
2065 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); | 2088 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
2066 if (linux_ui) { | 2089 if (linux_ui) { |
2067 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2090 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2068 if (native_theme) | 2091 if (native_theme) |
2069 return native_theme; | 2092 return native_theme; |
2070 } | 2093 } |
2071 | 2094 |
2072 return ui::NativeTheme::instance(); | 2095 return ui::NativeTheme::instance(); |
2073 } | 2096 } |
2074 | 2097 |
2075 } // namespace views | 2098 } // namespace views |
OLD | NEW |