blob: d7b3af8c0b410ce175622838649d8a637e483400 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EMBEDDER_RESPONDER_H_
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EMBEDDER_RESPONDER_H_
#include <gdk/gdk.h>
#include <functional>
#include "flutter/shell/platform/linux/fl_key_responder.h"
#include "flutter/shell/platform/linux/fl_keyboard_manager.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"
constexpr int kMaxConvertedKeyData = 3;
typedef std::function<void(const FlutterKeyEvent* event,
FlutterKeyEventCallback callback,
void* user_data)>
EmbedderSendKeyEvent;
G_BEGIN_DECLS
#define FL_TYPE_KEY_EMBEDDER_RESPONDER fl_key_embedder_responder_get_type()
G_DECLARE_FINAL_TYPE(FlKeyEmbedderResponder,
fl_key_embedder_responder,
FL,
KEY_EMBEDDER_RESPONDER,
GObject);
/**
* FlKeyEmbedderResponder:
*
* A #FlKeyResponder that handles events by sending the converted events
* through the embedder API.
*
* This class communicates with the HardwareKeyboard API in the framework.
*/
/**
* fl_key_embedder_responder_new:
* @engine: The #FlEngine, whose the embedder API will be used to send
* the event.
*
* Creates a new #FlKeyEmbedderResponder.
*
* Returns: a new #FlKeyEmbedderResponder.
*/
FlKeyEmbedderResponder* fl_key_embedder_responder_new(
EmbedderSendKeyEvent send_key_event);
/**
* fl_key_embedder_responder_sync_modifiers_if_needed:
* @responder: the #FlKeyEmbedderResponder self.
* @state: the state of the modifiers mask.
* @event_time: the time attribute of the incoming GDK event.
*
* If needed, synthesize modifier keys up and down event by comparing their
* current pressing states with the given modifiers mask.
*/
void fl_key_embedder_responder_sync_modifiers_if_needed(
FlKeyEmbedderResponder* responder,
guint state,
double event_time);
G_END_DECLS
#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EMBEDDER_RESPONDER_H_