Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: ui/base/gtk/gtk_screen_util.cc

Issue 9390038: Move automation/ui_controls to ui/ui_controls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win_aura fix, sync Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/gtk/gtk_screen_util.h ('k') | ui/base/gtk/gtk_screen_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/gtk/gtk_screen_util.cc
diff --git a/ui/base/gtk/gtk_screen_util.cc b/ui/base/gtk/gtk_screen_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..911681b71dd315a577448b5d4dab96724ea291d6
--- /dev/null
+++ b/ui/base/gtk/gtk_screen_util.cc
@@ -0,0 +1,60 @@
+// 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.
+
+#include "ui/base/gtk/gtk_screen_util.h"
+
+#include "base/logging.h"
+
+namespace ui {
+
+bool IsScreenComposited() {
+ GdkScreen* screen = gdk_screen_get_default();
+ return gdk_screen_is_composited(screen) == TRUE;
+}
+
+gfx::Point ScreenPoint(GtkWidget* widget) {
+ int x, y;
+ gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y,
+ NULL);
+ return gfx::Point(x, y);
+}
+
+gfx::Point ClientPoint(GtkWidget* widget) {
+ int x, y;
+ gtk_widget_get_pointer(widget, &x, &y);
+ return gfx::Point(x, y);
+}
+
+gfx::Point GetWidgetScreenPosition(GtkWidget* widget) {
+ GdkWindow* window = gtk_widget_get_window(widget);
+
+ if (!window) {
+ NOTREACHED() << "Must only be called on realized widgets.";
+ return gfx::Point(0, 0);
+ }
+
+ gint x, y;
+ gdk_window_get_origin(window, &x, &y);
+
+ if (!gtk_widget_get_has_window(widget)) {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+ x += allocation.x;
+ y += allocation.y;
+ }
+
+ return gfx::Point(x, y);
+}
+
+gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) {
+ gfx::Point position = GetWidgetScreenPosition(widget);
+
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+
+ return gfx::Rect(position.x(), position.y(),
+ allocation.width, allocation.height);
+}
+
+} // namespace ui
« no previous file with comments | « ui/base/gtk/gtk_screen_util.h ('k') | ui/base/gtk/gtk_screen_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698