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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Issue 286733002: [Refactor] Consolidate the logic for whether a widget can be activated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/cursor_client.h" 10 #include "ui/aura/client/cursor_client.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 new DesktopNativeWidgetTopLevelHandler; 87 new DesktopNativeWidgetTopLevelHandler;
88 88
89 child_window->SetBounds(gfx::Rect(bounds.size())); 89 child_window->SetBounds(gfx::Rect(bounds.size()));
90 90
91 Widget::InitParams init_params; 91 Widget::InitParams init_params;
92 init_params.type = full_screen ? Widget::InitParams::TYPE_WINDOW : 92 init_params.type = full_screen ? Widget::InitParams::TYPE_WINDOW :
93 Widget::InitParams::TYPE_POPUP; 93 Widget::InitParams::TYPE_POPUP;
94 init_params.bounds = bounds; 94 init_params.bounds = bounds;
95 init_params.ownership = Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; 95 init_params.ownership = Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET;
96 init_params.layer_type = aura::WINDOW_LAYER_NOT_DRAWN; 96 init_params.layer_type = aura::WINDOW_LAYER_NOT_DRAWN;
97 init_params.can_activate = full_screen; 97 init_params.activatable = full_screen ?
98 Widget::InitParams::ACTIVATABLE_YES :
99 Widget::InitParams::ACTIVATABLE_NO;
98 init_params.keep_on_top = root_is_always_on_top; 100 init_params.keep_on_top = root_is_always_on_top;
99 101
100 // This widget instance will get deleted when the window is 102 // This widget instance will get deleted when the window is
101 // destroyed. 103 // destroyed.
102 top_level_handler->top_level_widget_ = new Widget(); 104 top_level_handler->top_level_widget_ = new Widget();
103 top_level_handler->top_level_widget_->Init(init_params); 105 top_level_handler->top_level_widget_->Init(init_params);
104 106
105 top_level_handler->top_level_widget_->SetFullscreen(full_screen); 107 top_level_handler->top_level_widget_->SetFullscreen(full_screen);
106 top_level_handler->top_level_widget_->Show(); 108 top_level_handler->top_level_widget_->Show();
107 109
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 int DesktopNativeWidgetAura::cursor_reference_count_ = 0; 245 int DesktopNativeWidgetAura::cursor_reference_count_ = 0;
244 DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ = 246 DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ =
245 NULL; 247 NULL;
246 wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL; 248 wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL;
247 249
248 DesktopNativeWidgetAura::DesktopNativeWidgetAura( 250 DesktopNativeWidgetAura::DesktopNativeWidgetAura(
249 internal::NativeWidgetDelegate* delegate) 251 internal::NativeWidgetDelegate* delegate)
250 : desktop_window_tree_host_(NULL), 252 : desktop_window_tree_host_(NULL),
251 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 253 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
252 close_widget_factory_(this), 254 close_widget_factory_(this),
253 can_activate_(true),
254 content_window_container_(NULL), 255 content_window_container_(NULL),
255 content_window_(new aura::Window(this)), 256 content_window_(new aura::Window(this)),
256 native_widget_delegate_(delegate), 257 native_widget_delegate_(delegate),
257 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), 258 last_drop_operation_(ui::DragDropTypes::DRAG_NONE),
258 restore_focus_on_activate_(false), 259 restore_focus_on_activate_(false),
259 cursor_(gfx::kNullCursor), 260 cursor_(gfx::kNullCursor),
260 widget_type_(Widget::InitParams::TYPE_WINDOW) { 261 widget_type_(Widget::InitParams::TYPE_WINDOW) {
261 aura::client::SetFocusChangeObserver(content_window_, this); 262 aura::client::SetFocusChangeObserver(content_window_, this);
262 aura::client::SetActivationChangeObserver(content_window_, this); 263 aura::client::SetActivationChangeObserver(content_window_, this);
263 } 264 }
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 } 1043 }
1043 1044
1044 void DesktopNativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) { 1045 void DesktopNativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) {
1045 native_widget_delegate_->OnGestureEvent(event); 1046 native_widget_delegate_->OnGestureEvent(event);
1046 } 1047 }
1047 1048
1048 //////////////////////////////////////////////////////////////////////////////// 1049 ////////////////////////////////////////////////////////////////////////////////
1049 // DesktopNativeWidgetAura, aura::client::ActivationDelegate implementation: 1050 // DesktopNativeWidgetAura, aura::client::ActivationDelegate implementation:
1050 1051
1051 bool DesktopNativeWidgetAura::ShouldActivate() const { 1052 bool DesktopNativeWidgetAura::ShouldActivate() const {
1052 return can_activate_ && native_widget_delegate_->CanActivate(); 1053 return native_widget_delegate_->CanActivate();
1053 } 1054 }
1054 1055
1055 //////////////////////////////////////////////////////////////////////////////// 1056 ////////////////////////////////////////////////////////////////////////////////
1056 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver 1057 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver
1057 // implementation: 1058 // implementation:
1058 1059
1059 void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active, 1060 void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active,
1060 aura::Window* lost_active) { 1061 aura::Window* lost_active) {
1061 DCHECK(content_window_ == gained_active || content_window_ == lost_active); 1062 DCHECK(content_window_ == gained_active || content_window_ == lost_active);
1062 if (gained_active == content_window_ && restore_focus_on_activate_) { 1063 if (gained_active == content_window_ && restore_focus_on_activate_) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 if (cursor_reference_count_ == 0) { 1195 if (cursor_reference_count_ == 0) {
1195 // We are the last DesktopNativeWidgetAura instance, and we are responsible 1196 // We are the last DesktopNativeWidgetAura instance, and we are responsible
1196 // for cleaning up |cursor_manager_|. 1197 // for cleaning up |cursor_manager_|.
1197 delete cursor_manager_; 1198 delete cursor_manager_;
1198 native_cursor_manager_ = NULL; 1199 native_cursor_manager_ = NULL;
1199 cursor_manager_ = NULL; 1200 cursor_manager_ = NULL;
1200 } 1201 }
1201 } 1202 }
1202 1203
1203 } // namespace views 1204 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.h ('k') | ui/views/widget/native_widget_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698