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 <gdk/gdkx.h> | 7 #include <gdk/gdkx.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 GtkWindow* window = GTK_WINDOW(top_level); | 69 GtkWindow* window = GTK_WINDOW(top_level); |
70 GdkScreen* screen = gtk_window_get_screen(window); | 70 GdkScreen* screen = gtk_window_get_screen(window); |
71 gint monitor_num = gdk_screen_get_monitor_at_window(screen, | 71 gint monitor_num = gdk_screen_get_monitor_at_window(screen, |
72 top_level->window); | 72 top_level->window); |
73 GdkRectangle bounds; | 73 GdkRectangle bounds; |
74 gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds); | 74 gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds); |
75 return gfx::Rect(bounds); | 75 return gfx::Rect(bounds); |
76 } | 76 } |
77 | 77 |
78 // static | 78 // static |
| 79 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { |
| 80 // TODO(jamiewalch): Restrict this to the work area of the monitor. |
| 81 return GetMonitorAreaNearestPoint(point); |
| 82 } |
| 83 |
| 84 // static |
79 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { | 85 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { |
80 GdkScreen* screen = gdk_screen_get_default(); | 86 GdkScreen* screen = gdk_screen_get_default(); |
81 gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y()); | 87 gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y()); |
82 GdkRectangle bounds; | 88 GdkRectangle bounds; |
83 gdk_screen_get_monitor_geometry(screen, monitor, &bounds); | 89 gdk_screen_get_monitor_geometry(screen, monitor, &bounds); |
84 return gfx::Rect(bounds); | 90 return gfx::Rect(bounds); |
85 } | 91 } |
86 | 92 |
87 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { | 93 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { |
88 GdkWindow* window = gdk_window_at_pointer(NULL, NULL); | 94 GdkWindow* window = gdk_window_at_pointer(NULL, NULL); |
89 if (!window) | 95 if (!window) |
90 return NULL; | 96 return NULL; |
91 | 97 |
92 gpointer data = NULL; | 98 gpointer data = NULL; |
93 gdk_window_get_user_data(window, &data); | 99 gdk_window_get_user_data(window, &data); |
94 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); | 100 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); |
95 if (!widget) | 101 if (!widget) |
96 return NULL; | 102 return NULL; |
97 widget = gtk_widget_get_toplevel(widget); | 103 widget = gtk_widget_get_toplevel(widget); |
98 return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL; | 104 return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL; |
99 } | 105 } |
100 | 106 |
101 } // namespace | 107 } // namespace |
102 | 108 |
OLD | NEW |