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

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

Issue 9181012: Don't activate a window if screen is locked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reduced the scope Created 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "ui/aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void Window::Blur() { 341 void Window::Blur() {
342 DCHECK(GetFocusManager()); 342 DCHECK(GetFocusManager());
343 GetFocusManager()->SetFocusedWindow(NULL); 343 GetFocusManager()->SetFocusedWindow(NULL);
344 } 344 }
345 345
346 bool Window::HasFocus() const { 346 bool Window::HasFocus() const {
347 const internal::FocusManager* focus_manager = GetFocusManager(); 347 const internal::FocusManager* focus_manager = GetFocusManager();
348 return focus_manager ? focus_manager->IsFocusedWindow(this) : false; 348 return focus_manager ? focus_manager->IsFocusedWindow(this) : false;
349 } 349 }
350 350
351 // For a given window, we determine its focusability by inspecting each sibling 351 // For a given window, we determine its focusability and ability to
352 // after it (i.e. drawn in front of it in the z-order) to see if it stops 352 // receive events by inspecting each sibling after it (i.e. drawn in
353 // propagation of events that would otherwise be targeted at windows behind it. 353 // front of it in the z-order) to see if it stops propagation of
354 // We then perform this same check on every window up to the root. 354 // events that would otherwise be targeted at windows behind it. We
355 // then perform this same check on every window up to the root.
355 bool Window::CanFocus() const { 356 bool Window::CanFocus() const {
356 if (!IsVisible() || !parent_ || (delegate_ && !delegate_->CanFocus())) 357 if (!IsVisible() || !parent_ || (delegate_ && !delegate_->CanFocus()))
357 return false; 358 return false;
359 return !IsBehindStopEventsWindow() && parent_->CanFocus();
360 }
358 361
359 Windows::const_iterator i = std::find(parent_->children().begin(), 362 bool Window::CanReceiveEvents() const {
sky 2012/01/12 21:11:36 Do we really need this? Can we instead use CanFocu
oshima 2012/01/12 21:32:50 I needed separate method because non focusable win
360 parent_->children().end(), 363 return parent_ && IsVisible() && !IsBehindStopEventsWindow() &&
361 this); 364 parent_->CanReceiveEvents();
362 for (++i; i != parent_->children().end(); ++i) {
363 if ((*i)->StopsEventPropagation())
364 return false;
365 }
366 return parent_->CanFocus();
367 } 365 }
368 366
369 internal::FocusManager* Window::GetFocusManager() { 367 internal::FocusManager* Window::GetFocusManager() {
370 return const_cast<internal::FocusManager*>( 368 return const_cast<internal::FocusManager*>(
371 static_cast<const Window*>(this)->GetFocusManager()); 369 static_cast<const Window*>(this)->GetFocusManager());
372 } 370 }
373 371
374 const internal::FocusManager* Window::GetFocusManager() const { 372 const internal::FocusManager* Window::GetFocusManager() const {
375 return parent_ ? parent_->GetFocusManager() : NULL; 373 return parent_ ? parent_->GetFocusManager() : NULL;
376 } 374 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (iter == prop_map_.end()) 416 if (iter == prop_map_.end())
419 return NULL; 417 return NULL;
420 return iter->second; 418 return iter->second;
421 } 419 }
422 420
423 int Window::GetIntProperty(const char* name) const { 421 int Window::GetIntProperty(const char* name) const {
424 return static_cast<int>(reinterpret_cast<intptr_t>( 422 return static_cast<int>(reinterpret_cast<intptr_t>(
425 GetProperty(name))); 423 GetProperty(name)));
426 } 424 }
427 425
426 bool Window::StopsEventPropagation() const {
427 if (!stops_event_propagation_ || children_.empty())
428 return false;
429 aura::Window::Windows::const_iterator it =
430 std::find_if(children_.begin(), children_.end(),
431 std::mem_fun(&aura::Window::IsVisible));
432 return it != children_.end();
433 }
434
428 RootWindow* Window::GetRootWindow() { 435 RootWindow* Window::GetRootWindow() {
429 return parent_ ? parent_->GetRootWindow() : NULL; 436 return parent_ ? parent_->GetRootWindow() : NULL;
430 } 437 }
431 438
432 void Window::WindowDetachedFromRootWindow(aura::Window* window) { 439 void Window::WindowDetachedFromRootWindow(aura::Window* window) {
433 } 440 }
434 441
435 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { 442 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) {
436 gfx::Rect actual_new_bounds(new_bounds); 443 gfx::Rect actual_new_bounds(new_bounds);
437 444
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 if (parent_ && parent_->layout_manager_.get()) 487 if (parent_ && parent_->layout_manager_.get())
481 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible); 488 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible);
482 FOR_EACH_OBSERVER(WindowObserver, observers_, 489 FOR_EACH_OBSERVER(WindowObserver, observers_,
483 OnWindowVisibilityChanged(this, visible)); 490 OnWindowVisibilityChanged(this, visible));
484 } 491 }
485 492
486 void Window::SchedulePaint() { 493 void Window::SchedulePaint() {
487 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); 494 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height()));
488 } 495 }
489 496
490 bool Window::StopsEventPropagation() const {
491 return stops_event_propagation_ && !children_.empty();
492 }
493
494 Window* Window::GetWindowForPoint(const gfx::Point& local_point, 497 Window* Window::GetWindowForPoint(const gfx::Point& local_point,
495 bool return_tightest, 498 bool return_tightest,
496 bool for_event_handling) { 499 bool for_event_handling) {
497 if (!IsVisible()) 500 if (!IsVisible())
498 return NULL; 501 return NULL;
499 502
500 if ((for_event_handling && !HitTest(local_point)) || 503 if ((for_event_handling && !HitTest(local_point)) ||
501 (!for_event_handling && !ContainsPoint(local_point))) 504 (!for_event_handling && !ContainsPoint(local_point)))
502 return NULL; 505 return NULL;
503 506
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 552
550 if (id_ != -1) { 553 if (id_ != -1) {
551 char id_buf[10]; 554 char id_buf[10];
552 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); 555 base::snprintf(id_buf, sizeof(id_buf), " %d", id_);
553 layer_name.append(id_buf); 556 layer_name.append(id_buf);
554 } 557 }
555 layer()->set_name(layer_name); 558 layer()->set_name(layer_name);
556 #endif 559 #endif
557 } 560 }
558 561
562 bool Window::IsBehindStopEventsWindow() const {
563 Windows::const_iterator i = std::find(parent_->children().begin(),
564 parent_->children().end(),
565 this);
566 for (++i; i != parent_->children().end(); ++i) {
567 if ((*i)->StopsEventPropagation())
568 return true;
569 }
570 return false;
571 }
572
559 } // namespace aura 573 } // namespace aura
OLDNEW
« ui/aura/window.h ('K') | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698