OLD | NEW |
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_window_gtk.h" | 5 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/gtk/browser_titlebar.h" | 9 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
10 #include "chrome/browser/ui/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace { | 21 namespace { |
22 | 22 |
23 // RGB values for titlebar in draw attention state. A shade of orange. | 23 // RGB values for titlebar in draw attention state. A shade of orange. |
24 const int kDrawAttentionR = 0xfa; | 24 const int kDrawAttentionR = 0xfa; |
25 const int kDrawAttentionG = 0x98; | 25 const int kDrawAttentionG = 0x98; |
26 const int kDrawAttentionB = 0x3a; | 26 const int kDrawAttentionB = 0x3a; |
27 const float kDrawAttentionRFraction = kDrawAttentionR / 255.0; | 27 const float kDrawAttentionRFraction = kDrawAttentionR / 255.0; |
28 const float kDrawAttentionGFraction = kDrawAttentionG / 255.0; | 28 const float kDrawAttentionGFraction = kDrawAttentionG / 255.0; |
29 const float kDrawAttentionBFraction = kDrawAttentionB / 255.0; | 29 const float kDrawAttentionBFraction = kDrawAttentionB / 255.0; |
30 | 30 |
31 // Delay before click on a titlebar is allowed to minimize the panel after | |
32 // the 'draw attention' mode has been cleared. | |
33 const int kSuspendMinimizeOnClickIntervalMs = 500; | |
34 | |
35 // Markup for title text in draw attention state. Set to color white. | 31 // Markup for title text in draw attention state. Set to color white. |
36 const char* const kDrawAttentionTitleMarkupPrefix = | 32 const char* const kDrawAttentionTitleMarkupPrefix = |
37 "<span fgcolor='#ffffff'>"; | 33 "<span fgcolor='#ffffff'>"; |
38 const char* const kDrawAttentionTitleMarkupSuffix = "</span>"; | 34 const char* const kDrawAttentionTitleMarkupSuffix = "</span>"; |
39 | 35 |
40 // Set minimium width for window really small so it can be reduced to icon only | 36 // Set minimium width for window really small so it can be reduced to icon only |
41 // size in overflow expansion state. | 37 // size in overflow expansion state. |
42 const int kMinWindowWidth = 2; | 38 const int kMinWindowWidth = 2; |
43 | 39 |
44 } // namespace | 40 } // namespace |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 cairo_paint(cr); | 241 cairo_paint(cr); |
246 gdk_region_destroy(dest_region); | 242 gdk_region_destroy(dest_region); |
247 } | 243 } |
248 | 244 |
249 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { | 245 void PanelBrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { |
250 bool was_active = IsActive(); | 246 bool was_active = IsActive(); |
251 BrowserWindowGtk::ActiveWindowChanged(active_window); | 247 BrowserWindowGtk::ActiveWindowChanged(active_window); |
252 if (!window() || was_active == IsActive()) // State didn't change. | 248 if (!window() || was_active == IsActive()) // State didn't change. |
253 return; | 249 return; |
254 | 250 |
| 251 if (IsActive() && is_drawing_attention_) { |
| 252 DCHECK(!panel_->IsMinimized()); |
| 253 panel_->FlashFrame(false); |
| 254 } |
| 255 |
255 content::NotificationService::current()->Notify( | 256 content::NotificationService::current()->Notify( |
256 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | 257 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
257 content::Source<Panel>(panel_.get()), | 258 content::Source<Panel>(panel_.get()), |
258 content::NotificationService::NoDetails()); | 259 content::NotificationService::NoDetails()); |
259 } | 260 } |
260 | 261 |
261 BrowserWindowGtk::TitleDecoration PanelBrowserWindowGtk::GetWindowTitle( | 262 BrowserWindowGtk::TitleDecoration PanelBrowserWindowGtk::GetWindowTitle( |
262 std::string* title) const { | 263 std::string* title) const { |
263 if (is_drawing_attention_) { | 264 if (is_drawing_attention_) { |
264 std::string title_original; | 265 std::string title_original; |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 702 |
702 gboolean PanelBrowserWindowGtk::OnTitlebarButtonReleaseEvent( | 703 gboolean PanelBrowserWindowGtk::OnTitlebarButtonReleaseEvent( |
703 GtkWidget* widget, GdkEventButton* event) { | 704 GtkWidget* widget, GdkEventButton* event) { |
704 if (event->button != 1) { | 705 if (event->button != 1) { |
705 DCHECK(!last_mouse_down_); | 706 DCHECK(!last_mouse_down_); |
706 return TRUE; | 707 return TRUE; |
707 } | 708 } |
708 | 709 |
709 CleanupDragDrop(); | 710 CleanupDragDrop(); |
710 | 711 |
711 if (event->state & GDK_CONTROL_MASK) { | 712 panel_->OnTitlebarClicked((event->state & GDK_CONTROL_MASK) ? |
712 panel_->OnTitlebarClicked(panel::APPLY_TO_ALL); | 713 panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
713 return TRUE; | |
714 } | |
715 | |
716 // TODO(jennb): Move remaining titlebar click handling out of here. | |
717 // (http://crbug.com/118431) | |
718 PanelStrip* panel_strip = panel_->panel_strip(); | |
719 if (!panel_strip) | |
720 return TRUE; | |
721 | |
722 if (panel_strip->type() == PanelStrip::DOCKED && | |
723 panel_->expansion_state() == Panel::EXPANDED) { | |
724 if (base::Time::Now() < disableMinimizeUntilTime_) | |
725 return TRUE; | |
726 | |
727 panel_->SetExpansionState(Panel::MINIMIZED); | |
728 } else { | |
729 panel_->Activate(); | |
730 } | |
731 | |
732 return TRUE; | 714 return TRUE; |
733 } | 715 } |
734 | 716 |
735 void PanelBrowserWindowGtk::HandleFocusIn(GtkWidget* widget, | |
736 GdkEventFocus* event) { | |
737 BrowserWindowGtk::HandleFocusIn(widget, event); | |
738 | |
739 if (!is_drawing_attention_) | |
740 return; | |
741 | |
742 panel_->FlashFrame(false); | |
743 DCHECK(panel_->expansion_state() == Panel::EXPANDED); | |
744 | |
745 disableMinimizeUntilTime_ = base::Time::Now() + | |
746 base::TimeDelta::FromMilliseconds(kSuspendMinimizeOnClickIntervalMs); | |
747 } | |
748 | |
749 void PanelBrowserWindowGtk::OnDragBegin(GtkWidget* widget, | 717 void PanelBrowserWindowGtk::OnDragBegin(GtkWidget* widget, |
750 GdkDragContext* context) { | 718 GdkDragContext* context) { |
751 // Set drag icon to be a transparent pixbuf. | 719 // Set drag icon to be a transparent pixbuf. |
752 GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); | 720 GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); |
753 gdk_pixbuf_fill(pixbuf, 0); | 721 gdk_pixbuf_fill(pixbuf, 0); |
754 gtk_drag_set_icon_pixbuf(context, pixbuf, 0, 0); | 722 gtk_drag_set_icon_pixbuf(context, pixbuf, 0, 0); |
755 g_object_unref(pixbuf); | 723 g_object_unref(pixbuf); |
756 } | 724 } |
757 | 725 |
758 gboolean PanelBrowserWindowGtk::OnDragFailed( | 726 gboolean PanelBrowserWindowGtk::OnDragFailed( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 MessageLoopForUI::current()->RunAllPending(); | 858 MessageLoopForUI::current()->RunAllPending(); |
891 } | 859 } |
892 | 860 |
893 bool NativePanelTestingGtk::IsWindowSizeKnown() const { | 861 bool NativePanelTestingGtk::IsWindowSizeKnown() const { |
894 return !panel_browser_window_gtk_->frame_size_.IsEmpty(); | 862 return !panel_browser_window_gtk_->frame_size_.IsEmpty(); |
895 } | 863 } |
896 | 864 |
897 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 865 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
898 return panel_browser_window_gtk_->IsAnimatingBounds(); | 866 return panel_browser_window_gtk_->IsAnimatingBounds(); |
899 } | 867 } |
OLD | NEW |