| 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
5 #include "flutter/shell/platform/windows/window_proc_delegate_manager.h"
6
7 #include <algorithm>
8
9 #include "flutter/shell/platform/embedder/embedder.h"
10
11 namespace flutter {
12
13 WindowProcDelegateManager::WindowProcDelegateManager() = default;
14 WindowProcDelegateManager::~WindowProcDelegateManager() = default;
15
16 void WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate(
17 FlutterDesktopWindowProcCallback callback,
18 void* user_data) {
19 UnregisterTopLevelWindowProcDelegate(callback);
20
21 delegates_.push_back(WindowProcDelegate{
22 .callback = callback,
23 .user_data = user_data,
24 });
25 }
26
27 void WindowProcDelegateManager::UnregisterTopLevelWindowProcDelegate(
28 FlutterDesktopWindowProcCallback callback) {
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
37 std::optional<LRESULT> WindowProcDelegateManager::OnTopLevelWindowProc(
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
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::UnregisterTopLevelWindowProcDelegate
void UnregisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback callback)
Definition: window_proc_delegate_manager.cc:27
flutter::WindowProcDelegateManager::WindowProcDelegateManager
WindowProcDelegateManager()
flutter::WindowProcDelegateManager::~WindowProcDelegateManager
~WindowProcDelegateManager()
flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate
void RegisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback callback, void *user_data)
Definition: window_proc_delegate_manager.cc:16
FlutterDesktopWindowProcCallback
bool(* FlutterDesktopWindowProcCallback)(HWND, UINT, WPARAM, LPARAM, void *, LRESULT *result)
Definition: flutter_windows.h:275
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:53
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::WindowProcDelegate
std::function< std::optional< LRESULT >(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)> WindowProcDelegate
Definition: plugin_registrar_windows.h:24
window_proc_delegate_manager.h