| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/gfx/screen.h" | |
| 6 | |
| 7 #include <X11/Xlib.h> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "ui/base/x/x11_util.h" | |
| 11 | |
| 12 #if !defined(USE_ASH) | |
| 13 | |
| 14 namespace gfx { | |
| 15 namespace { | |
| 16 gfx::Size Screen::GetPrimaryMonitorSize() { | |
| 17 ::Display* display = ui::GetXDisplay(); | |
| 18 ::Screen* screen = DefaultScreenOfDisplay(display); | |
| 19 int width = WidthOfScreen(screen); | |
| 20 int height = HeightOfScreen(screen); | |
| 21 | |
| 22 return gfx::Size(width, height); | |
| 23 } | |
| 24 } // namespace | |
| 25 | |
| 26 // TODO(piman,erg): This file needs to be rewritten by someone who understands | |
| 27 // the subtlety of X11. That is not erg. | |
| 28 | |
| 29 // static | |
| 30 gfx::Point Screen::GetCursorScreenPoint() { | |
| 31 Display* display = ui::GetXDisplay(); | |
| 32 | |
| 33 // Unsure if I can leave these as NULL. | |
| 34 ::Window root, child; | |
| 35 int root_x, root_y, win_x, win_y; | |
| 36 unsigned int mask; | |
| 37 XQueryPointer(display, | |
| 38 DefaultRootWindow(display), | |
| 39 &root, | |
| 40 &child, | |
| 41 &root_x, | |
| 42 &root_y, | |
| 43 &win_x, | |
| 44 &win_y, | |
| 45 &mask); | |
| 46 | |
| 47 return gfx::Point(root_x, root_y); | |
| 48 } | |
| 49 | |
| 50 // static | |
| 51 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { | |
| 52 // TODO(erg): I have no clue. May need collaboration with | |
| 53 // RootWindowHostLinux? | |
| 54 return NULL; | |
| 55 } | |
| 56 | |
| 57 // static | |
| 58 int Screen::GetNumMonitors() { | |
| 59 // TODO(erg): Figure this out with oshima or piman because I have no clue | |
| 60 // about the Xinerama implications here. | |
| 61 return 1; | |
| 62 } | |
| 63 | |
| 64 // static | |
| 65 Monitor Screen::GetMonitorNearestWindow(NativeWindow window) { | |
| 66 // TODO(erg): We need to eventually support multiple monitors. | |
| 67 return GetPrimaryMonitor(); | |
| 68 } | |
| 69 | |
| 70 // static | |
| 71 Monitor Screen::GetMonitorNearestPoint(const Point& point) { | |
| 72 // TODO(erg): We need to eventually support multiple monitors. | |
| 73 return GetPrimaryMonitor(); | |
| 74 } | |
| 75 | |
| 76 // static | |
| 77 Monitor Screen::GetPrimaryMonitor() { | |
| 78 // TODO(erg): There was a comment about how we shouldn't use _NET_WORKAREA | |
| 79 // for work area by danakj@. | |
| 80 // TODO(jamiewalch): Restrict work area to the actual work area of | |
| 81 // the monitor. | |
| 82 return Monitor(gfx::Rect(GetPrimaryMonitorSize())); | |
| 83 } | |
| 84 | |
| 85 // static | |
| 86 Monitor Screen::GetMonitorMatching(const gfx::Rect& match_rect) { | |
| 87 return GetPrimaryMonitor(); | |
| 88 } | |
| 89 | |
| 90 } // namespace gfx | |
| 91 #endif // !defined(USE_ASH) | |
| OLD | NEW |