OLD | NEW |
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/aura_constants.h" |
8 #include "ui/aura/desktop.h" | 9 #include "ui/aura/desktop.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" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 67 } |
67 | 68 |
68 //////////////////////////////////////////////////////////////////////////////// | 69 //////////////////////////////////////////////////////////////////////////////// |
69 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: | 70 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: |
70 | 71 |
71 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { | 72 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
72 ownership_ = params.ownership; | 73 ownership_ = params.ownership; |
73 window_->set_user_data(this); | 74 window_->set_user_data(this); |
74 Widget::InitParams::Type window_type = | 75 Widget::InitParams::Type window_type = |
75 params.child ? Widget::InitParams::TYPE_CONTROL : params.type; | 76 params.child ? Widget::InitParams::TYPE_CONTROL : params.type; |
76 SetNativeWindowProperty(kWindowTypeKey, reinterpret_cast<void*>(window_type)); | 77 window_->SetIntProperty(kWindowTypeKey, window_type); |
| 78 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL); |
77 window_->SetType(window_type == Widget::InitParams::TYPE_CONTROL ? | 79 window_->SetType(window_type == Widget::InitParams::TYPE_CONTROL ? |
78 aura::kWindowType_Control : aura::kWindowType_None); | 80 aura::kWindowType_Control : aura::kWindowType_None); |
79 window_->Init(params.create_texture_for_layer ? | 81 window_->Init(params.create_texture_for_layer ? |
80 ui::Layer::LAYER_HAS_TEXTURE : ui::Layer::LAYER_HAS_NO_TEXTURE); | 82 ui::Layer::LAYER_HAS_TEXTURE : ui::Layer::LAYER_HAS_NO_TEXTURE); |
81 // TODO(beng): respect |params| authoritah wrt transparency. | 83 // TODO(beng): respect |params| authoritah wrt transparency. |
82 window_->layer()->SetFillsBoundsOpaquely(false); | 84 window_->layer()->SetFillsBoundsOpaquely(false); |
83 delegate_->OnNativeWidgetCreated(); | 85 delegate_->OnNativeWidgetCreated(); |
84 window_->set_minimum_size(delegate_->GetMinimumSize()); | 86 window_->set_minimum_size(delegate_->GetMinimumSize()); |
85 window_->SetBounds(params.bounds); | 87 window_->SetBounds(params.bounds); |
86 if (params.type == Widget::InitParams::TYPE_CONTROL) { | 88 if (params.type == Widget::InitParams::TYPE_CONTROL) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 const gfx::Rect parent_bounds = window_->parent()->bounds(); | 219 const gfx::Rect parent_bounds = window_->parent()->bounds(); |
218 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, | 220 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, |
219 (parent_bounds.height() - size.height())/2, | 221 (parent_bounds.height() - size.height())/2, |
220 size.width(), | 222 size.width(), |
221 size.height())); | 223 size.height())); |
222 } | 224 } |
223 | 225 |
224 void NativeWidgetAura::GetWindowPlacement( | 226 void NativeWidgetAura::GetWindowPlacement( |
225 gfx::Rect* bounds, | 227 gfx::Rect* bounds, |
226 ui::WindowShowState* maximized) const { | 228 ui::WindowShowState* maximized) const { |
227 *maximized = window_->show_state(); | 229 *maximized = static_cast<ui::WindowShowState>( |
| 230 window_->GetIntProperty(aura::kShowStateKey)); |
228 } | 231 } |
229 | 232 |
230 void NativeWidgetAura::SetWindowTitle(const string16& title) { | 233 void NativeWidgetAura::SetWindowTitle(const string16& title) { |
231 // Aura doesn't have native window frames. | 234 // Aura doesn't have native window frames. |
232 } | 235 } |
233 | 236 |
234 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon, | 237 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon, |
235 const SkBitmap& app_icon) { | 238 const SkBitmap& app_icon) { |
236 // Aura doesn't have window icons. | 239 // Aura doesn't have window icons. |
237 } | 240 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 window_->Show(); | 316 window_->Show(); |
314 } | 317 } |
315 | 318 |
316 void NativeWidgetAura::Hide() { | 319 void NativeWidgetAura::Hide() { |
317 window_->Hide(); | 320 window_->Hide(); |
318 } | 321 } |
319 | 322 |
320 void NativeWidgetAura::ShowMaximizedWithBounds( | 323 void NativeWidgetAura::ShowMaximizedWithBounds( |
321 const gfx::Rect& restored_bounds) { | 324 const gfx::Rect& restored_bounds) { |
322 window_->SetBounds(restored_bounds); | 325 window_->SetBounds(restored_bounds); |
323 window_->Maximize(); | 326 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
324 window_->Show(); | 327 window_->Show(); |
325 } | 328 } |
326 | 329 |
327 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { | 330 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { |
328 switch(state) { | 331 if (state == ui::SHOW_STATE_MAXIMIZED || |
329 case ui::SHOW_STATE_MAXIMIZED: | 332 state == ui::SHOW_STATE_FULLSCREEN) { |
330 window_->Maximize(); | 333 window_->SetIntProperty(aura::kShowStateKey, state); |
331 break; | |
332 case ui::SHOW_STATE_FULLSCREEN: | |
333 window_->Fullscreen(); | |
334 break; | |
335 default: | |
336 break; | |
337 } | 334 } |
338 window_->Show(); | 335 window_->Show(); |
339 } | 336 } |
340 | 337 |
341 bool NativeWidgetAura::IsVisible() const { | 338 bool NativeWidgetAura::IsVisible() const { |
342 return window_->IsVisible(); | 339 return window_->IsVisible(); |
343 } | 340 } |
344 | 341 |
345 void NativeWidgetAura::Activate() { | 342 void NativeWidgetAura::Activate() { |
346 window_->Activate(); | 343 window_->Activate(); |
347 } | 344 } |
348 | 345 |
349 void NativeWidgetAura::Deactivate() { | 346 void NativeWidgetAura::Deactivate() { |
350 window_->Deactivate(); | 347 window_->Deactivate(); |
351 } | 348 } |
352 | 349 |
353 bool NativeWidgetAura::IsActive() const { | 350 bool NativeWidgetAura::IsActive() const { |
354 return aura::Desktop::GetInstance()->active_window() == window_; | 351 return aura::Desktop::GetInstance()->active_window() == window_; |
355 } | 352 } |
356 | 353 |
357 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { | 354 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { |
358 NOTIMPLEMENTED(); | 355 NOTIMPLEMENTED(); |
359 } | 356 } |
360 | 357 |
361 void NativeWidgetAura::Maximize() { | 358 void NativeWidgetAura::Maximize() { |
362 window_->Maximize(); | 359 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
363 } | 360 } |
364 | 361 |
365 void NativeWidgetAura::Minimize() { | 362 void NativeWidgetAura::Minimize() { |
366 NOTIMPLEMENTED(); | 363 NOTIMPLEMENTED(); |
367 } | 364 } |
368 | 365 |
369 bool NativeWidgetAura::IsMaximized() const { | 366 bool NativeWidgetAura::IsMaximized() const { |
370 return window_->show_state() == ui::SHOW_STATE_MAXIMIZED; | 367 return window_->GetIntProperty(aura::kShowStateKey) == |
| 368 ui::SHOW_STATE_MAXIMIZED; |
371 } | 369 } |
372 | 370 |
373 bool NativeWidgetAura::IsMinimized() const { | 371 bool NativeWidgetAura::IsMinimized() const { |
374 return window_->show_state() == ui::SHOW_STATE_MINIMIZED; | 372 return window_->GetIntProperty(aura::kShowStateKey) == |
| 373 ui::SHOW_STATE_MINIMIZED; |
375 } | 374 } |
376 | 375 |
377 void NativeWidgetAura::Restore() { | 376 void NativeWidgetAura::Restore() { |
378 window_->Restore(); | 377 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL); |
379 } | 378 } |
380 | 379 |
381 void NativeWidgetAura::SetFullscreen(bool fullscreen) { | 380 void NativeWidgetAura::SetFullscreen(bool fullscreen) { |
382 fullscreen ? window_->Fullscreen() : window_->Restore(); | 381 window_->SetIntProperty( |
| 382 aura::kShowStateKey, |
| 383 fullscreen ? ui::SHOW_STATE_FULLSCREEN : ui::SHOW_STATE_NORMAL); |
383 } | 384 } |
384 | 385 |
385 bool NativeWidgetAura::IsFullscreen() const { | 386 bool NativeWidgetAura::IsFullscreen() const { |
386 return window_->show_state() == ui::SHOW_STATE_FULLSCREEN; | 387 return window_->GetIntProperty(aura::kShowStateKey) == |
| 388 ui::SHOW_STATE_FULLSCREEN; |
387 } | 389 } |
388 | 390 |
389 void NativeWidgetAura::SetOpacity(unsigned char opacity) { | 391 void NativeWidgetAura::SetOpacity(unsigned char opacity) { |
390 window_->layer()->SetOpacity(opacity / 255.0); | 392 window_->layer()->SetOpacity(opacity / 255.0); |
391 } | 393 } |
392 | 394 |
393 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { | 395 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { |
394 NOTIMPLEMENTED(); | 396 NOTIMPLEMENTED(); |
395 } | 397 } |
396 | 398 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 | 546 |
545 void NativeWidgetAura::OnWindowDestroying() { | 547 void NativeWidgetAura::OnWindowDestroying() { |
546 delegate_->OnNativeWidgetDestroying(); | 548 delegate_->OnNativeWidgetDestroying(); |
547 | 549 |
548 // If the aura::Window is destroyed, we can no longer show tooltips. | 550 // If the aura::Window is destroyed, we can no longer show tooltips. |
549 tooltip_manager_.reset(); | 551 tooltip_manager_.reset(); |
550 } | 552 } |
551 | 553 |
552 void NativeWidgetAura::OnWindowDestroyed() { | 554 void NativeWidgetAura::OnWindowDestroyed() { |
553 window_ = NULL; | 555 window_ = NULL; |
| 556 tooltip_manager_.reset(); |
554 delegate_->OnNativeWidgetDestroyed(); | 557 delegate_->OnNativeWidgetDestroyed(); |
555 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 558 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
556 delete this; | 559 delete this; |
557 } | 560 } |
558 | 561 |
559 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { | 562 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { |
560 delegate_->OnNativeWidgetVisibilityChanged(visible); | 563 delegate_->OnNativeWidgetVisibilityChanged(visible); |
561 } | 564 } |
562 | 565 |
563 //////////////////////////////////////////////////////////////////////////////// | 566 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } | 649 } |
647 | 650 |
648 // static | 651 // static |
649 bool NativeWidgetPrivate::IsMouseButtonDown() { | 652 bool NativeWidgetPrivate::IsMouseButtonDown() { |
650 NOTIMPLEMENTED(); | 653 NOTIMPLEMENTED(); |
651 return false; | 654 return false; |
652 } | 655 } |
653 | 656 |
654 } // namespace internal | 657 } // namespace internal |
655 } // namespace views | 658 } // namespace views |
OLD | NEW |