187 Commits

Author SHA1 Message Date
Robert Ancell
6678efaacf Implement SystemSound.play 2020-12-11 13:38:47 +13:00
Robert Ancell
4338849250 Replace g_object_weak_ref with g_object_add_weak_pointer
In these cases it is simpler to use the latter. Newer code is using this method.
2020-12-11 09:07:26 +13:00
Robert Ancell
69651402eb
Stop potential lockup due to GHashTable being modified when cleared. (#22917)
This doesn't seem to be currently occuring, but I triggered such a lockup
when modifying other code.
2020-12-09 07:26:35 +13:00
Greg Spencer
bdadaad20d
Add delayed event delivery for Linux. (#22577)
This changes the text handling so that keyboard events are sent to the framework first for handling, and then passed to the text input plugin, so that the framework has a chance to handle keys before they get given to the text field.

This is complicated by the async nature of the interaction with the framework, since GTK wants a synchronous response. So, in this change, I always tell GTK that the event was handled, and if it wasn't, then I re-dispatch the event once we know one way or the other.
2020-12-03 15:00:37 -08:00
Greg Spencer
4b859cee93
Fix typos and fix some env var state leakage in tests (#22576)
This just fixes some typos, and a small state leak in some of the tests that set env variables.
2020-11-17 21:51:37 -08:00
Robert Ancell
46f78c6496
Fix typo in documentation for FlPlatformPlugin (#22426) 2020-11-12 12:02:44 +13:00
William Wold
bc45d04f4b
Set the IM context when showing the input method (#21896) 2020-11-06 09:22:17 +13:00
stuartmorgan
bf259226b2
Switch Linux embedding to proc table embedder API (#22280)
Switches the Linux embedding from the standard C API to the new proctable version, to allow for unit testing of the embedding layer separately from the embedder APIs implementation.
2020-11-04 15:12:44 -08:00
Omar Emara
092cbf519c
Fix Linux handling of window exposure events (#22268)
Currently, the Linux embedder does not handle window exposure events.
This is typically not a problem for users who use compositing window
managers, since they keep the display buffers even if the window is
completely covered. However, for users that don't use a compositor, the
window will not be redrawn by the engine if it was previously covered
until another event triggers the redraw.

This patch implements the GtkWidget draw callback to handle window
exposure events. The callback doesn't actually draw anything, it just
schedule a frame for drawing by the engine.

The engine doesn't support exposure events, so instead, we force redraw
by sending a window metrics event of the same geometry. Since the
geometry didn't change, only a frame will be scheduled.
2020-11-04 16:43:47 +13:00
Robert Ancell
bd19181117
Add braces on if statements to match linter style (#22130) 2020-11-03 12:32:39 +13:00
Robert Ancell
8d3d953192
Fix warning when no entrypoing args provided. (#22136)
Fixes errors like:
GLib-CRITICAL **: 14:20:17.248: g_strv_length: assertion 'str_array != NULL' failed

Introduced in fc72bd2ada5d8d9b4ab2c1255d4f960cc44b5de0
2020-10-30 14:57:35 +13:00
Robert Ancell
382f5ccba5
Fix incorrect parameter used for self object (#22135)
Fix incorrect parameter used for self object

Rename the GWeakNotify function parameters.
This matches the prototype and makes it harder to accidentally use the object
parameter the wrong way.
2020-10-30 14:52:24 +13:00
J-P Nurmi
bb32446c68
Fix FlTextInputPlugin tear down (#22007) 2020-10-29 15:18:04 -07:00
J-P Nurmi
28497c864b
Fix typos in FlValue docs (#21875) 2020-10-29 15:13:04 -07:00
Anirudh Balaji
b457e2dd85
Refactor make_mock_engine into fl_test (#21585) 2020-10-29 15:08:03 -07:00
Robert Ancell
5ca5e2614b
Add FlEventChannel (#21316)
Related to https://github.com/flutter/flutter/issues/65270
2020-10-22 15:06:52 -07:00
stuartmorgan
1233fe4902
Revert "Revert "Explicitly make the X connection for EGL. (#21831)" (#21851)" (#21871)
This reverts commit d2ea378be45dd0de7a86b521d48240fd9d276283.
2020-10-22 13:50:14 -07:00
George Wright
fc72bd2ada
Plumb through Dart entrypoint arguments on the Linux embedder (#21933) 2020-10-22 09:47:04 +13:00
Damian Wrobel
91c81ebfae
Fix linking issue (missing wayland-client library) (#21408)
As fl_renderer_wayland.cc uses directly some of the wayland-client
related functions it should also add this library as a dependency.
2020-10-20 05:47:40 -07:00
Chris Bracken
bcc557f1ba
Add multi-step input method support for Linux (#21897)
This implements the Gtk hooks required to support multi-step input
methods on Linux. This builds on the support for composing regions
(preedit region in Gtk terminology) added to TextInputModel in
https://github.com/flutter/engine/pull/21682.

Specifically, the following changes are included:

1. Add handler for TextInput.setMarkedTextRegion framework messages: On
any change to the EditableText in the framework, this message is sent
which provides an updated rect (in the local co-ordinates of the
EditableText) for the composing region. If not in composing mode, the
cursor rect is sent.

2. Add handler for TextInput.setEditableSizeAndTransform framework messages:
On any change to the RenderObject underlying the EditableText, an
updated size for the full EditableText widget, as well as an affine
transform matrix from local co-ordinates to Flutter root co-ordinates is
sent.

3. On either of the above messages, we use the transformed composing
rect to compute the cursor position in Gtk window co-ordinates and
inform Gtk, so that it can position any system IM composing window
correctly for on-the-spot composing, such as is used when inputting
Japanese text.

4. Adds handlers for preedit-start, preedit-changed, and preedit-end
signals from Gtk. These are passed on to the TextInputModel.

5. Updates the preedit-commit handler to commit the composing region to
the text or, if not composing, insert new text at the cursor.

6. Updates the handler for TextInput.setEditingState framework messages
to extract the composing range base and extent and pass these on to
TextInputModel.

7. Updates update_editing_state function to set composing base and
extent on text input state updates sent to the framework.
2020-10-19 16:25:56 -07:00
J-P Nurmi
9946be45a9
FlTextInputPlugin: fix memory leaks (#21879)
This PR fixes a few small memory leaks in FlTextInputPlugin. All three cases
are creating temporary FlValue instances for lookups and comparison without
ever releasing them.
2020-10-19 16:23:10 -07:00
Chris Bracken
b8fd0013a8
Update FLUTTER_NOLINT uses to include issue link (#21921)
In an upcoming patch, we'll enable enforcement that all FLUTTER_NOLINT
comments include an issue link. This migrates the remaining uses to that
format.

Bug: https://github.com/flutter/flutter/issues/68273
2020-10-16 16:08:36 -07:00
Chris Bracken
b715d3f21d
Migrate TextInputPlugin API to TextRange (#21854)
Replaces selection_base() and selection_extent() with selection() and
SetSelection(int, int) with SetSelection(range).

This also adds the following convenience methods to TextRange:
* reversed()
* Contains(size_t position)
* Contains(const TextRange& range)

as well as operator== for use in unit tests. When Flutter migrates to
C++20, we can replace that method with a default declaration.
2020-10-15 09:54:06 -07:00
gaaclarke
d2ea378be4
Revert "Explicitly make the X connection for EGL. (#21831)" (#21851)
This reverts commit 516cbaee8736cb4bbc9fdaa6af4ae9a2ec55c5cc.
2020-10-14 16:30:40 -07:00
Robert Ancell
516cbaee87
Explicitly make the X connection for EGL. (#21831)
Explicitly make the X connection for EGL.

EGL can mistakenly choose the GBM backend when using EGL_DEFAULT_DISPLAY.

Fixes https://github.com/flutter/flutter/issues/60429
2020-10-15 11:06:08 +13:00
Damian Wrobel
6634406889
Support Wayland only (without X11 support in gdk) (#21218)
Adds a support for compiling flutter engine when
gdk does not have X11 backend. In such a configuration
the generated gdkconfig.h header file looks like the following:

 /* gdkconfig.h
  *
  * This is a generated file.  Please modify `configure.ac'
  */

 #ifndef __GDKCONFIG_H__
 #define __GDKCONFIG_H__

 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
 #error "Only <gdk/gdk.h> can be included directly."
 #endif

 #include <glib.h>

 G_BEGIN_DECLS

 #define GDK_WINDOWING_WAYLAND

 G_END_DECLS

 #endif  /* __GDKCONFIG_H__ */

Additionally headers like <gdk/gdkx.h> are not available at all.

Above configuration can be found on the most of the embedded systems.

This patch enables compilation of X11 specific code only when gdk
defines GDK_WINDOWING_X11.

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-10-13 15:54:44 +13:00
J-P Nurmi
d9a24814c5
Add workaround for missing fl_method_xxx_response_get_type() symbols (#21405) 2020-10-12 19:32:02 -07:00
J-P Nurmi
2ab369fca1
fl_method_response.cc: fix lint failures (#21406)
Fix lint issues caused by `google-readability-braces-around-statements`.
2020-10-08 14:47:07 -07:00
Justin McCandless
9a7b556f91
hasStrings Linux (#21388)
hasStrings method for clipboard status, Linux
2020-10-06 16:29:12 -07:00
stuartmorgan
042c7f0422
[linux] Allow engine flags via environment vars (#21497)
Adds the ability to pass engine switches temporarily at runtime via
environment variables. Uses the same approach recently added to
Windows and macOS.

This is enabled only for debug/profile to avoid potential issues with
tampering with released applications, but if there is a need for that in
the future it could be added (potentially with a whitelist, as is
currently used for Dart VM flags).

Fixes flutter/flutter#60393
2020-10-06 11:17:19 -07:00
Chris Bracken
7e6191de07
Separate mutators for text and selection (#21612)
Previously, TextInputModel's SetEditingState method was a 1:1 mapping of
the underlying protocol used on the text input channel between the
framework and the engine. This breaks it up into two methods, which
allows the selection to be updated independently of the text, and avoids
tying the API the the underlying protocol.

This will become more important when we add additional state to support
composing regions for multi-step input methods such as those used for
Japanese.

SetText resets the selection rather than making a best-efforts attempt
to preserve it. This choice was primarily to keep the code simple and
make the API easier to reason about. An alternative would have been to
make a best-effort attempt to preserve the selection, potentially
clamping one or both to the end of the new string. In all cases where an
embedder resets the string, it is expected that they also have the
selection, so can call SetSelection with an updated selection if needed.
2020-10-06 11:07:21 -07:00
Robert Ancell
5e9b235b8e
Detect errors encoding method channel responses (#21314) 2020-09-25 10:33:38 +12:00
Robert Ancell
e17cb83726
Fix segfault if engine is disposed with an uncompleted task. (#21234) 2020-09-24 11:29:38 +12:00
Damian Wrobel
2226c2a1ec
Add missing cstring header (fixes fl_renderer_wayland.cc) (#21217) 2020-09-16 09:07:01 -07:00
William Wold
dbab3fc553
Add Linux Wayland support (#20629) 2020-09-16 14:13:06 +12:00
Damian Wrobel
21fd8917c0
Add missing <cstring> header for (strcmp, strrchr) (#21176)
Fixes the following compilation errors:
../../flutter/shell/platform/linux/fl_platform_plugin.cc:89:7: error: use of undeclared identifier 'strcmp'
  if (strcmp(format, kTextPlainFormat) != 0) {
      ^
../../flutter/shell/platform/linux/fl_platform_plugin.cc:127:7: error: use of undeclared identifier 'strcmp'
  if (strcmp(method, kSetClipboardDataMethod) == 0)
      ^
../../flutter/shell/platform/linux/fl_platform_plugin.cc:129:12: error: use of undeclared identifier 'strcmp'
  else if (strcmp(method, kGetClipboardDataMethod) == 0)
           ^
../../flutter/shell/platform/linux/fl_platform_plugin.cc:131:12: error: use of undeclared identifier 'strcmp'
  else if (strcmp(method, kSystemNavigatorPopMethod) == 0)
           ^
../../flutter/shell/platform/linux/fl_view.cc:194:7: error: use of undeclared identifier 'strcmp'
  if (strcmp(pspec->name, "scale-factor") == 0) {
      ^
../../flutter/shell/platform/linux/fl_engine.cc:67:18: error: use of undeclared identifier 'strrchr'
  gchar* match = strrchr(l, '@');
                 ^
../../flutter/shell/platform/linux/fl_engine.cc:75:11: error: use of undeclared identifier 'strrchr'
  match = strrchr(l, '.');
          ^
../../flutter/shell/platform/linux/fl_engine.cc:83:11: error: use of undeclared identifier 'strrchr'
  match = strrchr(l, '_');
          ^

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-09-15 08:05:12 -07:00
Greg Spencer
d19a6fab13
Track lock key down state instead of lock state (#20836)
This converts the GTK keyboard code to track the key down states of the lock modifiers NumLock and CapsLock so that they represent the actual "down" state of the key, rather than the lock state itself.

GTK tracks the lock state, and Flutter expects the down state.
2020-09-13 14:44:25 -07:00
Chris Bracken
08dabe9601
Clean up C++ includes (#21127)
Cleans up header order/grouping for consistency: associated header, C/C++ system/standard library headers, library headers, platform-specific #includes.

Adds <cstring> where strlen, memcpy are being used: there are a bunch of places we use them transitively.

Applies linter-required cleanups. Disables linter on one file due to included RapidJson header. See https://github.com/flutter/flutter/issues/65676

This patch does not cover flutter/shell/platform/darwin. There's a separate, slightly more intensive cleanup for those in progress.
2020-09-11 21:18:35 -07:00
Chris Bracken
16b900b63e
Prefer C++ standard headers to their C counterpart (#21091)
We currently use a mix of C standard includes (e.g. limits.h) and their
C++ variants (e.g. climits). This migrates to a consistent style for all
cases where the C++ variants are acceptable, but leaves the C
equivalents in place where they are required, such as in the embedder
API and other headers that may be used from C.
2020-09-11 17:10:00 -07:00
Chris Bracken
fd17e0846b
Fix linter errors in mock_engine (#21102)
Make a single-param ctor explicit in order to prevent surprising
implicit conversions.

Add a check for zero message-size and don't malloc/memcpy the incoming
message in those cases.

Add braces where they were missing.
2020-09-11 10:27:00 -07:00
Damian Wrobel
e831433a20
Add missing <cstring> header (#21069)
Fixes the following compilation errors:

../../flutter/shell/platform/linux/fl_value.cc:267:3: error: use of undeclared identifier 'memcpy'
  memcpy(self->values, data, sizeof(uint8_t) * data_length);
  ^
../../flutter/shell/platform/linux/fl_value.cc:284:3: error: use of undeclared identifier 'memcpy'
  memcpy(self->values, data, sizeof(int32_t) * data_length);
  ^
../../flutter/shell/platform/linux/fl_value.cc:294:3: error: use of undeclared identifier 'memcpy'
  memcpy(self->values, data, sizeof(int64_t) * data_length);
  ^
../../flutter/shell/platform/linux/fl_value.cc:304:3: error: use of undeclared identifier 'memcpy'
  memcpy(self->values, data, sizeof(double) * data_length);
  ^

../../flutter/shell/platform/linux/fl_string_codec.cc:29:28: error: use of undeclared identifier 'strlen'
  return g_bytes_new(text, strlen(text));
                           ^

../../flutter/shell/platform/linux/fl_standard_message_codec.cc:512:23: error: use of undeclared identifier 'strlen'
      size_t length = strlen(text);
                      ^

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2020-09-10 09:24:54 -07:00
William Wold
1a034bde75
Replace FlRenderer::get_visual() with more generic FlRenderer::setup_window_attr() (#20833) 2020-08-28 14:31:34 +12:00
William Wold
dcb9244c38
Consolidate FlRenderer initialization into fl_renderer_start() (#20763) 2020-08-28 09:57:14 +12:00
Maksim Lin
57fdf0a1fb
send newline char when input type is multiline (#20660) 2020-08-25 10:51:02 -07:00
William Wold
7a022774c2
Improve FlRenderer interface in preperation for Wayland on Linux (#20006) 2020-08-05 12:04:01 +12:00
Robert Ancell
ab23dc3a74 Update code style to pass clang-tidy checks 2020-08-05 10:35:03 +12:00
Robert Ancell
083282e33b Fix Implments typo 2020-08-03 10:45:01 +12:00
Robert Ancell
8fbdd3f1bd Fix parameter names 2020-08-03 10:44:20 +12:00
Siva
b955e15ee9
Manual roll of Dart from 24c7666def...40fd1c456e (#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
29f63349c8
Fix invalid selection handling in text plugins (#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