summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
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/gtk/gtk_compat.h4
-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
8 files changed, 57 insertions, 37 deletions
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/gtk/gtk_compat.h b/ui/base/gtk/gtk_compat.h
index 2372387..4ca12df 100644
--- a/ui/base/gtk/gtk_compat.h
+++ b/ui/base/gtk/gtk_compat.h
@@ -49,6 +49,10 @@ inline void gtk_widget_set_realized(GtkWidget* widget,
else
GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
}
+
+inline void gtk_widget_style_attach(GtkWidget* widget) {
+ widget->style = gtk_style_attach(widget->style, widget->window);
+}
#endif // !GTK_CHECK_VERSION(2, 20, 0) || defined(GOOGLE_CHROME_BUILD)
#if !GTK_CHECK_VERSION(2, 22, 0)
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index f6292b3..6b11de4 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(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);