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 14 matching lines...) Expand all Loading... |
25 #include "ui/aura/window_property.h" | 25 #include "ui/aura/window_property.h" |
26 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" | 26 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" |
27 #include "ui/base/hit_test.h" | 27 #include "ui/base/hit_test.h" |
28 #include "ui/base/ime/input_method.h" | 28 #include "ui/base/ime/input_method.h" |
29 #include "ui/base/x/x11_util.h" | 29 #include "ui/base/x/x11_util.h" |
30 #include "ui/base/x/x11_util_internal.h" | 30 #include "ui/base/x/x11_util_internal.h" |
31 #include "ui/events/devices/x11/device_data_manager_x11.h" | 31 #include "ui/events/devices/x11/device_data_manager_x11.h" |
32 #include "ui/events/devices/x11/device_list_cache_x11.h" | 32 #include "ui/events/devices/x11/device_list_cache_x11.h" |
33 #include "ui/events/devices/x11/touch_factory_x11.h" | 33 #include "ui/events/devices/x11/touch_factory_x11.h" |
34 #include "ui/events/event_utils.h" | 34 #include "ui/events/event_utils.h" |
| 35 #include "ui/events/null_event_targeter.h" |
35 #include "ui/events/platform/platform_event_source.h" | 36 #include "ui/events/platform/platform_event_source.h" |
36 #include "ui/events/platform/x11/x11_event_source.h" | 37 #include "ui/events/platform/x11/x11_event_source.h" |
37 #include "ui/gfx/display.h" | 38 #include "ui/gfx/display.h" |
38 #include "ui/gfx/geometry/insets.h" | 39 #include "ui/gfx/geometry/insets.h" |
39 #include "ui/gfx/geometry/size_conversions.h" | 40 #include "ui/gfx/geometry/size_conversions.h" |
40 #include "ui/gfx/image/image_skia.h" | 41 #include "ui/gfx/image/image_skia.h" |
41 #include "ui/gfx/image/image_skia_rep.h" | 42 #include "ui/gfx/image/image_skia_rep.h" |
42 #include "ui/gfx/path.h" | 43 #include "ui/gfx/path.h" |
43 #include "ui/gfx/path_x11.h" | 44 #include "ui/gfx/path_x11.h" |
44 #include "ui/gfx/screen.h" | 45 #include "ui/gfx/screen.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 break; | 147 break; |
147 if (child_windows) | 148 if (child_windows) |
148 XFree(child_windows); | 149 XFree(child_windows); |
149 window = parent_win; | 150 window = parent_win; |
150 } | 151 } |
151 return result; | 152 return result; |
152 } | 153 } |
153 | 154 |
154 } // namespace | 155 } // namespace |
155 | 156 |
| 157 DesktopWindowTreeHostX11::ScopedHandle::ScopedHandle(const base::Closure& |
| 158 destroy_callback) |
| 159 : destroy_callback_(destroy_callback) { |
| 160 } |
| 161 |
| 162 DesktopWindowTreeHostX11::ScopedHandle::~ScopedHandle() { |
| 163 if (!destroy_callback_.is_null()) |
| 164 destroy_callback_.Run(); |
| 165 } |
| 166 |
156 //////////////////////////////////////////////////////////////////////////////// | 167 //////////////////////////////////////////////////////////////////////////////// |
157 // DesktopWindowTreeHostX11, public: | 168 // DesktopWindowTreeHostX11, public: |
158 | 169 |
159 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( | 170 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( |
160 internal::NativeWidgetDelegate* native_widget_delegate, | 171 internal::NativeWidgetDelegate* native_widget_delegate, |
161 DesktopNativeWidgetAura* desktop_native_widget_aura) | 172 DesktopNativeWidgetAura* desktop_native_widget_aura) |
162 : xdisplay_(gfx::GetXDisplay()), | 173 : xdisplay_(gfx::GetXDisplay()), |
163 xwindow_(0), | 174 xwindow_(0), |
164 x_root_window_(DefaultRootWindow(xdisplay_)), | 175 x_root_window_(DefaultRootWindow(xdisplay_)), |
165 atom_cache_(xdisplay_, kAtomsToCache), | 176 atom_cache_(xdisplay_, kAtomsToCache), |
166 window_mapped_(false), | 177 window_mapped_(false), |
167 is_fullscreen_(false), | 178 is_fullscreen_(false), |
168 is_always_on_top_(false), | 179 is_always_on_top_(false), |
169 use_native_frame_(false), | 180 use_native_frame_(false), |
170 should_maximize_after_map_(false), | 181 should_maximize_after_map_(false), |
171 use_argb_visual_(false), | 182 use_argb_visual_(false), |
172 drag_drop_client_(NULL), | 183 drag_drop_client_(NULL), |
173 native_widget_delegate_(native_widget_delegate), | 184 native_widget_delegate_(native_widget_delegate), |
174 desktop_native_widget_aura_(desktop_native_widget_aura), | 185 desktop_native_widget_aura_(desktop_native_widget_aura), |
175 content_window_(NULL), | 186 content_window_(NULL), |
176 window_parent_(NULL), | 187 window_parent_(NULL), |
177 custom_window_shape_(false), | 188 custom_window_shape_(false), |
178 urgency_hint_set_(false), | 189 urgency_hint_set_(false), |
179 activatable_(true), | 190 activatable_(true), |
| 191 modal_dialog_xid_(0), |
180 close_widget_factory_(this) { | 192 close_widget_factory_(this) { |
181 } | 193 } |
182 | 194 |
183 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { | 195 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { |
184 window()->ClearProperty(kHostForRootWindow); | 196 window()->ClearProperty(kHostForRootWindow); |
185 aura::client::SetWindowMoveClient(window(), NULL); | 197 aura::client::SetWindowMoveClient(window(), NULL); |
186 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 198 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
187 DestroyDispatcher(); | 199 DestroyDispatcher(); |
188 } | 200 } |
189 | 201 |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 if (g_current_capture && g_current_capture != this && | 1532 if (g_current_capture && g_current_capture != this && |
1521 event->type() == ui::ET_TOUCH_PRESSED) { | 1533 event->type() == ui::ET_TOUCH_PRESSED) { |
1522 ConvertEventToDifferentHost(event, g_current_capture); | 1534 ConvertEventToDifferentHost(event, g_current_capture); |
1523 g_current_capture->SendEventToProcessor(event); | 1535 g_current_capture->SendEventToProcessor(event); |
1524 } else { | 1536 } else { |
1525 SendEventToProcessor(event); | 1537 SendEventToProcessor(event); |
1526 } | 1538 } |
1527 } | 1539 } |
1528 | 1540 |
1529 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { | 1541 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { |
1530 GetInputMethod()->DispatchKeyEvent(event); | 1542 if (native_widget_delegate_->AsWidget()->IsActive()) |
| 1543 GetInputMethod()->DispatchKeyEvent(event); |
1531 } | 1544 } |
1532 | 1545 |
1533 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( | 1546 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( |
1534 ui::LocatedEvent* located_event, | 1547 ui::LocatedEvent* located_event, |
1535 DesktopWindowTreeHostX11* host) { | 1548 DesktopWindowTreeHostX11* host) { |
1536 DCHECK_NE(this, host); | 1549 DCHECK_NE(this, host); |
1537 const gfx::Display display_src = | 1550 const gfx::Display display_src = |
1538 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); | 1551 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); |
1539 const gfx::Display display_dest = | 1552 const gfx::Display display_dest = |
1540 gfx::Screen::GetScreen()->GetDisplayNearestWindow(host->window()); | 1553 gfx::Screen::GetScreen()->GetDisplayNearestWindow(host->window()); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 return gfx::ToEnclosingRect(rect_in_dip); | 2026 return gfx::ToEnclosingRect(rect_in_dip); |
2014 } | 2027 } |
2015 | 2028 |
2016 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( | 2029 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( |
2017 const gfx::Rect& rect_in_dip) const { | 2030 const gfx::Rect& rect_in_dip) const { |
2018 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); | 2031 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); |
2019 GetRootTransform().TransformRect(&rect_in_pixels); | 2032 GetRootTransform().TransformRect(&rect_in_pixels); |
2020 return gfx::ToEnclosingRect(rect_in_pixels); | 2033 return gfx::ToEnclosingRect(rect_in_pixels); |
2021 } | 2034 } |
2022 | 2035 |
| 2036 XID DesktopWindowTreeHostX11::GetModalDialog() { |
| 2037 return modal_dialog_xid_; |
| 2038 } |
| 2039 |
| 2040 std::unique_ptr<DesktopWindowTreeHostX11::ScopedHandle> |
| 2041 DesktopWindowTreeHostX11::DisableEventListening(XID dialog) { |
| 2042 DCHECK(dialog); |
| 2043 DCHECK(!modal_dialog_xid_); |
| 2044 modal_dialog_xid_ = dialog; |
| 2045 // ScopedWindowTargeter is used to temporarily replace the event-targeter |
| 2046 // with NullEventTargeter to make |dialog| modal. |
| 2047 targeter_for_modal_.reset(new aura::ScopedWindowTargeter(window(), |
| 2048 std::unique_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); |
| 2049 |
| 2050 return base::WrapUnique( |
| 2051 new DesktopWindowTreeHostX11::ScopedHandle( |
| 2052 base::Bind(&DesktopWindowTreeHostX11::EnableEventListening, |
| 2053 close_widget_factory_.GetWeakPtr()))); |
| 2054 } |
| 2055 |
| 2056 void DesktopWindowTreeHostX11::EnableEventListening() { |
| 2057 DCHECK(modal_dialog_xid_); |
| 2058 modal_dialog_xid_ = 0; |
| 2059 targeter_for_modal_.reset(); |
| 2060 } |
| 2061 |
2023 //////////////////////////////////////////////////////////////////////////////// | 2062 //////////////////////////////////////////////////////////////////////////////// |
2024 // DesktopWindowTreeHost, public: | 2063 // DesktopWindowTreeHost, public: |
2025 | 2064 |
2026 // static | 2065 // static |
2027 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 2066 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
2028 internal::NativeWidgetDelegate* native_widget_delegate, | 2067 internal::NativeWidgetDelegate* native_widget_delegate, |
2029 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 2068 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
2030 return new DesktopWindowTreeHostX11(native_widget_delegate, | 2069 return new DesktopWindowTreeHostX11(native_widget_delegate, |
2031 desktop_native_widget_aura); | 2070 desktop_native_widget_aura); |
2032 } | 2071 } |
2033 | 2072 |
2034 // static | 2073 // static |
2035 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { | 2074 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { |
2036 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); | 2075 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
2037 if (linux_ui) { | 2076 if (linux_ui) { |
2038 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2077 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2039 if (native_theme) | 2078 if (native_theme) |
2040 return native_theme; | 2079 return native_theme; |
2041 } | 2080 } |
2042 | 2081 |
2043 return ui::NativeThemeAura::instance(); | 2082 return ui::NativeThemeAura::instance(); |
2044 } | 2083 } |
2045 | 2084 |
2046 } // namespace views | 2085 } // namespace views |
OLD | NEW |