diff options
25 files changed, 108 insertions, 42 deletions
diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc index f1fe047..7919aca 100644 --- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc @@ -37,6 +37,7 @@ #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" #include "grit/ui_resources.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/gfx/canvas_skia_paint.h" #include "ui/gfx/gtk_util.h" @@ -802,7 +803,7 @@ gboolean BrowserActionsToolbarGtk::OnDragFailed(GtkWidget* widget, void BrowserActionsToolbarGtk::OnHierarchyChanged( GtkWidget* widget, GtkWidget* previous_toplevel) { GtkWidget* toplevel = gtk_widget_get_toplevel(widget); - if (!GTK_WIDGET_TOPLEVEL(toplevel)) + if (!gtk_widget_is_toplevel(toplevel)) return; signals_.Connect(toplevel, "set-focus", G_CALLBACK(OnSetFocusThunk), this); diff --git a/chrome/browser/ui/gtk/bubble/bubble_gtk.cc b/chrome/browser/ui/gtk/bubble/bubble_gtk.cc index 089dae6..4af8597 100644 --- a/chrome/browser/ui/gtk/bubble/bubble_gtk.cc +++ b/chrome/browser/ui/gtk/bubble/bubble_gtk.cc @@ -12,6 +12,7 @@ #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/notification_source.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/gtk/gtk_windowing.h" #include "ui/gfx/gtk_util.h" @@ -100,7 +101,7 @@ void BubbleGtk::Init(GtkWidget* anchor_widget, DCHECK(!window_); anchor_widget_ = anchor_widget; toplevel_window_ = GTK_WINDOW(gtk_widget_get_toplevel(anchor_widget_)); - DCHECK(GTK_WIDGET_TOPLEVEL(toplevel_window_)); + DCHECK(gtk_widget_is_toplevel(GTK_WIDGET(toplevel_window_))); rect_ = rect ? *rect : gtk_util::WidgetBounds(anchor_widget); preferred_arrow_location_ = arrow_location; diff --git a/chrome/browser/ui/gtk/constrained_window_gtk.cc b/chrome/browser/ui/gtk/constrained_window_gtk.cc index a6f7c21..9d9f23f 100644 --- a/chrome/browser/ui/gtk/constrained_window_gtk.cc +++ b/chrome/browser/ui/gtk/constrained_window_gtk.cc @@ -13,6 +13,7 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" #if defined(TOUCH_UI) @@ -163,7 +164,7 @@ gboolean ConstrainedWindowGtk::OnKeyPress(GtkWidget* sender, void ConstrainedWindowGtk::OnHierarchyChanged(GtkWidget* sender, GtkWidget* previous_toplevel) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!GTK_WIDGET_TOPLEVEL(gtk_widget_get_toplevel(widget()))) + if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget()))) return; FocusConstrainedWindow(); diff --git a/chrome/browser/ui/gtk/gtk_chrome_link_button.cc b/chrome/browser/ui/gtk/gtk_chrome_link_button.cc index 2a3bf83..12bd5bb 100644 --- a/chrome/browser/ui/gtk/gtk_chrome_link_button.cc +++ b/chrome/browser/ui/gtk/gtk_chrome_link_button.cc @@ -7,6 +7,7 @@ #include <stdlib.h> #include "chrome/browser/ui/gtk/gtk_util.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/gfx/gtk_util.h" static const gchar* kLinkMarkup = "<u><span color=\"%s\">%s</span></u>"; @@ -54,7 +55,7 @@ G_DEFINE_TYPE(GtkChromeLinkButton, gtk_chrome_link_button, GTK_TYPE_BUTTON) static void gtk_chrome_link_button_set_text(GtkChromeLinkButton* button) { // If we were called before we were realized, abort. We'll be called for // real when |button| is realized. - if (!GTK_WIDGET_REALIZED(button)) + if (!gtk_widget_get_realized(GTK_WIDGET(button))) return; g_free(button->native_markup); diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc index b5fa941..b00c062 100644 --- a/chrome/browser/ui/gtk/gtk_util.cc +++ b/chrome/browser/ui/gtk/gtk_util.cc @@ -37,6 +37,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/base/events.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" @@ -101,7 +102,7 @@ gboolean OnMouseButtonReleased(GtkWidget* widget, GdkEventButton* event, // Returns the approximate number of characters that can horizontally fit in // |pixel_width| pixels. int GetCharacterWidthForPixels(GtkWidget* widget, int pixel_width) { - DCHECK(GTK_WIDGET_REALIZED(widget)) + DCHECK(gtk_widget_get_realized(widget)) << " widget must be realized to compute font metrics correctly"; PangoContext* context = gtk_widget_create_pango_context(widget); @@ -274,7 +275,7 @@ GtkWidget* CreateBoldLabel(const std::string& text) { void GetWidgetSizeFromCharacters( GtkWidget* widget, double width_chars, double height_lines, int* width, int* height) { - DCHECK(GTK_WIDGET_REALIZED(widget)) + DCHECK(gtk_widget_get_realized(widget)) << " widget must be realized to compute font metrics correctly"; PangoContext* context = gtk_widget_create_pango_context(widget); PangoFontMetrics* metrics = pango_context_get_metrics(context, @@ -297,7 +298,7 @@ void GetWidgetSizeFromCharacters( void GetWidgetSizeFromResources( GtkWidget* widget, int width_chars, int height_lines, int* width, int* height) { - DCHECK(GTK_WIDGET_REALIZED(widget)) + DCHECK(gtk_widget_get_realized(widget)) << " widget must be realized to compute font metrics correctly"; double chars = 0; @@ -841,11 +842,11 @@ void SetAlwaysShowImage(GtkWidget* image_menu_item) { } gfx::Rect GetWidgetRectRelativeToToplevel(GtkWidget* widget) { - DCHECK(GTK_WIDGET_REALIZED(widget)); + DCHECK(gtk_widget_get_realized(widget)); GtkWidget* toplevel = gtk_widget_get_toplevel(widget); DCHECK(toplevel); - DCHECK(GTK_WIDGET_REALIZED(toplevel)); + DCHECK(gtk_widget_get_realized(toplevel)); gint x = 0, y = 0; gtk_widget_translate_coordinates(widget, @@ -1145,7 +1146,7 @@ void SetLabelWidth(GtkWidget* label, int pixel_width) { gtk_widget_set_size_request(label, pixel_width, -1); } else { // The label has to be realized before we can adjust its width. - if (GTK_WIDGET_REALIZED(label)) { + if (gtk_widget_get_realized(label)) { OnLabelRealize(label, GINT_TO_POINTER(pixel_width)); } else { g_signal_connect(label, "realize", G_CALLBACK(OnLabelRealize), diff --git a/chrome/browser/ui/gtk/hover_controller_gtk.cc b/chrome/browser/ui/gtk/hover_controller_gtk.cc index f110ad8..d58a05a 100644 --- a/chrome/browser/ui/gtk/hover_controller_gtk.cc +++ b/chrome/browser/ui/gtk/hover_controller_gtk.cc @@ -6,6 +6,7 @@ #include "base/message_loop.h" #include "chrome/browser/ui/gtk/gtk_chrome_button.h" +#include "ui/base/gtk/gtk_compat.h" static const gchar* kHoverControllerGtkKey = "__HOVER_CONTROLLER_GTK__"; @@ -114,7 +115,7 @@ void HoverControllerGtk::OnHierarchyChanged(GtkWidget* widget, GtkWidget* previous_toplevel) { // GTK+ does not emit leave-notify-event signals when a widget // becomes unanchored, so manually unset the hover states. - if (!GTK_WIDGET_TOPLEVEL(gtk_widget_get_toplevel(widget))) { + if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget))) { gtk_widget_set_state(button_, GTK_STATE_NORMAL); hover_animation_.Reset(); gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0.0); diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc index 5cf9267..441b812 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc +++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc @@ -28,6 +28,7 @@ #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/notification_source.h" #include "grit/theme_resources.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/gtk/gtk_windowing.h" #include "ui/gfx/color_utils.h" @@ -365,7 +366,7 @@ void OmniboxPopupViewGtk::UpdatePopupAppearance() { } gfx::Rect OmniboxPopupViewGtk::GetTargetBounds() { - if (!GTK_WIDGET_REALIZED(window_)) + if (!gtk_widget_get_realized(window_)) return gfx::Rect(); gfx::Rect retval = gtk_util::GetWidgetScreenBounds(window_); @@ -461,7 +462,7 @@ void OmniboxPopupViewGtk::StackWindow() { gfx::NativeView omnibox_view = omnibox_view_->GetNativeView(); DCHECK(GTK_IS_WIDGET(omnibox_view)); GtkWidget* toplevel = gtk_widget_get_toplevel(omnibox_view); - DCHECK(GTK_WIDGET_TOPLEVEL(toplevel)); + DCHECK(gtk_widget_is_toplevel(toplevel)); ui::StackPopupWindow(window_, toplevel); } diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc index 6ea2a4a..6d03644 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc +++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc @@ -36,6 +36,7 @@ #include "ui/base/animation/multi_animation.h" #include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/dragdrop/gtk_dnd_util.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" @@ -763,7 +764,7 @@ gfx::NativeView OmniboxViewGtk::GetNativeView() const { gfx::NativeView OmniboxViewGtk::GetRelativeWindowForPopup() const { GtkWidget* toplevel = gtk_widget_get_toplevel(GetNativeView()); - DCHECK(GTK_WIDGET_TOPLEVEL(toplevel)); + DCHECK(gtk_widget_is_toplevel(toplevel)); return toplevel; } @@ -1932,7 +1933,7 @@ void OmniboxViewGtk::SelectAllInternal(bool reversed, } void OmniboxViewGtk::StartUpdatingHighlightedText() { - if (GTK_WIDGET_REALIZED(text_view_)) { + if (gtk_widget_get_realized(text_view_)) { GtkClipboard* clipboard = gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); DCHECK(clipboard); @@ -1944,7 +1945,7 @@ void OmniboxViewGtk::StartUpdatingHighlightedText() { } void OmniboxViewGtk::FinishUpdatingHighlightedText() { - if (GTK_WIDGET_REALIZED(text_view_)) { + if (gtk_widget_get_realized(text_view_)) { GtkClipboard* clipboard = gtk_widget_get_clipboard(text_view_, GDK_SELECTION_PRIMARY); DCHECK(clipboard); diff --git a/chrome/browser/ui/gtk/rounded_window.cc b/chrome/browser/ui/gtk/rounded_window.cc index 03d98d6..ca72c38 100644 --- a/chrome/browser/ui/gtk/rounded_window.cc +++ b/chrome/browser/ui/gtk/rounded_window.cc @@ -10,6 +10,7 @@ #include "base/i18n/rtl.h" #include "base/logging.h" #include "chrome/browser/ui/gtk/gtk_util.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_signal_registrar.h" namespace gtk_util { @@ -286,7 +287,7 @@ void ActAsRoundedWindow( void StopActingAsRoundedWindow(GtkWidget* widget) { g_object_set_data(G_OBJECT(widget), kRoundedData, NULL); - if (GTK_WIDGET_REALIZED(widget)) + if (gtk_widget_get_realized(widget)) gdk_window_shape_combine_mask(widget->window, NULL, 0, 0); if (gtk_widget_get_visible(widget)) diff --git a/chrome/browser/ui/gtk/ssl_client_certificate_selector.cc b/chrome/browser/ui/gtk/ssl_client_certificate_selector.cc index 229fcf9..f320cbf 100644 --- a/chrome/browser/ui/gtk/ssl_client_certificate_selector.cc +++ b/chrome/browser/ui/gtk/ssl_client_certificate_selector.cc @@ -24,6 +24,7 @@ #include "content/public/browser/browser_thread.h" #include "grit/generated_resources.h" #include "net/base/x509_certificate.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/gtk/gtk_signal.h" #include "ui/base/gtk/owned_widget_gtk.h" @@ -383,7 +384,7 @@ void SSLClientCertificateSelector::OnOkClicked(GtkWidget* button) { void SSLClientCertificateSelector::OnPromptShown(GtkWidget* widget, GtkWidget* previous_toplevel) { if (!root_widget_.get() || - !GTK_WIDGET_TOPLEVEL(gtk_widget_get_toplevel(root_widget_.get()))) + !gtk_widget_is_toplevel(gtk_widget_get_toplevel(root_widget_.get()))) return; gtk_widget_set_can_default(select_button_, TRUE); gtk_widget_grab_default(select_button_); diff --git a/chrome/browser/ui/gtk/status_bubble_gtk.cc b/chrome/browser/ui/gtk/status_bubble_gtk.cc index f081ff7..7d113ea 100644 --- a/chrome/browser/ui/gtk/status_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/status_bubble_gtk.cc @@ -18,6 +18,7 @@ #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/notification_source.h" #include "ui/base/animation/slide_animation.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/text/text_elider.h" @@ -93,7 +94,7 @@ void StatusBubbleGtk::SetStatusTextToURL() { GtkWidget* parent = gtk_widget_get_parent(container_.get()); // It appears that parent can be NULL (probably only during shutdown). - if (!parent || !GTK_WIDGET_REALIZED(parent)) + if (!parent || !gtk_widget_get_realized(parent)) return; int desired_width = parent->allocation.width; @@ -166,11 +167,11 @@ void StatusBubbleGtk::MouseMoved( last_mouse_location_ = location; last_mouse_left_content_ = left_content; - if (!GTK_WIDGET_REALIZED(container_.get())) + if (!gtk_widget_get_realized(container_.get())) return; GtkWidget* parent = gtk_widget_get_parent(container_.get()); - if (!parent || !GTK_WIDGET_REALIZED(parent)) + if (!parent || !gtk_widget_get_realized(parent)) return; int old_y_offset = y_offset_; @@ -181,7 +182,7 @@ void StatusBubbleGtk::MouseMoved( y_offset_ = 0; } else { GtkWidget* toplevel = gtk_widget_get_toplevel(container_.get()); - if (!toplevel || !GTK_WIDGET_REALIZED(toplevel)) + if (!toplevel || !gtk_widget_get_realized(toplevel)) return; bool ltr = !base::i18n::IsRTL(); diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc index fe528fe..a6259b8 100644 --- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc @@ -34,6 +34,7 @@ #include "ui/base/animation/animation_delegate.h" #include "ui/base/animation/slide_animation.h" #include "ui/base/dragdrop/gtk_dnd_util.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_screen_utils.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/gtk_util.h" @@ -1611,7 +1612,7 @@ bool TabStripGtk::IsCursorInTabStripZone() const { } void TabStripGtk::ReStack() { - if (!GTK_WIDGET_REALIZED(tabstrip_.get())) { + if (!gtk_widget_get_realized(tabstrip_.get())) { // If the window isn't realized yet, we can't stack them yet. It will be // done by the OnMap signal handler. return; diff --git a/chrome/browser/ui/login/login_prompt_gtk.cc b/chrome/browser/ui/login/login_prompt_gtk.cc index 1070117..e16856c 100644 --- a/chrome/browser/ui/login/login_prompt_gtk.cc +++ b/chrome/browser/ui/login/login_prompt_gtk.cc @@ -22,6 +22,7 @@ #include "content/public/browser/browser_thread.h" #include "grit/generated_resources.h" #include "net/url_request/url_request.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/gtk/gtk_signal.h" #include "ui/base/l10n/l10n_util.h" @@ -177,7 +178,7 @@ void LoginHandlerGtk::OnPromptHierarchyChanged(GtkWidget* sender, GtkWidget* previous_toplevel) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!GTK_WIDGET_TOPLEVEL(gtk_widget_get_toplevel(ok_))) + if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(ok_))) return; // Now that we have attached ourself to the window, we can make our OK diff --git a/content/browser/renderer_host/gtk_window_utils.cc b/content/browser/renderer_host/gtk_window_utils.cc index a574941..2c43d54 100644 --- a/content/browser/renderer_host/gtk_window_utils.cc +++ b/content/browser/renderer_host/gtk_window_utils.cc @@ -7,6 +7,7 @@ #include <gdk/gdkx.h> #include <gtk/gtk.h> +#include "ui/base/gtk/gtk_compat.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" #include "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFactory.h" @@ -14,7 +15,7 @@ namespace content { void GetScreenInfoFromNativeWindow( GdkWindow* gdk_window, WebKit::WebScreenInfo* results) { - GdkScreen* screen = gdk_drawable_get_screen(gdk_window); + GdkScreen* screen = gdk_window_get_screen(gdk_window); *results = WebKit::WebScreenInfoFactory::screenInfo( gdk_x11_drawable_get_xdisplay(gdk_window), gdk_x11_screen_get_screen_number(screen)); diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index 7fa23c7..1994e1f 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -1383,7 +1383,7 @@ gfx::Point RenderWidgetHostViewGtk::GetWidgetCenter() { gdk_window_get_origin(window, &window_x, &window_y); gint window_w = 0; gint window_h = 0; - gdk_drawable_get_size(window, &window_w, &window_h); + gdk_window_get_size(window, &window_w, &window_h); widget_center_.SetPoint(window_x + window_w / 2, window_y + window_h / 2); diff --git a/content/browser/tab_contents/web_drag_source_gtk.cc b/content/browser/tab_contents/web_drag_source_gtk.cc index 7c01fa4..7ef64dc 100644 --- a/content/browser/tab_contents/web_drag_source_gtk.cc +++ b/content/browser/tab_contents/web_drag_source_gtk.cc @@ -21,6 +21,7 @@ #include "net/base/file_stream.h" #include "net/base/net_util.h" #include "ui/base/dragdrop/gtk_dnd_util.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_screen_utils.h" #include "ui/gfx/gtk_util.h" #include "webkit/glue/webdropdata.h" @@ -321,7 +322,7 @@ void WebDragSourceGtk::OnDragBegin(GtkWidget* sender, gdk_pixbuf_get_height(drag_pixbuf_)); // We only need to do this once. - if (!GTK_WIDGET_REALIZED(drag_icon_)) { + if (!gtk_widget_get_realized(drag_icon_)) { GdkScreen* screen = gtk_widget_get_screen(drag_icon_); GdkColormap* rgba = gdk_screen_get_rgba_colormap(screen); if (rgba) diff --git a/ui/base/gtk/gtk_compat.h b/ui/base/gtk/gtk_compat.h new file mode 100644 index 0000000..e6c119a --- /dev/null +++ b/ui/base/gtk/gtk_compat.h @@ -0,0 +1,39 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_BASE_GTK_GTK_COMPAT_H_ +#define UI_BASE_GTK_GTK_COMPAT_H_ +#pragma once + +#include <gtk/gtk.h> + +// Google Chrome must depend on GTK 2.18, at least until the next LTS drops +// (and we might have to extend which version of GTK we want to target due to +// RHEL). To make our porting job for GTK3 easier, we define all the methods +// that replace deprecated APIs in this file and then include it everywhere. +// +// This file is organized first by version, and then with each version, +// alphabetically by method. + +#if !GTK_CHECK_VERSION(2, 20, 0) +inline gboolean gtk_widget_get_realized(GtkWidget* widget) { + return GTK_WIDGET_REALIZED(widget); +} + +inline gboolean gtk_widget_is_toplevel(GtkWidget* widget) { + return GTK_WIDGET_TOPLEVEL(widget); +} +#endif + +#if !GTK_CHECK_VERSION(2, 24, 0) +inline void gdk_pixmap_get_size(GdkPixmap* pixmap, gint* width, gint* height) { + gdk_drawable_get_size(GDK_DRAWABLE(pixmap), width, height); +} + +inline GdkScreen* gdk_window_get_screen(GdkWindow* window) { + return gdk_drawable_get_screen(GDK_DRAWABLE(window)); +} +#endif + +#endif // UI_BASE_GTK_GTK_COMPAT_H_ diff --git a/ui/base/gtk/gtk_expanded_container.cc b/ui/base/gtk/gtk_expanded_container.cc index e5b23b5..bfc5a46 100644 --- a/ui/base/gtk/gtk_expanded_container.cc +++ b/ui/base/gtk/gtk_expanded_container.cc @@ -8,6 +8,8 @@ #include <algorithm> +#include "ui/base/gtk/gtk_compat.h" + namespace { enum { @@ -143,7 +145,7 @@ static void gtk_expanded_container_size_allocate(GtkWidget* widget, GtkAllocation* allocation) { widget->allocation = *allocation; - if (!GTK_WIDGET_NO_WINDOW(widget) && GTK_WIDGET_REALIZED(widget)) { + if (!GTK_WIDGET_NO_WINDOW(widget) && gtk_widget_get_realized(widget)) { gdk_window_move_resize(widget->window, allocation->x, allocation->y, @@ -180,7 +182,7 @@ void gtk_expanded_container_move(GtkExpandedContainer* container, void gtk_expanded_container_set_has_window(GtkExpandedContainer* container, gboolean has_window) { g_return_if_fail(GTK_IS_EXPANDED_CONTAINER(container)); - g_return_if_fail(!GTK_WIDGET_REALIZED(container)); + g_return_if_fail(!gtk_widget_get_realized(GTK_WIDGET(container))); gtk_fixed_set_has_window(GTK_FIXED(container), has_window); } diff --git a/ui/base/gtk/gtk_floating_container.cc b/ui/base/gtk/gtk_floating_container.cc index 0bda427..edb080f 100644 --- a/ui/base/gtk/gtk_floating_container.cc +++ b/ui/base/gtk/gtk_floating_container.cc @@ -10,6 +10,8 @@ #include <algorithm> +#include "ui/base/gtk/gtk_compat.h" + namespace { enum { @@ -205,7 +207,7 @@ static void gtk_floating_container_size_allocate(GtkWidget* widget, GtkAllocation* allocation) { widget->allocation = *allocation; - if (!GTK_WIDGET_NO_WINDOW(widget) && GTK_WIDGET_REALIZED(widget)) { + if (gtk_widget_get_has_window(widget) && gtk_widget_get_realized(widget)) { gdk_window_move_resize(widget->window, allocation->x, allocation->y, diff --git a/ui/base/gtk/gtk_windowing.cc b/ui/base/gtk/gtk_windowing.cc index 7f26b84..4ca4a1d 100644 --- a/ui/base/gtk/gtk_windowing.cc +++ b/ui/base/gtk/gtk_windowing.cc @@ -7,15 +7,16 @@ #include <gdk/gdkx.h> #include "base/logging.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/x/x11_util.h" namespace ui { void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel) { - DCHECK(GTK_IS_WINDOW(popup) && GTK_WIDGET_TOPLEVEL(popup) && - GTK_WIDGET_REALIZED(popup)); - DCHECK(GTK_IS_WINDOW(toplevel) && GTK_WIDGET_TOPLEVEL(toplevel) && - GTK_WIDGET_REALIZED(toplevel)); + DCHECK(GTK_IS_WINDOW(popup) && gtk_widget_is_toplevel(popup) && + gtk_widget_get_realized(popup)); + DCHECK(GTK_IS_WINDOW(toplevel) && gtk_widget_is_toplevel(toplevel) && + gtk_widget_get_realized(toplevel)); // Stack the |popup| window directly above the |toplevel| window. // The popup window is a direct child of the root window, so we need to diff --git a/ui/gfx/gtk_native_view_id_manager.cc b/ui/gfx/gtk_native_view_id_manager.cc index 14105f8..4f1623d 100644 --- a/ui/gfx/gtk_native_view_id_manager.cc +++ b/ui/gfx/gtk_native_view_id_manager.cc @@ -9,6 +9,7 @@ #include "base/logging.h" #include "base/rand_util.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/gfx/gtk_preserve_window.h" // ----------------------------------------------------------------------------- @@ -66,7 +67,7 @@ gfx::NativeViewId GtkNativeViewManager::GetIdForWidget(gfx::NativeView widget) { NativeViewInfo info; info.widget = widget; - if (GTK_WIDGET_REALIZED(widget)) { + if (gtk_widget_get_realized(widget)) { GdkWindow *gdk_window = widget->window; DCHECK(gdk_window); info.x_window_id = GDK_WINDOW_XID(gdk_window); diff --git a/ui/gfx/gtk_preserve_window.cc b/ui/gfx/gtk_preserve_window.cc index d67bc92..5a80302 100644 --- a/ui/gfx/gtk_preserve_window.cc +++ b/ui/gfx/gtk_preserve_window.cc @@ -9,6 +9,8 @@ #include <gtk/gtkwidget.h> #include <gtk/gtkfixed.h> +#include "ui/base/gtk/gtk_compat.h" + G_BEGIN_DECLS #define GTK_PRESERVE_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ @@ -180,7 +182,7 @@ void gtk_preserve_window_set_preserve(GtkPreserveWindow* window, attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_NOREDIR; widget->window = gdk_window_new( gdk_get_default_root_window(), &attributes, attributes_mask); - } else if (!value && widget->window && !GTK_WIDGET_REALIZED(widget)) { + } else if (!value && widget->window && !gtk_widget_get_realized(widget)) { gdk_window_destroy(widget->window); widget->window = NULL; } @@ -192,7 +194,7 @@ void gtk_preserve_window_size_allocate(GtkWidget* widget, widget->allocation = *allocation; - if (GTK_WIDGET_REALIZED(widget)) { + if (gtk_widget_get_realized(widget)) { GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); if (priv->delegate_resize) { gdk_window_move(widget->window, allocation->x, allocation->y); diff --git a/webkit/plugins/npapi/gtk_plugin_container_manager.cc b/webkit/plugins/npapi/gtk_plugin_container_manager.cc index 1c84bfb..79897e2 100644 --- a/webkit/plugins/npapi/gtk_plugin_container_manager.cc +++ b/webkit/plugins/npapi/gtk_plugin_container_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,6 +7,7 @@ #include <gtk/gtk.h> #include "base/logging.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/gfx/gtk_util.h" #include "webkit/plugins/npapi/gtk_plugin_container.h" #include "webkit/plugins/npapi/webplugin.h" @@ -80,7 +81,7 @@ void GtkPluginContainerManager::MovePluginContainer( // TODO(piman): if the widget hasn't been realized (e.g. the tab has been // torn off and the parent gtk widget has been detached from the hierarchy), // we lose the cutout information. - if (GTK_WIDGET_REALIZED(widget)) { + if (gtk_widget_get_realized(widget)) { GdkRectangle clip_rect = move.clip_rect.ToGdkRectangle(); GdkRegion* clip_region = gdk_region_rectangle(&clip_rect); gfx::SubtractRectanglesFromRegion(clip_region, move.cutout_rects); diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc index ebd7619..e7d6ff5 100644 --- a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc +++ b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc @@ -19,6 +19,7 @@ #include "skia/ext/platform_canvas.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/gfx/blit.h" #include "webkit/plugins/npapi/gtk_plugin_container.h" #include "webkit/plugins/npapi/plugin_constants_win.h" @@ -242,7 +243,7 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry( void WebPluginDelegateImpl::EnsurePixmapAtLeastSize(int width, int height) { if (pixmap_) { gint cur_width, cur_height; - gdk_drawable_get_size(pixmap_, &cur_width, &cur_height); + gdk_pixmap_get_size(pixmap_, &cur_width, &cur_height); if (cur_width >= width && cur_height >= height) return; // We are already the appropriate size. @@ -256,9 +257,10 @@ void WebPluginDelegateImpl::EnsurePixmapAtLeastSize(int width, int height) { pixmap_ = gdk_pixmap_new(NULL, // use width/height/depth params std::max(1, width), std::max(1, height), sys_visual->depth); + // TODO(erg): Replace this with GdkVisual when we move to GTK3. GdkColormap* colormap = gdk_colormap_new(gdk_visual_get_system(), FALSE); - gdk_drawable_set_colormap(GDK_DRAWABLE(pixmap_), colormap); + gdk_drawable_set_colormap(pixmap_, colormap); // The GdkDrawable now owns the GdkColormap. g_object_unref(colormap); } diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index e4a638b..c2b37b1 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -25,6 +25,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" +#include "ui/base/gtk/gtk_compat.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/webkit_glue.h" @@ -431,7 +432,7 @@ void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) { gtk_widget_grab_focus(widget); } else if (gtk_widget_is_focus(widget)) { GtkWidget *toplevel = gtk_widget_get_toplevel(widget); - if (GTK_WIDGET_TOPLEVEL(toplevel)) + if (gtk_widget_is_toplevel(toplevel)) gtk_window_set_focus(GTK_WINDOW(toplevel), NULL); } } |