1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// Copyright (c) 2012 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/aura/desktop/desktop_screen.h"
#include <X11/Xlib.h>
// It clashes with out RootWindow.
#undef RootWindow
#include "base/logging.h"
#include "ui/aura/root_window.h"
#include "ui/aura/root_window_host.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/display.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/screen_impl.h"
namespace {
// TODO(erg): This method is a temporary hack, until we can reliably extract
// location data out of XRandR.
gfx::Size GetPrimaryDisplaySize() {
::Display* display = ui::GetXDisplay();
::Screen* screen = DefaultScreenOfDisplay(display);
int width = WidthOfScreen(screen);
int height = HeightOfScreen(screen);
return gfx::Size(width, height);
}
class DesktopScreenX11 : public gfx::ScreenImpl {
public:
DesktopScreenX11();
virtual ~DesktopScreenX11();
// Overridden from gfx::ScreenImpl:
virtual gfx::Point GetCursorScreenPoint() OVERRIDE;
virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE;
virtual int GetNumDisplays() OVERRIDE;
virtual gfx::Display GetDisplayNearestWindow(
gfx::NativeView window) const OVERRIDE;
virtual gfx::Display GetDisplayNearestPoint(
const gfx::Point& point) const OVERRIDE;
virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11);
};
////////////////////////////////////////////////////////////////////////////////
// DesktopScreenX11, public:
DesktopScreenX11::DesktopScreenX11() {
}
DesktopScreenX11::~DesktopScreenX11() {
}
////////////////////////////////////////////////////////////////////////////////
// DesktopScreenX11, gfx::ScreenImpl implementation:
gfx::Point DesktopScreenX11::GetCursorScreenPoint() {
Display* display = ui::GetXDisplay();
::Window root, child;
int root_x, root_y, win_x, win_y;
unsigned int mask;
XQueryPointer(display,
DefaultRootWindow(display),
&root,
&child,
&root_x,
&root_y,
&win_x,
&win_y,
&mask);
return gfx::Point(root_x, root_y);
}
gfx::NativeWindow DesktopScreenX11::GetWindowAtCursorScreenPoint() {
// TODO(erg): Implement using the discussion at
// http://codereview.chromium.org/10279005/
return NULL;
}
int DesktopScreenX11::GetNumDisplays() {
// TODO(erg): Figure this out with oshima or piman because I have no clue
// about the XRandR implications here.
return 1;
}
gfx::Display DesktopScreenX11::GetDisplayNearestWindow(
gfx::NativeView window) const {
// TODO(erg): Do the right thing once we know what that is.
return gfx::Display(0, gfx::Rect(GetPrimaryDisplaySize()));
}
gfx::Display DesktopScreenX11::GetDisplayNearestPoint(
const gfx::Point& point) const {
// TODO(erg): Do the right thing once we know what that is.
return gfx::Display(0, gfx::Rect(GetPrimaryDisplaySize()));
}
gfx::Display DesktopScreenX11::GetPrimaryDisplay() const {
// TODO(erg): Do the right thing once we know what that is.
return gfx::Display(0, gfx::Rect(GetPrimaryDisplaySize()));
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
namespace aura {
gfx::ScreenImpl* CreateDesktopScreen() {
return new DesktopScreenX11;
}
} // namespace aura
|