flutter_flutter/shell/platform/windows/window_binding_handler.h
Chris Bracken 8671aef05b
Notify Win32FlutterWindow of cursor updates (#23795)
During multi-step text input composing, such as with Chinese, Japanese,
and Korean text input, the framework sends embedders cursor rect updates
in the form of two messages:

* TextInput.setMarkedTextRect: notifies the embedder the size and
  position of the composing text rect (or cursor when not composing) in
  local coordinates.
* TextInput.setEditableSizeAndTransform: notifies the embedder of the
  size of the EditableText and 4x4 transform matrix from local to
  PipelineOwner.rootNode coordinates.

On receipt of either message, we cache a local copy on the
TextInputPlugin and notify the Win32FlutterWindow of the updated cursor
rect. In a followup patch, we update Win32FlutterWindow to implement the
Win32 input manager (IMM) calls required to position the IME candidates
window while editing.
2021-01-22 16:31:09 -08:00

63 lines
2.0 KiB
C++

// 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_WINDOWS_WINDOW_BINDING_HANDLER_H_
#define FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_H_
#include <windows.h>
#include <string>
#include <variant>
#include "flutter/shell/platform/common/cpp/geometry.h"
#include "flutter/shell/platform/windows/public/flutter_windows.h"
#include "flutter/shell/platform/windows/window_binding_handler_delegate.h"
namespace flutter {
class FlutterWindowsView;
// Structure containing physical bounds of a Window
struct PhysicalWindowBounds {
size_t width;
size_t height;
};
using WindowsRenderTarget = std::variant<
/*winrt::Windows::UI::Composition::SpriteVisual, */ HWND>;
// Abstract class for binding Windows platform windows to Flutter views.
class WindowBindingHandler {
public:
virtual ~WindowBindingHandler() = default;
// Sets the delegate used to communicate state changes from window to view
// such as key presses, mouse position updates etc.
virtual void SetView(WindowBindingHandlerDelegate* view) = 0;
// Returns a valid WindowsRenderTarget representing the backing
// window.
virtual WindowsRenderTarget GetRenderTarget() = 0;
// Returns the scale factor for the backing window.
virtual float GetDpiScale() = 0;
// Returns the bounds of the backing window in physical pixels.
virtual PhysicalWindowBounds GetPhysicalWindowBounds() = 0;
// Invoked after the window has been resized.
virtual void OnWindowResized() = 0;
// Sets the cursor that should be used when the mouse is over the Flutter
// content. See mouse_cursor.dart for the values and meanings of cursor_name.
virtual void UpdateFlutterCursor(const std::string& cursor_name) = 0;
// Sets the cursor rect in root view coordinates.
virtual void UpdateCursorRect(const Rect& rect) = 0;
};
} // namespace flutter
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_H_