summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/gtk/browser_titlebar.cc14
-rw-r--r--chrome/browser/gtk/browser_titlebar.h6
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc12
-rw-r--r--chrome/browser/gtk/custom_button.cc10
4 files changed, 33 insertions, 9 deletions
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc
index 222f249..86d4ba9 100644
--- a/chrome/browser/gtk/browser_titlebar.cc
+++ b/chrome/browser/gtk/browser_titlebar.cc
@@ -41,6 +41,11 @@ const int kOTRBottomSpacing = 2;
// it on the left, and between it and the tabstrip on the right).
const int kOTRSideSpacing = 2;
+// The thickness of the custom frame border; we need it here to enlarge the
+// close button whent the custom frame border isn't showing but the custom
+// titlebar is showing.
+const int kFrameBorderThickness = 4;
+
gboolean OnMouseMoveEvent(GtkWidget* widget, GdkEventMotion* event,
BrowserWindowGtk* browser_window) {
// Reset to the default mouse cursor.
@@ -124,6 +129,10 @@ void BrowserTitlebar::Init() {
IDR_MINIMIZE_H, buttons_hbox,
IDS_XPFRAME_MINIMIZE_TOOLTIP));
+ GtkRequisition req;
+ gtk_widget_size_request(close_button_->widget(), &req);
+ close_button_default_width_ = req.width;
+
gtk_box_pack_end(GTK_BOX(container_), titlebar_buttons_box_, FALSE,
FALSE, 0);
@@ -162,6 +171,11 @@ void BrowserTitlebar::UpdateTitlebarAlignment() {
} else {
gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), 0, 0, 0, 0);
}
+
+ int close_button_width = close_button_default_width_;
+ if (using_custom_frame_ && browser_window_->IsMaximized())
+ close_button_width += kFrameBorderThickness;
+ gtk_widget_set_size_request(close_button_->widget(), close_button_width, -1);
}
// static
diff --git a/chrome/browser/gtk/browser_titlebar.h b/chrome/browser/gtk/browser_titlebar.h
index 3d141d4..3a88f80 100644
--- a/chrome/browser/gtk/browser_titlebar.h
+++ b/chrome/browser/gtk/browser_titlebar.h
@@ -85,6 +85,12 @@ class BrowserTitlebar : public MenuGtk::Delegate {
// Whether we are using a custom frame.
bool using_custom_frame_;
+ // The normal width of the close button (the width it appears to the user)
+ // which is determined by the width of the bitmap we use to paint it. Its
+ // actual clickable width may differ if we are showing a custom frame and the
+ // window is maximized.
+ int close_button_default_width_;
+
// Maximize and restore widgets in the titlebar.
scoped_ptr<CustomDrawButton> minimize_button_;
scoped_ptr<CustomDrawButton> maximize_button_;
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 2e30b72..2cc2d196 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -415,7 +415,6 @@ gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget,
}
// Draw the default background.
- // TODO(tc): Handle maximized windows.
cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window));
cairo_rectangle(cr, event->area.x, event->area.y, event->area.width,
event->area.height);
@@ -432,7 +431,7 @@ gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget,
// canvas->DrawBitmapInt(*theme_overlay, 0, 0);
// }
- if (window->use_custom_frame_.GetValue()) {
+ if (window->use_custom_frame_.GetValue() && !window->IsMaximized()) {
if (!custom_frame_border) {
custom_frame_border = new NineBox(
theme_provider,
@@ -1068,9 +1067,12 @@ void BrowserWindowGtk::UpdateWindowShape(int width, int height) {
gdk_region_union_with_rect(mask, &bot_rect);
gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, mask, 0, 0);
gdk_region_destroy(mask);
+ gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1,
+ kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness);
} else {
// Disable rounded corners.
gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, NULL, 0, 0);
+ gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0);
}
}
@@ -1095,12 +1097,6 @@ void BrowserWindowGtk::UpdateCustomFrame() {
gtk_window_set_decorated(window_, !enable);
titlebar_->UpdateCustomFrame(enable);
UpdateWindowShape(bounds_.width(), bounds_.height());
- if (enable) {
- gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1,
- kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness);
- } else {
- gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0);
- }
}
void BrowserWindowGtk::SaveWindowPosition() {
diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc
index e047202..e828243 100644
--- a/chrome/browser/gtk/custom_button.cc
+++ b/chrome/browser/gtk/custom_button.cc
@@ -45,7 +45,15 @@ gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, GdkEventExpose* e) {
cairo_t* cairo_context = gdk_cairo_create(GDK_DRAWABLE(widget->window));
cairo_translate(cairo_context, widget->allocation.x, widget->allocation.y);
- gdk_cairo_set_source_pixbuf(cairo_context, pixbuf, 0, 0);
+
+ // The widget might be larger than the pixbuf. Paint the pixbuf flush with the
+ // start of the widget (left for LTR, right for RTL).
+ int pixbuf_width = gdk_pixbuf_get_width(pixbuf);
+ int widget_width = widget->allocation.width;
+ int x = gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL ?
+ widget_width - pixbuf_width : 0;
+
+ gdk_cairo_set_source_pixbuf(cairo_context, pixbuf, x, 0);
cairo_paint(cairo_context);
cairo_destroy(cairo_context);