| OLD | NEW |
| 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/aura/remote_window_tree_host_win.h" | 5 #include "ui/aura/remote_window_tree_host_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 void HandleMetroExit() { | 145 void HandleMetroExit() { |
| 146 DCHECK(aura::RemoteWindowTreeHostWin::Instance()); | 146 DCHECK(aura::RemoteWindowTreeHostWin::Instance()); |
| 147 aura::RemoteWindowTreeHostWin::Instance()->HandleMetroExit(); | 147 aura::RemoteWindowTreeHostWin::Instance()->HandleMetroExit(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 RemoteWindowTreeHostWin* g_instance = NULL; | 150 RemoteWindowTreeHostWin* g_instance = NULL; |
| 151 | 151 |
| 152 // static | 152 // static |
| 153 RemoteWindowTreeHostWin* RemoteWindowTreeHostWin::Instance() { | 153 RemoteWindowTreeHostWin* RemoteWindowTreeHostWin::Instance() { |
| 154 if (!g_instance) | |
| 155 g_instance = new RemoteWindowTreeHostWin(gfx::Rect()); | |
| 156 return g_instance; | 154 return g_instance; |
| 157 } | 155 } |
| 158 | 156 |
| 159 // static | 157 RemoteWindowTreeHostWin::RemoteWindowTreeHostWin() |
| 160 void RemoteWindowTreeHostWin::SetInstance(RemoteWindowTreeHostWin* instance) { | |
| 161 CHECK(!g_instance); | |
| 162 g_instance = instance; | |
| 163 } | |
| 164 | |
| 165 RemoteWindowTreeHostWin::RemoteWindowTreeHostWin(const gfx::Rect& bounds) | |
| 166 : remote_window_(NULL), | 158 : remote_window_(NULL), |
| 167 host_(NULL), | 159 host_(NULL), |
| 168 ignore_mouse_moves_until_set_cursor_ack_(false), | 160 ignore_mouse_moves_until_set_cursor_ack_(false), |
| 169 event_flags_(0), | 161 event_flags_(0), |
| 170 window_size_(aura::WindowTreeHost::GetNativeScreenSize()) { | 162 window_size_(aura::WindowTreeHost::GetNativeScreenSize()) { |
| 163 CHECK(!g_instance); |
| 164 g_instance = this; |
| 171 prop_.reset(new ui::ViewProp(NULL, kWindowTreeHostWinKey, this)); | 165 prop_.reset(new ui::ViewProp(NULL, kWindowTreeHostWinKey, this)); |
| 172 CreateCompositor(GetAcceleratedWidget()); | 166 CreateCompositor(GetAcceleratedWidget()); |
| 173 } | 167 } |
| 174 | 168 |
| 175 RemoteWindowTreeHostWin::~RemoteWindowTreeHostWin() { | 169 RemoteWindowTreeHostWin::~RemoteWindowTreeHostWin() { |
| 176 DestroyCompositor(); | 170 DestroyCompositor(); |
| 177 DestroyDispatcher(); | 171 DestroyDispatcher(); |
| 172 DCHECK_EQ(g_instance, this); |
| 178 g_instance = NULL; | 173 g_instance = NULL; |
| 179 } | 174 } |
| 180 | 175 |
| 181 // static | 176 // static |
| 182 bool RemoteWindowTreeHostWin::IsValid() { | 177 bool RemoteWindowTreeHostWin::IsValid() { |
| 183 return Instance()->remote_window_ != NULL; | 178 return Instance()->remote_window_ != NULL; |
| 184 } | 179 } |
| 185 | 180 |
| 186 void RemoteWindowTreeHostWin::InitializeRemoteWindowAndScaleFactor( | 181 void RemoteWindowTreeHostWin::SetRemoteWindowHandle(HWND remote_window) { |
| 187 HWND remote_window, | |
| 188 float device_scale) { | |
| 189 remote_window_ = remote_window; | 182 remote_window_ = remote_window; |
| 190 gfx::InitDeviceScaleFactor(device_scale); | |
| 191 // Do not create compositor here, but in Connected() below. | |
| 192 // See http://crbug.com/330179 and http://crbug.com/334380. | |
| 193 } | 183 } |
| 194 | 184 |
| 195 void RemoteWindowTreeHostWin::Connected(IPC::Sender* host) { | 185 void RemoteWindowTreeHostWin::Connected(IPC::Sender* host) { |
| 196 CHECK(host_ == NULL); | 186 CHECK(host_ == NULL); |
| 197 DCHECK(remote_window_); | 187 DCHECK(remote_window_); |
| 198 host_ = host; | 188 host_ = host; |
| 199 // Recreate the compositor for the target surface represented by the | 189 // Recreate the compositor for the target surface represented by the |
| 200 // remote_window HWND. | 190 // remote_window HWND. |
| 201 CreateCompositor(remote_window_); | 191 CreateCompositor(remote_window_); |
| 202 InitCompositor(); | 192 InitCompositor(); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 } | 732 } |
| 743 | 733 |
| 744 void RemoteWindowTreeHostWin::SetEventFlags(uint32 flags) { | 734 void RemoteWindowTreeHostWin::SetEventFlags(uint32 flags) { |
| 745 if (flags == event_flags_) | 735 if (flags == event_flags_) |
| 746 return; | 736 return; |
| 747 event_flags_ = flags; | 737 event_flags_ = flags; |
| 748 SetVirtualKeyStates(event_flags_); | 738 SetVirtualKeyStates(event_flags_); |
| 749 } | 739 } |
| 750 | 740 |
| 751 } // namespace aura | 741 } // namespace aura |
| OLD | NEW |