Commit 9ae95a7c authored by erg@chromium.org's avatar erg@chromium.org

GTK: More removal of raw GtkWidget->allocation access.

BUG=79722
TEST=none


Review URL: http://codereview.chromium.org/8773025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113031 0039d316-1c4b-4281-b951-d872f2087c98
parent 26335f9e
...@@ -43,7 +43,10 @@ void TestingAutomationProvider::WindowGetViewBounds(int handle, ...@@ -43,7 +43,10 @@ void TestingAutomationProvider::WindowGetViewBounds(int handle,
if (!widget) if (!widget)
return; return;
*success = true; *success = true;
*bounds = gfx::Rect(widget->allocation.width, widget->allocation.height);
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
*bounds = gfx::Rect(allocation.width, allocation.height);
gint x, y; gint x, y;
if (screen_coordinates) { if (screen_coordinates) {
gfx::Point point = gtk_util::GetWidgetScreenPosition(widget); gfx::Point point = gtk_util::GetWidgetScreenPosition(widget);
......
...@@ -162,7 +162,10 @@ void TabContentsViewGtk::GetContainerBounds(gfx::Rect* out) const { ...@@ -162,7 +162,10 @@ void TabContentsViewGtk::GetContainerBounds(gfx::Rect* out) const {
GdkWindow* expanded_window = gtk_widget_get_window(expanded_.get()); GdkWindow* expanded_window = gtk_widget_get_window(expanded_.get());
if (expanded_window) if (expanded_window)
gdk_window_get_origin(expanded_window, &x, &y); gdk_window_get_origin(expanded_window, &x, &y);
out->SetRect(x + expanded_->allocation.x, y + expanded_->allocation.y,
GtkAllocation allocation;
gtk_widget_get_allocation(expanded_.get(), &allocation);
out->SetRect(x + allocation.x, y + allocation.y,
requested_size_.width(), requested_size_.height()); requested_size_.width(), requested_size_.height());
} }
......
...@@ -135,14 +135,17 @@ gboolean OnDragIconExpose(GtkWidget* sender, ...@@ -135,14 +135,17 @@ gboolean OnDragIconExpose(GtkWidget* sender,
cairo_paint(cr); cairo_paint(cr);
cairo_destroy(cr); cairo_destroy(cr);
GtkAllocation allocation;
gtk_widget_get_allocation(sender, &allocation);
// Paint the title text. // Paint the title text.
gfx::CanvasSkiaPaint canvas(event, false); gfx::CanvasSkiaPaint canvas(event, false);
int text_x = gdk_pixbuf_get_width(data->favicon) + kBarButtonPadding; int text_x = gdk_pixbuf_get_width(data->favicon) + kBarButtonPadding;
int text_width = sender->allocation.width - text_x; int text_width = allocation.width - text_x;
ResourceBundle& rb = ResourceBundle::GetSharedInstance(); ResourceBundle& rb = ResourceBundle::GetSharedInstance();
const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
canvas.DrawStringInt(data->text, base_font, data->text_color, canvas.DrawStringInt(data->text, base_font, data->text_color,
text_x, 0, text_width, sender->allocation.height); text_x, 0, text_width, allocation.height);
return TRUE; return TRUE;
} }
......
...@@ -852,8 +852,11 @@ void BrowserTitlebar::MaximizeButtonClicked() { ...@@ -852,8 +852,11 @@ void BrowserTitlebar::MaximizeButtonClicked() {
gint x, y; gint x, y;
gtk_window_get_position(window_, &x, &y); gtk_window_get_position(window_, &x, &y);
gint width = widget->allocation.width;
gint height = widget->allocation.height; GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
gint width = allocation.width;
gint height = allocation.height;
if (event->button.button == 3) { if (event->button.button == 3) {
x = 0; x = 0;
......
...@@ -178,5 +178,7 @@ void ExtensionPopupGtk::DestroyPopupWithoutResult() { ...@@ -178,5 +178,7 @@ void ExtensionPopupGtk::DestroyPopupWithoutResult() {
} }
gfx::Rect ExtensionPopupGtk::GetViewBounds() { gfx::Rect ExtensionPopupGtk::GetViewBounds() {
return gfx::Rect(host_->view()->native_view()->allocation); GtkAllocation allocation;
gtk_widget_get_allocation(host_->view()->native_view(), &allocation);
return gfx::Rect(allocation);
} }
...@@ -372,7 +372,9 @@ void FindBarGtk::UpdateUIForFindResult(const FindNotificationDetails& result, ...@@ -372,7 +372,9 @@ void FindBarGtk::UpdateUIForFindResult(const FindNotificationDetails& result,
if (!result.selection_rect().IsEmpty()) { if (!result.selection_rect().IsEmpty()) {
selection_rect_ = result.selection_rect(); selection_rect_ = result.selection_rect();
int xposition = GetDialogPosition(result.selection_rect()).x(); int xposition = GetDialogPosition(result.selection_rect()).x();
if (xposition != widget()->allocation.x) GtkAllocation allocation;
gtk_widget_get_allocation(widget(), &allocation);
if (xposition != allocation.x)
Reposition(); Reposition();
} }
...@@ -814,12 +816,9 @@ gboolean FindBarGtk::OnContentEventBoxExpose(GtkWidget* widget, ...@@ -814,12 +816,9 @@ gboolean FindBarGtk::OnContentEventBoxExpose(GtkWidget* widget,
// (*cough*Clearlooks*cough*) don't do any blending and use thickness to // (*cough*Clearlooks*cough*) don't do any blending and use thickness to
// make sure that widgets never overlap. // make sure that widgets never overlap.
int padding = gtk_widget_get_style(widget)->xthickness; int padding = gtk_widget_get_style(widget)->xthickness;
GdkRectangle rec = { GdkRectangle rec;
widget->allocation.x, gtk_widget_get_allocation(widget, &rec);
widget->allocation.y, rec.width -= padding;
widget->allocation.width - padding,
widget->allocation.height
};
gtk_util::DrawTextEntryBackground(bar->text_entry_, widget, gtk_util::DrawTextEntryBackground(bar->text_entry_, widget,
&event->area, &rec); &event->area, &rec);
...@@ -831,11 +830,14 @@ gboolean FindBarGtk::OnContentEventBoxExpose(GtkWidget* widget, ...@@ -831,11 +830,14 @@ gboolean FindBarGtk::OnContentEventBoxExpose(GtkWidget* widget,
// Used to handle custom painting of |container_|. // Used to handle custom painting of |container_|.
gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e,
FindBarGtk* bar) { FindBarGtk* bar) {
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
if (bar->theme_service_->UsingNativeTheme()) { if (bar->theme_service_->UsingNativeTheme()) {
if (bar->container_width_ != widget->allocation.width || if (bar->container_width_ != allocation.width ||
bar->container_height_ != widget->allocation.height) { bar->container_height_ != allocation.height) {
std::vector<GdkPoint> mask_points = MakeFramePolygonPoints( std::vector<GdkPoint> mask_points = MakeFramePolygonPoints(
widget->allocation.width, widget->allocation.height, FRAME_MASK); allocation.width, allocation.height, FRAME_MASK);
GdkRegion* mask_region = gdk_region_polygon(&mask_points[0], GdkRegion* mask_region = gdk_region_polygon(&mask_points[0],
mask_points.size(), mask_points.size(),
GDK_EVEN_ODD_RULE); GDK_EVEN_ODD_RULE);
...@@ -844,8 +846,8 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, ...@@ -844,8 +846,8 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e,
gdk_window_shape_combine_region(widget->window, mask_region, 0, 0); gdk_window_shape_combine_region(widget->window, mask_region, 0, 0);
gdk_region_destroy(mask_region); gdk_region_destroy(mask_region);
bar->container_width_ = widget->allocation.width; bar->container_width_ = allocation.width;
bar->container_height_ = widget->allocation.height; bar->container_height_ = allocation.height;
} }
GdkDrawable* drawable = GDK_DRAWABLE(e->window); GdkDrawable* drawable = GDK_DRAWABLE(e->window);
...@@ -856,19 +858,19 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, ...@@ -856,19 +858,19 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e,
// Stroke the frame border. // Stroke the frame border.
std::vector<GdkPoint> points = MakeFramePolygonPoints( std::vector<GdkPoint> points = MakeFramePolygonPoints(
widget->allocation.width, widget->allocation.height, FRAME_STROKE); allocation.width, allocation.height, FRAME_STROKE);
gdk_draw_lines(drawable, gc, &points[0], points.size()); gdk_draw_lines(drawable, gc, &points[0], points.size());
g_object_unref(gc); g_object_unref(gc);
} else { } else {
if (bar->container_width_ != widget->allocation.width || if (bar->container_width_ != allocation.width ||
bar->container_height_ != widget->allocation.height) { bar->container_height_ != allocation.height) {
// Reset the shape. // Reset the shape.
gdk_window_shape_combine_region(widget->window, NULL, 0, 0); gdk_window_shape_combine_region(widget->window, NULL, 0, 0);
SetDialogShape(bar->container_); SetDialogShape(bar->container_);
bar->container_width_ = widget->allocation.width; bar->container_width_ = allocation.width;
bar->container_height_ = widget->allocation.height; bar->container_height_ = allocation.height;
} }
cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window));
......
...@@ -137,11 +137,13 @@ static gboolean gtk_chrome_link_button_expose(GtkWidget* widget, ...@@ -137,11 +137,13 @@ static gboolean gtk_chrome_link_button_expose(GtkWidget* widget,
// Draw the focus rectangle. // Draw the focus rectangle.
if (gtk_widget_has_focus(widget)) { if (gtk_widget_has_focus(widget)) {
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
gtk_paint_focus(widget->style, widget->window, gtk_paint_focus(widget->style, widget->window,
gtk_widget_get_state(widget), gtk_widget_get_state(widget),
&event->area, widget, NULL, &event->area, widget, NULL,
widget->allocation.x, widget->allocation.y, allocation.x, allocation.y,
widget->allocation.width, widget->allocation.height); allocation.width, allocation.height);
} }
return TRUE; return TRUE;
......
...@@ -205,16 +205,22 @@ static void gtk_custom_menu_item_expose_button(GtkWidget* hbox, ...@@ -205,16 +205,22 @@ static void gtk_custom_menu_item_expose_button(GtkWidget* hbox,
if (base::i18n::IsRTL()) if (base::i18n::IsRTL())
std::swap(first_button, last_button); std::swap(first_button, last_button);
int x = first_button->allocation.x; GtkAllocation first_allocation;
int y = first_button->allocation.y; gtk_widget_get_allocation(first_button, &first_allocation);
int width = last_button->allocation.width + last_button->allocation.x - GtkAllocation current_allocation;
first_button->allocation.x; gtk_widget_get_allocation(current_button, &current_allocation);
int height = last_button->allocation.height; GtkAllocation last_allocation;
gtk_widget_get_allocation(last_button, &last_allocation);
int x = first_allocation.x;
int y = first_allocation.y;
int width = last_allocation.width + last_allocation.x - first_allocation.x;
int height = last_allocation.height;
gtk_paint_box(hbox->style, hbox->window, gtk_paint_box(hbox->style, hbox->window,
gtk_widget_get_state(current_button), gtk_widget_get_state(current_button),
GTK_SHADOW_OUT, GTK_SHADOW_OUT,
&current_button->allocation, hbox, "button", &current_allocation, hbox, "button",
x, y, width, height); x, y, width, height);
// Propagate to the button's children. // Propagate to the button's children.
...@@ -248,16 +254,19 @@ static gboolean gtk_custom_menu_item_hbox_expose(GtkWidget* widget, ...@@ -248,16 +254,19 @@ static gboolean gtk_custom_menu_item_hbox_expose(GtkWidget* widget,
GList* next_item = g_list_next(current_item); GList* next_item = g_list_next(current_item);
if (next_item && GTK_IS_BUTTON(next_item->data)) { if (next_item && GTK_IS_BUTTON(next_item->data)) {
GtkWidget* current_button = GTK_WIDGET(current_item->data); GtkWidget* current_button = GTK_WIDGET(current_item->data);
GtkAllocation child_alloc = GtkAllocation button_allocation;
gtk_bin_get_child(GTK_BIN(current_button))->allocation; gtk_widget_get_allocation(current_button, &button_allocation);
GtkAllocation child_alloc;
gtk_widget_get_allocation(gtk_bin_get_child(GTK_BIN(current_button)),
&child_alloc);
int half_offset = widget->style->xthickness / 2; int half_offset = widget->style->xthickness / 2;
gtk_paint_vline(widget->style, widget->window, gtk_paint_vline(widget->style, widget->window,
gtk_widget_get_state(current_button), gtk_widget_get_state(current_button),
&event->area, widget, "button", &event->area, widget, "button",
child_alloc.y, child_alloc.y,
child_alloc.y + child_alloc.height, child_alloc.y + child_alloc.height,
current_button->allocation.x + button_allocation.x +
current_button->allocation.width - half_offset); button_allocation.width - half_offset);
} }
} }
} }
...@@ -368,7 +377,8 @@ void gtk_custom_menu_item_receive_motion_event(GtkCustomMenuItem* menu_item, ...@@ -368,7 +377,8 @@ void gtk_custom_menu_item_receive_motion_event(GtkCustomMenuItem* menu_item,
GList* current = menu_item->button_widgets; GList* current = menu_item->button_widgets;
for (; current != NULL; current = current->next) { for (; current != NULL; current = current->next) {
GtkWidget* current_widget = GTK_WIDGET(current->data); GtkWidget* current_widget = GTK_WIDGET(current->data);
GtkAllocation alloc = current_widget->allocation; GtkAllocation alloc;
gtk_widget_get_allocation(current_widget, &alloc);
int offset_x, offset_y; int offset_x, offset_y;
gtk_widget_translate_coordinates(current_widget, GTK_WIDGET(menu_item), gtk_widget_translate_coordinates(current_widget, GTK_WIDGET(menu_item),
0, 0, &offset_x, &offset_y); 0, 0, &offset_x, &offset_y);
......
...@@ -123,7 +123,7 @@ static void gtk_input_event_box_size_allocate(GtkWidget* widget, ...@@ -123,7 +123,7 @@ static void gtk_input_event_box_size_allocate(GtkWidget* widget,
GtkAllocation* allocation) { GtkAllocation* allocation) {
g_return_if_fail(GTK_IS_INPUT_EVENT_BOX(widget)); g_return_if_fail(GTK_IS_INPUT_EVENT_BOX(widget));
widget->allocation = *allocation; gtk_widget_set_allocation(widget, allocation);
GtkInputEventBoxPrivate* priv = GTK_INPUT_EVENT_BOX_GET_PRIVATE(widget); GtkInputEventBoxPrivate* priv = GTK_INPUT_EVENT_BOX_GET_PRIVATE(widget);
if (priv->event_window) { if (priv->event_window) {
......
...@@ -1217,11 +1217,13 @@ gboolean GtkThemeService::OnSeparatorExpose(GtkWidget* widget, ...@@ -1217,11 +1217,13 @@ gboolean GtkThemeService::OnSeparatorExpose(GtkWidget* widget,
static_cast<double>(bottom_color.green / 257) / 255.0, static_cast<double>(bottom_color.green / 257) / 255.0,
static_cast<double>(bottom_color.blue / 257) / 255.0, }; static_cast<double>(bottom_color.blue / 257) / 255.0, };
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
cairo_pattern_t* pattern = cairo_pattern_t* pattern =
cairo_pattern_create_linear(widget->allocation.x, widget->allocation.y, cairo_pattern_create_linear(allocation.x, allocation.y,
widget->allocation.x, allocation.x,
widget->allocation.y + allocation.y + allocation.height);
widget->allocation.height);
cairo_pattern_add_color_stop_rgb( cairo_pattern_add_color_stop_rgb(
pattern, 0.0, pattern, 0.0,
kTopSeparatorColor[0], kTopSeparatorColor[1], kTopSeparatorColor[2]); kTopSeparatorColor[0], kTopSeparatorColor[1], kTopSeparatorColor[2]);
...@@ -1233,12 +1235,11 @@ gboolean GtkThemeService::OnSeparatorExpose(GtkWidget* widget, ...@@ -1233,12 +1235,11 @@ gboolean GtkThemeService::OnSeparatorExpose(GtkWidget* widget,
bottom_color_rgb[0], bottom_color_rgb[1], bottom_color_rgb[2]); bottom_color_rgb[0], bottom_color_rgb[1], bottom_color_rgb[2]);
cairo_set_source(cr, pattern); cairo_set_source(cr, pattern);
double start_x = 0.5 + widget->allocation.x; double start_x = 0.5 + allocation.x;
cairo_new_path(cr); cairo_new_path(cr);
cairo_set_line_width(cr, 1.0); cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, start_x, widget->allocation.y); cairo_move_to(cr, start_x, allocation.y);
cairo_line_to(cr, start_x, cairo_line_to(cr, start_x, allocation.y + allocation.height);
widget->allocation.y + widget->allocation.height);
cairo_stroke(cr); cairo_stroke(cr);
cairo_destroy(cr); cairo_destroy(cr);
cairo_pattern_destroy(pattern); cairo_pattern_destroy(pattern);
......
...@@ -96,7 +96,7 @@ void SetupImageIcon(GtkWidget* button, ...@@ -96,7 +96,7 @@ void SetupImageIcon(GtkWidget* button,
// Returns the new Y position of the popup menu. // Returns the new Y position of the popup menu.
int CalculateMenuYPosition(const GdkRectangle* screen_rect, int CalculateMenuYPosition(const GdkRectangle* screen_rect,
const GtkRequisition* menu_req, const GtkRequisition* menu_req,
const GtkWidget* widget, const int y) { GtkWidget* widget, const int y) {
CHECK(screen_rect); CHECK(screen_rect);
CHECK(menu_req); CHECK(menu_req);
// If the menu would run off the bottom of the screen, and there is enough // If the menu would run off the bottom of the screen, and there is enough
...@@ -107,8 +107,11 @@ int CalculateMenuYPosition(const GdkRectangle* screen_rect, ...@@ -107,8 +107,11 @@ int CalculateMenuYPosition(const GdkRectangle* screen_rect,
const int screen_bottom = screen_rect->y + screen_rect->height; const int screen_bottom = screen_rect->y + screen_rect->height;
const int menu_bottom = y + menu_req->height; const int menu_bottom = y + menu_req->height;
int alternate_y = y - menu_req->height; int alternate_y = y - menu_req->height;
if (widget) if (widget) {
alternate_y -= widget->allocation.height; GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
alternate_y -= allocation.height;
}
if (menu_bottom >= screen_bottom && alternate_y >= screen_top) if (menu_bottom >= screen_bottom && alternate_y >= screen_top)
return alternate_y; return alternate_y;
return y; return y;
...@@ -695,11 +698,14 @@ void MenuGtk::WidgetMenuPositionFunc(GtkMenu* menu, ...@@ -695,11 +698,14 @@ void MenuGtk::WidgetMenuPositionFunc(GtkMenu* menu,
gdk_screen_get_monitor_geometry(screen, monitor, gdk_screen_get_monitor_geometry(screen, monitor,
&screen_rect); &screen_rect);
if (GTK_WIDGET_NO_WINDOW(widget)) { GtkAllocation allocation;
*x += widget->allocation.x; gtk_widget_get_allocation(widget, &allocation);
*y += widget->allocation.y;
if (!gtk_widget_get_has_window(widget)) {
*x += allocation.x;
*y += allocation.y;
} }
*y += widget->allocation.height; *y += allocation.height;
bool start_align = bool start_align =
!!g_object_get_data(G_OBJECT(widget), "left-align-popup"); !!g_object_get_data(G_OBJECT(widget), "left-align-popup");
...@@ -707,7 +713,7 @@ void MenuGtk::WidgetMenuPositionFunc(GtkMenu* menu, ...@@ -707,7 +713,7 @@ void MenuGtk::WidgetMenuPositionFunc(GtkMenu* menu,
start_align = !start_align; start_align = !start_align;
if (!start_align) if (!start_align)
*x += widget->allocation.width - menu_req.width; *x += allocation.width - menu_req.width;
*y = CalculateMenuYPosition(&screen_rect, &menu_req, widget, *y); *y = CalculateMenuYPosition(&screen_rect, &menu_req, widget, *y);
......
...@@ -175,8 +175,10 @@ void NineBox::RenderTopCenterStrip(cairo_t* cr, int x, int y, ...@@ -175,8 +175,10 @@ void NineBox::RenderTopCenterStrip(cairo_t* cr, int x, int y,
} }
void NineBox::ContourWidget(GtkWidget* widget) const { void NineBox::ContourWidget(GtkWidget* widget) const {
int width = widget->allocation.width; GtkAllocation allocation;
int height = widget->allocation.height; gtk_widget_get_allocation(widget, &allocation);
int width = allocation.width;
int height = allocation.height;
int x1 = gdk_pixbuf_get_width(images_[0]); int x1 = gdk_pixbuf_get_width(images_[0]);
int x2 = width - gdk_pixbuf_get_width(images_[2]); int x2 = width - gdk_pixbuf_get_width(images_[2]);
......
...@@ -417,15 +417,17 @@ gboolean BalloonViewImpl::OnContentsExpose(GtkWidget* sender, ...@@ -417,15 +417,17 @@ gboolean BalloonViewImpl::OnContentsExpose(GtkWidget* sender,
gdk_cairo_rectangle(cr, &event->area); gdk_cairo_rectangle(cr, &event->area);
cairo_clip(cr); cairo_clip(cr);
GtkAllocation allocation;
gtk_widget_get_allocation(sender, &allocation);
// According to a discussion on a mailing list I found, these degenerate // According to a discussion on a mailing list I found, these degenerate
// paths are the officially supported way to draw points in Cairo. // paths are the officially supported way to draw points in Cairo.
cairo_set_source_rgb(cr, 0, 0, 0); cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_width(cr, 1.0); cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, 0.5, sender->allocation.height - 0.5); cairo_move_to(cr, 0.5, allocation.height - 0.5);
cairo_close_path(cr); cairo_close_path(cr);
cairo_move_to(cr, sender->allocation.width - 0.5, cairo_move_to(cr, allocation.width - 0.5, allocation.height - 0.5);
sender->allocation.height - 0.5);
cairo_close_path(cr); cairo_close_path(cr);
cairo_stroke(cr); cairo_stroke(cr);
cairo_destroy(cr); cairo_destroy(cr);
......
...@@ -97,7 +97,9 @@ void StatusBubbleGtk::SetStatusTextToURL() { ...@@ -97,7 +97,9 @@ void StatusBubbleGtk::SetStatusTextToURL() {
if (!parent || !gtk_widget_get_realized(parent)) if (!parent || !gtk_widget_get_realized(parent))
return; return;
int desired_width = parent->allocation.width; GtkAllocation allocation;
gtk_widget_get_allocation(parent, &allocation);
int desired_width = allocation.width;
if (!expanded()) { if (!expanded()) {
expand_timer_.Stop(); expand_timer_.Stop();
expand_timer_.Start(FROM_HERE, expand_timer_.Start(FROM_HERE,
...@@ -190,6 +192,9 @@ void StatusBubbleGtk::MouseMoved( ...@@ -190,6 +192,9 @@ void StatusBubbleGtk::MouseMoved(
GtkRequisition requisition; GtkRequisition requisition;
gtk_widget_size_request(container_.get(), &requisition); gtk_widget_size_request(container_.get(), &requisition);
GtkAllocation parent_allocation;
gtk_widget_get_allocation(parent, &parent_allocation);
// Get our base position (that is, not including the current offset) // Get our base position (that is, not including the current offset)
// relative to the origin of the root window. // relative to the origin of the root window.
gint toplevel_x = 0, toplevel_y = 0; gint toplevel_x = 0, toplevel_y = 0;
...@@ -198,9 +203,9 @@ void StatusBubbleGtk::MouseMoved( ...@@ -198,9 +203,9 @@ void StatusBubbleGtk::MouseMoved(
gtk_util::GetWidgetRectRelativeToToplevel(parent); gtk_util::GetWidgetRectRelativeToToplevel(parent);
gfx::Rect bubble_rect( gfx::Rect bubble_rect(
toplevel_x + parent_rect.x() + toplevel_x + parent_rect.x() +
(ltr ? 0 : parent->allocation.width - requisition.width), (ltr ? 0 : parent_allocation.width - requisition.width),
toplevel_y + parent_rect.y() + toplevel_y + parent_rect.y() +
parent->allocation.height - requisition.height, parent_allocation.height - requisition.height,
requisition.width, requisition.width,
requisition.height); requisition.height);
...@@ -328,7 +333,9 @@ void StatusBubbleGtk::SetFlipHorizontally(bool flip_horizontally) { ...@@ -328,7 +333,9 @@ void StatusBubbleGtk::SetFlipHorizontally(bool flip_horizontally) {
} }
void StatusBubbleGtk::ExpandURL() { void StatusBubbleGtk::ExpandURL() {
start_width_ = label_.get()->allocation.width; GtkAllocation allocation;
gtk_widget_get_allocation(label_.get(), &allocation);
start_width_ = allocation.width;
expand_animation_.reset(new ui::SlideAnimation(this)); expand_animation_.reset(new ui::SlideAnimation(this));
expand_animation_->SetTweenType(ui::Tween::LINEAR); expand_animation_->SetTweenType(ui::Tween::LINEAR);
expand_animation_->Show(); expand_animation_->Show();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment