Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: components/exo/shell_surface.cc

Issue 2909213003: Handle input events for ARC++ popup windows. (Closed)
Patch Set: Addressed comments. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_underlay = local_point;
114 return gfx::Rect(shadow_underlay->layer()->size()).Contains(local_point); 114 aura::Window::ConvertPointToTarget(window, shadow_underlay,
115 &local_point_in_shadow_underlay);
116 if (gfx::Rect(shadow_underlay->layer()->size())
117 .Contains(local_point_in_shadow_underlay)) {
118 return true;
119 }
115 } 120 }
116 121
122 // Otherwise, fallback to hit test on the surface.
117 aura::Window::ConvertPointToTarget(window, surface->window(), &local_point); 123 aura::Window::ConvertPointToTarget(window, surface->window(), &local_point);
118 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))); 124 return surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1)));
119 } 125 }
120 126
121 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, 127 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root,
122 ui::Event* event) override { 128 ui::Event* event) override {
123 aura::Window* window = static_cast<aura::Window*>(root); 129 aura::Window* window = static_cast<aura::Window*>(root);
124 Surface* surface = ShellSurface::GetMainSurface(window); 130 Surface* surface = ShellSurface::GetMainSurface(window);
125 131
126 // Send events which are outside of the surface's bounds to the underlay. 132 // Send events which wouldn't be handled by the surface, to the shadow
133 // underlay.
127 aura::Window* shadow_underlay = 134 aura::Window* shadow_underlay =
128 static_cast<ShellSurface*>( 135 static_cast<ShellSurface*>(
129 widget_->widget_delegate()->GetContentsView()) 136 widget_->widget_delegate()->GetContentsView())
130 ->shadow_underlay(); 137 ->shadow_underlay();
131 if (surface && event->IsLocatedEvent() && shadow_underlay) { 138 if (surface && event->IsLocatedEvent() && shadow_underlay) {
132 gfx::Point local_point = event->AsLocatedEvent()->location(); 139 gfx::Point local_point = event->AsLocatedEvent()->location();
133 int component = widget_->non_client_view()->NonClientHitTest(local_point); 140 int component = widget_->non_client_view()->NonClientHitTest(local_point);
134 if (component == HTNOWHERE) 141 if (component == HTNOWHERE) {
135 return shadow_underlay; 142 aura::Window::ConvertPointToTarget(window, surface->window(),
143 &local_point);
144 if (!surface->HitTestRect(gfx::Rect(local_point, gfx::Size(1, 1))))
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698