Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
| 6 | 6 |
| 7 // If this gets included after the gtk headers, then a bunch of compiler | 7 // If this gets included after the gtk headers, then a bunch of compiler |
| 8 // errors happen because of a "#define Status int" in Xlib.h, which interacts | 8 // errors happen because of a "#define Status int" in Xlib.h, which interacts |
| 9 // badly with net::URLRequestStatus::Status. | 9 // badly with net::URLRequestStatus::Status. |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 // ignore them so we don't re-allocate the backing store. We will paint | 595 // ignore them so we don't re-allocate the backing store. We will paint |
| 596 // everything again when we become selected again. | 596 // everything again when we become selected again. |
| 597 is_hidden_ = true; | 597 is_hidden_ = true; |
| 598 | 598 |
| 599 // If we have a renderer, then inform it that we are being hidden so it can | 599 // If we have a renderer, then inform it that we are being hidden so it can |
| 600 // reduce its resource utilization. | 600 // reduce its resource utilization. |
| 601 GetRenderWidgetHost()->WasHidden(); | 601 GetRenderWidgetHost()->WasHidden(); |
| 602 } | 602 } |
| 603 | 603 |
| 604 void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { | 604 void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { |
| 605 gfx::Rect rect = GetViewBounds(); | |
| 606 rect.set_size(size); | |
| 607 SetBounds(rect); | |
|
Evan Stade
2011/02/22 19:56:19
this is backwards. SetBounds should use SetSize, n
honten.org
2011/02/23 01:31:57
Done.
| |
| 608 } | |
| 609 | |
| 610 void RenderWidgetHostViewGtk::SetBounds(const gfx::Rect& rect) { | |
| 605 // This is called when webkit has sent us a Move message. | 611 // This is called when webkit has sent us a Move message. |
| 606 int width = std::min(size.width(), kMaxWindowWidth); | 612 int width = std::min(rect.width(), kMaxWindowWidth); |
| 607 int height = std::min(size.height(), kMaxWindowHeight); | 613 int height = std::min(rect.height(), kMaxWindowHeight); |
| 608 if (IsPopup()) { | 614 if (IsPopup()) { |
| 609 // We're a popup, honor the size request. | 615 // We're a popup, honor the size request. |
| 610 gtk_widget_set_size_request(view_.get(), width, height); | 616 gtk_widget_set_size_request(view_.get(), width, height); |
| 611 } else { | 617 } else { |
| 612 #if defined(TOOLKIT_VIEWS) | 618 #if defined(TOOLKIT_VIEWS) |
| 613 // TOOLKIT_VIEWS' resize logic flow matches windows. so we go ahead and | 619 // TOOLKIT_VIEWS' resize logic flow matches windows. so we go ahead and |
| 614 // size the widget. In GTK+, the size of the widget is determined by its | 620 // size the widget. In GTK+, the size of the widget is determined by its |
| 615 // children. | 621 // children. |
| 616 gtk_widget_set_size_request(view_.get(), width, height); | 622 gtk_widget_set_size_request(view_.get(), width, height); |
| 617 #endif | 623 #endif |
| 618 } | 624 } |
| 625 | |
| 626 GtkWidget* parent_widget = gtk_widget_get_parent(view_.get()); | |
| 627 if (GTK_IS_WINDOW(parent_widget)) | |
| 628 gtk_window_move(GTK_WINDOW(parent_widget), rect.x(), rect.y()); | |
| 629 | |
| 619 // Update the size of the RWH. | 630 // Update the size of the RWH. |
| 620 if (requested_size_.width() != width || | 631 if (requested_size_.width() != width || |
| 621 requested_size_.height() != height) { | 632 requested_size_.height() != height) { |
| 622 requested_size_ = gfx::Size(width, height); | 633 requested_size_ = gfx::Size(width, height); |
| 623 host_->WasResized(); | 634 host_->WasResized(); |
| 624 } | 635 } |
| 625 } | 636 } |
| 626 | 637 |
| 627 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { | 638 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { |
| 628 return view_.get(); | 639 return view_.get(); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 656 void RenderWidgetHostViewGtk::Hide() { | 667 void RenderWidgetHostViewGtk::Hide() { |
| 657 gtk_widget_hide(view_.get()); | 668 gtk_widget_hide(view_.get()); |
| 658 } | 669 } |
| 659 | 670 |
| 660 bool RenderWidgetHostViewGtk::IsShowing() { | 671 bool RenderWidgetHostViewGtk::IsShowing() { |
| 661 // TODO(jcivelli): use gtk_widget_get_visible once we build with GTK 2.18. | 672 // TODO(jcivelli): use gtk_widget_get_visible once we build with GTK 2.18. |
| 662 return (GTK_WIDGET_FLAGS(view_.get()) & GTK_VISIBLE) != 0; | 673 return (GTK_WIDGET_FLAGS(view_.get()) & GTK_VISIBLE) != 0; |
| 663 } | 674 } |
| 664 | 675 |
| 665 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { | 676 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { |
| 666 GtkAllocation* alloc = &view_.get()->allocation; | 677 gint x, y; |
| 667 return gfx::Rect(alloc->x, alloc->y, | 678 gtk_widget_get_pointer(view_.get(), &x, &y); |
|
Evan Stade
2011/02/22 19:56:19
I fail to see how the location of the pointer is r
honten.org
2011/02/23 01:31:57
Roll back.
On 2011/02/22 19:56:19, Evan Stade wrot
| |
| 679 return gfx::Rect(x, y, | |
| 668 requested_size_.width(), | 680 requested_size_.width(), |
| 669 requested_size_.height()); | 681 requested_size_.height()); |
| 670 } | 682 } |
| 671 | 683 |
| 672 void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) { | 684 void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) { |
| 673 // Optimize the common case, where the cursor hasn't changed. | 685 // Optimize the common case, where the cursor hasn't changed. |
| 674 // However, we can switch between different pixmaps, so only on the | 686 // However, we can switch between different pixmaps, so only on the |
| 675 // non-pixmap branch. | 687 // non-pixmap branch. |
| 676 if (current_cursor_.GetCursorType() != GDK_CURSOR_IS_PIXMAP && | 688 if (current_cursor_.GetCursorType() != GDK_CURSOR_IS_PIXMAP && |
| 677 current_cursor_.GetCursorType() == cursor.GetCursorType()) { | 689 current_cursor_.GetCursorType() == cursor.GetCursorType()) { |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1133 } | 1145 } |
| 1134 | 1146 |
| 1135 // static | 1147 // static |
| 1136 RenderWidgetHostView* | 1148 RenderWidgetHostView* |
| 1137 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1149 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
| 1138 gfx::NativeView widget) { | 1150 gfx::NativeView widget) { |
| 1139 gpointer user_data = g_object_get_data(G_OBJECT(widget), | 1151 gpointer user_data = g_object_get_data(G_OBJECT(widget), |
| 1140 kRenderWidgetHostViewKey); | 1152 kRenderWidgetHostViewKey); |
| 1141 return reinterpret_cast<RenderWidgetHostView*>(user_data); | 1153 return reinterpret_cast<RenderWidgetHostView*>(user_data); |
| 1142 } | 1154 } |
| OLD | NEW |