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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 break; | 145 break; |
145 if (child_windows) | 146 if (child_windows) |
146 XFree(child_windows); | 147 XFree(child_windows); |
147 window = parent_win; | 148 window = parent_win; |
148 } | 149 } |
149 return result; | 150 return result; |
150 } | 151 } |
151 | 152 |
152 } // namespace | 153 } // namespace |
153 | 154 |
| 155 ScopedHandle::ScopedHandle(const base::Closure& destroy_callback) |
| 156 : destroy_callback_(destroy_callback) {} |
| 157 |
| 158 ScopedHandle::~ScopedHandle() { |
| 159 if (!destroy_callback_.is_null()) |
| 160 destroy_callback_.Run(); |
| 161 } |
| 162 |
154 //////////////////////////////////////////////////////////////////////////////// | 163 //////////////////////////////////////////////////////////////////////////////// |
155 // DesktopWindowTreeHostX11, public: | 164 // DesktopWindowTreeHostX11, public: |
156 | 165 |
157 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( | 166 DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( |
158 internal::NativeWidgetDelegate* native_widget_delegate, | 167 internal::NativeWidgetDelegate* native_widget_delegate, |
159 DesktopNativeWidgetAura* desktop_native_widget_aura) | 168 DesktopNativeWidgetAura* desktop_native_widget_aura) |
160 : xdisplay_(gfx::GetXDisplay()), | 169 : xdisplay_(gfx::GetXDisplay()), |
161 xwindow_(0), | 170 xwindow_(0), |
162 x_root_window_(DefaultRootWindow(xdisplay_)), | 171 x_root_window_(DefaultRootWindow(xdisplay_)), |
163 atom_cache_(xdisplay_, kAtomsToCache), | 172 atom_cache_(xdisplay_, kAtomsToCache), |
164 window_mapped_(false), | 173 window_mapped_(false), |
165 is_fullscreen_(false), | 174 is_fullscreen_(false), |
166 is_always_on_top_(false), | 175 is_always_on_top_(false), |
167 use_native_frame_(false), | 176 use_native_frame_(false), |
168 should_maximize_after_map_(false), | 177 should_maximize_after_map_(false), |
169 use_argb_visual_(false), | 178 use_argb_visual_(false), |
170 drag_drop_client_(NULL), | 179 drag_drop_client_(NULL), |
171 native_widget_delegate_(native_widget_delegate), | 180 native_widget_delegate_(native_widget_delegate), |
172 desktop_native_widget_aura_(desktop_native_widget_aura), | 181 desktop_native_widget_aura_(desktop_native_widget_aura), |
173 content_window_(NULL), | 182 content_window_(NULL), |
174 window_parent_(NULL), | 183 window_parent_(NULL), |
175 custom_window_shape_(false), | 184 custom_window_shape_(false), |
176 urgency_hint_set_(false), | 185 urgency_hint_set_(false), |
177 activatable_(true), | 186 activatable_(true), |
| 187 modal_dialog_xid_(0), |
178 close_widget_factory_(this) { | 188 close_widget_factory_(this) { |
179 } | 189 } |
180 | 190 |
181 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { | 191 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { |
182 window()->ClearProperty(kHostForRootWindow); | 192 window()->ClearProperty(kHostForRootWindow); |
183 aura::client::SetWindowMoveClient(window(), NULL); | 193 aura::client::SetWindowMoveClient(window(), NULL); |
184 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 194 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
185 DestroyDispatcher(); | 195 DestroyDispatcher(); |
186 } | 196 } |
187 | 197 |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 if (g_current_capture && g_current_capture != this && | 1528 if (g_current_capture && g_current_capture != this && |
1519 event->type() == ui::ET_TOUCH_PRESSED) { | 1529 event->type() == ui::ET_TOUCH_PRESSED) { |
1520 ConvertEventToDifferentHost(event, g_current_capture); | 1530 ConvertEventToDifferentHost(event, g_current_capture); |
1521 g_current_capture->SendEventToProcessor(event); | 1531 g_current_capture->SendEventToProcessor(event); |
1522 } else { | 1532 } else { |
1523 SendEventToProcessor(event); | 1533 SendEventToProcessor(event); |
1524 } | 1534 } |
1525 } | 1535 } |
1526 | 1536 |
1527 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { | 1537 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { |
1528 GetInputMethod()->DispatchKeyEvent(event); | 1538 if (native_widget_delegate_->AsWidget()->IsActive()) |
| 1539 GetInputMethod()->DispatchKeyEvent(event); |
1529 } | 1540 } |
1530 | 1541 |
1531 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( | 1542 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( |
1532 ui::LocatedEvent* located_event, | 1543 ui::LocatedEvent* located_event, |
1533 DesktopWindowTreeHostX11* host) { | 1544 DesktopWindowTreeHostX11* host) { |
1534 DCHECK_NE(this, host); | 1545 DCHECK_NE(this, host); |
1535 const gfx::Display display_src = | 1546 const gfx::Display display_src = |
1536 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); | 1547 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); |
1537 const gfx::Display display_dest = | 1548 const gfx::Display display_dest = |
1538 gfx::Screen::GetScreen()->GetDisplayNearestWindow(host->window()); | 1549 gfx::Screen::GetScreen()->GetDisplayNearestWindow(host->window()); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2011 return gfx::ToEnclosingRect(rect_in_dip); | 2022 return gfx::ToEnclosingRect(rect_in_dip); |
2012 } | 2023 } |
2013 | 2024 |
2014 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( | 2025 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( |
2015 const gfx::Rect& rect_in_dip) const { | 2026 const gfx::Rect& rect_in_dip) const { |
2016 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); | 2027 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); |
2017 GetRootTransform().TransformRect(&rect_in_pixels); | 2028 GetRootTransform().TransformRect(&rect_in_pixels); |
2018 return gfx::ToEnclosingRect(rect_in_pixels); | 2029 return gfx::ToEnclosingRect(rect_in_pixels); |
2019 } | 2030 } |
2020 | 2031 |
| 2032 XID DesktopWindowTreeHostX11::GetModalDialog() { |
| 2033 return modal_dialog_xid_; |
| 2034 } |
| 2035 |
| 2036 scoped_ptr<ScopedHandle> DesktopWindowTreeHostX11::DisableEventListening( |
| 2037 XID dialog) { |
| 2038 DCHECK(dialog); |
| 2039 DCHECK(!modal_dialog_xid_); |
| 2040 modal_dialog_xid_ = dialog; |
| 2041 // ScopedWindowTargeter is used to temporarily replace the event-targeter |
| 2042 // with NullEventTargeter to make |dialog| modal. |
| 2043 targeter_for_modal_.reset(new aura::ScopedWindowTargeter(window(), |
| 2044 scoped_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); |
| 2045 |
| 2046 return make_scoped_ptr( |
| 2047 new ScopedHandle( |
| 2048 base::Bind(&DesktopWindowTreeHostX11::EnableEventListening, |
| 2049 close_widget_factory_.GetWeakPtr()))); |
| 2050 } |
| 2051 |
| 2052 void DesktopWindowTreeHostX11::EnableEventListening() { |
| 2053 DCHECK(modal_dialog_xid_); |
| 2054 modal_dialog_xid_ = 0; |
| 2055 targeter_for_modal_.reset(); |
| 2056 } |
| 2057 |
2021 //////////////////////////////////////////////////////////////////////////////// | 2058 //////////////////////////////////////////////////////////////////////////////// |
2022 // DesktopWindowTreeHost, public: | 2059 // DesktopWindowTreeHost, public: |
2023 | 2060 |
2024 // static | 2061 // static |
2025 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 2062 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
2026 internal::NativeWidgetDelegate* native_widget_delegate, | 2063 internal::NativeWidgetDelegate* native_widget_delegate, |
2027 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 2064 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
2028 return new DesktopWindowTreeHostX11(native_widget_delegate, | 2065 return new DesktopWindowTreeHostX11(native_widget_delegate, |
2029 desktop_native_widget_aura); | 2066 desktop_native_widget_aura); |
2030 } | 2067 } |
2031 | 2068 |
2032 // static | 2069 // static |
2033 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { | 2070 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { |
2034 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); | 2071 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
2035 if (linux_ui) { | 2072 if (linux_ui) { |
2036 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2073 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2037 if (native_theme) | 2074 if (native_theme) |
2038 return native_theme; | 2075 return native_theme; |
2039 } | 2076 } |
2040 | 2077 |
2041 return ui::NativeThemeAura::instance(); | 2078 return ui::NativeThemeAura::instance(); |
2042 } | 2079 } |
2043 | 2080 |
2044 } // namespace views | 2081 } // namespace views |
OLD | NEW |