| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/base/gtk/gtk_screen_util.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 namespace ui { |
| 10 |
| 11 bool IsScreenComposited() { |
| 12 GdkScreen* screen = gdk_screen_get_default(); |
| 13 return gdk_screen_is_composited(screen) == TRUE; |
| 14 } |
| 15 |
| 16 gfx::Point ScreenPoint(GtkWidget* widget) { |
| 17 int x, y; |
| 18 gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y, |
| 19 NULL); |
| 20 return gfx::Point(x, y); |
| 21 } |
| 22 |
| 23 gfx::Point ClientPoint(GtkWidget* widget) { |
| 24 int x, y; |
| 25 gtk_widget_get_pointer(widget, &x, &y); |
| 26 return gfx::Point(x, y); |
| 27 } |
| 28 |
| 29 gfx::Point GetWidgetScreenPosition(GtkWidget* widget) { |
| 30 GdkWindow* window = gtk_widget_get_window(widget); |
| 31 |
| 32 if (!window) { |
| 33 NOTREACHED() << "Must only be called on realized widgets."; |
| 34 return gfx::Point(0, 0); |
| 35 } |
| 36 |
| 37 gint x, y; |
| 38 gdk_window_get_origin(window, &x, &y); |
| 39 |
| 40 if (!gtk_widget_get_has_window(widget)) { |
| 41 GtkAllocation allocation; |
| 42 gtk_widget_get_allocation(widget, &allocation); |
| 43 x += allocation.x; |
| 44 y += allocation.y; |
| 45 } |
| 46 |
| 47 return gfx::Point(x, y); |
| 48 } |
| 49 |
| 50 gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) { |
| 51 gfx::Point position = GetWidgetScreenPosition(widget); |
| 52 |
| 53 GtkAllocation allocation; |
| 54 gtk_widget_get_allocation(widget, &allocation); |
| 55 |
| 56 return gfx::Rect(position.x(), position.y(), |
| 57 allocation.width, allocation.height); |
| 58 } |
| 59 |
| 60 } // namespace ui |
| OLD | NEW |