Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CR Feedback
  • Loading branch information
clarkezone committed Jul 4, 2020
commit f5422b9e1e3d4b93458d4fcdec5bb8bd46983228
34 changes: 17 additions & 17 deletions shell/platform/windows/flutter_windows_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@

namespace flutter {

// Struct holding the mouse state. The engine doesn't keep track of which mouse
// buttons have been pressed, so it's the embedding's responsibility.
struct MouseState {
// True if the last event sent to Flutter had at least one mouse button.
// pressed.
bool flutter_state_is_down = false;

// True if kAdd has been sent to Flutter. Used to determine whether
// to send a kAdd event before sending an incoming mouse event, since Flutter
// expects pointers to be added before events are sent for them.
bool flutter_state_is_added = false;

// The currently pressed buttons, as represented in FlutterPointerEvent.
uint64_t buttons = 0;
};

// An OS-windowing neutral abstration for flutter
// view that works with win32 hwnds and Windows::UI::Composition visuals.
class FlutterWindowsView : public WindowBindingHandlerDelegate {
Expand Down Expand Up @@ -117,6 +101,22 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate {
void OnFontChange() override;

private:
// Struct holding the mouse state. The engine doesn't keep track of which
// mouse buttons have been pressed, so it's the embedding's responsibility.
struct MouseState {
// True if the last event sent to Flutter had at least one mouse button.
// pressed.
bool flutter_state_is_down = false;

// True if kAdd has been sent to Flutter. Used to determine whether
// to send a kAdd event before sending an incoming mouse event, since
// Flutter expects pointers to be added before events are sent for them.
bool flutter_state_is_added = false;

// The currently pressed buttons, as represented in FlutterPointerEvent.
uint64_t buttons = 0;
};

// Sends a window metrics update to the Flutter engine using current window
// dimensions in physical
void SendWindowMetrics(size_t width, size_t height, double dpiscale) const;
Expand Down Expand Up @@ -185,7 +185,7 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate {

// An object used for intializing Angle and creating / destroying render
// surfaces. Surface creation functionality requires a valid render_target.
std::unique_ptr<AngleSurfaceManager> surface_manager_ = nullptr;
std::unique_ptr<AngleSurfaceManager> surface_manager_;

// The handle to the Flutter engine instance.
FLUTTER_API_SYMBOL(FlutterEngine) engine_ = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/win32_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Win32Window {
unsigned int width,
unsigned int height);

::HWND GetWindowHandle();
HWND GetWindowHandle();

protected:
// Converts a c string to a wide unicode string.
Expand Down
3 changes: 1 addition & 2 deletions shell/platform/windows/window_binding_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ class WindowBindingHandler {
public:
virtual ~WindowBindingHandler() = default;

// Sets the view used to communicate state changes from Window to view such
// 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.
Expand Down
18 changes: 9 additions & 9 deletions shell/platform/windows/window_binding_handler_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,47 @@ namespace flutter {

class WindowBindingHandlerDelegate {
public:
// Notifies view that backing window size has changed.
// Notifies delegate that backing window size has changed.
// Typically called by currently configured WindowBindingHandler
virtual void OnWindowSizeChanged(size_t width, size_t height) const = 0;

// Notifies view that backing window mouse has moved.
// Notifies delegate that backing window mouse has moved.
// Typically called by currently configured WindowBindingHandler
virtual void OnPointerMove(double x, double y) = 0;

// Notifies view that backing window mouse pointer button has been pressed.
// Notifies delegate that backing window mouse pointer button has been pressed.
// Typically called by currently configured WindowBindingHandler
virtual void OnPointerDown(double x,
double y,
FlutterPointerMouseButtons button) = 0;

// Notifies view that backing window mouse pointer button has been released.
// Notifies delegate that backing window mouse pointer button has been released.
// Typically called by currently configured WindowBindingHandler
virtual void OnPointerUp(double x,
double y,
FlutterPointerMouseButtons button) = 0;

// Notifies view that backing window mouse pointer has left the window.
// Notifies delegate that backing window mouse pointer has left the window.
// Typically called by currently configured WindowBindingHandler
virtual void OnPointerLeave() = 0;

// Notifies view that backing window has received text.
// Notifies delegate that backing window has received text.
// Typically called by currently configured WindowBindingHandler
virtual void OnText(const std::u16string&) = 0;

// Notifies view that backing window size has received key press.
// Notifies delegate that backing window size has received key press.
// Typically called by currently configured WindowBindingHandler
virtual void OnKey(int key, int scancode, int action, char32_t character) = 0;

// Notifies view that backing window size has recevied scroll.
// Notifies delegate that backing window size has recevied scroll.
// Typically called by currently configured WindowBindingHandler
virtual void OnScroll(double x,
double y,
double delta_x,
double delta_y,
int scroll_offset_multiplier) = 0;

// Notifies view that backing window size has had system font change.
// Notifies delegate that backing window size has had system font change.
// Typically called by currently configured WindowBindingHandler
virtual void OnFontChange() = 0;
};
Expand Down