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

Side by Side Diff: views/widget/native_widget_aura.cc

Issue 8351042: Gets disable inactive frame rendering to work correctly for aura. This (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks Created 9 years, 1 month 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 | « views/widget/native_widget_aura.h ('k') | views/widget/native_widget_gtk.h » ('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) 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 "views/widget/native_widget_aura.h" 5 #include "views/widget/native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ui/aura/desktop.h" 8 #include "ui/aura/desktop.h"
9 #include "ui/aura/desktop_observer.h"
9 #include "ui/aura/event.h" 10 #include "ui/aura/event.h"
10 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
11 #include "ui/aura/window_types.h" 12 #include "ui/aura/window_types.h"
12 #include "ui/base/ui_base_types.h" 13 #include "ui/base/ui_base_types.h"
13 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/compositor/layer.h" 15 #include "ui/gfx/compositor/layer.h"
15 #include "ui/gfx/font.h" 16 #include "ui/gfx/font.h"
16 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
17 #include "views/widget/native_widget_delegate.h" 18 #include "views/widget/native_widget_delegate.h"
18 #include "views/widget/tooltip_manager_views.h" 19 #include "views/widget/tooltip_manager_views.h"
(...skipping 28 matching lines...) Expand all
47 case Widget::InitParams::TYPE_TOOLTIP: 48 case Widget::InitParams::TYPE_TOOLTIP:
48 return aura::WINDOW_TYPE_TOOLTIP; 49 return aura::WINDOW_TYPE_TOOLTIP;
49 default: 50 default:
50 NOTREACHED() << "Unhandled widget type " << type; 51 NOTREACHED() << "Unhandled widget type " << type;
51 return aura::WINDOW_TYPE_UNKNOWN; 52 return aura::WINDOW_TYPE_UNKNOWN;
52 } 53 }
53 } 54 }
54 55
55 } // namespace 56 } // namespace
56 57
58 // Used when SetInactiveRenderingDisabled() is invoked to track when active
59 // status changes in such a way that we should enable inactive rendering.
60 class NativeWidgetAura::DesktopObserverImpl : public aura::DesktopObserver {
61 public:
62 explicit DesktopObserverImpl(NativeWidgetAura* host)
63 : host_(host) {
64 aura::Desktop::GetInstance()->AddObserver(this);
65 }
66
67 virtual ~DesktopObserverImpl() {
68 aura::Desktop::GetInstance()->RemoveObserver(this);
69 }
70
71 // DesktopObserver overrides:
72 virtual void OnActiveWindowChanged(aura::Window* active) OVERRIDE {
73 if (!active || (active != host_->window_ &&
74 active->transient_parent() != host_->window_)) {
75 host_->delegate_->EnableInactiveRendering();
76 }
77 }
78
79 private:
80 NativeWidgetAura* host_;
81
82 DISALLOW_COPY_AND_ASSIGN(DesktopObserverImpl);
83 };
84
57 //////////////////////////////////////////////////////////////////////////////// 85 ////////////////////////////////////////////////////////////////////////////////
58 // NativeWidgetAura, public: 86 // NativeWidgetAura, public:
59 87
60 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) 88 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
61 : delegate_(delegate), 89 : delegate_(delegate),
62 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), 90 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))),
63 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 91 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
64 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), 92 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
65 can_activate_(true), 93 can_activate_(true),
66 cursor_(gfx::kNullCursor) { 94 cursor_(gfx::kNullCursor) {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 void NativeWidgetAura::SetFullscreen(bool fullscreen) { 437 void NativeWidgetAura::SetFullscreen(bool fullscreen) {
410 fullscreen ? window_->Fullscreen() : window_->Restore(); 438 fullscreen ? window_->Fullscreen() : window_->Restore();
411 } 439 }
412 440
413 bool NativeWidgetAura::IsFullscreen() const { 441 bool NativeWidgetAura::IsFullscreen() const {
414 return window_->show_state() == ui::SHOW_STATE_FULLSCREEN; 442 return window_->show_state() == ui::SHOW_STATE_FULLSCREEN;
415 } 443 }
416 444
417 void NativeWidgetAura::SetOpacity(unsigned char opacity) { 445 void NativeWidgetAura::SetOpacity(unsigned char opacity) {
418 window_->layer()->SetOpacity(opacity / 255.0); 446 window_->layer()->SetOpacity(opacity / 255.0);
447 window_->layer()->ScheduleDraw();
Ben Goodger (Google) 2011/11/01 19:22:00 Is this your other CL leaking through? I thought y
sky 2011/11/01 19:50:56 Ya, sorry. I'll remove that.
419 } 448 }
420 449
421 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { 450 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) {
422 NOTIMPLEMENTED(); 451 NOTIMPLEMENTED();
423 } 452 }
424 453
425 bool NativeWidgetAura::IsAccessibleWidget() const { 454 bool NativeWidgetAura::IsAccessibleWidget() const {
426 NOTIMPLEMENTED(); 455 NOTIMPLEMENTED();
427 return false; 456 return false;
428 } 457 }
(...skipping 26 matching lines...) Expand all
455 bool NativeWidgetAura::ConvertPointFromAncestor(const Widget* ancestor, 484 bool NativeWidgetAura::ConvertPointFromAncestor(const Widget* ancestor,
456 gfx::Point* point) const { 485 gfx::Point* point) const {
457 NOTIMPLEMENTED(); 486 NOTIMPLEMENTED();
458 return false; 487 return false;
459 } 488 }
460 489
461 gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { 490 gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const {
462 return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); 491 return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView());
463 } 492 }
464 493
494 void NativeWidgetAura::SetInactiveRenderingDisabled(bool value) {
495 if (!value)
496 desktop_observer_.reset();
497 else
498 desktop_observer_.reset(new DesktopObserverImpl(this));
499 }
500
465 //////////////////////////////////////////////////////////////////////////////// 501 ////////////////////////////////////////////////////////////////////////////////
466 // NativeWidgetAura, views::InputMethodDelegate implementation: 502 // NativeWidgetAura, views::InputMethodDelegate implementation:
467 503
468 void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) { 504 void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) {
469 if (delegate_->OnKeyEvent(key)) 505 if (delegate_->OnKeyEvent(key))
470 return; 506 return;
471 if (key.type() == ui::ET_KEY_PRESSED && GetWidget()->GetFocusManager()) 507 if (key.type() == ui::ET_KEY_PRESSED && GetWidget()->GetFocusManager())
472 GetWidget()->GetFocusManager()->OnKeyEvent(key); 508 GetWidget()->GetFocusManager()->OnKeyEvent(key);
473 } 509 }
474 510
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 710 }
675 711
676 // static 712 // static
677 bool NativeWidgetPrivate::IsMouseButtonDown() { 713 bool NativeWidgetPrivate::IsMouseButtonDown() {
678 NOTIMPLEMENTED(); 714 NOTIMPLEMENTED();
679 return false; 715 return false;
680 } 716 }
681 717
682 } // namespace internal 718 } // namespace internal
683 } // namespace views 719 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/native_widget_aura.h ('k') | views/widget/native_widget_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698