Flutter Windows Embedder
window_proc_delegate_manager.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 
6 
7 #include <algorithm>
8 
9 #include "flutter/shell/platform/embedder/embedder.h"
10 
11 namespace flutter {
12 
15 
18  void* user_data) {
20 
21  delegates_.push_back(WindowProcDelegate{
22  .callback = callback,
23  .user_data = user_data,
24  });
25 }
26 
29  delegates_.erase(
30  std::remove_if(delegates_.begin(), delegates_.end(),
31  [&callback](const WindowProcDelegate& delegate) {
32  return delegate.callback == callback;
33  }),
34  delegates_.end());
35 }
36 
38  HWND hwnd,
39  UINT message,
40  WPARAM wparam,
41  LPARAM lparam) const {
42  std::optional<LRESULT> result;
43  for (const auto& delegate : delegates_) {
44  LPARAM handler_result;
45  // Stop as soon as any delegate indicates that it has handled the message.
46  if (delegate.callback(hwnd, message, wparam, lparam, delegate.user_data,
47  &handler_result)) {
48  result = handler_result;
49  break;
50  }
51  }
52  return result;
53 }
54 
55 } // namespace flutter
window_proc_delegate_manager.h
flutter::WindowProcDelegateManager::WindowProcDelegateManager
WindowProcDelegateManager()
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:53
flutter::WindowProcDelegateManager::OnTopLevelWindowProc
std::optional< LRESULT > OnTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) const
Definition: window_proc_delegate_manager.cc:37
flutter::WindowProcDelegateManager::~WindowProcDelegateManager
~WindowProcDelegateManager()
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::WindowProcDelegateManager::UnregisterTopLevelWindowProcDelegate
void UnregisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback callback)
Definition: window_proc_delegate_manager.cc:27
flutter::WindowProcDelegate
std::function< std::optional< LRESULT >(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)> WindowProcDelegate
Definition: plugin_registrar_windows.h:24
message
Win32Message message
Definition: keyboard_unittests.cc:137
FlutterDesktopWindowProcCallback
bool(* FlutterDesktopWindowProcCallback)(HWND, UINT, WPARAM, LPARAM, void *, LRESULT *result)
Definition: flutter_windows.h:245
flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate
void RegisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback callback, void *user_data)
Definition: window_proc_delegate_manager.cc:16
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52