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

Side by Side Diff: ui/aura/window_targeter.cc

Issue 118553004: aura: Add an EasyResizeWindowTargeter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r243131 Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/window_targeter.h ('k') | ui/wm/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/aura/window_targeter.h" 5 #include "ui/aura/window_targeter.h"
6 6
7 #include "ui/aura/client/capture_client.h" 7 #include "ui/aura/client/capture_client.h"
8 #include "ui/aura/client/event_client.h" 8 #include "ui/aura/client/event_client.h"
9 #include "ui/aura/client/focus_client.h" 9 #include "ui/aura/client/focus_client.h"
10 #include "ui/aura/root_window.h" 10 #include "ui/aura/root_window.h"
11 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
12 #include "ui/aura/window_delegate.h" 12 #include "ui/aura/window_delegate.h"
13 #include "ui/events/event_target.h" 13 #include "ui/events/event_target.h"
14 14
15 namespace aura { 15 namespace aura {
16 16
17 WindowTargeter::WindowTargeter() {} 17 WindowTargeter::WindowTargeter() {}
18 WindowTargeter::~WindowTargeter() {} 18 WindowTargeter::~WindowTargeter() {}
19 19
20 bool WindowTargeter::WindowCanAcceptEvent(aura::Window* window,
21 const ui::LocatedEvent& event) const {
22 if (!window->IsVisible())
23 return false;
24 if (window->ignore_events())
25 return false;
26 client::EventClient* client = client::GetEventClient(window->GetRootWindow());
27 if (client && !client->CanProcessEventsWithinSubtree(window))
28 return false;
29
30 Window* parent = window->parent();
31 if (parent && parent->delegate_ && !parent->delegate_->
32 ShouldDescendIntoChildForEventHandling(window, event.location())) {
33 return false;
34 }
35 return true;
36 }
37
38 bool WindowTargeter::EventLocationInsideBounds(
39 aura::Window* window, const ui::LocatedEvent& event) const {
40 return window->bounds().Contains(event.location());
41 }
42
20 ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root, 43 ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root,
21 ui::Event* event) { 44 ui::Event* event) {
22 if (event->IsKeyEvent()) { 45 if (event->IsKeyEvent()) {
23 Window* window = static_cast<Window*>(root); 46 Window* window = static_cast<Window*>(root);
24 Window* root_window = window->GetRootWindow(); 47 Window* root_window = window->GetRootWindow();
25 const ui::KeyEvent& key = static_cast<const ui::KeyEvent&>(*event); 48 const ui::KeyEvent& key = static_cast<const ui::KeyEvent&>(*event);
26 if (key.key_code() == ui::VKEY_UNKNOWN) 49 if (key.key_code() == ui::VKEY_UNKNOWN)
27 return NULL; 50 return NULL;
28 client::EventClient* event_client = client::GetEventClient(root_window); 51 client::EventClient* event_client = client::GetEventClient(root_window);
29 client::FocusClient* focus_client = client::GetFocusClient(root_window); 52 client::FocusClient* focus_client = client::GetFocusClient(root_window);
30 Window* focused_window = focus_client->GetFocusedWindow(); 53 Window* focused_window = focus_client->GetFocusedWindow();
31 if (event_client && 54 if (event_client &&
32 !event_client->CanProcessEventsWithinSubtree(focused_window)) { 55 !event_client->CanProcessEventsWithinSubtree(focused_window)) {
33 focus_client->FocusWindow(NULL); 56 focus_client->FocusWindow(NULL);
34 return NULL; 57 return NULL;
35 } 58 }
36 return focused_window ? focused_window : window; 59 return focused_window ? focused_window : window;
37 } 60 }
38 return EventTargeter::FindTargetForEvent(root, event); 61 return EventTargeter::FindTargetForEvent(root, event);
39 } 62 }
40 63
41 bool WindowTargeter::SubtreeShouldBeExploredForEvent( 64 bool WindowTargeter::SubtreeShouldBeExploredForEvent(
42 ui::EventTarget* root, 65 ui::EventTarget* root,
43 const ui::LocatedEvent& event) { 66 const ui::LocatedEvent& event) {
44 Window* window = static_cast<Window*>(root); 67 Window* window = static_cast<Window*>(root);
45 if (!window->IsVisible()) 68 if (!WindowCanAcceptEvent(window, event))
46 return false;
47 if (window->ignore_events())
48 return false;
49 client::EventClient* client = client::GetEventClient(window->GetRootWindow());
50 if (client && !client->CanProcessEventsWithinSubtree(window))
51 return false; 69 return false;
52 70
53 Window* parent = window->parent(); 71 return EventLocationInsideBounds(window, event);
54 if (parent && parent->delegate_ && !parent->delegate_->
55 ShouldDescendIntoChildForEventHandling(window, event.location())) {
56 return false;
57 }
58 return window->bounds().Contains(event.location());
59 } 72 }
60 73
61 ui::EventTarget* WindowTargeter::FindTargetForLocatedEvent( 74 ui::EventTarget* WindowTargeter::FindTargetForLocatedEvent(
62 ui::EventTarget* root, 75 ui::EventTarget* root,
63 ui::LocatedEvent* event) { 76 ui::LocatedEvent* event) {
64 Window* window = static_cast<Window*>(root); 77 Window* window = static_cast<Window*>(root);
65 if (!window->parent()) { 78 if (!window->parent()) {
66 Window* target = FindTargetInRootWindow(window, *event); 79 Window* target = FindTargetInRootWindow(window, *event);
67 if (target) { 80 if (target) {
68 window->ConvertEventToTarget(target, event); 81 window->ConvertEventToTarget(target, event);
(...skipping 17 matching lines...) Expand all
86 99
87 // All events should be directed towards the capture window (if any). 100 // All events should be directed towards the capture window (if any).
88 Window* capture_window = client::GetCaptureWindow(root_window); 101 Window* capture_window = client::GetCaptureWindow(root_window);
89 if (capture_window) 102 if (capture_window)
90 return capture_window; 103 return capture_window;
91 104
92 return NULL; 105 return NULL;
93 } 106 }
94 107
95 } // namespace aura 108 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_targeter.h ('k') | ui/wm/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698