summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/browser_window_gtk.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-30 21:35:43 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-30 21:35:43 +0000
commit1c25e879bed12692e57e954b288fa4c4d9c6d5e2 (patch)
treedad94b7ce3a6f087b95cf25ee1a4ee8b7e595afc /chrome/browser/gtk/browser_window_gtk.cc
parent174cec74c38d2bb5d861e0e570d69b5dc3bef173 (diff)
downloadchromium_src-1c25e879bed12692e57e954b288fa4c4d9c6d5e2.zip
chromium_src-1c25e879bed12692e57e954b288fa4c4d9c6d5e2.tar.gz
chromium_src-1c25e879bed12692e57e954b288fa4c4d9c6d5e2.tar.bz2
GTK: Popup windows that use the custom frame should use the tab image instead of the frame.
This is how mac does things, and Miranda is going to change the windows version, too. BUG=21672 TEST=none Review URL: http://codereview.chromium.org/1775012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46121 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/browser_window_gtk.cc')
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc124
1 files changed, 89 insertions, 35 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index dfddbd8..04a4f9a 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -391,42 +391,15 @@ BrowserWindowGtk::~BrowserWindowGtk() {
gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget,
GdkEventExpose* event,
BrowserWindowGtk* window) {
- GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(
- window->browser()->profile());
-
// Draw the default background.
cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window));
gdk_cairo_rectangle(cr, &event->area);
cairo_clip(cr);
- bool off_the_record = window->browser()->profile()->IsOffTheRecord();
- int image_name;
- if (window->IsActive()) {
- image_name = off_the_record ? IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME;
+ if (window->UsingCustomPopupFrame()) {
+ DrawPopupFrame(cr, widget, event, window);
} else {
- image_name = off_the_record ?
- IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE;
- }
- CairoCachedSurface* surface = theme_provider->GetSurfaceNamed(
- image_name, widget);
- if (event->area.y < surface->Height()) {
- surface->SetSource(cr,
- 0,
- window->UseCustomFrame() ? 0 : -kCustomFrameBackgroundVerticalOffset);
- // The frame background isn't tiled vertically.
- cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
- cairo_rectangle(cr, event->area.x, event->area.y,
- event->area.width, surface->Height() - event->area.y);
- cairo_fill(cr);
- }
-
- if (theme_provider->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
- !off_the_record) {
- CairoCachedSurface* theme_overlay = theme_provider->GetSurfaceNamed(
- window->IsActive() ? IDR_THEME_FRAME_OVERLAY
- : IDR_THEME_FRAME_OVERLAY_INACTIVE, widget);
- theme_overlay->SetSource(cr, 0, 0);
- cairo_paint(cr);
+ DrawCustomFrame(cr, widget, event, window);
}
DrawContentShadow(cr, window);
@@ -569,6 +542,78 @@ void BrowserWindowGtk::DrawContentShadow(cairo_t* cr,
cairo_fill(cr);
}
+// static
+void BrowserWindowGtk::DrawPopupFrame(cairo_t* cr,
+ GtkWidget* widget,
+ GdkEventExpose* event,
+ BrowserWindowGtk* window) {
+ GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(
+ window->browser()->profile());
+
+ // In popups, we use the tab images for the background, as that's legible
+ // for text to be written on.
+ int image_name;
+ if (window->IsActive()) {
+ image_name = IDR_THEME_TOOLBAR;
+ } else {
+ bool off_the_record = window->browser()->profile()->IsOffTheRecord();
+ image_name = off_the_record ? IDR_THEME_TAB_BACKGROUND_INCOGNITO :
+ IDR_THEME_TAB_BACKGROUND;
+ }
+
+ CairoCachedSurface* surface = theme_provider->GetSurfaceNamed(
+ image_name, widget);
+ if (event->area.y < surface->Height()) {
+ surface->SetSource(cr,
+ 0,
+ window->UseCustomFrame() ? 0 : -kCustomFrameBackgroundVerticalOffset);
+ cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REFLECT);
+ cairo_rectangle(cr, event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ cairo_fill(cr);
+ }
+}
+
+// static
+void BrowserWindowGtk::DrawCustomFrame(cairo_t* cr,
+ GtkWidget* widget,
+ GdkEventExpose* event,
+ BrowserWindowGtk* window) {
+ GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(
+ window->browser()->profile());
+
+ bool off_the_record = window->browser()->profile()->IsOffTheRecord();
+ int image_name;
+ if (window->IsActive()) {
+ image_name = off_the_record ? IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME;
+ } else {
+ image_name = off_the_record ? IDR_THEME_FRAME_INCOGNITO_INACTIVE :
+ IDR_THEME_FRAME_INACTIVE;
+ }
+
+ CairoCachedSurface* surface = theme_provider->GetSurfaceNamed(
+ image_name, widget);
+ if (event->area.y < surface->Height()) {
+ surface->SetSource(cr,
+ 0,
+ window->UseCustomFrame() ? 0 : -kCustomFrameBackgroundVerticalOffset);
+ // The frame background isn't tiled vertically.
+ cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
+ cairo_rectangle(cr, event->area.x, event->area.y,
+ event->area.width, surface->Height() - event->area.y);
+ cairo_fill(cr);
+ }
+
+ if (theme_provider->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
+ !off_the_record) {
+ CairoCachedSurface* theme_overlay = theme_provider->GetSurfaceNamed(
+ window->IsActive() ? IDR_THEME_FRAME_OVERLAY
+ : IDR_THEME_FRAME_OVERLAY_INACTIVE, widget);
+ theme_overlay->SetSource(cr, 0, 0);
+ cairo_paint(cr);
+ }
+}
+
void BrowserWindowGtk::Show() {
// The Browser associated with this browser window must become the active
// browser at the time Show() is called. This is the natural behaviour under
@@ -1556,14 +1601,16 @@ void BrowserWindowGtk::SetBackgroundColor() {
Profile* profile = browser()->profile();
GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(profile);
int frame_color_id;
- if (IsActive()) {
+ if (UsingCustomPopupFrame()) {
+ frame_color_id = BrowserThemeProvider::COLOR_TOOLBAR;
+ } else if (IsActive()) {
frame_color_id = browser()->profile()->IsOffTheRecord()
- ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO
- : BrowserThemeProvider::COLOR_FRAME;
+ ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO
+ : BrowserThemeProvider::COLOR_FRAME;
} else {
frame_color_id = browser()->profile()->IsOffTheRecord()
- ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE
- : BrowserThemeProvider::COLOR_FRAME_INACTIVE;
+ ? BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE
+ : BrowserThemeProvider::COLOR_FRAME_INACTIVE;
}
SkColor frame_color = theme_provider->GetColor(frame_color_id);
@@ -1971,6 +2018,13 @@ bool BrowserWindowGtk::IsBookmarkBarSupported() const {
return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR);
}
+bool BrowserWindowGtk::UsingCustomPopupFrame() const {
+ GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(
+ browser()->profile());
+ return !theme_provider->UseGtkTheme() &&
+ browser()->type() & Browser::TYPE_POPUP;
+}
+
bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) {
if (!UseCustomFrame())
return false;