OLD | NEW |
1 // Copyright (c) 2012 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" |
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( | 83 monitor_num = gdk_screen_get_monitor_at_window(screen, top_level->window); |
84 screen, | |
85 gtk_widget_get_window(top_level)); | |
86 } | 84 } |
87 GdkRectangle bounds; | 85 GdkRectangle bounds; |
88 gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds); | 86 gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds); |
89 return gfx::Rect(bounds); | 87 return gfx::Rect(bounds); |
90 } | 88 } |
91 | 89 |
92 // static | 90 // static |
93 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { | 91 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { |
94 // TODO(jamiewalch): Restrict this to the work area of the monitor. | 92 // TODO(jamiewalch): Restrict this to the work area of the monitor. |
95 return GetMonitorAreaNearestPoint(point); | 93 return GetMonitorAreaNearestPoint(point); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 149 |
152 // static | 150 // static |
153 int Screen::GetNumMonitors() { | 151 int Screen::GetNumMonitors() { |
154 // This query is kinda bogus for Linux -- do we want number of X screens? | 152 // This query is kinda bogus for Linux -- do we want number of X screens? |
155 // The number of monitors Xinerama has? We'll just use whatever GDK uses. | 153 // The number of monitors Xinerama has? We'll just use whatever GDK uses. |
156 GdkScreen* screen = gdk_screen_get_default(); | 154 GdkScreen* screen = gdk_screen_get_default(); |
157 return gdk_screen_get_n_monitors(screen); | 155 return gdk_screen_get_n_monitors(screen); |
158 } | 156 } |
159 | 157 |
160 } // namespace gfx | 158 } // namespace gfx |
OLD | NEW |