OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/shell_surface.h" | 5 #include "components/exo/shell_surface.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/frame/custom_frame_view_ash.h" | 9 #include "ash/frame/custom_frame_view_ash.h" |
10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 | 96 |
97 if (window->parent()) { | 97 if (window->parent()) { |
98 aura::Window::ConvertPointToTarget(window->parent(), window, | 98 aura::Window::ConvertPointToTarget(window->parent(), window, |
99 &local_point); | 99 &local_point); |
100 } | 100 } |
101 | 101 |
102 int component = widget_->non_client_view()->NonClientHitTest(local_point); | 102 int component = widget_->non_client_view()->NonClientHitTest(local_point); |
103 if (component != HTNOWHERE && component != HTCLIENT) | 103 if (component != HTNOWHERE && component != HTCLIENT) |
104 return true; | 104 return true; |
105 | 105 |
106 // If there is an underlay, test against it's bounds instead since it will | 106 // If there is an underlay, test against it first as it's bounds may be |
107 // be equal or larger than the surface's bounds. | 107 // larger than the surface's bounds. |
108 aura::Window* shadow_underlay = | 108 aura::Window* shadow_underlay = |
109 static_cast<ShellSurface*>( | 109 static_cast<ShellSurface*>( |
110 widget_->widget_delegate()->GetContentsView()) | 110 widget_->widget_delegate()->GetContentsView()) |
111 ->shadow_underlay(); | 111 ->shadow_underlay(); |
112 if (shadow_underlay) { | 112 if (shadow_underlay) { |
113 aura::Window::ConvertPointToTarget(window, shadow_underlay, &local_point); | 113 gfx::Point local_point_in_shadow = local_point; |
reveman
2017/05/30 13:33:55
nit: local_point_in_shadow_underlay as we might re
mtomasz
2017/05/31 01:38:19
Done.
| |
114 return gfx::Rect(shadow_underlay->layer()->size()).Contains(local_point); | 114 aura::Window::ConvertPointToTarget(window, shadow_underlay, |
115 &local_point_in_shadow); | |
116 if (gfx::Rect(shadow_underlay->layer()->size()) | |
117 .Contains(local_point_in_shadow)) | |
reveman
2017/05/30 13:33:55
nit: use {} when statement and/or conditional code
mtomasz
2017/05/31 01:38:19
Done.
| |
118 return true; | |
115 } | 119 } |
116 | 120 |
121 // Otherwise, fallback to hit test on the surface. | |
117 aura::Window::ConvertPointToTarget(window, surface->window(), &local_point); | 122 aura::Window::ConvertPointToTarget(window, surface->window(), &local_point); |
118 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); | 123 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); |
119 } | 124 } |
120 | 125 |
121 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, | 126 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, |
122 ui::Event* event) override { | 127 ui::Event* event) override { |
123 aura::Window* window = static_cast<aura::Window*>(root); | 128 aura::Window* window = static_cast<aura::Window*>(root); |
124 Surface* surface = ShellSurface::GetMainSurface(window); | 129 Surface* surface = ShellSurface::GetMainSurface(window); |
125 | 130 |
126 // Send events which are outside of the surface's bounds to the underlay. | 131 // Send events which wouldn't be handled by the surface, to the shadow |
132 // underlay. | |
127 aura::Window* shadow_underlay = | 133 aura::Window* shadow_underlay = |
128 static_cast<ShellSurface*>( | 134 static_cast<ShellSurface*>( |
129 widget_->widget_delegate()->GetContentsView()) | 135 widget_->widget_delegate()->GetContentsView()) |
130 ->shadow_underlay(); | 136 ->shadow_underlay(); |
131 if (surface && event->IsLocatedEvent() && shadow_underlay) { | 137 if (surface && event->IsLocatedEvent() && shadow_underlay) { |
132 gfx::Point local_point = event->AsLocatedEvent()->location(); | 138 gfx::Point local_point = event->AsLocatedEvent()->location(); |
133 int component = widget_->non_client_view()->NonClientHitTest(local_point); | 139 int component = widget_->non_client_view()->NonClientHitTest(local_point); |
134 if (component == HTNOWHERE) | 140 |
141 aura::Window::ConvertPointToTarget(window, surface->window(), | |
142 &local_point); | |
143 if (!surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))) && | |
144 component == HTNOWHERE) { | |
reveman
2017/05/30 13:33:55
nit: please do this "component == HTNOWHERE" check
| |
135 return shadow_underlay; | 145 return shadow_underlay; |
146 } | |
136 } | 147 } |
137 return aura::WindowTargeter::FindTargetForEvent(root, event); | 148 return aura::WindowTargeter::FindTargetForEvent(root, event); |
138 } | 149 } |
139 | 150 |
140 private: | 151 private: |
141 views::Widget* const widget_; | 152 views::Widget* const widget_; |
142 | 153 |
143 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); | 154 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); |
144 }; | 155 }; |
145 | 156 |
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1664 gfx::Point ShellSurface::GetMouseLocation() const { | 1675 gfx::Point ShellSurface::GetMouseLocation() const { |
1665 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); | 1676 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); |
1666 gfx::Point location = | 1677 gfx::Point location = |
1667 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); | 1678 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); |
1668 aura::Window::ConvertPointToTarget( | 1679 aura::Window::ConvertPointToTarget( |
1669 root_window, widget_->GetNativeWindow()->parent(), &location); | 1680 root_window, widget_->GetNativeWindow()->parent(), &location); |
1670 return location; | 1681 return location; |
1671 } | 1682 } |
1672 | 1683 |
1673 } // namespace exo | 1684 } // namespace exo |
OLD | NEW |