428 Commits

Author SHA1 Message Date
Robert Ancell
bb8679e23f Move send_key_event from FlKeyboardViewDelegate to FlKeyboardManager. (flutter/engine#56020)
Ideally the tests would mock FlEngine, but I wasn't able to get it
working so I've added fl_keyboard_manager_set_send_key_event_handler for
now.
2024-10-23 22:05:09 +13:00
Robert Ancell
15129c0bbc Move keymap from FlKeyboardViewDelegate to FlKeyboardManager (flutter/engine#55942)
Ideally the tests would mock gdk_keymap_lookup_key, but I wasn't able to get it working so I've added fl_keyboard_manager_set_lookup_key_handler for now.
2024-10-19 01:36:10 +00:00
Robert Ancell
aca239fe59 Move redispatch_event from FlKeyboardViewDelegate to FlKeyboardManager (flutter/engine#55941)
Events can only be redispatched using gdk_event_put which is not
dependent on the view.

Ideally the tests would mock gdk_event_put, but I wasn't able to get it
working so I've added fl_keyboard_manager_set_redispatch_handler for
now.
2024-10-18 14:34:52 +13:00
Robert Ancell
a54730d091 Remove FlKeyResponder and use the two responder classes directly. (flutter/engine#55925)
We only ever have two classes and implementation, so reduce complexity
by removing the parent class and related code.
2024-10-18 13:19:47 +13:00
Robert Ancell
2ccc210029 Remove obsolete fl_keyboard_view_delegate_get_messenger (flutter/engine#54857)
This is unnecessary - we already have the messenger.
2024-10-16 14:53:27 +13:00
Robert Ancell
6203c3e0f3 Split FlKeyboardManager out of FlKeyboardHandler (flutter/engine#55892)
They continue to share a FlKeyboardViewDelegate, but this will be split
too in a later change as part of moving these classes from FlView to
FlEngine.
2024-10-16 13:26:42 +13:00
Robert Ancell
db1e63b948 Simplify code for dispatching events (flutter/engine#55871) 2024-10-16 10:00:34 +13:00
Robert Ancell
0388529ef9 Use GWeakRef API (flutter/engine#55795)
For consistency with other code.
2024-10-14 14:36:37 +13:00
Robert Ancell
e0daa80cb2 Remove unnecessary use of std::vector (flutter/engine#55796) 2024-10-14 13:57:12 +13:00
Robert Ancell
7790182059 Remove fl_keyboard_view_delegate_subscribe_to_layout_change and just access the object directly via a method (flutter/engine#55817)
A step on the way to get FlKeyboardHandler out of FlView and into
FlEngine.
2024-10-14 13:54:05 +13:00
Robert Ancell
24ceeac432 Split out FlKeyboardLayout into its own class (flutter/engine#55816) 2024-10-14 12:07:26 +13:00
Robert Ancell
b9db87f8ac When rendering into secondary views, copy the pixel contents between contexts (flutter/engine#55639)
This is because GTK3 can't share contexts between GtkGLAreas.

We may be able to avoid the copy using the GL_OES_EGL_image or
GL_OES_EGL_image_external extensions.

Note that keyboard input doesn't work on the secondary view, this
requires moving the keyboard handling from FlView to FlEngine. Proposing
this now as a step forwards, but not yet useful for real applications.
2024-10-14 12:05:12 +13:00
Robert Ancell
b857ade17e Make FlRenderable interface (flutter/engine#55763)
Added to make testing of FlRenderer easier.
2024-10-14 10:30:41 +13:00
Robert Ancell
e5ecdd9c94 Fix dispose methods that didn't chain the parent. (flutter/engine#55794)
Remove empty dispose methods and convert finalize methods to dispose for
consistency.
2024-10-14 09:40:47 +13:00
Robert Ancell
971dbd79fb Refactor FlKeyboardHandler (flutter/engine#55601)
Refactor FlKeyboardHandler to be more GObject and less C++.

Done as we will need to move the handler from FlView to FlEngine to
support multi-view.
2024-10-04 12:00:00 +13:00
Robert Ancell
788cdbe3be Deregister views when they are destroyed (flutter/engine#55542) 2024-10-02 10:00:33 +13:00
Robert Ancell
166590d6c2 Allocate a view ID for secondary views (flutter/engine#55541)
Allocate view IDs for secondary Flutter views - another step towards
full multi-view support.
2024-10-02 09:04:31 +13:00
Robert Ancell
53b8ece3c8 Use GTask integer return APIs and fix documentation on return value on error. (flutter/engine#55353) 2024-09-24 13:25:15 +12:00
Robert Ancell
3443af6a5c Delay the window until the first frame is received from the Flutter engine (flutter/engine#54703)
Fixes https://github.com/flutter/flutter/issues/151098
2024-09-17 10:48:43 +12:00
Robert Ancell
e3f49a5875 Match Windows logic for picking RGB/BGR textures. (flutter/engine#55121)
The existing code had a lot of additional checks that didn't seem to
need to be there.

BGR could be passed back to Flutter, but this was never used in creating
the texture.

There has been a report of a Flutter app on Linux with swapped red and
blue color channels, so this seems like it is likely not working on some
drivers.

The original logic was introduced in
87509d8518cea0e90912cc30b08192b1dd4da760
2024-09-16 12:17:57 +12:00
Robert Ancell
420b1b5d44 Filter out bad locales returned by g_get_language_names (flutter/engine#55091)
We're seeing issues with and "und" (undefined) locale and exceptions in
applications (see https://github.com/ubuntu/app-center/issues/1659). It
seems the GLib method for getting the language names doesn't clean up
invalid values, so we should do that.
2024-09-13 11:40:52 +12:00
Robert Ancell
2a10ec7c44 Fix crash quitting application due to iterating over a changing list. (flutter/engine#55062)
Detected as the FlPlatformHandlerTest.ExitApplicationDispose was
crashing sometimes, valgrind showed invalid memory access.
2024-09-12 09:40:45 +12:00
Robert Ancell
a89c2ae2a4 Use a signal for the pre-engine restart event (flutter/engine#55063)
With multiple FlViews a callback doesn't scale.
2024-09-12 09:25:52 +12:00
Robert Ancell
d6415a16c7 Make FlApplication class (flutter/engine#54637)
An app can now be:
```c
#include <flutter_linux/flutter_linux.h>

#include "flutter/generated_plugin_registrant.h"

static void register_plugins_cb(FlApplication *app, FlPluginRegistry *registry) {
  fl_register_plugins(registry);
}

static GtkWindow *create_window_cb(FlApplication *app, FlView *view) {
  GtkApplicationWindow *window =
      GTK_APPLICATION_WINDOW(gtk_application_window_new(GTK_APPLICATION(app)));

  gtk_window_set_title(GTK_WINDOW(window), "flutter_application_test");
  gtk_window_set_default_size(GTK_WINDOW(window), 1280, 720);

  gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));

  return GTK_WINDOW(window);
}

int main(int argc, char** argv) {
  g_autoptr(FlApplication) app = fl_application_new(APPLICATION_ID, G_APPLICATION_NON_UNIQUE);
  g_signal_connect(app, "register-plugins", G_CALLBACK(register_plugins_cb), nullptr);
  g_signal_connect(app, "create-window", G_CALLBACK(create_window_cb), nullptr);
  return g_application_run(G_APPLICATION(app), argc, argv);
}
```

With this simplified, we can now build multi-window behaviour without having to modify the template much in the future.

Fixes https://github.com/flutter/flutter/issues/142920
2024-09-03 16:02:21 +12:00
Robert Ancell
3fc9ab6c1a Store a set of layers per view. (flutter/engine#54793)
This means when rendering the correct layers are rendered for a view.
2024-08-27 20:28:05 +12:00
Robert Ancell
4b992b898f Use TRUE/FALSE consistently for gboolean values. (flutter/engine#54768)
Some code was using stbool true/false - use the gboolean values
consistently.
2024-08-27 15:43:13 +12:00
Robert Ancell
2bbc3b4b41 Allow the default background color to be changed (flutter/engine#54575)
Fixes https://github.com/flutter/flutter/issues/149920
2024-08-20 08:00:06 +12:00
Robert Ancell
5c4ffe8f9c Add a precision to the fragment shader (flutter/engine#54109)
This is required for OpenGL ES.

See https://registry.khronos.org/OpenGL/specs/es/3.2/GLSL_ES_Specification_3.20.html#precision-and-precision-qualifiers

https://github.com/flutter/flutter/issues/152297
2024-08-08 20:07:41 +00:00
Chris Bracken
853222c175 Revert "Set GLArea.has-alpha = true (#54053)" (flutter/engine#54190)
Reason for revert: Regression + no tests. Must have been at the end of a long day, cause I missed the missing test and glaring warning about that.

This reverts commit 0325e590babb33963dc35283cd425b39290919e5.

Re-opens https://github.com/flutter/flutter/issues/152154

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-07-29 20:09:04 +00:00
Sam Lakerveld
0325e590ba Set GLArea.has-alpha = true (flutter/engine#54053)
GLArea.has-alpha defaults to false, which makes it impossible for a Flutter app to be transparent.

The additional change to glClearColor is to prevent a black flash when the application starts, before Flutter widgets become visible. This will also affect applications that aren't transparent, by showing the default GTK background color instead of black. This will not make the window transparent, because the developer currently has to add some code to their `linux/my_application.cc` to support transparency.

Fixes flutter/flutter#152154

Transparent windows were possible before #50754. Would it be ok to add a test for this to prevent breaking transparency again in the future?

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-07-26 16:48:05 +00:00
Robert Ancell
613b0b2fb2 Remove unused virtual methods (flutter/engine#54074) 2024-07-26 04:51:12 +12:00
Robert Ancell
385b900221 Allow creating views from an external engine (flutter/engine#54080)
While only one view works at this point in the future this will allow a runner to create multiple views.
2024-07-25 19:45:37 +12:00
Robert Ancell
12a4ffb403 Support multiple views in FlRenderer (flutter/engine#54072) 2024-07-25 19:44:52 +12:00
Robert Ancell
102617432b Don't rely on the renderer accessing the engine through the view. (flutter/engine#54049)
In the multi-view case there will be 0-N views, so instead hold a weak
reference on the engine.
2024-07-25 02:41:31 +12:00
Robert Ancell
83dca15abd Rename FlBackingStoreProvider to FlFramebuffer (flutter/engine#54047)
The name was confusing, as it only provided one type of backing store.
FlBackingStoreProvider sounds more like an interface that the
FlFramebuffer would implement if we had multiple backing stores.

Use OpenGL types for values.

Fix cases where this was sometimes called a texture.

Improve documentation.

Remove the use of GdkRectangle for dimensions - the framebuffer only has
a width and a height. There was code that was using the x,y values which
would always have been zero - this has now been removed.
2024-07-24 18:55:36 +12:00
Robert Ancell
bc9c7efb58 Remove unnecessary double cast (flutter/engine#54044) 2024-07-24 18:54:42 +12:00
Robert Ancell
904a1ab58f Fix variable name (flutter/engine#54045) 2024-07-24 18:54:30 +12:00
Robert Ancell
94a7e50936 Temporarily disable use of glBlitFramebuffer on NVIDIA (flutter/engine#54040)
Workaround for https://github.com/flutter/flutter/issues/152099
2024-07-24 05:08:11 +12:00
Robert Ancell
c9ddcc41a4 Set the view ID for FlView (flutter/engine#54043)
Follow up to https://github.com/flutter/engine/pull/54018.
2024-07-24 04:57:12 +12:00
Robert Ancell
e1f2360083 Add fl_engine_add/remove_view (flutter/engine#54018)
This is API that will be required when we get multi-view support on
Linux. While this internal API is not currently used, I've made a PR so
it can be more easily reviewed.
2024-07-23 23:34:47 +12:00
Robert Ancell
d11f10ccb6 Make FlWindowStateMonitor (flutter/engine#54011)
Split window state monitor out of FlView and FlEngine to make it easier
to handle different API when using GTK4. It also allows better tests.
2024-07-23 22:47:56 +12:00
Robert Ancell
7855b2c857 Don't leak binary messenger in tests (flutter/engine#53985)
Looks like the original code was just copied around. Should have no
effect on the tests other than making it easier to detect other leaks.
2024-07-19 14:36:32 +12:00
Robert Ancell
4a63063be6 Renamed plugin classes to handler (flutter/engine#53736)
The Linux embedder had a number of handlers for Flutter channels that
were named plugin/handler/manager. Rename these all to handler to be
consistent and reduce confusion with Flutter plugins (which these don't
use the infrastructure for).
2024-07-19 12:44:41 +12:00
Robert Ancell
dde01765c9 Use glBlitFramebuffer when rendering (flutter/engine#53080)
This is much faster than using a shader which is not required currently
(we are not doing any transformations).
2024-07-18 16:02:39 +12:00
Robert Ancell
e3b2d11dba Restore creation of engine before Linux widget is realized. (flutter/engine#53604)
Due to changes in the renderer in fc560d4 the engine was created once a
widget is realized, not when the widget is created. If a Flutter
application changed the default my_application.cc template to show the
Flutter widget after plugins are run then these plugins would not be
able to access the engine.

Solved by removing the GdkWindow from the renderer constructor and
setting in later when the widget is realized. This works because the
renderer is not used until the widget is realized.
    
Fixes https://github.com/flutter/flutter/issues/144873
2024-07-02 17:18:07 +12:00
Callum Moffat
22f181c1d3 Map mouse pointer type on Linux (flutter/engine#52418)
Before all mouse clicks were set to `PointerDeviceKind.mouse` on Linux. Now use the proper type according to the source `GdkEvent`.

Fixes https://github.com/flutter/flutter/issues/147277
2024-06-10 22:35:55 +00:00
Robert Ancell
2eff476e2c Fix rendering corruption by Flutter and GDK sharing the same OpenGL context (flutter/engine#53103)
Fix rendering corruption by Flutter and GDK sharing the same OpenGL
context

Solved by having three contexts - one for GDK and two for Flutter.

Regression introduced in https://github.com/flutter/engine/pull/50754

Fixes https://github.com/flutter/flutter/issues/148653
2024-06-04 11:02:09 +12:00
Yegor
d3b6b1be14 add SemanticsAction.focus (flutter/engine#53094)
Add `SemanticsAction.focus`. This PR just adds the new enum value without any logic. Adding the enum value first to unblock work that needs to be done on both the engine and framework side that will actually implement all the necessary logic.

This is PR 1 out of ~3 for https://github.com/flutter/flutter/issues/83809
2024-05-30 17:15:53 +00:00
Byoungchan Lee
d56c301037 Add Linux platform support for fetching refresh rate on startup. (flutter/engine#52934)
This patch addresses the missing implementation of
`platformDispatcher.views` on Linux. It checks the refresh rate of the
renderer's window and returns the value. Without this implementation,
`WidgetsBinding.instance.platformDispatcher.views.first.display.size`
would throw an exception on Linux, preventing safe usage.

Related: https://github.com/flutter/flutter/issues/144230
2024-05-28 12:38:07 +12:00
auto-submit[bot]
ea811b97ba Reverts "Manual roll of Clang from 725656bdd885 to 145176dc0c93 (#52823)" (flutter/engine#52890)
Reverts: flutter/engine#52823
Initiated by: zanderso
Reason for reverting: Engine crashes on framework CI following this roll https://ci.chromium.org/ui/p/flutter/builders/prod/Linux_android%20flutter_gallery__transition_perf_with_semantics/12126/overview
Original PR Author: jason-simmons

Reviewed By: {zanderso}

This change reverts the following previous change:
See https://github.com/flutter/flutter/issues/143178
2024-05-16 22:01:38 +00:00