Skip to content

Commit 29c6a39

Browse files
authored
[windows] Add key event support (#193)
Enables the GLFW raw key event handler for Windows.
1 parent 5c77651 commit 29c6a39

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

library/windows/GLFW Library.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@
263263
</PreLinkEvent>
264264
</ItemDefinitionGroup>
265265
<ItemGroup>
266+
<ClCompile Include="..\common\glfw\key_event_handler.cc" />
266267
<ClCompile Include="..\common\glfw\text_input_plugin.cc" />
267268
<ClCompile Include="..\common\internal\engine_method_result.cc" />
268269
<ClCompile Include="..\common\internal\json_message_codec.cc" />

library/windows/GLFW Library.vcxproj.filters

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,45 @@
2121
<ClCompile Include="..\common\internal\plugin_handler.cc">
2222
<Filter>Source Files</Filter>
2323
</ClCompile>
24+
<ClCompile Include="..\common\glfw\text_input_plugin.cc">
25+
<Filter>Source Files</Filter>
26+
</ClCompile>
27+
<ClCompile Include="..\common\internal\engine_method_result.cc">
28+
<Filter>Source Files</Filter>
29+
</ClCompile>
30+
<ClCompile Include="..\common\internal\json_message_codec.cc">
31+
<Filter>Source Files</Filter>
32+
</ClCompile>
33+
<ClCompile Include="..\common\internal\text_input_model.cc">
34+
<Filter>Source Files</Filter>
35+
</ClCompile>
36+
<ClCompile Include="..\common\json_method_call.cc">
37+
<Filter>Source Files</Filter>
38+
</ClCompile>
39+
<ClCompile Include="..\common\json_method_codec.cc">
40+
<Filter>Source Files</Filter>
41+
</ClCompile>
42+
<ClCompile Include="..\common\json_plugin.cc">
43+
<Filter>Source Files</Filter>
44+
</ClCompile>
45+
<ClCompile Include="..\common\method_call.cc">
46+
<Filter>Source Files</Filter>
47+
</ClCompile>
48+
<ClCompile Include="..\common\method_channel.cc">
49+
<Filter>Source Files</Filter>
50+
</ClCompile>
51+
<ClCompile Include="..\common\method_codec.cc">
52+
<Filter>Source Files</Filter>
53+
</ClCompile>
54+
<ClCompile Include="..\common\method_result.cc">
55+
<Filter>Source Files</Filter>
56+
</ClCompile>
57+
<ClCompile Include="..\common\plugin.cc">
58+
<Filter>Source Files</Filter>
59+
</ClCompile>
60+
<ClCompile Include="..\common\glfw\key_event_handler.cc">
61+
<Filter>Source Files</Filter>
62+
</ClCompile>
2463
</ItemGroup>
2564
<ItemGroup>
2665
<ClInclude Include="embedder.h">
@@ -32,4 +71,4 @@
3271
<Filter>Source Files</Filter>
3372
</None>
3473
</ItemGroup>
35-
</Project>
74+
</Project>

library/windows/embedder.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <flutter_embedder.h>
2323

24+
#include "library/common/glfw/key_event_handler.h"
2425
#include "library/common/glfw/keyboard_hook_handler.h"
2526
#include "library/common/glfw/text_input_plugin.h"
2627
#include "library/common/internal/plugin_handler.h"
@@ -36,6 +37,10 @@ struct FlutterEmbedderState {
3637
// deleted from the heap.
3738
std::vector<flutter_desktop_embedding::KeyboardHookHandler *>
3839
keyboard_hook_handlers;
40+
41+
// Handles raw key interactions from GLFW.
42+
// TODO: Revisit ownership model once Issue #102 is resolved.
43+
std::unique_ptr<flutter_desktop_embedding::KeyEventHandler> key_event_handler;
3944
};
4045

4146
static constexpr char kDefaultWindowTitle[] = "Flutter";
@@ -268,6 +273,10 @@ GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height,
268273
FlutterEmbedderState *state = new FlutterEmbedderState();
269274
state->plugin_handler = std::make_unique<PluginHandler>(engine);
270275
state->engine = engine;
276+
277+
state->key_event_handler =
278+
std::make_unique<KeyEventHandler>(state->plugin_handler.get());
279+
state->keyboard_hook_handlers.push_back(state->key_event_handler.get());
271280
auto input_plugin = std::make_unique<TextInputPlugin>();
272281
state->keyboard_hook_handlers.push_back(input_plugin.get());
273282

0 commit comments

Comments
 (0)