405 Commits

Author SHA1 Message Date
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
Jason Simmons
31d7cb2870 Manual roll of Clang from 725656bdd885 to 145176dc0c93 (flutter/engine#52823)
See https://github.com/flutter/flutter/issues/143178
2024-05-16 17:16:21 +00:00
Robert Ancell
2ab69c9f42 Use a AT-SPI socket/plug to export the Flutter accessibility state. (flutter/engine#52355)
This will be useful when using GTK4, which doesn't support custom a11y
code in GTK and will require the Flutter code to be exported in a plug.
2024-04-29 09:34:20 +12:00
Jason Simmons
b84c057bfb Fix some warnings reported by recent versions of clang-tidy (flutter/engine#52349)
* Invalid enum values in the embedder library
* Disable a check that warns about standard usage of GTK macros in the Linux embedder
2024-04-24 17:46:19 +00:00
Robert Ancell
2ba71d60e9 Fix incorrect function name in documentation (flutter/engine#52184) 2024-04-18 09:23:21 +12:00
Jason Simmons
e5d0cae6cd Save and restore OpenGL bindings that are changed by fl_renderer_render (flutter/engine#51887)
fl_renderer_render uses the raster thread GL context that is also used by Skia.  Skia expects that its bindings have not been changed elsewhere.
2024-04-11 19:39:03 +00:00
Robert Ancell
ae2ac7f706 Add fl_standard_method_codec_new_with_message_codec() (flutter/engine#51599)
Matches constructor in
https://api.flutter.dev/flutter/services/StandardMethodCodec-class.html
and is required to make method calls with custom value types.
2024-03-25 14:06:27 +13:00
Tong Mu
ba26f6ee8b Multi-view View Metrics (flutter/engine#46174)
This PR adds `FlutterWindowMetricsEvent.viewId` to the embedder API.

This PR only tests the ability to send metrics event for the implicit
view. Once multiple views can be added via embedder API, we should test
the ability to send different IDs.

Part of https://github.com/flutter/flutter/issues/144806
Part of https://github.com/flutter/flutter/issues/142845

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I signed the [CLA].
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-03-13 17:00:17 -07:00
Zachary Anderson
2fdc3293eb Disable flaky linux desktop test (flutter/engine#51231)
For https://github.com/flutter/flutter/issues/138197
2024-03-06 20:27:00 +00:00
Robert Ancell
614df9461d Fix custom FlValue API not being exported (flutter/engine#51154)
Would fail to link when using it in a Flutter app.
2024-03-04 15:05:41 +13:00
Robert Ancell
fc560d4bc2 Refactor GL rendering to prepare for GTK4 (flutter/engine#50754)
Refactor GL rendering to prepare for GTK4    
- Remove FlGLArea - we can just use GtkGLArea directly
- Stop using gdk_cairo_draw_from_gl, it's not available in GTK4.
- Rename FlRendererGL to FlRendererGdk, this was implying that
FlRenderer could be something other than OpenGL which is not the case
currently.
- Remove unnecessary virtual methods in FlRenderer, just implement them
as standard methods.

Related: https://github.com/flutter/flutter/issues/143408
2024-03-01 10:24:11 +13:00
Robert Ancell
da5550db7f Update Linux embedder to latest semantics API (flutter/engine#51030)
Change to the latest semantics API and remove an unused class.
2024-02-29 15:18:19 +13:00
Robert Ancell
1aa5dbf113 Code consistency fixes in FlScrollingManager (flutter/engine#50959) 2024-02-28 09:06:20 +13:00
Zachary Anderson
f6629ffe5c Use 'et format' in CI. Check formatting of all files in CI (flutter/engine#50810)
This PR changes the format check on CI to use the command added in
https://github.com/flutter/engine/pull/50747.

Additionally, while making this change, I noticed that the CI check was
not checking the formatting of all files, and that as a result, files
were present in the repo with incorrect formatting. I have fixed the
formatting and fixed the check to always check all files.
2024-02-21 09:38:08 -08:00
Robert Ancell
0c1e0846c0 Connect signals in swapped form. (flutter/engine#50705)
This makes them look more like methods.
2024-02-16 17:01:03 -08:00
Chinmay Garde
6c17d7bf9d Use a GN variable (dart_src) to reference the location of the Dart checkout. (flutter/engine#50624)
Towards https://github.com/flutter/flutter/issues/143335
2024-02-14 21:12:23 -08:00
Robert Ancell
51c9fc1c08 Replace usage of an integer for GdkModifierType (flutter/engine#50481)
The integer is replaced with the enumerated type in GTK4. The
documentation in GTK3 indicates the value is the enumerated type.
2024-02-13 12:26:46 +13:00
Robert Ancell
08995aae83 Remove FlKeyEvent.dispose_origin and use GdkEvent type for origin (flutter/engine#50483)
This removes casting. origin was a pointer for testing purposes to be
mocked but the tests make no use of this.
2024-02-13 12:19:29 +13:00
Robert Ancell
6f39b9941b Clear objects before setting them. (flutter/engine#50344)
The existing code worked, but it cleared the objects before calling
init_keyboard. This made it look like init_keyboard might leak the
existing values. If a third case was added later where init_keyboard was
called it would leak if the caller didn't clear the objects before
calling it.
2024-02-08 16:20:57 +13:00
Robert Ancell
bd70ef1215 Remove string field from FlKeyEvent (flutter/engine#50189)
This field is deprecated in GTK3 [1] and not used in Flutter. It does
not exist in GTK4.

[1] https://docs.gtk.org/gdk3/struct.EventKey.html
2024-02-01 16:17:19 +13:00
Jason Simmons
e6d660a059 Handle construction/destruction of GObject private data containing C++ objects in Linux embedder tests (flutter/engine#50022)
See https://github.com/flutter/flutter/issues/140183
2024-01-29 20:07:04 +00:00
Matan Lurey
e9e5a237f8 Finish landing missing/incorrect header guards across flutter/engine (flutter/engine#50069)
Generated by https://github.com/flutter/engine/pull/48903 (`dart ./tools/header_guard_check/bin/main.dart --fix`).

As discussed with @cbracken and @jmagman, the guards are not technically needed on the Mac/iOS code, but they (a) do not hurt and (b) still provide value if for some reason `#include` is used instead of `#import` (though I suspect we could try to add that to the tool in the future as well).
2024-01-26 19:42:36 +00:00
Robert Ancell
7efa9951c2 Add custom FlValue types and support their en/decoding via FlStandardMessageCodec (flutter/engine#49162)
Add Linux support for custom data types in Flutter channels.

Fixes https://github.com/flutter/flutter/issues/140299
2024-01-25 09:29:54 +13:00
Loïc Sharma
9792c4bd03 Reland "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49726)
## Original pull request description

This migrates the Windows embedder to `FlutterCompositor` so that the engine renders off-screen to a framebuffer instead of directly onto the window's surface. This will allow us to support platform views and multiple views on Windows.

Addresses https://github.com/flutter/flutter/issues/128904

## Reland (again)

https://github.com/flutter/engine/pull/49262 was reverted as it regressed [`package:material_floating_search_bar_2`](https://pub.dev/packages/material_floating_search_bar_2/versions/0.5.0). See: https://github.com/flutter/flutter/issues/140828

This pull request is split into the following commits:

1. d337378a74 is the previous reland pull request, unchanged
2. e866af0229 disables the scissor test before blitting the framebuffer, allowing us to "force" copy the framebuffer's contents by ignoring scissoring values

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-01-16 22:14:02 +00:00