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

Side by Side Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view_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
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 "chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h"
6 6
7 #include "chrome/browser/ui/views/frame/browser_frame.h" 7 #include "chrome/browser/ui/views/frame/browser_frame.h"
8 #include "chrome/browser/ui/views/frame/browser_view.h" 8 #include "chrome/browser/ui/views/frame/browser_view.h"
9 #include "grit/generated_resources.h" // Accessibility names 9 #include "grit/generated_resources.h" // Accessibility names
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (frame_component != HTNOWHERE) 252 if (frame_component != HTNOWHERE)
253 return frame_component; 253 return frame_component;
254 // Use HTCAPTION as a final fallback. 254 // Use HTCAPTION as a final fallback.
255 return HTCAPTION; 255 return HTCAPTION;
256 } 256 }
257 257
258 // Pass |active_window| explicitly because deactivating a window causes 258 // Pass |active_window| explicitly because deactivating a window causes
259 // OnWidgetActivationChanged() to be called before GetWidget()->IsActive() 259 // OnWidgetActivationChanged() to be called before GetWidget()->IsActive()
260 // changes state. 260 // changes state.
261 gfx::Rect BrowserNonClientFrameViewAura::GetFrameBackgroundBounds( 261 gfx::Rect BrowserNonClientFrameViewAura::GetFrameBackgroundBounds(
262 int hittest_code, bool active_window) { 262 int hittest_code,
263 bool active_window) {
263 bool show_left = false; 264 bool show_left = false;
264 bool show_top = false; 265 bool show_top = false;
265 bool show_right = false; 266 bool show_right = false;
266 bool show_bottom = false; 267 bool show_bottom = false;
267 switch (hittest_code) { 268 switch (hittest_code) {
268 case HTBOTTOM: 269 case HTBOTTOM:
269 show_bottom = true; 270 show_bottom = true;
270 break; 271 break;
271 case HTBOTTOMLEFT: 272 case HTBOTTOMLEFT:
272 show_bottom = true; 273 show_bottom = true;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return target; 314 return target;
314 } 315 }
315 316
316 void BrowserNonClientFrameViewAura::UpdateFrameBackground(bool active_window) { 317 void BrowserNonClientFrameViewAura::UpdateFrameBackground(bool active_window) {
317 gfx::Rect start_bounds = GetFrameBackgroundBounds(HTNOWHERE, active_window); 318 gfx::Rect start_bounds = GetFrameBackgroundBounds(HTNOWHERE, active_window);
318 gfx::Rect end_bounds = 319 gfx::Rect end_bounds =
319 GetFrameBackgroundBounds(last_hittest_code_, active_window); 320 GetFrameBackgroundBounds(last_hittest_code_, active_window);
320 frame_background_->Configure(start_bounds, end_bounds); 321 frame_background_->Configure(start_bounds, end_bounds);
321 } 322 }
322 323
324 void BrowserNonClientFrameViewAura::ActiveStateChanged() {
325 bool active = ShouldPaintAsActive();
326 // Active windows have different background bounds.
327 UpdateFrameBackground(active);
328 if (active)
329 frame_background_->Show();
330 else
331 frame_background_->Hide();
332 maximize_button_->SetVisible(active);
333 close_button_->SetVisible(active);
334 }
335
323 /////////////////////////////////////////////////////////////////////////////// 336 ///////////////////////////////////////////////////////////////////////////////
324 // BrowserNonClientFrameView overrides: 337 // BrowserNonClientFrameView overrides:
325 338
326 gfx::Rect BrowserNonClientFrameViewAura::GetBoundsForTabStrip( 339 gfx::Rect BrowserNonClientFrameViewAura::GetBoundsForTabStrip(
327 views::View* tabstrip) const { 340 views::View* tabstrip) const {
328 if (!tabstrip) 341 if (!tabstrip)
329 return gfx::Rect(); 342 return gfx::Rect();
330 // TODO(jamescook): Avatar icon support. 343 // TODO(jamescook): Avatar icon support.
331 // Reserve space on the right for close/maximize buttons. 344 // Reserve space on the right for close/maximize buttons.
332 int tabstrip_x = kResizeBorderThickness; 345 int tabstrip_x = kResizeBorderThickness;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 403
391 void BrowserNonClientFrameViewAura::ResetWindowControls() { 404 void BrowserNonClientFrameViewAura::ResetWindowControls() {
392 maximize_button_->SetState(views::CustomButton::BS_NORMAL); 405 maximize_button_->SetState(views::CustomButton::BS_NORMAL);
393 // The close button isn't affected by this constraint. 406 // The close button isn't affected by this constraint.
394 } 407 }
395 408
396 void BrowserNonClientFrameViewAura::UpdateWindowIcon() { 409 void BrowserNonClientFrameViewAura::UpdateWindowIcon() {
397 // TODO(jamescook): We will need this for app frames. 410 // TODO(jamescook): We will need this for app frames.
398 } 411 }
399 412
413 void BrowserNonClientFrameViewAura::ShouldPaintAsActiveChanged() {
414 ActiveStateChanged();
415 }
416
400 /////////////////////////////////////////////////////////////////////////////// 417 ///////////////////////////////////////////////////////////////////////////////
401 // views::View overrides: 418 // views::View overrides:
402 419
403 void BrowserNonClientFrameViewAura::Layout() { 420 void BrowserNonClientFrameViewAura::Layout() {
404 // Layout window buttons from right to left. 421 // Layout window buttons from right to left.
405 int right = width() - kResizeBorderThickness; 422 int right = width() - kResizeBorderThickness;
406 gfx::Size preferred = close_button_->GetPreferredSize(); 423 gfx::Size preferred = close_button_->GetPreferredSize();
407 close_button_->SetBounds(right - preferred.width(), kTopBorderThickness, 424 close_button_->SetBounds(right - preferred.width(), kTopBorderThickness,
408 preferred.width(), preferred.height()); 425 preferred.width(), preferred.height());
409 right -= preferred.width(); // No padding. 426 right -= preferred.width(); // No padding.
410 preferred = maximize_button_->GetPreferredSize(); 427 preferred = maximize_button_->GetPreferredSize();
411 maximize_button_->SetBounds(right - preferred.width(), kTopBorderThickness, 428 maximize_button_->SetBounds(right - preferred.width(), kTopBorderThickness,
412 preferred.width(), preferred.height()); 429 preferred.width(), preferred.height());
413 UpdateFrameBackground(GetWidget()->IsActive()); 430 UpdateFrameBackground(ShouldPaintAsActive());
414 } 431 }
415 432
416 views::View* BrowserNonClientFrameViewAura::GetEventHandlerForPoint( 433 views::View* BrowserNonClientFrameViewAura::GetEventHandlerForPoint(
417 const gfx::Point& point) { 434 const gfx::Point& point) {
418 // Mouse hovers near the resizing edges result in the animation starting and 435 // Mouse hovers near the resizing edges result in the animation starting and
419 // stopping as the frame background changes size. Just ignore events 436 // stopping as the frame background changes size. Just ignore events
420 // destined for the frame background and handle them at this level. 437 // destined for the frame background and handle them at this level.
421 views::View* view = View::GetEventHandlerForPoint(point); 438 views::View* view = View::GetEventHandlerForPoint(point);
422 if (view == frame_background_) 439 if (view == frame_background_)
423 return this; 440 return this;
(...skipping 25 matching lines...) Expand all
449 // completely. We need to do this since we're not a parent of the tabstrip, 466 // completely. We need to do this since we're not a parent of the tabstrip,
450 // meaning ConvertPointToView would otherwise return something bogus. 467 // meaning ConvertPointToView would otherwise return something bogus.
451 gfx::Point browser_view_point(p); 468 gfx::Point browser_view_point(p);
452 View::ConvertPointToView(parent(), browser_view_, &browser_view_point); 469 View::ConvertPointToView(parent(), browser_view_, &browser_view_point);
453 return browser_view_->IsPositionInWindowCaption(browser_view_point); 470 return browser_view_->IsPositionInWindowCaption(browser_view_point);
454 } 471 }
455 472
456 void BrowserNonClientFrameViewAura::OnMouseMoved( 473 void BrowserNonClientFrameViewAura::OnMouseMoved(
457 const views::MouseEvent& event) { 474 const views::MouseEvent& event) {
458 // We may be hovering over the resize edge. 475 // We may be hovering over the resize edge.
459 UpdateFrameBackground(GetWidget()->IsActive()); 476 UpdateFrameBackground(ShouldPaintAsActive());
460 frame_background_->Show(); 477 frame_background_->Show();
461 } 478 }
462 479
463 void BrowserNonClientFrameViewAura::OnMouseExited( 480 void BrowserNonClientFrameViewAura::OnMouseExited(
464 const views::MouseEvent& event) { 481 const views::MouseEvent& event) {
465 frame_background_->Hide(); 482 frame_background_->Hide();
466 } 483 }
467 484
468 gfx::NativeCursor BrowserNonClientFrameViewAura::GetCursor( 485 gfx::NativeCursor BrowserNonClientFrameViewAura::GetCursor(
469 const views::MouseEvent& event) { 486 const views::MouseEvent& event) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 browser_frame_->Close(); 525 browser_frame_->Close();
509 } else if (sender == maximize_button_) { 526 } else if (sender == maximize_button_) {
510 if (browser_frame_->IsMaximized()) 527 if (browser_frame_->IsMaximized())
511 browser_frame_->Restore(); 528 browser_frame_->Restore();
512 else 529 else
513 browser_frame_->Maximize(); 530 browser_frame_->Maximize();
514 } 531 }
515 } 532 }
516 533
517 /////////////////////////////////////////////////////////////////////////////// 534 ///////////////////////////////////////////////////////////////////////////////
518 // views::ButtonListener overrides: 535 // views::Widget::Observer overrides:
519 536
520 void BrowserNonClientFrameViewAura::OnWidgetActivationChanged( 537 void BrowserNonClientFrameViewAura::OnWidgetActivationChanged(
521 views::Widget* widget, bool active) { 538 views::Widget* widget,
522 // Active windows have different background bounds. 539 bool active) {
523 UpdateFrameBackground(active); 540 ActiveStateChanged();
524 if (active)
525 frame_background_->Show();
526 else
527 frame_background_->Hide();
528 maximize_button_->SetVisible(active);
529 close_button_->SetVisible(active);
530 } 541 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698