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

Side by Side Diff: chrome/browser/ui/panels/panel_browser_view.cc

Issue 10408047: Fix bug 105043: Panels [WIN]: For minimize panels, taskbar hover preview show the 4-pixel represent… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 8 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 "chrome/browser/ui/panels/panel_browser_view.h" 5 #include "chrome/browser/ui/panels/panel_browser_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/native_window_notification_source.h" 9 #include "chrome/browser/native_window_notification_source.h"
10 #include "chrome/browser/ui/panels/display_settings_provider.h" 10 #include "chrome/browser/ui/panels/display_settings_provider.h"
11 #include "chrome/browser/ui/panels/panel.h" 11 #include "chrome/browser/ui/panels/panel.h"
12 #include "chrome/browser/ui/panels/panel_bounds_animation.h" 12 #include "chrome/browser/ui/panels/panel_bounds_animation.h"
13 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" 13 #include "chrome/browser/ui/panels/panel_browser_frame_view.h"
14 #include "chrome/browser/ui/panels/panel_manager.h" 14 #include "chrome/browser/ui/panels/panel_manager.h"
15 #include "chrome/browser/ui/panels/panel_strip.h" 15 #include "chrome/browser/ui/panels/panel_strip.h"
16 #include "chrome/browser/ui/panels/taskbar_window_thumbnailer_win.h"
16 #include "chrome/browser/ui/views/frame/browser_frame.h" 17 #include "chrome/browser/ui/views/frame/browser_frame.h"
17 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
18 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
19 #include "grit/chromium_strings.h" 20 #include "grit/chromium_strings.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/gfx/canvas.h"
21 #include "ui/views/controls/button/image_button.h" 23 #include "ui/views/controls/button/image_button.h"
22 #include "ui/views/controls/label.h" 24 #include "ui/views/controls/label.h"
23 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
24 26
27 #if defined(OS_WIN)
28 #include "base/win/windows_version.h"
29 #endif
30
25 using content::NativeWebKeyboardEvent; 31 using content::NativeWebKeyboardEvent;
32
26 using content::WebContents; 33 using content::WebContents;
27 34
28 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, 35 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel,
29 const gfx::Rect& bounds) { 36 const gfx::Rect& bounds) {
30 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); 37 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds);
31 (new BrowserFrame(view))->InitBrowserFrame(); 38 (new BrowserFrame(view))->InitBrowserFrame();
32 return view; 39 return view;
33 } 40 }
34 41
35 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel, 42 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel,
36 const gfx::Rect& bounds) 43 const gfx::Rect& bounds)
37 : BrowserView(browser), 44 : BrowserView(browser),
38 panel_(panel), 45 panel_(panel),
39 bounds_(bounds), 46 bounds_(bounds),
40 closed_(false), 47 closed_(false),
41 focused_(false), 48 focused_(false),
42 mouse_pressed_(false), 49 mouse_pressed_(false),
43 mouse_dragging_state_(NO_DRAGGING), 50 mouse_dragging_state_(NO_DRAGGING),
44 is_drawing_attention_(false), 51 is_drawing_attention_(false),
52 force_to_paint_as_inactive_(false),
45 old_focused_view_(NULL) { 53 old_focused_view_(NULL) {
46 } 54 }
47 55
48 PanelBrowserView::~PanelBrowserView() { 56 PanelBrowserView::~PanelBrowserView() {
49 } 57 }
50 58
51 void PanelBrowserView::Init() { 59 void PanelBrowserView::Init() {
52 if (!panel_->manager()->display_settings_provider()->is_full_screen()) { 60 if (!panel_->manager()->display_settings_provider()->is_full_screen()) {
53 // TODO(prasadt): Implement this code. 61 // TODO(prasadt): Implement this code.
54 // HideThePanel. 62 // HideThePanel.
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 return bounds_animator_.get() && bounds_animator_->is_animating(); 520 return bounds_animator_.get() && bounds_animator_->is_animating();
513 } 521 }
514 522
515 void PanelBrowserView::EnableResizeByMouse(bool enable) { 523 void PanelBrowserView::EnableResizeByMouse(bool enable) {
516 } 524 }
517 525
518 void PanelBrowserView::UpdatePanelMinimizeRestoreButtonVisibility() { 526 void PanelBrowserView::UpdatePanelMinimizeRestoreButtonVisibility() {
519 GetFrameView()->UpdateTitleBarMinimizeRestoreButtonVisibility(); 527 GetFrameView()->UpdateTitleBarMinimizeRestoreButtonVisibility();
520 } 528 }
521 529
522
523 #if defined(OS_WIN) && !defined(USE_AURA) 530 #if defined(OS_WIN) && !defined(USE_AURA)
524 void PanelBrowserView::UpdateWindowAttribute(int attribute_index, 531 void PanelBrowserView::UpdateWindowAttribute(int attribute_index,
525 int attribute_value, 532 int attribute_value,
526 bool to_set) { 533 bool to_set) {
527 gfx::NativeWindow native_window = GetNativePanelHandle(); 534 gfx::NativeWindow native_window = GetNativePanelHandle();
528 int value = ::GetWindowLong(native_window, attribute_index); 535 int value = ::GetWindowLong(native_window, attribute_index);
529 int expected_value; 536 int expected_value;
530 if (to_set) 537 if (to_set)
531 expected_value = value | attribute_value; 538 expected_value = value | attribute_value;
532 else 539 else
533 expected_value = value & ~attribute_value; 540 expected_value = value & ~attribute_value;
534 if (value != expected_value) 541 if (value != expected_value)
535 ::SetWindowLong(native_window, attribute_index, expected_value); 542 ::SetWindowLong(native_window, attribute_index, expected_value);
536 } 543 }
537 #endif 544 #endif
538 545
546 void PanelBrowserView::PanelExpansionStateChanging(
547 Panel::ExpansionState old_state, Panel::ExpansionState new_state) {
548 #if defined(OS_WIN) && !defined(USE_AURA)
Ben Goodger (Google) 2012/05/22 23:05:48 USE_ASH
jianli 2012/05/22 23:34:04 Done.
549 // Live preview is only available since Windows 7.
550 if (base::win::GetVersion() < base::win::VERSION_WIN7)
551 return;
552
553 bool is_minimized = old_state != Panel::EXPANDED;
554 bool will_be_minimized = new_state != Panel::EXPANDED;
555 if (is_minimized == will_be_minimized)
556 return;
557
558 HWND native_window = GetNativeHandle();
559
560 // Cache the image at this point.
561 if (will_be_minimized) {
562 // If the panel is still active (we will deactivate the minimizd panel at
563 // later time), we need to paint it immediately as inactive so that we can
564 // take a snapshot of inactive panel.
565 if (focused_) {
566 force_to_paint_as_inactive_ = true;
567 ::RedrawWindow(native_window, NULL, NULL,
568 RDW_NOCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW);
569 }
570
571 thumbnail_subclass_.reset(new ui::HWNDSubclass(native_window));
572 thumbnail_subclass_->SetFilter(
573 new TaskbarWindowThumbnailerWin(native_window));
574 } else {
575 force_to_paint_as_inactive_ = false;
576 thumbnail_subclass_.reset();
577 }
578
579 #endif
580 }
581
539 // NativePanelTesting implementation. 582 // NativePanelTesting implementation.
540 class NativePanelTestingWin : public NativePanelTesting { 583 class NativePanelTestingWin : public NativePanelTesting {
541 public: 584 public:
542 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view); 585 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view);
543 586
544 private: 587 private:
545 virtual void PressLeftMouseButtonTitlebar( 588 virtual void PressLeftMouseButtonTitlebar(
546 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE; 589 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE;
547 virtual void ReleaseMouseButtonTitlebar( 590 virtual void ReleaseMouseButtonTitlebar(
548 panel::ClickModifier modifier) OVERRIDE; 591 panel::ClickModifier modifier) OVERRIDE;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 return frame_view->close_button_->visible(); 673 return frame_view->close_button_->visible();
631 case MINIMIZE_BUTTON: 674 case MINIMIZE_BUTTON:
632 return frame_view->minimize_button_->visible(); 675 return frame_view->minimize_button_->visible();
633 case RESTORE_BUTTON: 676 case RESTORE_BUTTON:
634 return frame_view->restore_button_->visible(); 677 return frame_view->restore_button_->visible();
635 default: 678 default:
636 NOTREACHED(); 679 NOTREACHED();
637 } 680 }
638 return false; 681 return false;
639 } 682 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698