OLD | NEW |
1 // Copyright (c) 2012 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" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 namespace gfx { | 76 namespace gfx { |
77 | 77 |
78 // static | 78 // static |
79 bool Screen::IsDIPEnabled() { | 79 bool Screen::IsDIPEnabled() { |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 // static | 83 // static |
84 gfx::Point Screen::GetCursorScreenPoint() { | 84 gfx::Point Screen::GetCursorScreenPoint(gfx::NativeView context) { |
85 gint x, y; | 85 gint x, y; |
86 gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL); | 86 gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL); |
87 return gfx::Point(x, y); | 87 return gfx::Point(x, y); |
88 } | 88 } |
89 | 89 |
90 // static | 90 // static |
91 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { | 91 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint( |
| 92 gfx::NativeView context) { |
92 GdkWindow* window = gdk_window_at_pointer(NULL, NULL); | 93 GdkWindow* window = gdk_window_at_pointer(NULL, NULL); |
93 if (!window) | 94 if (!window) |
94 return NULL; | 95 return NULL; |
95 | 96 |
96 gpointer data = NULL; | 97 gpointer data = NULL; |
97 gdk_window_get_user_data(window, &data); | 98 gdk_window_get_user_data(window, &data); |
98 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); | 99 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); |
99 if (!widget) | 100 if (!widget) |
100 return NULL; | 101 return NULL; |
101 widget = gtk_widget_get_toplevel(widget); | 102 widget = gtk_widget_get_toplevel(widget); |
(...skipping 10 matching lines...) Expand all Loading... |
112 // TODO(danakj) This is a work-around as there is no standard way to get this | 113 // TODO(danakj) This is a work-around as there is no standard way to get this |
113 // area, but it is a rect that we should be computing. The standard means | 114 // area, but it is a rect that we should be computing. The standard means |
114 // to compute this rect would be to watch all windows with | 115 // to compute this rect would be to watch all windows with |
115 // _NET_WM_STRUT(_PARTIAL) hints, and subtract their space from the physical | 116 // _NET_WM_STRUT(_PARTIAL) hints, and subtract their space from the physical |
116 // area of the display to construct a work area. | 117 // area of the display to construct a work area. |
117 // TODO(oshima): Implement ID and Observer. | 118 // TODO(oshima): Implement ID and Observer. |
118 return gfx::Display(0, bounds); | 119 return gfx::Display(0, bounds); |
119 } | 120 } |
120 | 121 |
121 // static | 122 // static |
122 gfx::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) { | 123 gfx::Display Screen::GetDisplayNearestPoint( |
| 124 gfx::NativeView context, const gfx::Point& point) { |
123 GdkScreen* screen = gdk_screen_get_default(); | 125 GdkScreen* screen = gdk_screen_get_default(); |
124 gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y()); | 126 gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y()); |
125 GdkRectangle bounds; | 127 GdkRectangle bounds; |
126 gdk_screen_get_monitor_geometry(screen, monitor, &bounds); | 128 gdk_screen_get_monitor_geometry(screen, monitor, &bounds); |
127 // TODO(oshima): Implement ID and Observer. | 129 // TODO(oshima): Implement ID and Observer. |
128 return gfx::Display(0, gfx::Rect(bounds)); | 130 return gfx::Display(0, gfx::Rect(bounds)); |
129 } | 131 } |
130 | 132 |
131 // static | 133 // static |
132 gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { | 134 gfx::Display Screen::GetDisplayMatching( |
| 135 gfx::NativeView context, const gfx::Rect& match_rect) { |
133 // TODO(thestig) Implement multi-monitor support. | 136 // TODO(thestig) Implement multi-monitor support. |
134 return GetPrimaryDisplay(); | 137 return GetPrimaryDisplay(); |
135 } | 138 } |
136 | 139 |
137 // static | 140 // static |
138 gfx::Display Screen::GetPrimaryDisplay() { | 141 gfx::Display Screen::GetPrimaryDisplay(gfx::NativeView context) { |
139 gfx::Rect bounds = NativePrimaryMonitorBounds(); | 142 gfx::Rect bounds = NativePrimaryMonitorBounds(); |
140 // TODO(oshima): Implement ID and Observer. | 143 // TODO(oshima): Implement ID and Observer. |
141 gfx::Display display(0, bounds); | 144 gfx::Display display(0, bounds); |
142 gfx::Rect rect; | 145 gfx::Rect rect; |
143 if (GetScreenWorkArea(&rect)) { | 146 if (GetScreenWorkArea(&rect)) { |
144 display.set_work_area(rect.Intersect(bounds)); | 147 display.set_work_area(rect.Intersect(bounds)); |
145 } else { | 148 } else { |
146 // Return the best we've got. | 149 // Return the best we've got. |
147 display.set_work_area(bounds); | 150 display.set_work_area(bounds); |
148 } | 151 } |
149 return display; | 152 return display; |
150 } | 153 } |
151 | 154 |
152 // static | 155 // static |
153 int Screen::GetNumDisplays() { | 156 int Screen::GetNumDisplays(gfx::NativeView context) { |
154 // This query is kinda bogus for Linux -- do we want number of X screens? | 157 // 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. | 158 // The number of monitors Xinerama has? We'll just use whatever GDK uses. |
156 GdkScreen* screen = gdk_screen_get_default(); | 159 GdkScreen* screen = gdk_screen_get_default(); |
157 return gdk_screen_get_n_monitors(screen); | 160 return gdk_screen_get_n_monitors(screen); |
158 } | 161 } |
159 | 162 |
160 } // namespace gfx | 163 } // namespace gfx |
OLD | NEW |