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() { |
| 33 return g_instance; |
| 34 } |
| 35 |
| 36 RemoteRootWindowHostWin* RemoteRootWindowHostWin::Create( |
| 37 const gfx::Rect& bounds) { |
| 38 g_instance = new RemoteRootWindowHostWin(bounds); |
| 39 return g_instance; |
| 40 } |
| 41 |
| 42 RemoteRootWindowHostWin::RemoteRootWindowHostWin(const gfx::Rect& bounds) |
| 43 : delegate_(NULL) { |
| 44 prop_.reset(new ui::ViewProp(NULL, kRootWindowHostWinKey, this)); |
| 45 } |
| 46 |
| 47 RemoteRootWindowHostWin::~RemoteRootWindowHostWin() { |
| 48 } |
| 49 |
| 50 void RemoteRootWindowHostWin::SetDelegate(RootWindowHostDelegate* delegate) { |
| 51 delegate_ = delegate; |
| 52 } |
| 53 |
| 54 RootWindow* RemoteRootWindowHostWin::GetRootWindow() { |
| 55 return delegate_->AsRootWindow(); |
| 56 } |
| 57 |
| 58 gfx::AcceleratedWidget RemoteRootWindowHostWin::GetAcceleratedWidget() { |
| 59 // TODO(cpu): This is bad. Chrome's compositor needs a valid window |
| 60 // initially and then later on we swap it. Since the compositor never |
| 61 // uses this initial window we tell ourselves this hack is ok to get |
| 62 // thing off the ground. |
| 63 return ::GetDesktopWindow(); |
| 64 } |
| 65 |
| 66 void RemoteRootWindowHostWin::Show() { |
| 67 } |
| 68 |
| 69 void RemoteRootWindowHostWin::Hide() { |
| 70 NOTIMPLEMENTED(); |
| 71 } |
| 72 |
| 73 void RemoteRootWindowHostWin::ToggleFullScreen() { |
| 74 } |
| 75 |
| 76 gfx::Rect RemoteRootWindowHostWin::GetBounds() const { |
| 77 gfx::Rect r(gfx::Point(0, 0), aura::RootWindowHost::GetNativeScreenSize()); |
| 78 return r; |
| 79 } |
| 80 |
| 81 void RemoteRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { |
| 82 } |
| 83 |
| 84 gfx::Point RemoteRootWindowHostWin::GetLocationOnNativeScreen() const { |
| 85 return gfx::Point(0, 0); |
| 86 } |
| 87 |
| 88 void RemoteRootWindowHostWin::SetCursor(gfx::NativeCursor native_cursor) { |
| 89 } |
| 90 |
| 91 void RemoteRootWindowHostWin::SetCapture() { |
| 92 } |
| 93 |
| 94 void RemoteRootWindowHostWin::ReleaseCapture() { |
| 95 } |
| 96 |
| 97 void RemoteRootWindowHostWin::ShowCursor(bool show) { |
| 98 } |
| 99 |
| 100 bool RemoteRootWindowHostWin::QueryMouseLocation(gfx::Point* location_return) { |
| 101 POINT pt; |
| 102 GetCursorPos(&pt); |
| 103 *location_return = |
| 104 gfx::Point(static_cast<int>(pt.x), static_cast<int>(pt.y)); |
| 105 return true; |
| 106 } |
| 107 |
| 108 bool RemoteRootWindowHostWin::ConfineCursorToRootWindow() { |
| 109 return true; |
| 110 } |
| 111 |
| 112 bool RemoteRootWindowHostWin::GrabSnapshot( |
| 113 const gfx::Rect& snapshot_bounds, |
| 114 std::vector<unsigned char>* png_representation) { |
| 115 NOTIMPLEMENTED(); |
| 116 return false; |
| 117 } |
| 118 |
| 119 void RemoteRootWindowHostWin::UnConfineCursor() { |
| 120 } |
| 121 |
| 122 void RemoteRootWindowHostWin::MoveCursorTo(const gfx::Point& location) { |
| 123 } |
| 124 |
| 125 void RemoteRootWindowHostWin::SetFocusWhenShown(bool focus_when_shown) { |
| 126 NOTIMPLEMENTED(); |
| 127 } |
| 128 |
| 129 void RemoteRootWindowHostWin::PostNativeEvent( |
| 130 const base::NativeEvent& native_event) { |
| 131 } |
| 132 |
| 133 void RemoteRootWindowHostWin::OnDeviceScaleFactorChanged( |
| 134 float device_scale_factor) { |
| 135 NOTIMPLEMENTED(); |
| 136 } |
| 137 |
| 138 void RemoteRootWindowHostWin::PrepareForShutdown() { |
| 139 NOTIMPLEMENTED(); |
| 140 } |
| 141 |
| 142 void RemoteRootWindowHostWin::OnMouseMoved(int x, int y, int extra) { |
| 143 gfx::Point location(x, y); |
| 144 ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, 0); |
| 145 delegate_->OnHostMouseEvent(&event); |
| 146 } |
| 147 |
| 148 void RemoteRootWindowHostWin::OnMouseClick(int x, int y, int extra) { |
| 149 gfx::Point location(x, y); |
| 150 ui::EventType type = (extra == 1) ? |
| 151 ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED; |
| 152 ui::MouseEvent event(type, location, location, 0); |
| 153 event.SetClickCount(1); |
| 154 event.set_flags(ui::EF_LEFT_MOUSE_BUTTON); |
| 155 delegate_->OnHostMouseEvent(&event); |
| 156 } |
| 157 |
| 158 } // namespace aura |
| 159 |
OLD | NEW |