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

Side by Side Diff: ui/gfx/screen_aurax11.cc

Issue 9960042: Refactor screen/monitor so that gfx::Screen returns monitor object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/screen_aura.cc ('k') | ui/gfx/screen_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/base/x/x11_util.h" 10 #include "ui/base/x/x11_util.h"
11 11
12 #if !defined(USE_ASH) 12 #if !defined(USE_ASH)
13 13
14 namespace gfx { 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
15 25
16 // TODO(piman,erg): This file needs to be rewritten by someone who understands 26 // TODO(piman,erg): This file needs to be rewritten by someone who understands
17 // the subtlety of X11. That is not erg. 27 // the subtlety of X11. That is not erg.
18 28
29 // static
19 gfx::Point Screen::GetCursorScreenPoint() { 30 gfx::Point Screen::GetCursorScreenPoint() {
20 Display* display = ui::GetXDisplay(); 31 Display* display = ui::GetXDisplay();
21 32
22 // Unsure if I can leave these as NULL. 33 // Unsure if I can leave these as NULL.
23 ::Window root, child; 34 ::Window root, child;
24 int root_x, root_y, win_x, win_y; 35 int root_x, root_y, win_x, win_y;
25 unsigned int mask; 36 unsigned int mask;
26 XQueryPointer(display, 37 XQueryPointer(display,
27 DefaultRootWindow(display), 38 DefaultRootWindow(display),
28 &root, 39 &root,
29 &child, 40 &child,
30 &root_x, 41 &root_x,
31 &root_y, 42 &root_y,
32 &win_x, 43 &win_x,
33 &win_y, 44 &win_y,
34 &mask); 45 &mask);
35 46
36 return gfx::Point(root_x, root_y); 47 return gfx::Point(root_x, root_y);
37 } 48 }
38 49
39 gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(
40 gfx::NativeView view) {
41 // TODO(erg): There was a comment about how we shouldn't use _NET_WORKAREA
42 // here by danakj@.
43 return GetMonitorAreaNearestWindow(view);
44 }
45
46 gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) {
47 // TODO(erg): Yet another stub.
48 return GetPrimaryMonitorBounds();
49 }
50
51 // static 50 // static
52 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) {
53 // TODO(jamiewalch): Restrict this to the work area of the monitor.
54 return GetMonitorAreaNearestPoint(point);
55 }
56
57 // static
58 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
59 // TODO(erg): gdk actually has a description for this! We can implement this
60 // one.
61 return GetPrimaryMonitorBounds();
62 }
63
64 gfx::Rect Screen::GetPrimaryMonitorWorkArea() {
65 // TODO(erg): Also needs a real implementation.
66 return gfx::Rect(gfx::Point(0, 0), GetPrimaryMonitorSize());
67 }
68
69 gfx::Rect Screen::GetPrimaryMonitorBounds() {
70 // TODO(erg): Probably needs to be smarter?
71 return gfx::Rect(gfx::Point(0, 0), GetPrimaryMonitorSize());
72 }
73
74 gfx::Rect Screen::GetMonitorWorkAreaMatching(const gfx::Rect& match_rect) {
75 // TODO(erg): We need to eventually support multiple monitors.
76 return GetPrimaryMonitorWorkArea();
77 }
78
79 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { 51 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
80 // TODO(erg): I have no clue. May need collaboration with 52 // TODO(erg): I have no clue. May need collaboration with
81 // RootWindowHostLinux? 53 // RootWindowHostLinux?
82 return NULL; 54 return NULL;
83 } 55 }
84 56
85 gfx::Size Screen::GetPrimaryMonitorSize() { 57 // static
86 ::Display* display = ui::GetXDisplay();
87 ::Screen* screen = DefaultScreenOfDisplay(display);
88 int width = WidthOfScreen(screen);
89 int height = HeightOfScreen(screen);
90
91 return gfx::Size(width, height);
92 }
93
94 int Screen::GetNumMonitors() { 58 int Screen::GetNumMonitors() {
95 // TODO(erg): Figure this out with oshima or piman because I have no clue 59 // TODO(erg): Figure this out with oshima or piman because I have no clue
96 // about the Xinerama implications here. 60 // about the Xinerama implications here.
97 return 1; 61 return 1;
98 } 62 }
99 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
100 } // namespace gfx 90 } // namespace gfx
101
102 #endif // !defined(USE_ASH) 91 #endif // !defined(USE_ASH)
OLDNEW
« no previous file with comments | « ui/gfx/screen_aura.cc ('k') | ui/gfx/screen_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698