From e6ce7549e8b3e6e31dad6347cc9fa7fcb28e4da8 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 11 Dec 2018 13:41:41 -0800 Subject: [PATCH] [windows] Add key event support Enables the GLFW raw key event handler for Windows. --- library/windows/GLFW Library.vcxproj | 1 + library/windows/GLFW Library.vcxproj.filters | 41 +++++++++++++++++++- library/windows/embedder.cpp | 9 +++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 634ea94d9..8ea8c4899 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -263,6 +263,7 @@ + diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index 02a3922cf..bf7b4fad3 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -21,6 +21,45 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -32,4 +71,4 @@ Source Files - + \ No newline at end of file diff --git a/library/windows/embedder.cpp b/library/windows/embedder.cpp index e76f35f9a..f6522ca3f 100644 --- a/library/windows/embedder.cpp +++ b/library/windows/embedder.cpp @@ -21,6 +21,7 @@ #include +#include "library/common/glfw/key_event_handler.h" #include "library/common/glfw/keyboard_hook_handler.h" #include "library/common/glfw/text_input_plugin.h" #include "library/common/internal/plugin_handler.h" @@ -36,6 +37,10 @@ struct FlutterEmbedderState { // deleted from the heap. std::vector keyboard_hook_handlers; + + // Handles raw key interactions from GLFW. + // TODO: Revisit ownership model once Issue #102 is resolved. + std::unique_ptr key_event_handler; }; static constexpr char kDefaultWindowTitle[] = "Flutter"; @@ -268,6 +273,10 @@ GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height, FlutterEmbedderState *state = new FlutterEmbedderState(); state->plugin_handler = std::make_unique(engine); state->engine = engine; + + state->key_event_handler = + std::make_unique(state->plugin_handler.get()); + state->keyboard_hook_handlers.push_back(state->key_event_handler.get()); auto input_plugin = std::make_unique(); state->keyboard_hook_handlers.push_back(input_plugin.get());