diff options
-rw-r--r-- | chrome/browser/ui/gtk/bubble/bubble_gtk.cc | 15 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/certificate_viewer.cc | 2 | ||||
-rw-r--r-- | content/browser/renderer_host/gtk_im_context_wrapper.cc | 9 | ||||
-rw-r--r-- | content/browser/tab_contents/web_drag_dest_gtk.cc | 22 | ||||
-rw-r--r-- | content/browser/tab_contents/web_drag_source_gtk.cc | 4 | ||||
-rw-r--r-- | ui/base/clipboard/clipboard_gtk.cc | 33 | ||||
-rw-r--r-- | ui/base/dragdrop/gtk_dnd_util.cc | 20 | ||||
-rw-r--r-- | ui/base/gtk/focus_store_gtk.cc | 4 | ||||
-rw-r--r-- | ui/base/x/x11_util.cc | 2 | ||||
-rw-r--r-- | ui/gfx/gtk_native_view_id_manager.cc | 13 | ||||
-rw-r--r-- | ui/gfx/gtk_preserve_window.cc | 12 | ||||
-rw-r--r-- | ui/gfx/screen_gtk.cc | 6 |
12 files changed, 83 insertions, 59 deletions
diff --git a/chrome/browser/ui/gtk/bubble/bubble_gtk.cc b/chrome/browser/ui/gtk/bubble/bubble_gtk.cc index 1d4e6c3..1035f42 100644 --- a/chrome/browser/ui/gtk/bubble/bubble_gtk.cc +++ b/chrome/browser/ui/gtk/bubble/bubble_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -307,8 +307,10 @@ void BubbleGtk::UpdateWindowShape() { mask_region_ = gdk_region_polygon(&points[0], points.size(), GDK_EVEN_ODD_RULE); - gdk_window_shape_combine_region(window_->window, NULL, 0, 0); - gdk_window_shape_combine_region(window_->window, mask_region_, 0, 0); + + GdkWindow* gdk_window = gtk_widget_get_window(window_); + gdk_window_shape_combine_region(gdk_window, NULL, 0, 0); + gdk_window_shape_combine_region(gdk_window, mask_region_, 0, 0); } void BubbleGtk::MoveWindow() { @@ -373,10 +375,12 @@ void BubbleGtk::Close() { } void BubbleGtk::GrabPointerAndKeyboard() { + GdkWindow* gdk_window = gtk_widget_get_window(window_); + // Install X pointer and keyboard grabs to make sure that we have the focus // and get all mouse and keyboard events until we're closed. GdkGrabStatus pointer_grab_status = - gdk_pointer_grab(window_->window, + gdk_pointer_grab(gdk_window, TRUE, // owner_events GDK_BUTTON_PRESS_MASK, // event_mask NULL, // confine_to @@ -389,7 +393,7 @@ void BubbleGtk::GrabPointerAndKeyboard() { << pointer_grab_status << ")"; } GdkGrabStatus keyboard_grab_status = - gdk_keyboard_grab(window_->window, + gdk_keyboard_grab(gdk_window, FALSE, // owner_events GDK_CURRENT_TIME); if (keyboard_grab_status != GDK_GRAB_SUCCESS) { @@ -456,6 +460,7 @@ gboolean BubbleGtk::OnGtkAccelerator(GtkAccelGroup* group, } gboolean BubbleGtk::OnExpose(GtkWidget* widget, GdkEventExpose* expose) { + // TODO(erg): This whole method will need to be rewritten in cairo. GdkDrawable* drawable = GDK_DRAWABLE(window_->window); GdkGC* gc = gdk_gc_new(drawable); gdk_gc_set_rgb_fg_color(gc, &kFrameColor); diff --git a/chrome/browser/ui/gtk/certificate_viewer.cc b/chrome/browser/ui/gtk/certificate_viewer.cc index a4279d5..7f0b1d2 100644 --- a/chrome/browser/ui/gtk/certificate_viewer.cc +++ b/chrome/browser/ui/gtk/certificate_viewer.cc @@ -157,7 +157,7 @@ CertificateViewer::CertificateViewer( InitDetailsPage(); notebook_ = gtk_notebook_new(); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); + gtk_container_add(GTK_CONTAINER(content_area), notebook_); gtk_notebook_append_page( GTK_NOTEBOOK(notebook_), diff --git a/content/browser/renderer_host/gtk_im_context_wrapper.cc b/content/browser/renderer_host/gtk_im_context_wrapper.cc index 728e37e..414b9ac 100644 --- a/content/browser/renderer_host/gtk_im_context_wrapper.cc +++ b/content/browser/renderer_host/gtk_im_context_wrapper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -589,9 +589,10 @@ void GtkIMContextWrapper::HandleHostViewRealize(GtkWidget* widget) { // We should only set im context's client window once, because when setting // client window.im context may destroy and recreate its internal states and // objects. - if (widget->window) { - gtk_im_context_set_client_window(context_, widget->window); - gtk_im_context_set_client_window(context_simple_, widget->window); + GdkWindow* gdk_window = gtk_widget_get_window(widget); + if (gdk_window) { + gtk_im_context_set_client_window(context_, gdk_window); + gtk_im_context_set_client_window(context_simple_, gdk_window); } } diff --git a/content/browser/tab_contents/web_drag_dest_gtk.cc b/content/browser/tab_contents/web_drag_dest_gtk.cc index 3ba700c..5dc5cc5 100644 --- a/content/browser/tab_contents/web_drag_dest_gtk.cc +++ b/content/browser/tab_contents/web_drag_dest_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -143,14 +143,16 @@ void WebDragDestGtk::OnDragDataReceived( data_requests_--; // Decode the data. - if (data->data && data->length > 0) { + gint data_length = gtk_selection_data_get_length(data); + const guchar* raw_data = gtk_selection_data_get_data(data); + if (raw_data && data_length > 0) { // If the source can't provide us with valid data for a requested target, - // data->data will be NULL. + // raw_data will be NULL. if (data->target == ui::GetAtomForTarget(ui::TEXT_PLAIN)) { guchar* text = gtk_selection_data_get_text(data); if (text) { drop_data_->plain_text = - UTF8ToUTF16(std::string(reinterpret_cast<char*>(text))); + UTF8ToUTF16(std::string(reinterpret_cast<const char*>(text))); g_free(text); } } else if (data->target == ui::GetAtomForTarget(ui::TEXT_URI_LIST)) { @@ -181,12 +183,12 @@ void WebDragDestGtk::OnDragDataReceived( } else if (data->target == ui::GetAtomForTarget(ui::TEXT_HTML)) { // TODO(estade): Can the html have a non-UTF8 encoding? drop_data_->text_html = - UTF8ToUTF16(std::string(reinterpret_cast<char*>(data->data), - data->length)); + UTF8ToUTF16(std::string(reinterpret_cast<const char*>(raw_data), + data_length)); // We leave the base URL empty. } else if (data->target == ui::GetAtomForTarget(ui::NETSCAPE_URL)) { - std::string netscape_url(reinterpret_cast<char*>(data->data), - data->length); + std::string netscape_url(reinterpret_cast<const char*>(raw_data), + data_length); size_t split = netscape_url.find_first_of('\n'); if (split != std::string::npos) { drop_data_->url = GURL(netscape_url.substr(0, split)); @@ -197,7 +199,7 @@ void WebDragDestGtk::OnDragDataReceived( ui::ExtractNamedURL(data, &drop_data_->url, &drop_data_->url_title); } else if (data->target == ui::GetAtomForTarget(ui::CUSTOM_DATA)) { ui::ReadCustomDataIntoMap( - data->data, data->length, &drop_data_->custom_data); + raw_data, data_length, &drop_data_->custom_data); } } @@ -207,7 +209,7 @@ void WebDragDestGtk::OnDragDataReceived( // Note that bookmark drag data is encoded in the same format for both // GTK and Views, hence we can share the same logic here. if (delegate() && data->target == delegate()->GetBookmarkTargetAtom()) { - if (data->data && data->length > 0) { + if (raw_data && data_length > 0) { delegate()->OnReceiveDataFromGtk(data); } else { delegate()->OnReceiveProcessedData(drop_data_->url, diff --git a/content/browser/tab_contents/web_drag_source_gtk.cc b/content/browser/tab_contents/web_drag_source_gtk.cc index 7f7bccb..20f4a1f 100644 --- a/content/browser/tab_contents/web_drag_source_gtk.cc +++ b/content/browser/tab_contents/web_drag_source_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -264,7 +264,7 @@ void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender, // Return the status code to the file manager. gtk_selection_data_set(selection_data, - selection_data->target, + gtk_selection_data_get_target(selection_data), kBitsPerByte, reinterpret_cast<guchar*>(&status_code), 1); diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc index 5b6a1a9..b1ea51b 100644 --- a/ui/base/clipboard/clipboard_gtk.cc +++ b/ui/base/clipboard/clipboard_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -129,7 +129,8 @@ void GetData(GtkClipboard* clipboard, Clipboard::TargetMap* data_map = reinterpret_cast<Clipboard::TargetMap*>(user_data); - std::string target_string = GdkAtomToString(selection_data->target); + std::string target_string = GdkAtomToString( + gtk_selection_data_get_target(selection_data)); Clipboard::TargetMap::iterator iter = data_map->find(target_string); if (iter == data_map->end()) @@ -139,7 +140,8 @@ void GetData(GtkClipboard* clipboard, gtk_selection_data_set_pixbuf(selection_data, reinterpret_cast<GdkPixbuf*>(iter->second.first)); } else { - gtk_selection_data_set(selection_data, selection_data->target, 8, + gtk_selection_data_set(selection_data, + gtk_selection_data_get_target(selection_data), 8, reinterpret_cast<guchar*>(iter->second.first), iter->second.second); } @@ -421,7 +423,9 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer, clipboard, GetWebCustomDataFormatType().ToGdkAtom()); if (!data) return; - ReadCustomDataTypes(data->data, data->length, types); + ReadCustomDataTypes(gtk_selection_data_get_data(data), + gtk_selection_data_get_length(data), + types); gtk_selection_data_free(data); } @@ -484,12 +488,15 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup, // If the data starts with 0xFEFF, i.e., Byte Order Mark, assume it is // UTF-16, otherwise assume UTF-8. - if (data->length >= 2 && - reinterpret_cast<uint16_t*>(data->data)[0] == 0xFEFF) { - markup->assign(reinterpret_cast<uint16_t*>(data->data) + 1, - (data->length / 2) - 1); + gint data_length = gtk_selection_data_get_length(data); + const guchar* raw_data = gtk_selection_data_get_data(data); + + if (data_length >= 2 && + reinterpret_cast<const uint16_t*>(raw_data)[0] == 0xFEFF) { + markup->assign(reinterpret_cast<const uint16_t*>(raw_data) + 1, + (data_length / 2) - 1); } else { - UTF8ToUTF16(reinterpret_cast<char*>(data->data), data->length, markup); + UTF8ToUTF16(reinterpret_cast<const char*>(raw_data), data_length, markup); } // If there is a terminating NULL, drop it. @@ -532,7 +539,9 @@ void Clipboard::ReadCustomData(Buffer buffer, clipboard, GetWebCustomDataFormatType().ToGdkAtom()); if (!data) return; - ReadCustomDataForType(data->data, data->length, type, result); + ReadCustomDataForType(gtk_selection_data_get_data(data), + gtk_selection_data_get_length(data), + type, result); gtk_selection_data_free(data); } @@ -546,7 +555,9 @@ void Clipboard::ReadData(const FormatType& format, std::string* result) const { gtk_clipboard_wait_for_contents(clipboard_, format.ToGdkAtom()); if (!data) return; - result->assign(reinterpret_cast<char*>(data->data), data->length); + result->assign(reinterpret_cast<const char*>( + gtk_selection_data_get_data(data)), + gtk_selection_data_get_length(data)); gtk_selection_data_free(data); } diff --git a/ui/base/dragdrop/gtk_dnd_util.cc b/ui/base/dragdrop/gtk_dnd_util.cc index 165d91b..d70aac8 100644 --- a/ui/base/dragdrop/gtk_dnd_util.cc +++ b/ui/base/dragdrop/gtk_dnd_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -192,7 +192,7 @@ void WriteURLWithName(GtkSelectionData* selection_data, // _NETSCAPE_URL format is URL + \n + title. std::string utf8_text = url.spec() + "\n" + UTF16ToUTF8(title); gtk_selection_data_set(selection_data, - selection_data->target, + gtk_selection_data_get_target(selection_data), kBitsPerByte, reinterpret_cast<const guchar*>(utf8_text.c_str()), utf8_text.length()); @@ -209,11 +209,13 @@ void WriteURLWithName(GtkSelectionData* selection_data, bool ExtractNamedURL(GtkSelectionData* selection_data, GURL* url, string16* title) { - if (!selection_data || selection_data->length <= 0) + if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0) return false; - Pickle data(reinterpret_cast<char*>(selection_data->data), - selection_data->length); + Pickle data( + reinterpret_cast<const char*>( + gtk_selection_data_get_data(selection_data)), + gtk_selection_data_get_length(selection_data)); void* iter = NULL; std::string title_utf8, url_utf8; if (!data.ReadString(&iter, &title_utf8) || @@ -248,13 +250,15 @@ bool ExtractURIList(GtkSelectionData* selection_data, std::vector<GURL>* urls) { bool ExtractNetscapeURL(GtkSelectionData* selection_data, GURL* url, string16* title) { - if (!selection_data || selection_data->length <= 0) + if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0) return false; // Find the first '\n' in the data. It is the separator between the url and // the title. - std::string data(reinterpret_cast<char*>(selection_data->data), - selection_data->length); + std::string data( + reinterpret_cast<const char*>( + gtk_selection_data_get_data(selection_data)), + gtk_selection_data_get_length(selection_data)); std::string::size_type newline = data.find('\n'); if (newline == std::string::npos) return false; diff --git a/ui/base/gtk/focus_store_gtk.cc b/ui/base/gtk/focus_store_gtk.cc index b98787c..3af039d 100644 --- a/ui/base/gtk/focus_store_gtk.cc +++ b/ui/base/gtk/focus_store_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -25,7 +25,7 @@ void FocusStoreGtk::Store(GtkWidget* widget) { GtkWidget* toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW); GtkWindow* window = GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL; if (window) - focus_widget = window->focus_widget; + focus_widget = gtk_window_get_focus(window); } SetWidget(focus_widget); diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index dd47c10..f16388a 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -307,7 +307,7 @@ bool GetCurrentDesktop(int* desktop) { #if defined(TOOLKIT_USES_GTK) XID GetX11WindowFromGtkWidget(GtkWidget* widget) { - return GDK_WINDOW_XID(widget->window); + return GDK_WINDOW_XID(gtk_widget_get_window(widget)); } XID GetX11WindowFromGdkWindow(GdkWindow* window) { diff --git a/ui/gfx/gtk_native_view_id_manager.cc b/ui/gfx/gtk_native_view_id_manager.cc index 6c053b4..43f324c 100644 --- a/ui/gfx/gtk_native_view_id_manager.cc +++ b/ui/gfx/gtk_native_view_id_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -69,7 +69,7 @@ gfx::NativeViewId GtkNativeViewManager::GetIdForWidget(gfx::NativeView widget) { NativeViewInfo info; info.widget = widget; if (gtk_widget_get_realized(widget)) { - GdkWindow *gdk_window = widget->window; + GdkWindow *gdk_window = gtk_widget_get_window(widget); DCHECK(gdk_window); info.x_window_id = GDK_WINDOW_XID(gdk_window); } @@ -128,7 +128,7 @@ bool GtkNativeViewManager::GetPermanentXIDForId(XID* output, reinterpret_cast<GtkPreserveWindow*>(i->second.widget); gtk_preserve_window_set_preserve(widget, TRUE); - *output = GDK_WINDOW_XID(i->second.widget->window); + *output = GDK_WINDOW_XID(gtk_widget_get_window(i->second.widget)); // Update the reference count on the permanent XID. PermanentXIDInfo info; @@ -207,9 +207,10 @@ void GtkNativeViewManager::OnRealize(gfx::NativeView widget) { id_to_info_.find(id); CHECK(i != id_to_info_.end()); - CHECK(widget->window); - i->second.x_window_id = GDK_WINDOW_XID(widget->window); + GdkWindow* gdk_window = gtk_widget_get_window(widget); + CHECK(gdk_window); + i->second.x_window_id = GDK_WINDOW_XID(gdk_window); } void GtkNativeViewManager::OnUnrealize(gfx::NativeView widget) { @@ -239,7 +240,7 @@ void GtkNativeViewManager::OnDestroy(gfx::NativeView widget) { gtk_preserve_window_get_preserve( reinterpret_cast<GtkPreserveWindow*>(widget))) { std::map<XID, PermanentXIDInfo>::iterator k = - perm_xid_to_info_.find(GDK_WINDOW_XID(widget->window)); + perm_xid_to_info_.find(GDK_WINDOW_XID(gtk_widget_get_window(widget))); if (k != perm_xid_to_info_.end()) k->second.widget = NULL; diff --git a/ui/gfx/gtk_preserve_window.cc b/ui/gfx/gtk_preserve_window.cc index 5d40475..1af85b1 100644 --- a/ui/gfx/gtk_preserve_window.cc +++ b/ui/gfx/gtk_preserve_window.cc @@ -93,18 +93,16 @@ static void gtk_preserve_window_realize(GtkWidget* widget) { allocation.width, allocation.height); } - widget->style = gtk_style_attach(widget->style, widget->window); - gtk_style_set_background(gtk_widget_get_style(widget), - gdk_window, GTK_STATE_NORMAL); - gint event_mask = gtk_widget_get_events(widget); event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; gdk_window_set_events(gdk_window, (GdkEventMask) event_mask); gdk_window_set_user_data(gdk_window, widget); - // Deprecated as of GTK 2.22. Used for compatibility. - // It should be: gtk_widget_set_realized(widget, TRUE) - GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); + gtk_widget_set_realized(widget, TRUE); + + gtk_widget_style_attach(widget); + gtk_style_set_background(gtk_widget_get_style(widget), + gdk_window, GTK_STATE_NORMAL); } else { GTK_WIDGET_CLASS(gtk_preserve_window_parent_class)->realize(widget); } diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc index 579ad1a..1607cc8 100644 --- a/ui/gfx/screen_gtk.cc +++ b/ui/gfx/screen_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -80,7 +80,9 @@ gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) { DCHECK(GTK_IS_WINDOW(top_level)); GtkWindow* window = GTK_WINDOW(top_level); screen = gtk_window_get_screen(window); - monitor_num = gdk_screen_get_monitor_at_window(screen, top_level->window); + monitor_num = gdk_screen_get_monitor_at_window( + screen, + gtk_widget_get_window(top_level)); } GdkRectangle bounds; gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds); |