OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
11 | 11 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 // static | 74 // static |
75 gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) { | 75 gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) { |
76 GdkScreen* screen = gdk_screen_get_default(); | 76 GdkScreen* screen = gdk_screen_get_default(); |
77 gint monitor_num = 0; | 77 gint monitor_num = 0; |
78 if (view) { | 78 if (view) { |
79 GtkWidget* top_level = gtk_widget_get_toplevel(view); | 79 GtkWidget* top_level = gtk_widget_get_toplevel(view); |
80 DCHECK(GTK_IS_WINDOW(top_level)); | 80 DCHECK(GTK_IS_WINDOW(top_level)); |
81 GtkWindow* window = GTK_WINDOW(top_level); | 81 GtkWindow* window = GTK_WINDOW(top_level); |
82 screen = gtk_window_get_screen(window); | 82 screen = gtk_window_get_screen(window); |
83 monitor_num = gdk_screen_get_monitor_at_window(screen, top_level->window); | 83 monitor_num = gdk_screen_get_monitor_at_window( |
| 84 screen, |
| 85 gtk_widget_get_window(top_level)); |
84 } | 86 } |
85 GdkRectangle bounds; | 87 GdkRectangle bounds; |
86 gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds); | 88 gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds); |
87 return gfx::Rect(bounds); | 89 return gfx::Rect(bounds); |
88 } | 90 } |
89 | 91 |
90 // static | 92 // static |
91 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { | 93 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { |
92 // TODO(jamiewalch): Restrict this to the work area of the monitor. | 94 // TODO(jamiewalch): Restrict this to the work area of the monitor. |
93 return GetMonitorAreaNearestPoint(point); | 95 return GetMonitorAreaNearestPoint(point); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 151 |
150 // static | 152 // static |
151 int Screen::GetNumMonitors() { | 153 int Screen::GetNumMonitors() { |
152 // This query is kinda bogus for Linux -- do we want number of X screens? | 154 // This query is kinda bogus for Linux -- do we want number of X screens? |
153 // The number of monitors Xinerama has? We'll just use whatever GDK uses. | 155 // The number of monitors Xinerama has? We'll just use whatever GDK uses. |
154 GdkScreen* screen = gdk_screen_get_default(); | 156 GdkScreen* screen = gdk_screen_get_default(); |
155 return gdk_screen_get_n_monitors(screen); | 157 return gdk_screen_get_n_monitors(screen); |
156 } | 158 } |
157 | 159 |
158 } // namespace gfx | 160 } // namespace gfx |
OLD | NEW |