| Flutter Windows Embedder |

Public Member Functions | Public Attributes | List of all members
flutter::DirectManipulationOwner Class Reference

`#include <direct_manipulation.h>`

## Public Member Functions
| DirectManipulationOwner (FlutterWindow *window)
virtual | ~DirectManipulationOwner ()=default
int | Init (unsigned int width, unsigned int height)
void | ResizeViewport (unsigned int width, unsigned int height)
void | SetBindingHandlerDelegate (WindowBindingHandlerDelegate *binding_handler_delegate)
virtual void | SetContact (UINT contactId)
void | Update ()
void | Destroy ()

## Public Attributes
WindowBindingHandlerDelegate * | binding_handler_delegate

## Detailed Description

Definition at line 22 of file direct_manipulation.h.

## Constructor & Destructor Documentation

## ◆ DirectManipulationOwner()

flutter::DirectManipulationOwner::DirectManipulationOwner | ( | FlutterWindow * | window | ) |
| explicit

Definition at line 175 of file direct_manipulation.cc.

176 : window_(window) {}

## ◆ ~DirectManipulationOwner()

virtual flutter::DirectManipulationOwner::~DirectManipulationOwner | ( |  | ) |
| virtualdefault

## Member Function Documentation

## ◆ Destroy()

void flutter::DirectManipulationOwner::Destroy | ( |  | ) |

Definition at line 215 of file direct_manipulation.cc.

215 {
216 if (handler_) {
217 handler_->owner_ = nullptr;
218 }
219
220 if (viewport_) {
221 WARN_IF_FAILED(viewport_->Disable());
222 WARN_IF_FAILED(viewport_->Disable());
223 WARN_IF_FAILED(viewport_->RemoveEventHandler(viewportHandlerCookie_));
224 WARN_IF_FAILED(viewport_->Abandon());
225 }
226
227 if (window_ && manager_) {
228 WARN_IF_FAILED(manager_->Deactivate(window_->GetWindowHandle()));
229 }
230
231 handler_ = nullptr;
232 viewport_ = nullptr;
233 updateManager_ = nullptr;
234 manager_ = nullptr;
235 window_ = nullptr;
236 }

References flutter::FlutterWindow::GetWindowHandle(), and WARN_IF_FAILED.

## ◆ Init()

int flutter::DirectManipulationOwner::Init | ( | unsigned int | width,
|  | unsigned int | height
| ) |  |

Definition at line 178 of file direct_manipulation.cc.

178 {
179 RETURN_IF_FAILED(CoCreateInstance(CLSID_DirectManipulationManager, nullptr,
180 CLSCTX_INPROC_SERVER,
181 IID_IDirectManipulationManager, &manager_));
182 RETURN_IF_FAILED(manager_->GetUpdateManager(
183 IID_IDirectManipulationUpdateManager, &updateManager_));
184 RETURN_IF_FAILED(manager_->CreateViewport(nullptr, window_->GetWindowHandle(),
185 IID_IDirectManipulationViewport,
186 &viewport_));
187 DIRECTMANIPULATION_CONFIGURATION configuration =
188 DIRECTMANIPULATION_CONFIGURATION_INTERACTION |
189 DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_X |
190 DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_Y |
191 DIRECTMANIPULATION_CONFIGURATION_SCALING |
192 DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_INERTIA;
193 RETURN_IF_FAILED(viewport_->ActivateConfiguration(configuration));
194 RETURN_IF_FAILED(viewport_->SetViewportOptions(
195 DIRECTMANIPULATION_VIEWPORT_OPTIONS_MANUALUPDATE));
196 handler_ = fml::MakeRefCounted<DirectManipulationEventHandler>(this);
197 RETURN_IF_FAILED(viewport_->AddEventHandler(
198 window_->GetWindowHandle(), handler_.get(), &viewportHandlerCookie_));
199 RECT rect = {0, 0, (LONG)width, (LONG)height};
200 RETURN_IF_FAILED(viewport_->SetViewportRect(&rect));
201 RETURN_IF_FAILED(manager_->Activate(window_->GetWindowHandle()));
202 RETURN_IF_FAILED(viewport_->Enable());
203 RETURN_IF_FAILED(updateManager_->Update(nullptr));
204 return 0;
205 }

References flutter::FlutterWindow::GetWindowHandle(), and RETURN_IF_FAILED.

## ◆ ResizeViewport()

void flutter::DirectManipulationOwner::ResizeViewport | ( | unsigned int | width,
|  | unsigned int | height
| ) |  |

Definition at line 207 of file direct_manipulation.cc.

208 {
209 if (viewport_) {
210 RECT rect = {0, 0, (LONG)width, (LONG)height};
211 WARN_IF_FAILED(viewport_->SetViewportRect(&rect));
212 }
213 }

References WARN_IF_FAILED.

## ◆ SetBindingHandlerDelegate()

void flutter::DirectManipulationOwner::SetBindingHandlerDelegate | ( | WindowBindingHandlerDelegate * | binding_handler_delegate | ) |

Definition at line 244 of file direct_manipulation.cc.

245 {
246 binding_handler_delegate = delegate;
247 }

References binding_handler_delegate.

## ◆ SetContact()

void flutter::DirectManipulationOwner::SetContact | ( | UINT | contactId | ) |
| virtual

Definition at line 238 of file direct_manipulation.cc.

238 {
239 if (viewport_) {
240 viewport_->SetContact(contactId);
241 }
242 }

## ◆ Update()

void flutter::DirectManipulationOwner::Update | ( |  | ) |

Definition at line 249 of file direct_manipulation.cc.

249 {
250 if (updateManager_) {
251 HRESULT hr = updateManager_->Update(nullptr);
252 if (FAILED(hr)) {
253 FML_LOG(ERROR) << "updateManager_->Update failed";
254 auto error = GetLastError();
255 FML_LOG(ERROR) << error;
256 LPWSTR message = nullptr;
257 size_t size = FormatMessageW(
258 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
259 FORMAT_MESSAGE_IGNORE_INSERTS,
260 NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
261 reinterpret_cast<LPWSTR>(&message), 0, NULL);
262 FML_LOG(ERROR) << message;
263 }
264 }
265 }

References message.

## Member Data Documentation

## ◆ binding_handler_delegate

WindowBindingHandlerDelegate* flutter::DirectManipulationOwner::binding_handler_delegate

Definition at line 46 of file direct_manipulation.h.

Referenced by flutter::DirectManipulationEventHandler::OnContentUpdated(), flutter::DirectManipulationEventHandler::OnViewportStatusChanged(), and SetBindingHandlerDelegate().

The documentation for this class was generated from the following files:

- shell/platform/windows/direct_manipulation.h
- shell/platform/windows/direct_manipulation.cc

flutter::FlutterWindow::GetWindowHandle
virtual HWND GetWindowHandle() override
Definition: flutter_window.cc:463
WARN_IF_FAILED
#define WARN_IF_FAILED(operation)
Definition: direct_manipulation.cc:22
RETURN_IF_FAILED
#define RETURN_IF_FAILED(operation)
Definition: direct_manipulation.cc:13
flutter::DirectManipulationOwner::binding_handler_delegate
WindowBindingHandlerDelegate * binding_handler_delegate
Definition: direct_manipulation.h:46
message
Win32Message message
Definition: keyboard_unittests.cc:137