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/aura/remote_root_window_host_win.h" | |
6 | |
7 #include <windows.h> | |
8 | |
9 #include <algorithm> | |
10 | |
11 #include "base/message_loop.h" | |
12 #include "ui/aura/client/capture_client.h" | |
13 #include "ui/aura/env.h" | |
14 #include "ui/aura/root_window.h" | |
15 #include "ui/base/cursor/cursor_loader_win.h" | |
16 #include "ui/base/events/event.h" | |
17 #include "ui/base/view_prop.h" | |
18 | |
19 using std::max; | |
20 using std::min; | |
21 | |
22 namespace aura { | |
23 | |
24 namespace { | |
25 | |
26 const char* kRootWindowHostWinKey = "__AURA_REMOTE_ROOT_WINDOW_HOST_WIN__"; | |
27 | |
28 } // namespace | |
29 | |
30 RemoteRootWindowHostWin* g_instance = NULL; | |
31 | |
32 RemoteRootWindowHostWin* RemoteRootWindowHostWin::Instance() { | |
Ben Goodger (Google)
2012/10/04 15:48:30
This should be GetInstance() and create on first c
| |
33 return g_instance; | |
34 } | |
35 | |
36 RootWindow* RemoteRootWindowHostWin::CreateRootWindow( | |
Ben Goodger (Google)
2012/10/04 15:48:30
This function can go away per my comment in the mu
cpu_(ooo_6.6-7.5)
2012/10/04 19:57:56
See my comment on the multi-display-manager file.
| |
37 const gfx::Rect& bounds) { | |
38 RootWindow::CreateParams params(bounds); | |
39 g_instance = new RemoteRootWindowHostWin(NULL, bounds); | |
40 params.host = g_instance; | |
41 RootWindow* root = new RootWindow(params); | |
42 g_instance->delegate_ = root; | |
43 return root; | |
44 } | |
45 | |
46 RemoteRootWindowHostWin::RemoteRootWindowHostWin( | |
47 RootWindowHostDelegate* delegate, const gfx::Rect& bounds) | |
48 : delegate_(delegate) { | |
49 prop_.reset(new ui::ViewProp(NULL, kRootWindowHostWinKey, this)); | |
50 } | |
51 | |
52 RemoteRootWindowHostWin::~RemoteRootWindowHostWin() { | |
53 } | |
54 | |
55 RootWindow* RemoteRootWindowHostWin::GetRootWindow() { | |
56 return delegate_->AsRootWindow(); | |
57 } | |
58 | |
59 gfx::AcceleratedWidget RemoteRootWindowHostWin::GetAcceleratedWidget() { | |
60 // TODO(cpu): This is bad. Chrome's compositor needs a valid window | |
61 // initially and then later on we swap it. Since the compositor never | |
62 // uses this initial window we tell ourselves this hack is ok to get | |
63 // thing off the ground. | |
64 return ::GetDesktopWindow(); | |
65 } | |
66 | |
67 void RemoteRootWindowHostWin::Show() { | |
68 } | |
69 | |
70 void RemoteRootWindowHostWin::Hide() { | |
71 NOTIMPLEMENTED(); | |
72 } | |
73 | |
74 void RemoteRootWindowHostWin::ToggleFullScreen() { | |
75 } | |
76 | |
77 gfx::Rect RemoteRootWindowHostWin::GetBounds() const { | |
78 gfx::Rect r(gfx::Point(0,0), aura::RootWindowHost::GetNativeScreenSize()); | |
79 return r; | |
80 } | |
81 | |
82 void RemoteRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { | |
83 } | |
84 | |
85 gfx::Point RemoteRootWindowHostWin::GetLocationOnNativeScreen() const { | |
86 return gfx::Point(0, 0); | |
87 } | |
88 | |
89 void RemoteRootWindowHostWin::SetCursor(gfx::NativeCursor native_cursor) { | |
90 } | |
91 | |
92 void RemoteRootWindowHostWin::SetCapture() { | |
93 } | |
94 | |
95 void RemoteRootWindowHostWin::ReleaseCapture() { | |
96 } | |
97 | |
98 void RemoteRootWindowHostWin::ShowCursor(bool show) { | |
99 } | |
100 | |
101 bool RemoteRootWindowHostWin::QueryMouseLocation(gfx::Point* location_return) { | |
102 POINT pt; | |
103 GetCursorPos(&pt); | |
104 *location_return = | |
105 gfx::Point(static_cast<int>(pt.x), static_cast<int>(pt.y)); | |
106 return true; | |
107 } | |
108 | |
109 bool RemoteRootWindowHostWin::ConfineCursorToRootWindow() { | |
110 return true; | |
111 } | |
112 | |
113 bool RemoteRootWindowHostWin::GrabSnapshot( | |
114 const gfx::Rect& snapshot_bounds, | |
115 std::vector<unsigned char>* png_representation) { | |
116 NOTIMPLEMENTED(); | |
117 return false; | |
118 } | |
119 | |
120 void RemoteRootWindowHostWin::UnConfineCursor() { | |
121 } | |
122 | |
123 void RemoteRootWindowHostWin::MoveCursorTo(const gfx::Point& location) { | |
124 } | |
125 | |
126 void RemoteRootWindowHostWin::SetFocusWhenShown(bool focus_when_shown) { | |
127 NOTIMPLEMENTED(); | |
128 } | |
129 | |
130 void RemoteRootWindowHostWin::PostNativeEvent( | |
131 const base::NativeEvent& native_event) { | |
132 } | |
133 | |
134 void RemoteRootWindowHostWin::OnDeviceScaleFactorChanged( | |
135 float device_scale_factor) { | |
136 NOTIMPLEMENTED(); | |
137 } | |
138 | |
139 void RemoteRootWindowHostWin::PrepareForShutdown() { | |
140 NOTIMPLEMENTED(); | |
141 } | |
142 | |
143 void RemoteRootWindowHostWin::OnMouseMoved(int x, int y, int extra) { | |
144 gfx::Point location(x, y); | |
145 ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, 0); | |
146 delegate_->OnHostMouseEvent(&event); | |
147 } | |
148 | |
149 void RemoteRootWindowHostWin::OnMouseClick(int x, int y, int extra) { | |
150 gfx::Point location(x, y); | |
151 ui::EventType type = (extra == 1) ? | |
152 ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED; | |
153 ui::MouseEvent event(type, location, location, 0); | |
154 event.SetClickCount(1); | |
155 event.set_flags(ui::EF_LEFT_MOUSE_BUTTON); | |
156 delegate_->OnHostMouseEvent(&event); | |
157 } | |
158 | |
159 } // namespace aura | |
OLD | NEW |