53 Commits

Author SHA1 Message Date
stuartmorgan
e297b7d731 [windows] Rework controller/engine interaction in the API (flutter/engine#20266)
Changes the interaction between the view controller and engine in both the C API and
the engine API, so that there's always an engine (as on other platforms) rather than
the engine APIs being specific to headless mode.

While adjusting the C API, this does a large cleanup:
- Renames all methods to follow a `FlutterDesktop` (prefix) + "class" name + method-style name.
  E.g., `FlutterDestkopViewControllerCreate` rather than `FlutterDesktopCreateViewController`.
  This makes it easier to see what functions operate on which conceptual "object" in the API.
- Reorders and groups them by the object they operate on.

Fixes https://github.com/flutter/flutter/issues/61966
2020-08-10 09:41:18 -07:00
stuartmorgan
4bbcaf10c4 [windows] Separate the engine from the view (flutter/engine#19896)
Refactors the Windows embedding internals to make an engine object that
owns things associated with the engine rather than the view, and updates
the API surface to allow using the engine directly.

This is an incremental step toward both a cleaner, non-struct-based
internal structure and a finalized API surface.
2020-08-05 08:09:13 -07:00
stuartmorgan
d6fccfd566 Make EncodableValue a thin std::variant wrapper (flutter/engine#19983)
Instead of a hand-rolled discriminated union (originally used to avoid a C++17
dependency, which is no longer an issue), implement EncodableValue as a
std::variant. Rather than simply changing the internals, this makes EncodableValue
a minimal std::variant subclass with only a handful of added methodS, replacing
the old IsFoo/FooValue APIs with the standard std::holds_alternative/std::get,
so that plugin code will use a standard-based API rather than a Flutter-specific
API for wrapped values.

This is a breaking change for Windows and GLFW plugins. In the short
term USE_LEGACY_ENCODABLE_VALUE can be set in builds to use the old
version, to separate rolling from updating.

Fixes https://github.com/flutter/flutter/issues/61970
2020-08-04 08:53:07 -07:00
Siva
03706dce89 Manual roll of Dart from 24c7666def...40fd1c456e (flutter/engine#20092)
* Manual roll of Dart from 24c7666def...40fd1c456e

dart-lang/sdk@40fd1c456e Revert "[dart:io] Add Abort() on HttpClientRequest"
dart-lang/sdk@17d7296a42 [vm/nnbd/bytecode] Fix reuse of type arguments in bytecode
dart-lang/sdk@58b6f40c73 Issue 42797. Understand in legacy libraries that a function returning Never (in Null Safety library) never returns. (reland)
dart-lang/sdk@fc8a6d9f9b [VM/compiler] Dereference TypeRef literal when propagating constants.
dart-lang/sdk@0689ec527a Move "test.dart" (well, most of its contents) into pkg/test_runner.
dart-lang/sdk@1094b3c61d Prepare static error test updater tool to handle web tests.
dart-lang/sdk@b258585f2f [observatory] Migrate from deprecated isInstanceOf to isA.
dart-lang/sdk@dfe1d9b682 Disable OverrideContributor for Cider.
dart-lang/sdk@aea99b2f5c scope debug property assist to Diagnosticables
dart-lang/sdk@4b96f20a79 [dart:io] Add Abort() on HttpClientRequest
dart-lang/sdk@1b1a39708c [build] Use frameworks instead of libs
dart-lang/sdk@3fef522496 Revert "Reland "[vm] Replaces fuchsia.deprecatedtimezone""
dart-lang/sdk@8c664d4f3f Revert "Issue 42797. Understand in legacy libraries that a function returning Never (in Null Safety library) never returns."
dart-lang/sdk@2efb5bebc7 [ dart:_http ] Fix typo in HTTP response timeline event
dart-lang/sdk@0884dae36c Revert "Fix the #include path for ICU headers"
dart-lang/sdk@5171534e81 Scope tweaks. Report REFERENCED_BEFORE_DECLARATION in more places.
dart-lang/sdk@6bba75079a Issue 42797. Understand in legacy libraries that a function returning Never (in Null Safety library) never returns.
dart-lang/sdk@b4ebbb7f5c [build] Update gn to match Fuchsia
dart-lang/sdk@cb428a7a02 [dart2js] Remove old bug work around in collector.
dart-lang/sdk@08663c20ab Change flutter patch to match existing DEPS on master branch
dart-lang/sdk@146ad014d9 update js/meta for the 2.10 dev sdk
dart-lang/sdk@488c718793 [co19] Roll co19 to d79951e06e443213243e54c2c32694b79a221b65
dart-lang/sdk@ba20edd7be Add patch for flutter-engine when changing to version 2.10

* Rev buildroot to latest version.

* Update license.

* update.

* Update gn revision.

* Format BUILD.gn files as the gn revision has been updated.
2020-07-29 13:10:15 -07:00
stuartmorgan
cd66f501cb Fix invalid selection handling in text plugins (flutter/engine#19899)
The Windows, Linux, and GLFW embeddings (which all share a common code
ancestry) pass TextInput.setEditingState selection base and extents
straight through to the shared text model class. The model expects those
values to be valid, but the framework sends -1/-1 for "invalid"
selections, which happen for some empty text cases (e.g.,
TextFieldController.clear()).

This translates those invalid selection values to an empty selection at
the start of the string, as expected by the model.

Fixes https://github.com/flutter/flutter/issues/59140
2020-07-27 11:00:02 -07:00
Tong Mu
78f0fc74d9 Add all system cursors (engine) (flutter/engine#19550)
* Support all system cursors in WIn, Linux, mac, Web and Android.
2020-07-15 15:37:18 -07:00
stuartmorgan
f0c88b310c Implement cursor support for Windows (flutter/engine#19459)
Implements the basic engine support for Windows for
https://github.com/flutter/flutter/issues/31952
2020-07-09 11:18:39 -07:00
James Clarke
71dafa45b1 Refactor Win32FlutterWindow in preparation for UWP windowing implementation (flutter/engine#18878)
* Add flutter_windows_view and window_binding_handler

Switch input handling infra to FlutterWindowsView

win32_flutter_window implement WindowBindingHandler

Strip unneeded functionality from win32flutterwindow

Fulfill WindowBindingHandler interface in Win32FlutterWindow

Add implementations for missing input handling in Win32FlutterWindow

Cleanup dead code

Correctly hook up rendering again

Fix resizing

clang-format

Fix clipboard

Cleanup

Rename

Add comments

cleanup

* clang-format

* CR Feedback

* clang-format; gn format

* Fix licensing

* CR feedback

* CR feedback

* CR feedback

* Git rid of unnecessar :: prefixes

* Extract WindowBindingHandlerDelegate as an interface

* Missing file

* Extract physical window bounds as a struct

* CR Feedback

* CR feedback

* clang-format

Co-authored-by: Stuart Morgan <stuartmorgan@google.com>
2020-07-07 06:49:51 -07:00
stuartmorgan
45ce08ab01 Log Windows errors to stderr (flutter/engine#19095)
For error messages in the Windows embedding, use stderr rather than
Windows debug logging, so that it will go to the console where, e.g.,
'flutter run' will display it.
2020-06-17 13:35:21 -07:00
Robert Ancell
cd9cb596eb Remove the input type and action from TextInputModel. (flutter/engine#18919)
These aren't used by the model so are better managed outside of it.
2020-06-10 10:00:32 +12:00
stuartmorgan
35814367f6 Don't export embedder API in desktop embeddings (flutter/engine#18735)
The embedder.h API layer is an implementation detail of the desktop
embeddings, not part of the public API surface, so should not be part of
the public symbol list for those libraries.
2020-06-03 18:13:59 -07:00
Robert Ancell
72181d1083 Add FlTextInputPlugin (flutter/engine#18314)
* Add FlTextInputPlugin
2020-05-28 13:11:16 +12:00
stuartmorgan
c1f2f8e6d9 Support AOT mode for Windows (flutter/engine#18589)
- Adds a way to provide an AOT library to the C API.
- Adds app.so to the information provided by DartProject.
- Fixes the engine to only do static snapshot linking for Windows in
  debug mode, not all modes, so that the provided library is used.

Engine side of https://github.com/flutter/flutter/issues/38477
2020-05-26 11:01:48 -07:00
Robert Ancell
cb7e61ad20 Remove rapidjson from TextInputModel (flutter/engine#18397)
This allows this class to be shared with the Linux plugin.
Also move client_id outside this class as was noted in a TODO.
2020-05-15 14:59:56 +12:00
stuartmorgan
b8d0673b3f Refactor GLFW embedding to support headless mode (flutter/engine#18205)
This does some long-overdue refactoring of the spaghetti code that grew in the GLFW embedding to begin providing a clearer separation between the engine and the window. It is now possible to register plugins, and run the runloop, on a headless engine, which makes headless mode much more usable. This is useful in some automated testing environments.

There is more refactoring that should be done in the future, but this is a good incremental point to stop as the PR is already large, and it provides useful new functionality as-is.
2020-05-07 17:10:11 -07:00
stuartmorgan
6027990460 Add an API for resyncing output streams (flutter/engine#18070)
When creating a console on Windows, stdout/stderr aren't wired up to it.
They need to be re-opened afeter the console is created, and that needs
to be done separately in the engine due to the use of static runtime
linking. This provides a helper method that the runner can call when
creating a console so that output will work as expected.

Part of https://github.com/flutter/flutter/issues/53169
2020-05-01 08:38:42 -07:00
stuartmorgan
dda139248a Fix method handler control flow in Windows and Linux text input plugins (flutter/engine#17964)
The existing logic incorrectly factored out a check that there were arguments too early, applying it to any message not already handled (including unhandled methods, such as methods added after the initial implementation) and thus failing if any unhandled message had no arguments.

Fixes https://github.com/flutter/flutter/issues/55653
2020-04-29 19:43:12 -07:00
stuartmorgan
6823cf09f2 Use UTF-16 for C++ text input model (flutter/engine#17831)
The C++ text input model used by Windows and Linux currently uses UTF-32. The intention was to facilitate handling of arrow keys, backspace/delete, etc., however since part of what is synchronized with the engine is cursor+selection offsets, and those offsets are defined in terms of UTF-16 code units, this causes very bad interactions with the framework-side model.

This converts to using UTF-16, rather than UTF-32, so that the offsets align with the framework. It also adds surrogate pair handling to the operations that adjust indexes, to avoid breaking surrogate pairs. (Arbitrary grapheme cluster handling is out of scope for this PR; while definitely desirable in the long term, surrogate pair handling is much more critical since improper handling yields invalid UTF-16, which breaks the text field).

This partially fixes https://github.com/flutter/flutter/issues/55014. A framework-side fix is also necessary (since currently both the engine and the framework attempt to handle arrow keys, which is another out-of-scope-for-this-PR issue), but even without the framework fix this dramatically improves the cursor behavior on Windows when there are surrogate pairs somewhere in the string since at least the two sides agree on what indexes mean.

Includes minor plumbing changes to the text input plumbing on Windows so that we're not pointlessly converting from UTF-16 to UTF-32 and then back to UTF-16.
2020-04-21 11:01:01 -07:00
stuartmorgan
f166d4c159 Windows text input fixes (flutter/engine#17768)
Fixes a few issues with Windows text input:
- Filters out ASCII control characters
- Filters out lead surrogates, which aren't valid UTF-16 on their own so will cause assertion failures if sent to Flutter
- Adds a bandaid fix for a crash due to mismatches in indexing in the C++ and Dart text models. (A better fix would be to use UTF-16 and add surrogate pair handling to deletion and forward/back; that will be a later PR since it has a larger scope.)

Fixes https://github.com/flutter/flutter/issues/54879
2020-04-20 14:05:41 -07:00
stuartmorgan
cb13b1198f Fix Windows clipboard handling (flutter/engine#17706)
Fixes several bugs in the clipboard code, and makes some structural
improvements:
- Adds scoped wrappers for clipboard open/close and global lock/unlock,
  to prevent missing cleanup, fixing at least one case where the lock
  was not released.
- Adds the relevant window handle to the clipboard calls, since the docs
  suggest that some operations won't work without one.
- Adds a missing clear step to setting the clipboard data.
- Switches from TEXT to UNICODETEXT to handle non-ASCII text correctly.
  - To enable that, adds UTF-16/-8 conversion utilities built on the
    Win32 APIs (rather than the deprecated std::codecvt functions, as
    have been previously used in the engine).
- Fixes handling of getting data when the clipboard is empty, correctly
  returning null.
- Passes more errors back through the method channel, with details, for
  easier debugging of future issues.

Fixes https://github.com/flutter/flutter/issues/54226
2020-04-15 07:02:58 -07:00
Francisco Magdaleno
c38e7106c0 [windows] Sends complete key data to framework (flutter/engine#17577) 2020-04-09 20:55:02 -07:00
stuartmorgan
b64faf3a69 Reland "Improve C++ plugin lifetime handling" (flutter/engine#17570)
Relands #17489 with a fix for the unit test flake.

The previous unit test relied on the new instance not being created at the same memory address, which isn't guaranteed.
2020-04-07 14:11:56 -07:00
stuartmorgan
06e24a71ba Fix flutter_windows_unittests runtime dependency (flutter/engine#17524)
The transitive dependency on the embedder library brings in the right
runtime for the build mode, so directly depending on the JIT version
isn't necessary, and causes duplicate symbol issues in release builds.
2020-04-07 13:19:49 -07:00
Chris Bracken
4f108b7be1 Revert "Improve C++ plugin lifetime handling (#17489)" (flutter/engine#17563)
Seems to have triggered flaky failures on the Windows bot since landing.
Example failure:

    [ RUN      ] PluginRegistrarTest.ManagerRemovesOnDestruction
    c:\b\s\w\ir\cache\builder\src\flutter\shell\platform\common\cpp\client_wrapper\plugin_registrar_unittests.cc(149): error: Expected: (manager->GetRegistrar<PluginRegistrar>(dummy_registrar_handle)) != (first_wrapper), actual: 000002400A90E3D0 vs 000002400A90E3D0

This reverts commit 478a7855943d81a58dd9e9037fb338d3a18bb294.
2020-04-07 10:22:55 -07:00
stuartmorgan
478a785594 Improve C++ plugin lifetime handling (flutter/engine#17489)
This makes two changes:
- Adds a way to register a callback for when a FlutterDesktopPluginRegistrarRef is destroyed, and implements the logic to call it in the Windows and Linux embeddings.
- Adds a class to the C++ wrapper that handles making a singleton owning PluginRegistrar wrappers, and destroying them when the underlying reference goes away, to avoid needing that boilerplate code in every plugin's source.

Fixes https://github.com/flutter/flutter/issues/53496
2020-04-06 09:55:42 -07:00
stuartmorgan
7b222c8310 Remove JSON codec from C++ client wrapper (flutter/engine#17312)
The JSON codec is awkward to use in the wrapper (since the client has to build and link one of the JSON libraries to do so). Since it would be very cumbersome to wrap in a C API, and there's essentially no reason to use it instead of the standard codec, this removes it from the wrapper entirely.

Since some system channels (internal to the engine) still use it, it's moved into common/cpp instead of being eliminated entirely. Internally we always use RapidJSON though, so the jsoncpp implementation is removed. Also adds some unit test coverage, since there wasn't any.

Fixes #30669
2020-04-02 14:57:46 -07:00
stuartmorgan
bac62dd12e Add DartProject for Windows embedding API (flutter/engine#17210)
This is a step toward aligning the API with macOS, and will make it easier to add the precompiled library later for release mode (since it can just be added to the project directory, without any code changes required for wrapper clients).

At the C API, uses a struct instead of individual arguments, mirroring a change that was already made on the Linux side to make the C API cleaner.

Functional changes in addition to the restructuring:

adds relative path support, as was recently added for GLFW
Uses wstring, rather than string, for paths; the conversion to UTF-8 is actually a potential problem on Windows, so pushing it into the embedding allows us the possibility of removing it later (if we can figure out a good solution at the embedder.h layer) without API breakage.
The old APIs used by the standard runner are left in place for now to avoid breaking the template on an engine roll. Once the framework template has been updated, the old API paths will be removed.
2020-03-23 10:46:10 -07:00
Francisco Magdaleno
a3722df46e Expose DPI helper functions for Runner apps to use (flutter/engine#16313) 2020-02-11 15:03:03 -08:00
Francisco Magdaleno
40c7f488e9 Code cleanup on destructors (flutter/engine#16481) 2020-02-06 16:53:02 -08:00
stuartmorgan
1749454a9f Fix Windows embedding issues caught by clang (flutter/engine#16369)
Clang has different warning settings, so catches different issues than
the VS compile. This fixes various minor issues caught by clang.

Part of https://github.com/flutter/flutter/issues/16256
2020-02-05 14:27:09 -08:00
Chinmay Garde
426c48aaac Remove all uses of the redundant flutter_root variable. (flutter/engine#16311)
This was only necessary when the Engine had to build in multiple buildroots
where the sources where checked out at different paths relative to the
buildroot. This is no longer the case and there are already cases GN rules
have been written that mix and match variable usage with the direct
specification of the path to the Flutter sources relative to the sole buildroot.
2020-01-31 21:49:48 -08:00
Francisco Magdaleno
a4fe86b745 Gets the DPI for all awareness mode and older Windows versions (flutter/engine#15951) 2020-01-27 18:48:03 -08:00
stuartmorgan
d45eb4bed2 Add missing include in GLFW and Windows embeddings (flutter/engine#15867) 2020-01-21 17:48:03 -08:00
stuartmorgan
2b685ee536 Implement HWND access for Windows plugins (flutter/engine#15378)
plugin_registrar_windows.h was never fully updated for the Win32 switch,
and didn't actually compile. This introduces FlutterView (parallel to
the GLFW wrapper's FlutterWindow) as a ways of holding view-specific
functionality to expose via the plugin registrar, and moves HWND access
from the FlutterViewController to the FlutterView so that it's
available to plugins. This allows the implementation of plugins that need
access to the native HWND (e.g., moving or resizing the top-level window).

Adds simple unit tests of the new wrapper functionality, ensuring that the
files actually compile, and that the passthroughs work as expected.

This is a breaking change for Windows runners due to moving
GetNativeWindow() in the wrapper. It's not being done as a multi-stage
change (addition + deprecation + later removal) since this API is explicitly
unstable.
2020-01-13 19:04:17 -08:00
stuartmorgan
b5a0d966f7 Add plugin_registrar_windows.h to published wrapper (flutter/engine#15265) 2020-01-07 21:33:02 -08:00
gaaclarke
43dce83fc1 Refactor to passing functions by const ref (flutter/engine#13975)
Moved our code to passing functions by const ref
2019-11-22 12:20:02 -08:00
stuartmorgan
be5bc34af1 Add a task runner for the Win32 embedding (flutter/engine#13043)
Adds a task runner, and exposes API to allow application-level runloops to know when they need to next call the API to process engine events. Internally, sends null events to wake up the app runloop when new events are scheduled to ensure the wait time is updated accordingly.

Fixes #36420
2019-10-16 21:30:06 -07:00
Jason Simmons
4a39184fec Auto-formatter fixes for BUILD.gn files (flutter/engine#13005) 2019-10-08 15:15:47 -07:00
chunhtai
79ad29854f add windows embedding test (flutter/engine#12423) 2019-10-03 12:42:44 -07:00
Francisco Magdaleno
9c8f5d8074 Adds support for 5 mouse buttons (flutter/engine#12450) 2019-09-26 15:23:58 -07:00
Francisco Magdaleno
72e0f803b5 Track "mouse leave" event (flutter/engine#12363) 2019-09-23 16:44:44 -07:00
chunhtai
051ed653cc Add system font change listener for windows (flutter/engine#12276)
* Add windows font change logic

* update

* fix comment
2019-09-23 13:23:46 -07:00
stuartmorgan
c66d5e6d17 Adds PluginRegistry to the C++ client wrapper API (flutter/engine#12287)
Makes the plugin registration structure consistent with macOS. This will
be used in generated plugin registrant files rather than a specific
implemenation class, so this helps unblock the creation of generated
registrants on Windows and Linux.
2019-09-17 11:41:22 -07:00
Francisco Magdaleno
71f6d9cde9 [glfw/windows] Stops keeping track of input models (flutter/engine#12234) 2019-09-12 15:30:53 -07:00
shoryukenn
58c3192c32 Improve Unicode handling on Windows (flutter/engine#11899)
Significantly improves the behavior of non-ASCII text input on Windows. Correctly
processes incoming character events as UTF-16, and for now uses UTF-32 for
the text model so that the existing index-based logic will work much more often.

Future work is still needed, but this will handle far more cases correctly.
2019-09-08 12:13:59 -07:00
James Clarke
d1fa9b5f40 [Windows] Address #36422 by adding a context for async resource uploading (flutter/engine#11828)
Add a context for async resource uploading.

Fixes flutter/flutter#36422
2019-09-04 15:52:12 -07:00
James Clarke
a3822320b7 [Windows] Update API for alternative Windows shell platform implementation (flutter/engine#11327)
* Begin API evolution to a more native win32 API

* Child-window based hosting

* Plumb through an initial size for child window to avoid reallocated surface on start

* Windows API cleanup part 1

* Fix wrapper tests

* Ensure flutter's HWND resources are destroyed

* Final API cleanup

* Fix dynamic DPI handling

* Cleanup

* Fix a bug that was causing engine to not be shutdown correctly

* CR feedback

* auto format

* CR feedback: combine FlutterView and FlutterViewController

* The one that clang-format seems to always get wrong

* expletive

* fix sources for licesnse file

* CR Feedback

* cleanup

* Update GetNativeWindow() to return an HWND rather than a long

* fix formatting
2019-09-02 17:55:42 -07:00
Chinmay Garde
c379128221 Append newlines to EOF of all translation units. (flutter/engine#11654)
We are switching to -Wnewline-eof soon and these will become errors. Anyway, this was undefined behavior.
2019-08-28 15:06:49 -07:00
stuartmorgan
d46e7e2737 Clean up Windows and Linux build output (flutter/engine#11324)
Final portion of reworking the names of the Linux and Windows desktop build outputs.

See flutter/flutter#38589
2019-08-21 05:53:38 -07:00
stuartmorgan
3746a89cb2 Add _glfw versions of the GLFW desktop libraries (flutter/engine#11024)
Part of restructuring the artifacts to support transitioning away from
GLFW embeddings on desktop.

https://github.com/flutter/flutter/issues/38589
2019-08-15 14:41:15 -07:00