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

Side by Side Diff: ash/launcher/launcher.cc

Issue 9406031: Makes it so the launcher only gets focus when using the keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/launcher/launcher.h" 5 #include "ash/launcher/launcher.h"
6 6
7 #include "ash/focus_cycler.h"
7 #include "ash/launcher/launcher_model.h" 8 #include "ash/launcher/launcher_model.h"
8 #include "ash/launcher/launcher_view.h" 9 #include "ash/launcher/launcher_view.h"
9 #include "ash/shell.h" 10 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 11 #include "ash/shell_delegate.h"
11 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
12 #include "grit/ui_resources.h" 13 #include "grit/ui_resources.h"
13 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/compositor/layer.h" 17 #include "ui/gfx/compositor/layer.h"
17 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
18 #include "ui/views/accessible_pane_view.h" 19 #include "ui/views/accessible_pane_view.h"
19 #include "ui/views/painter.h" 20 #include "ui/views/painter.h"
20 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
22 #include "ui/views/widget/widget_delegate.h"
21 23
22 namespace ash { 24 namespace ash {
23 25
24 namespace { 26 namespace {
25 27
26 // Used to draw the background of the shelf. 28 // Used to draw the background of the shelf.
27 class ShelfPainter : public views::Painter { 29 class ShelfPainter : public views::Painter {
28 public: 30 public:
29 ShelfPainter() { 31 ShelfPainter() {
30 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 32 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
(...skipping 16 matching lines...) Expand all
47 // sizes it to the width of the widget minus the size of the status area. 49 // sizes it to the width of the widget minus the size of the status area.
48 class Launcher::DelegateView : public views::WidgetDelegate, 50 class Launcher::DelegateView : public views::WidgetDelegate,
49 public views::AccessiblePaneView { 51 public views::AccessiblePaneView {
50 public: 52 public:
51 explicit DelegateView(); 53 explicit DelegateView();
52 virtual ~DelegateView(); 54 virtual ~DelegateView();
53 55
54 void SetStatusWidth(int width); 56 void SetStatusWidth(int width);
55 int status_width() const { return status_width_; } 57 int status_width() const { return status_width_; }
56 58
59 void set_focus_cycler(const internal::FocusCycler* focus_cycler) {
60 focus_cycler_ = focus_cycler;
61 }
62
57 // views::View overrides 63 // views::View overrides
58 virtual gfx::Size GetPreferredSize() OVERRIDE; 64 virtual gfx::Size GetPreferredSize() OVERRIDE;
59 virtual void Layout() OVERRIDE; 65 virtual void Layout() OVERRIDE;
60 66
61 virtual views::Widget* GetWidget() OVERRIDE { 67 virtual views::Widget* GetWidget() OVERRIDE {
62 return View::GetWidget(); 68 return View::GetWidget();
63 } 69 }
64 70
65 virtual const views::Widget* GetWidget() const OVERRIDE { 71 virtual const views::Widget* GetWidget() const OVERRIDE {
66 return View::GetWidget(); 72 return View::GetWidget();
67 } 73 }
68 74
75 // views::WidgetDelegateView overrides:
76 virtual bool CanActivate() const OVERRIDE {
77 // We don't want mouse clicks to activate us, but we need to allow
78 // activation when the user is using the keyboard (FocusCycler).
79 return focus_cycler_ && focus_cycler_->widget_activating() == GetWidget();
80 }
69 81
70 private: 82 private:
71 int status_width_; 83 int status_width_;
84 const internal::FocusCycler* focus_cycler_;
72 85
73 DISALLOW_COPY_AND_ASSIGN(DelegateView); 86 DISALLOW_COPY_AND_ASSIGN(DelegateView);
74 }; 87 };
75 88
76 Launcher::DelegateView::DelegateView() 89 Launcher::DelegateView::DelegateView()
77 : status_width_(0) { 90 : status_width_(0),
91 focus_cycler_(NULL) {
78 set_background( 92 set_background(
79 views::Background::CreateBackgroundPainter(true, new ShelfPainter())); 93 views::Background::CreateBackgroundPainter(true, new ShelfPainter()));
80 } 94 }
81 95
82 Launcher::DelegateView::~DelegateView() { 96 Launcher::DelegateView::~DelegateView() {
83 } 97 }
84 98
99 void Launcher::SetFocusCycler(const internal::FocusCycler* focus_cycler) {
100 delegate_view_->set_focus_cycler(focus_cycler);
101 }
102
85 void Launcher::DelegateView::SetStatusWidth(int width) { 103 void Launcher::DelegateView::SetStatusWidth(int width) {
86 if (status_width_ == width) 104 if (status_width_ == width)
87 return; 105 return;
88 106
89 status_width_ = width; 107 status_width_ = width;
90 Layout(); 108 Layout();
91 } 109 }
92 110
93 gfx::Size Launcher::DelegateView::GetPreferredSize() { 111 gfx::Size Launcher::DelegateView::GetPreferredSize() {
94 return child_count() > 0 ? child_at(0)->GetPreferredSize() : gfx::Size(); 112 return child_count() > 0 ? child_at(0)->GetPreferredSize() : gfx::Size();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 154
137 void Launcher::SetStatusWidth(int width) { 155 void Launcher::SetStatusWidth(int width) {
138 delegate_view_->SetStatusWidth(width); 156 delegate_view_->SetStatusWidth(width);
139 } 157 }
140 158
141 int Launcher::GetStatusWidth() { 159 int Launcher::GetStatusWidth() {
142 return delegate_view_->status_width(); 160 return delegate_view_->status_width();
143 } 161 }
144 162
145 } // namespace ash 163 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698