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

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: . 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 {
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 bool stops_event_propagation = false;
430 for (Windows::const_reverse_iterator it = children_.rbegin();
431 it != children_.rend(); ++it) {
432 stops_event_propagation |=
433 (*it)->IsVisible() && (*it)->stops_event_propagation_;
434 }
435 return stops_event_propagation;
436 }
437
428 RootWindow* Window::GetRootWindow() { 438 RootWindow* Window::GetRootWindow() {
429 return parent_ ? parent_->GetRootWindow() : NULL; 439 return parent_ ? parent_->GetRootWindow() : NULL;
430 } 440 }
431 441
432 void Window::WindowDetachedFromRootWindow(aura::Window* window) { 442 void Window::WindowDetachedFromRootWindow(aura::Window* window) {
433 } 443 }
434 444
435 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { 445 void Window::SetBoundsInternal(const gfx::Rect& new_bounds) {
436 gfx::Rect actual_new_bounds(new_bounds); 446 gfx::Rect actual_new_bounds(new_bounds);
437 447
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 if (parent_ && parent_->layout_manager_.get()) 490 if (parent_ && parent_->layout_manager_.get())
481 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible); 491 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible);
482 FOR_EACH_OBSERVER(WindowObserver, observers_, 492 FOR_EACH_OBSERVER(WindowObserver, observers_,
483 OnWindowVisibilityChanged(this, visible)); 493 OnWindowVisibilityChanged(this, visible));
484 } 494 }
485 495
486 void Window::SchedulePaint() { 496 void Window::SchedulePaint() {
487 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); 497 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height()));
488 } 498 }
489 499
490 bool Window::StopsEventPropagation() const {
491 return stops_event_propagation_ && !children_.empty();
492 }
493
494 Window* Window::GetWindowForPoint(const gfx::Point& local_point, 500 Window* Window::GetWindowForPoint(const gfx::Point& local_point,
495 bool return_tightest, 501 bool return_tightest,
496 bool for_event_handling) { 502 bool for_event_handling) {
497 if (!IsVisible()) 503 if (!IsVisible())
498 return NULL; 504 return NULL;
499 505
500 if ((for_event_handling && !HitTest(local_point)) || 506 if ((for_event_handling && !HitTest(local_point)) ||
501 (!for_event_handling && !ContainsPoint(local_point))) 507 (!for_event_handling && !ContainsPoint(local_point)))
502 return NULL; 508 return NULL;
503 509
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 555
550 if (id_ != -1) { 556 if (id_ != -1) {
551 char id_buf[10]; 557 char id_buf[10];
552 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); 558 base::snprintf(id_buf, sizeof(id_buf), " %d", id_);
553 layer_name.append(id_buf); 559 layer_name.append(id_buf);
554 } 560 }
555 layer()->set_name(layer_name); 561 layer()->set_name(layer_name);
556 #endif 562 #endif
557 } 563 }
558 564
565 bool Window::IsBehindStopEventsWindow() const {
566 Windows::const_iterator i = std::find(parent_->children().begin(),
567 parent_->children().end(),
568 this);
569 for (++i; i != parent_->children().end(); ++i) {
570 if ((*i)->StopsEventPropagation())
571 return true;
572 }
573 return false;
574 }
575
559 } // namespace aura 576 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698