summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 01:09:48 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 01:09:48 +0000
commit9702f9511652af29060155d6809a2434eb4abb73 (patch)
tree9ea195fc7acde6e04e13fdedb746a391eeb12b5c /ui
parent8fd219ac9e5bcce8aa55abbae4f024d6a9a4f505 (diff)
downloadchromium_src-9702f9511652af29060155d6809a2434eb4abb73.zip
chromium_src-9702f9511652af29060155d6809a2434eb4abb73.tar.gz
chromium_src-9702f9511652af29060155d6809a2434eb4abb73.tar.bz2
Revert 116956 - GTK: Seal up GSEALs, focusing on GtkSelectionData.
BUG=79722 TEST=compiles Review URL: http://codereview.chromium.org/9151007 TBR=erg@chromium.org Review URL: http://codereview.chromium.org/9167002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116977 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/clipboard/clipboard_gtk.cc33
-rw-r--r--ui/base/dragdrop/gtk_dnd_util.cc20
-rw-r--r--ui/base/gtk/focus_store_gtk.cc4
-rw-r--r--ui/base/x/x11_util.cc2
-rw-r--r--ui/gfx/gtk_native_view_id_manager.cc13
-rw-r--r--ui/gfx/gtk_preserve_window.cc12
-rw-r--r--ui/gfx/screen_gtk.cc6
7 files changed, 37 insertions, 53 deletions
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc
index b1ea51b..5b6a1a9 100644
--- a/ui/base/clipboard/clipboard_gtk.cc
+++ b/ui/base/clipboard/clipboard_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 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.
@@ -129,8 +129,7 @@ void GetData(GtkClipboard* clipboard,
Clipboard::TargetMap* data_map =
reinterpret_cast<Clipboard::TargetMap*>(user_data);
- std::string target_string = GdkAtomToString(
- gtk_selection_data_get_target(selection_data));
+ std::string target_string = GdkAtomToString(selection_data->target);
Clipboard::TargetMap::iterator iter = data_map->find(target_string);
if (iter == data_map->end())
@@ -140,8 +139,7 @@ void GetData(GtkClipboard* clipboard,
gtk_selection_data_set_pixbuf(selection_data,
reinterpret_cast<GdkPixbuf*>(iter->second.first));
} else {
- gtk_selection_data_set(selection_data,
- gtk_selection_data_get_target(selection_data), 8,
+ gtk_selection_data_set(selection_data, selection_data->target, 8,
reinterpret_cast<guchar*>(iter->second.first),
iter->second.second);
}
@@ -423,9 +421,7 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer,
clipboard, GetWebCustomDataFormatType().ToGdkAtom());
if (!data)
return;
- ReadCustomDataTypes(gtk_selection_data_get_data(data),
- gtk_selection_data_get_length(data),
- types);
+ ReadCustomDataTypes(data->data, data->length, types);
gtk_selection_data_free(data);
}
@@ -488,15 +484,12 @@ 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.
- 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);
+ 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);
} else {
- UTF8ToUTF16(reinterpret_cast<const char*>(raw_data), data_length, markup);
+ UTF8ToUTF16(reinterpret_cast<char*>(data->data), data->length, markup);
}
// If there is a terminating NULL, drop it.
@@ -539,9 +532,7 @@ void Clipboard::ReadCustomData(Buffer buffer,
clipboard, GetWebCustomDataFormatType().ToGdkAtom());
if (!data)
return;
- ReadCustomDataForType(gtk_selection_data_get_data(data),
- gtk_selection_data_get_length(data),
- type, result);
+ ReadCustomDataForType(data->data, data->length, type, result);
gtk_selection_data_free(data);
}
@@ -555,9 +546,7 @@ 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<const char*>(
- gtk_selection_data_get_data(data)),
- gtk_selection_data_get_length(data));
+ result->assign(reinterpret_cast<char*>(data->data), data->length);
gtk_selection_data_free(data);
}
diff --git a/ui/base/dragdrop/gtk_dnd_util.cc b/ui/base/dragdrop/gtk_dnd_util.cc
index d70aac8..165d91b 100644
--- a/ui/base/dragdrop/gtk_dnd_util.cc
+++ b/ui/base/dragdrop/gtk_dnd_util.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 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.
@@ -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,
- gtk_selection_data_get_target(selection_data),
+ selection_data->target,
kBitsPerByte,
reinterpret_cast<const guchar*>(utf8_text.c_str()),
utf8_text.length());
@@ -209,13 +209,11 @@ void WriteURLWithName(GtkSelectionData* selection_data,
bool ExtractNamedURL(GtkSelectionData* selection_data,
GURL* url,
string16* title) {
- if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0)
+ if (!selection_data || selection_data->length <= 0)
return false;
- Pickle data(
- reinterpret_cast<const char*>(
- gtk_selection_data_get_data(selection_data)),
- gtk_selection_data_get_length(selection_data));
+ Pickle data(reinterpret_cast<char*>(selection_data->data),
+ selection_data->length);
void* iter = NULL;
std::string title_utf8, url_utf8;
if (!data.ReadString(&iter, &title_utf8) ||
@@ -250,15 +248,13 @@ bool ExtractURIList(GtkSelectionData* selection_data, std::vector<GURL>* urls) {
bool ExtractNetscapeURL(GtkSelectionData* selection_data,
GURL* url,
string16* title) {
- if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0)
+ if (!selection_data || selection_data->length <= 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<const char*>(
- gtk_selection_data_get_data(selection_data)),
- gtk_selection_data_get_length(selection_data));
+ std::string data(reinterpret_cast<char*>(selection_data->data),
+ selection_data->length);
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 3af039d..b98787c 100644
--- a/ui/base/gtk/focus_store_gtk.cc
+++ b/ui/base/gtk/focus_store_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 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.
@@ -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 = gtk_window_get_focus(window);
+ focus_widget = window->focus_widget;
}
SetWidget(focus_widget);
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 6b11de4..f6292b3 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -325,7 +325,7 @@ bool GetCurrentDesktop(int* desktop) {
#if defined(TOOLKIT_USES_GTK)
XID GetX11WindowFromGtkWidget(GtkWidget* widget) {
- return GDK_WINDOW_XID(gtk_widget_get_window(widget));
+ return GDK_WINDOW_XID(widget->window);
}
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 43f324c..6c053b4 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) 2012 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.
@@ -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 = gtk_widget_get_window(widget);
+ GdkWindow *gdk_window = widget->window;
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(gtk_widget_get_window(i->second.widget));
+ *output = GDK_WINDOW_XID(i->second.widget->window);
// Update the reference count on the permanent XID.
PermanentXIDInfo info;
@@ -207,10 +207,9 @@ void GtkNativeViewManager::OnRealize(gfx::NativeView widget) {
id_to_info_.find(id);
CHECK(i != id_to_info_.end());
+ CHECK(widget->window);
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- CHECK(gdk_window);
- i->second.x_window_id = GDK_WINDOW_XID(gdk_window);
+ i->second.x_window_id = GDK_WINDOW_XID(widget->window);
}
void GtkNativeViewManager::OnUnrealize(gfx::NativeView widget) {
@@ -240,7 +239,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(gtk_widget_get_window(widget)));
+ perm_xid_to_info_.find(GDK_WINDOW_XID(widget->window));
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 1af85b1..5d40475 100644
--- a/ui/gfx/gtk_preserve_window.cc
+++ b/ui/gfx/gtk_preserve_window.cc
@@ -93,16 +93,18 @@ 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);
- 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);
+ // 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);
} 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 1607cc8..579ad1a 100644
--- a/ui/gfx/screen_gtk.cc
+++ b/ui/gfx/screen_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 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.
@@ -80,9 +80,7 @@ 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,
- gtk_widget_get_window(top_level));
+ monitor_num = gdk_screen_get_monitor_at_window(screen, top_level->window);
}
GdkRectangle bounds;
gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds);