summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authorcsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-23 01:15:57 +0000
committercsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-23 01:15:57 +0000
commit1e218739ae3350c2932a34a6087d539eac65ed1d (patch)
tree5fbebafabb1bd4be146bcaa2928ff8b9ccef1d72 /ui/gfx
parent3b721d82c2d49058a30bd20afb03652b38c59e91 (diff)
downloadchromium_src-1e218739ae3350c2932a34a6087d539eac65ed1d.zip
chromium_src-1e218739ae3350c2932a34a6087d539eac65ed1d.tar.gz
chromium_src-1e218739ae3350c2932a34a6087d539eac65ed1d.tar.bz2
Revert 93744 - 2nd try. added UI_API to Screen class.
Move screen.h to ui/gfx because Screen doesn't depend on views, and they're useful outside views. BUG=none TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=93724 Review URL: http://codereview.chromium.org/7483014 TBR=oshima@google.com Review URL: http://codereview.chromium.org/7488035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/screen.h41
-rw-r--r--ui/gfx/screen_gtk.cc107
-rw-r--r--ui/gfx/screen_win.cc62
3 files changed, 0 insertions, 210 deletions
diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h
deleted file mode 100644
index 53b99fc..0000000
--- a/ui/gfx/screen.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_GFX_SCREEN_H_
-#define UI_GFX_SCREEN_H_
-#pragma once
-
-#include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/point.h"
-#include "ui/gfx/rect.h"
-
-namespace gfx {
-
-// A utility class for getting various info about screen size, monitors,
-// cursor position, etc.
-// TODO(erikkay) add more of those methods here
-class UI_API Screen {
- public:
- static gfx::Point GetCursorScreenPoint();
-
- // Returns the work area of the monitor nearest the specified window.
- static gfx::Rect GetMonitorWorkAreaNearestWindow(gfx::NativeView view);
-
- // Returns the bounds of the monitor nearest the specified window.
- static gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view);
-
- // Returns the work area of the monitor nearest the specified point.
- static gfx::Rect GetMonitorWorkAreaNearestPoint(const gfx::Point& point);
-
- // Returns the monitor area (not the work area, but the complete bounds) of
- // the monitor nearest the specified point.
- static gfx::Rect GetMonitorAreaNearestPoint(const gfx::Point& point);
-
- // Returns the window under the cursor.
- static gfx::NativeWindow GetWindowAtCursorScreenPoint();
-};
-
-} // namespace gfx
-
-#endif // VIEWS_SCREEN_H_
diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc
deleted file mode 100644
index bb71da5..0000000
--- a/ui/gfx/screen_gtk.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/screen.h"
-
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-#include "base/logging.h"
-
-namespace gfx {
-
-// 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);
-}
-
-gfx::Rect static GetPrimaryMonitorBounds() {
- guchar* raw_data = NULL;
- gint data_len = 0;
- gboolean success = gdk_property_get(gdk_get_default_root_window(),
- gdk_atom_intern("_NET_WORKAREA", FALSE),
- gdk_atom_intern("CARDINAL", FALSE),
- 0, 0xFF, false, NULL, NULL, &data_len,
- &raw_data);
- int top_left_x = 0;
- int top_left_y = 0;
- int width = 0;
- int height = 0;
-
- if (success) {
- glong* data = reinterpret_cast<glong*>(raw_data);
- top_left_x = data[0];
- top_left_y = data[1];
- width = data[2];
- height = data[3];
- g_free(raw_data);
- } else {
- // If there's no window manager, we can ask X for Monitor info directly.
- XWindowAttributes attributes;
- Status status = XGetWindowAttributes(gdk_x11_get_default_xdisplay(),
- gdk_x11_get_default_root_xwindow(),
- &attributes);
- if (status) {
- top_left_x = attributes.x;
- top_left_y = attributes.y;
- width = attributes.width;
- height = attributes.height;
- success = true;
- }
- }
- DCHECK(success);
- return gfx::Rect(top_left_x, top_left_y, width, height);
-}
-
-// static
-gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeView view) {
- // TODO(beng): use |view|.
- return GetPrimaryMonitorBounds();
-}
-
-// static
-gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) {
- GtkWidget* top_level = gtk_widget_get_toplevel(view);
- DCHECK(GTK_IS_WINDOW(top_level));
- GtkWindow* window = GTK_WINDOW(top_level);
- GdkScreen* screen = gtk_window_get_screen(window);
- gint monitor_num = gdk_screen_get_monitor_at_window(screen,
- top_level->window);
- GdkRectangle bounds;
- gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds);
- return gfx::Rect(bounds);
-}
-
-// static
-gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) {
- // TODO(jamiewalch): Restrict this to the work area of the monitor.
- return GetMonitorAreaNearestPoint(point);
-}
-
-// static
-gfx::Rect Screen::GetMonitorAreaNearestPoint(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);
- return gfx::Rect(bounds);
-}
-
-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;
-}
-
-} // namespace gfx
diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc
deleted file mode 100644
index 530cebe..0000000
--- a/ui/gfx/screen_win.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/screen.h"
-
-#include <windows.h>
-
-namespace gfx {
-
-// static
-gfx::Point Screen::GetCursorScreenPoint() {
- POINT pt;
- GetCursorPos(&pt);
- return gfx::Point(pt);
-}
-
-// static
-gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) {
- MONITORINFO monitor_info;
- monitor_info.cbSize = sizeof(monitor_info);
- GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST),
- &monitor_info);
- return gfx::Rect(monitor_info.rcWork);
-}
-
-// static
-gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) {
- MONITORINFO monitor_info;
- monitor_info.cbSize = sizeof(monitor_info);
- GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST),
- &monitor_info);
- return gfx::Rect(monitor_info.rcMonitor);
-}
-
-static gfx::Rect GetMonitorAreaOrWorkAreaNearestPoint(const gfx::Point& point,
- bool work_area) {
- POINT initial_loc = { point.x(), point.y() };
- HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi = {0};
- mi.cbSize = sizeof(mi);
- if (monitor && GetMonitorInfo(monitor, &mi))
- return gfx::Rect(work_area ? mi.rcWork : mi.rcMonitor);
- return gfx::Rect();
-}
-
-// static
-gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) {
- return GetMonitorAreaOrWorkAreaNearestPoint(point, true);
-}
-
-// static
-gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
- return GetMonitorAreaOrWorkAreaNearestPoint(point, false);
-}
-
-gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
- POINT location;
- return GetCursorPos(&location) ? WindowFromPoint(location) : NULL;
-}
-
-} // namespace gfx