| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "ui/gfx/screen.h" | 5 #include "ui/gfx/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { | 58 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { |
| 59 GdkScreen* screen = gdk_screen_get_default(); | 59 GdkScreen* screen = gdk_screen_get_default(); |
| 60 gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y()); | 60 gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y()); |
| 61 GdkRectangle bounds; | 61 GdkRectangle bounds; |
| 62 gdk_screen_get_monitor_geometry(screen, monitor, &bounds); | 62 gdk_screen_get_monitor_geometry(screen, monitor, &bounds); |
| 63 return gfx::Rect(bounds); | 63 return gfx::Rect(bounds); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // static |
| 66 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { | 67 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { |
| 67 GdkWindow* window = gdk_window_at_pointer(NULL, NULL); | 68 GdkWindow* window = gdk_window_at_pointer(NULL, NULL); |
| 68 if (!window) | 69 if (!window) |
| 69 return NULL; | 70 return NULL; |
| 70 | 71 |
| 71 gpointer data = NULL; | 72 gpointer data = NULL; |
| 72 gdk_window_get_user_data(window, &data); | 73 gdk_window_get_user_data(window, &data); |
| 73 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); | 74 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); |
| 74 if (!widget) | 75 if (!widget) |
| 75 return NULL; | 76 return NULL; |
| 76 widget = gtk_widget_get_toplevel(widget); | 77 widget = gtk_widget_get_toplevel(widget); |
| 77 return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL; | 78 return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL; |
| 78 } | 79 } |
| 79 | 80 |
| 81 // static |
| 82 gfx::Size Screen::GetPrimaryMonitorSize() { |
| 83 GdkScreen* screen = gdk_screen_get_default(); |
| 84 return gfx::Size(gdk_screen_get_width(screen), gdk_screen_get_height(screen)); |
| 85 } |
| 86 |
| 87 // static |
| 88 int Screen::GetNumMonitors() { |
| 89 // This query is kinda bogus for Linux -- do we want number of X screens? |
| 90 // The number of monitors Xinerama has? We'll just use whatever GDK uses. |
| 91 GdkScreen* screen = gdk_screen_get_default(); |
| 92 return gdk_screen_get_n_monitors(screen); |
| 93 } |
| 94 |
| 80 } // namespace gfx | 95 } // namespace gfx |
| OLD | NEW |