| 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 176 of file direct_manipulation.cc.

177 : window_(window) {}

## ◆ ~DirectManipulationOwner()

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

## Member Function Documentation

## ◆ Destroy()

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

Definition at line 216 of file direct_manipulation.cc.

216 {
217 if (handler_) {
218 handler_->owner_ = nullptr;
219 }
220
221 if (viewport_) {
222 WARN_IF_FAILED(viewport_->Disable());
223 WARN_IF_FAILED(viewport_->Disable());
224 WARN_IF_FAILED(viewport_->RemoveEventHandler(viewportHandlerCookie_));
225 WARN_IF_FAILED(viewport_->Abandon());
226 }
227
228 if (window_ && manager_) {
229 WARN_IF_FAILED(manager_->Deactivate(window_->GetWindowHandle()));
230 }
231
232 handler_ = nullptr;
233 viewport_ = nullptr;
234 updateManager_ = nullptr;
235 manager_ = nullptr;
236 window_ = nullptr;
237 }
flutter::FlutterWindow::GetWindowHandle
virtual HWND GetWindowHandle() override
Definition: flutter_window.cc:448
WARN_IF_FAILED
#define WARN_IF_FAILED(operation)
Definition: direct_manipulation.cc:23

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

## ◆ Init()

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

Definition at line 179 of file direct_manipulation.cc.

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

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

## ◆ ResizeViewport()

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

Definition at line 208 of file direct_manipulation.cc.

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

References WARN_IF_FAILED.

## ◆ SetBindingHandlerDelegate()

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

Definition at line 245 of file direct_manipulation.cc.

246 {
247 binding_handler_delegate = delegate;
248 }
flutter::DirectManipulationOwner::binding_handler_delegate
WindowBindingHandlerDelegate * binding_handler_delegate
Definition: direct_manipulation.h:46

References binding_handler_delegate.

## ◆ SetContact()

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

Definition at line 239 of file direct_manipulation.cc.

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

## ◆ Update()

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

Definition at line 250 of file direct_manipulation.cc.

250 {
251 if (updateManager_) {
252 HRESULT hr = updateManager_->Update(nullptr);
253 if (FAILED(hr)) {
254 FML_LOG(ERROR) << "updateManager_->Update failed";
255 auto error = GetLastError();
256 FML_LOG(ERROR) << error;
257 LPWSTR message = nullptr;
258 size_t size = FormatMessageW(
259 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
260 FORMAT_MESSAGE_IGNORE_INSERTS,
261 NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
262 reinterpret_cast<LPWSTR>(&message), 0, NULL);
263 FML_LOG(ERROR) << WCharBufferToString(message);
264 }
265 }
266 }
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter::WCharBufferToString
std::string WCharBufferToString(const wchar_t *wstr)
Convert a null terminated wchar_t buffer to a std::string using Windows utilities.
Definition: wchar_util.cc:11

References message, and flutter::WCharBufferToString().

## 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