Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Unified Diff: ui/gfx/screen_gtk.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix new addition Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/screen_aura.cc ('k') | ui/gfx/screen_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/screen_gtk.cc
diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc
index 7b0b34c8cd06dc4a51c0f396e2653b97dbd6a854..30908ce41f1c7f6676e09c4293bf686741604fbf 100644
--- a/ui/gfx/screen_gtk.cc
+++ b/ui/gfx/screen_gtk.cc
@@ -71,90 +71,110 @@ gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view) {
return gfx::Rect(bounds);
}
-} // namespace
+class ScreenGtk : public gfx::Screen {
+ public:
+ ScreenGtk() {
+ }
-namespace gfx {
+ virtual ~ScreenGtk() {
+ }
-// static
-bool Screen::IsDIPEnabled() {
- return false;
-}
+ virtual bool IsDIPEnabled() OVERRIDE {
+ return false;
+ }
-// static
-gfx::Point Screen::GetCursorScreenPoint() {
- gint x, y;
- gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL);
- return gfx::Point(x, y);
-}
+ virtual gfx::Point GetCursorScreenPoint() OVERRIDE {
+ gint x, y;
+ gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL);
+ return gfx::Point(x, y);
+ }
-// static
-gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
- GdkWindow* window = gdk_window_at_pointer(NULL, NULL);
- if (!window)
- return NULL;
-
- gpointer data = NULL;
- gdk_window_get_user_data(window, &data);
- GtkWidget* widget = reinterpret_cast<GtkWidget*>(data);
- if (!widget)
- return NULL;
- widget = gtk_widget_get_toplevel(widget);
- return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL;
-}
+ // Returns the window under the cursor.
+ virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE {
+ GdkWindow* window = gdk_window_at_pointer(NULL, NULL);
+ if (!window)
+ return NULL;
+
+ gpointer data = NULL;
+ gdk_window_get_user_data(window, &data);
+ GtkWidget* widget = reinterpret_cast<GtkWidget*>(data);
+ if (!widget)
+ return NULL;
+ widget = gtk_widget_get_toplevel(widget);
+ return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL;
+ }
-// static
-gfx::Display Screen::GetDisplayNearestWindow(gfx::NativeView view) {
- gfx::Rect bounds = GetMonitorAreaNearestWindow(view);
- // Do not use the _NET_WORKAREA here, this is supposed to be an area on a
- // specific monitor, and _NET_WORKAREA is a hint from the WM that generally
- // spans across all monitors. This would make the work area larger than the
- // monitor.
- // TODO(danakj) This is a work-around as there is no standard way to get this
- // area, but it is a rect that we should be computing. The standard means
- // to compute this rect would be to watch all windows with
- // _NET_WM_STRUT(_PARTIAL) hints, and subtract their space from the physical
- // area of the display to construct a work area.
- // TODO(oshima): Implement ID and Observer.
- return gfx::Display(0, bounds);
-}
+ // Returns the number of displays.
+ // Mirrored displays are excluded; this method is intended to return the
+ // number of distinct, usable displays.
+ virtual int GetNumDisplays() OVERRIDE {
+ // This query is kinda bogus for Linux -- do we want number of X screens?
+ // The number of monitors Xinerama has? We'll just use whatever GDK uses.
+ GdkScreen* screen = gdk_screen_get_default();
+ return gdk_screen_get_n_monitors(screen);
+ }
-// static
-gfx::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) {
- GdkScreen* screen = gdk_screen_get_default();
- gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y());
- GdkRectangle bounds;
- gdk_screen_get_monitor_geometry(screen, monitor, &bounds);
- // TODO(oshima): Implement ID and Observer.
- return gfx::Display(0, gfx::Rect(bounds));
-}
+ // Returns the display nearest the specified window.
+ virtual gfx::Display GetDisplayNearestWindow(
+ gfx::NativeView view) const OVERRIDE {
+ gfx::Rect bounds = GetMonitorAreaNearestWindow(view);
+ // Do not use the _NET_WORKAREA here, this is supposed to be an area on a
+ // specific monitor, and _NET_WORKAREA is a hint from the WM that
+ // generally spans across all monitors. This would make the work area
+ // larger than the monitor.
+ // TODO(danakj) This is a work-around as there is no standard way to get
+ // this area, but it is a rect that we should be computing. The standard
+ // means to compute this rect would be to watch all windows with
+ // _NET_WM_STRUT(_PARTIAL) hints, and subtract their space from the
+ // physical area of the display to construct a work area.
+ // TODO(oshima): Implement ID and Observer.
+ return gfx::Display(0, bounds);
+ }
-// static
-gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) {
- // TODO(thestig) Implement multi-monitor support.
- return GetPrimaryDisplay();
-}
+ // Returns the the display nearest the specified point.
+ virtual gfx::Display GetDisplayNearestPoint(
+ const gfx::Point& point) const OVERRIDE {
+ GdkScreen* screen = gdk_screen_get_default();
+ gint monitor = gdk_screen_get_monitor_at_point(
+ screen, point.x(), point.y());
+ GdkRectangle bounds;
+ gdk_screen_get_monitor_geometry(screen, monitor, &bounds);
+ // TODO(oshima): Implement ID and Observer.
+ return gfx::Display(0, gfx::Rect(bounds));
+ }
-// static
-gfx::Display Screen::GetPrimaryDisplay() {
- gfx::Rect bounds = NativePrimaryMonitorBounds();
- // TODO(oshima): Implement ID and Observer.
- gfx::Display display(0, bounds);
- gfx::Rect rect;
- if (GetScreenWorkArea(&rect)) {
- display.set_work_area(rect.Intersect(bounds));
- } else {
- // Return the best we've got.
- display.set_work_area(bounds);
+ // Returns the display that most closely intersects the provided bounds.
+ virtual gfx::Display GetDisplayMatching(
+ const gfx::Rect& match_rect) const OVERRIDE {
+ // TODO(thestig) Implement multi-monitor support.
+ return GetPrimaryDisplay();
}
- return display;
-}
-// static
-int Screen::GetNumDisplays() {
- // This query is kinda bogus for Linux -- do we want number of X screens?
- // The number of monitors Xinerama has? We'll just use whatever GDK uses.
- GdkScreen* screen = gdk_screen_get_default();
- return gdk_screen_get_n_monitors(screen);
+ // Returns the primary display.
+ virtual gfx::Display GetPrimaryDisplay() const OVERRIDE {
+ gfx::Rect bounds = NativePrimaryMonitorBounds();
+ // TODO(oshima): Implement ID and Observer.
+ gfx::Display display(0, bounds);
+ gfx::Rect rect;
+ if (GetScreenWorkArea(&rect)) {
+ display.set_work_area(rect.Intersect(bounds));
+ } else {
+ // Return the best we've got.
+ display.set_work_area(bounds);
+ }
+ return display;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScreenGtk);
+};
+
+} // namespace
+
+namespace gfx {
+
+Screen* CreateNativeScreen() {
+ return new ScreenGtk;
}
} // namespace gfx
« no previous file with comments | « ui/gfx/screen_aura.cc ('k') | ui/gfx/screen_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698