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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 use_native_frame_(false), | 166 use_native_frame_(false), |
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), |
176 modal_dialog_xid_(0), | |
175 close_widget_factory_(this) { | 177 close_widget_factory_(this) { |
176 } | 178 } |
177 | 179 |
178 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { | 180 DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() { |
179 window()->ClearProperty(kHostForRootWindow); | 181 window()->ClearProperty(kHostForRootWindow); |
180 aura::client::SetWindowMoveClient(window(), NULL); | 182 aura::client::SetWindowMoveClient(window(), NULL); |
181 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 183 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
182 DestroyDispatcher(); | 184 DestroyDispatcher(); |
183 } | 185 } |
184 | 186 |
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1513 if (g_current_capture && g_current_capture != this && | 1515 if (g_current_capture && g_current_capture != this && |
1514 event->type() == ui::ET_TOUCH_PRESSED) { | 1516 event->type() == ui::ET_TOUCH_PRESSED) { |
1515 ConvertEventToDifferentHost(event, g_current_capture); | 1517 ConvertEventToDifferentHost(event, g_current_capture); |
1516 g_current_capture->SendEventToProcessor(event); | 1518 g_current_capture->SendEventToProcessor(event); |
1517 } else { | 1519 } else { |
1518 SendEventToProcessor(event); | 1520 SendEventToProcessor(event); |
1519 } | 1521 } |
1520 } | 1522 } |
1521 | 1523 |
1522 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { | 1524 void DesktopWindowTreeHostX11::DispatchKeyEvent(ui::KeyEvent* event) { |
1523 GetInputMethod()->DispatchKeyEvent(event); | 1525 views::Widget* widget = native_widget_delegate_->AsWidget(); |
msw
2015/09/16 23:10:04
nit: inline this in the if statement below.
joone
2015/09/16 23:40:31
Done.
| |
1526 if (widget->IsActive()) | |
1527 GetInputMethod()->DispatchKeyEvent(event); | |
joone
2015/09/16 22:42:55
We don't need to feed key events to the input meth
msw
2015/09/16 23:10:04
This seems reasonable, but other reviewers on the
joone
2015/09/16 23:40:31
Acknowledged.
| |
1524 } | 1528 } |
1525 | 1529 |
1526 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( | 1530 void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( |
1527 ui::LocatedEvent* located_event, | 1531 ui::LocatedEvent* located_event, |
1528 DesktopWindowTreeHostX11* host) { | 1532 DesktopWindowTreeHostX11* host) { |
1529 DCHECK_NE(this, host); | 1533 DCHECK_NE(this, host); |
1530 const gfx::Display display_src = | 1534 const gfx::Display display_src = |
1531 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); | 1535 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); |
1532 const gfx::Display display_dest = | 1536 const gfx::Display display_dest = |
1533 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); | 1537 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2032 return gfx::ToEnclosingRect(rect_in_dip); | 2036 return gfx::ToEnclosingRect(rect_in_dip); |
2033 } | 2037 } |
2034 | 2038 |
2035 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( | 2039 gfx::Rect DesktopWindowTreeHostX11::ToPixelRect( |
2036 const gfx::Rect& rect_in_dip) const { | 2040 const gfx::Rect& rect_in_dip) const { |
2037 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); | 2041 gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip); |
2038 GetRootTransform().TransformRect(&rect_in_pixels); | 2042 GetRootTransform().TransformRect(&rect_in_pixels); |
2039 return gfx::ToEnclosingRect(rect_in_pixels); | 2043 return gfx::ToEnclosingRect(rect_in_pixels); |
2040 } | 2044 } |
2041 | 2045 |
2046 const XID DesktopWindowTreeHostX11::GetModalDialog() { | |
2047 return modal_dialog_xid_; | |
2048 } | |
2049 | |
2050 void DesktopWindowTreeHostX11::DisableEventListening(XID dialog) { | |
2051 DCHECK(dialog); | |
2052 DCHECK(!modal_dialog_xid_); | |
2053 modal_dialog_xid_ = dialog; | |
2054 // ScopedWindowTargeter is used to temporarily replace the event-targeter | |
2055 // with NullEventTargeter to make |dialog| modal. | |
2056 targeter_for_modal_.reset(new aura::ScopedWindowTargeter(window(), | |
2057 scoped_ptr<ui::EventTargeter>(new ui::NullEventTargeter))); | |
2058 } | |
2059 | |
2060 void DesktopWindowTreeHostX11::EnableEventListening() { | |
2061 DCHECK(modal_dialog_xid_); | |
2062 modal_dialog_xid_ = 0; | |
2063 targeter_for_modal_.reset(); | |
2064 } | |
2065 | |
2042 //////////////////////////////////////////////////////////////////////////////// | 2066 //////////////////////////////////////////////////////////////////////////////// |
2043 // DesktopWindowTreeHost, public: | 2067 // DesktopWindowTreeHost, public: |
2044 | 2068 |
2045 // static | 2069 // static |
2046 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 2070 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
2047 internal::NativeWidgetDelegate* native_widget_delegate, | 2071 internal::NativeWidgetDelegate* native_widget_delegate, |
2048 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 2072 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
2049 return new DesktopWindowTreeHostX11(native_widget_delegate, | 2073 return new DesktopWindowTreeHostX11(native_widget_delegate, |
2050 desktop_native_widget_aura); | 2074 desktop_native_widget_aura); |
2051 } | 2075 } |
2052 | 2076 |
2053 // static | 2077 // static |
2054 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { | 2078 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { |
2055 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); | 2079 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
2056 if (linux_ui) { | 2080 if (linux_ui) { |
2057 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 2081 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
2058 if (native_theme) | 2082 if (native_theme) |
2059 return native_theme; | 2083 return native_theme; |
2060 } | 2084 } |
2061 | 2085 |
2062 return ui::NativeTheme::instance(); | 2086 return ui::NativeTheme::instance(); |
2063 } | 2087 } |
2064 | 2088 |
2065 } // namespace views | 2089 } // namespace views |
OLD | NEW |