OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "views/screen.h" | 5 #include "views/screen.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 // static | 52 // static |
53 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { | 53 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { |
54 GdkScreen* screen = gdk_screen_get_default(); | 54 GdkScreen* screen = gdk_screen_get_default(); |
55 gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y()); | 55 gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y()); |
56 GdkRectangle bounds; | 56 GdkRectangle bounds; |
57 gdk_screen_get_monitor_geometry(screen, monitor, &bounds); | 57 gdk_screen_get_monitor_geometry(screen, monitor, &bounds); |
58 return gfx::Rect(bounds); | 58 return gfx::Rect(bounds); |
59 } | 59 } |
60 | 60 |
| 61 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { |
| 62 GdkWindow* window = gdk_window_at_pointer(NULL, NULL); |
| 63 if (!window) |
| 64 return NULL; |
| 65 |
| 66 gpointer data = NULL; |
| 67 gdk_window_get_user_data(window, &data); |
| 68 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); |
| 69 if (!widget) |
| 70 return NULL; |
| 71 widget = gtk_widget_get_toplevel(widget); |
| 72 return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL; |
| 73 } |
| 74 |
61 } // namespace | 75 } // namespace |
62 | 76 |
OLD | NEW |