201 Commits

Author SHA1 Message Date
Damian Wrobel
4ba79a34a0
Fix argument specifier for g_warning() (#23674)
Fixes the following compilation error:
 ../../flutter/shell/platform/linux/fl_key_event_plugin.cc:189:7:
 error: format specifies type 'long' but the argument has type
 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
2021-01-28 14:36:02 -08:00
Robert Ancell
546e70df8c Use the scroll multiplier that the Chromium source uses.
Fixes https://github.com/flutter/flutter/issues/71385
2021-01-14 09:06:36 +13:00
Robert Ancell
047f3180d9 Only handle smooth scroll events.
On X11 scroll events are being directly sent to the FlView X window. This is
causing them to bypass the normal scroll handling and means this widget received
both smooth and non-smooth scroll events.

I haven't been able to find a solution to the root cause of the problem, so only
smooth scroll event are being processed. This could cause issues on older
versions of the X server that don't send smooth scroll events, but fixes the
problem for the common modern case.

This issue doesn't occur in Wayland.
2021-01-14 09:06:36 +13:00
Robert Ancell
20991a5985
Add accessibility suport to Linux shell. (#19634)
Add accessibility support to the Linux shell
2021-01-13 13:49:48 +13:00
Robert Ancell
5fd25a971c Only remove weak pointers that are set.
If the pointer has already been removed this generates a runtime warning.
2021-01-12 15:35:39 +13:00
Greg Spencer
250dcd5287
Fix indexing error in Linux key event handling (#23598)
Fixes an indexing error in the linux key handling code.

I also found another error when checking to see if an event is re-dispatched, and some off-by-one errors in the search. Not sure what I was smoking that day, but hopefully these are all the issues.
2021-01-11 13:01:06 -08:00
Robert Ancell
48edbf3d1d Re-enable test 2021-01-11 11:36:40 +13:00
Robert Ancell
36fa767d4a Fix double frees in FlSettingsPlugin tests.
Fixes https://github.com/flutter/flutter/issues/73517
2021-01-11 11:36:40 +13:00
Robert Ancell
59a965eaef Remove debugging code 2021-01-11 11:36:40 +13:00
Greg Spencer
9cb4d2dd24
Make pending event handling more lenient to allow out of order responses (#23504)
This PR makes the Linux key handling code a little more lenient when it comes to the order in which it receives responses to key events from the framework. I had assumed that there wasn't a case where responses could get out of order, but it seems that it is possible, given that you can mash on the keyboard and eventually get one out of order.

This changes the code so that instead of just looking at the first entry in the pending event deque, it searches the deque starting at the beginning to find the event, and remove it.
2021-01-08 10:43:59 -08:00
Jason Simmons
5f7a12097f
Skip the FlEngineTest.SettingsPlugin test (#23516)
See https://github.com/flutter/flutter/issues/73517
2021-01-07 17:03:28 -08:00
Damian Wrobel
3a1b62b362
Fix argument specifier for g_warning() (#23138) 2021-01-07 15:34:03 -08:00
Robert Ancell
90d1f05686
Implement settings channel for the Linux shell (#22486)
Implement settings channel for the Linux shell

Fixes https://github.com/flutter/flutter/issues/65591
2021-01-05 12:28:43 +13:00
Robert Ancell
02abfc9360 Add engine tests for Linux shell 2021-01-05 09:50:52 +13:00
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