Skip to content

Commit ba828e6

Browse files
committed
Merge branch 'dev'
2 parents dd8e46c + 615ea4b commit ba828e6

File tree

16 files changed

+497
-64
lines changed

16 files changed

+497
-64
lines changed

simple_live_app/.metadata

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: "adc901062556672b4138e18a4dc62a4be8f4b3c2"
7+
revision: "19074d12f7eaf6a8180cd4036a430c1d76de904e"
88
channel: "stable"
99

1010
project_type: app
@@ -13,11 +13,11 @@ project_type: app
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
17-
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
18-
- platform: android
19-
create_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
20-
base_revision: adc901062556672b4138e18a4dc62a4be8f4b3c2
16+
create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e
17+
base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e
18+
- platform: linux
19+
create_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e
20+
base_revision: 19074d12f7eaf6a8180cd4036a430c1d76de904e
2121

2222
# User provided section
2323

simple_live_app/linux/CMakeLists.txt

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Project-level configuration.
2-
cmake_minimum_required(VERSION 3.10)
2+
cmake_minimum_required(VERSION 3.13)
33
project(runner LANGUAGES CXX)
44

55
# The name of the executable created for the application. Change this to change
@@ -54,25 +54,8 @@ add_subdirectory(${FLUTTER_MANAGED_DIR})
5454
find_package(PkgConfig REQUIRED)
5555
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
5656

57-
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
58-
59-
# Define the application target. To change its name, change BINARY_NAME above,
60-
# not the value here, or `flutter run` will no longer work.
61-
#
62-
# Any new source files that you add to the application should be added here.
63-
add_executable(${BINARY_NAME}
64-
"main.cc"
65-
"my_application.cc"
66-
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
67-
)
68-
69-
# Apply the standard set of build settings. This can be removed for applications
70-
# that need different build settings.
71-
apply_standard_settings(${BINARY_NAME})
72-
73-
# Add dependency libraries. Add any application-specific dependencies here.
74-
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
75-
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
57+
# Application build; see runner/CMakeLists.txt.
58+
add_subdirectory("runner")
7659

7760
# Run the Flutter tool portions of the build. This must not be removed.
7861
add_dependencies(${BINARY_NAME} flutter_assemble)
@@ -91,7 +74,6 @@ set_target_properties(${BINARY_NAME}
9174
# them to the application.
9275
include(flutter/generated_plugins.cmake)
9376

94-
target_link_libraries(${BINARY_NAME} PRIVATE ${MIMALLOC_LIB})
9577

9678
# === Installation ===
9779
# By default, "installing" just makes a relocatable bundle in the build
@@ -124,6 +106,12 @@ foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
124106
COMPONENT Runtime)
125107
endforeach(bundled_library)
126108

109+
# Copy the native assets provided by the build.dart from all packages.
110+
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
111+
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
112+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
113+
COMPONENT Runtime)
114+
127115
# Fully re-copy the assets directory on each build to avoid having stale files
128116
# from a previous install.
129117
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
project(runner LANGUAGES CXX)
3+
4+
# Define the application target. To change its name, change BINARY_NAME in the
5+
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6+
# work.
7+
#
8+
# Any new source files that you add to the application should be added here.
9+
add_executable(${BINARY_NAME}
10+
"main.cc"
11+
"my_application.cc"
12+
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
13+
)
14+
15+
# Apply the standard set of build settings. This can be removed for applications
16+
# that need different build settings.
17+
apply_standard_settings(${BINARY_NAME})
18+
19+
# Add preprocessor definitions for the application ID.
20+
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
21+
22+
# Add dependency libraries. Add any application-specific dependencies here.
23+
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
24+
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
25+
26+
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")

simple_live_app/linux/my_application.cc renamed to simple_live_app/linux/runner/my_application.cc

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ struct _MyApplication {
1414

1515
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
1616

17+
// Called when first Flutter frame received.
18+
static void first_frame_cb(MyApplication* self, FlView* view) {
19+
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
20+
}
21+
1722
// Implements GApplication::activate.
1823
static void my_application_activate(GApplication* application) {
1924
MyApplication* self = MY_APPLICATION(application);
@@ -48,31 +53,44 @@ static void my_application_activate(GApplication* application) {
4853
}
4954

5055
gtk_window_set_default_size(window, 1280, 720);
51-
gtk_widget_show(GTK_WIDGET(window));
5256

5357
g_autoptr(FlDartProject) project = fl_dart_project_new();
54-
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
58+
fl_dart_project_set_dart_entrypoint_arguments(
59+
project, self->dart_entrypoint_arguments);
5560

5661
FlView* view = fl_view_new(project);
62+
GdkRGBA background_color;
63+
// Background defaults to black, override it here if necessary, e.g. #00000000
64+
// for transparent.
65+
gdk_rgba_parse(&background_color, "#000000");
66+
fl_view_set_background_color(view, &background_color);
5767
gtk_widget_show(GTK_WIDGET(view));
5868
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
5969

70+
// Show the window when Flutter renders.
71+
// Requires the view to be realized so we can start rendering.
72+
g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb),
73+
self);
74+
gtk_widget_realize(GTK_WIDGET(view));
75+
6076
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
6177

6278
gtk_widget_grab_focus(GTK_WIDGET(view));
6379
}
6480

6581
// Implements GApplication::local_command_line.
66-
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
82+
static gboolean my_application_local_command_line(GApplication* application,
83+
gchar*** arguments,
84+
int* exit_status) {
6785
MyApplication* self = MY_APPLICATION(application);
6886
// Strip out the first argument as it is the binary name.
6987
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
7088

7189
g_autoptr(GError) error = nullptr;
7290
if (!g_application_register(application, nullptr, &error)) {
73-
g_warning("Failed to register: %s", error->message);
74-
*exit_status = 1;
75-
return TRUE;
91+
g_warning("Failed to register: %s", error->message);
92+
*exit_status = 1;
93+
return TRUE;
7694
}
7795

7896
g_application_activate(application);
@@ -81,6 +99,24 @@ static gboolean my_application_local_command_line(GApplication* application, gch
8199
return TRUE;
82100
}
83101

102+
// Implements GApplication::startup.
103+
static void my_application_startup(GApplication* application) {
104+
// MyApplication* self = MY_APPLICATION(object);
105+
106+
// Perform any actions required at application startup.
107+
108+
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
109+
}
110+
111+
// Implements GApplication::shutdown.
112+
static void my_application_shutdown(GApplication* application) {
113+
// MyApplication* self = MY_APPLICATION(object);
114+
115+
// Perform any actions required at application shutdown.
116+
117+
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
118+
}
119+
84120
// Implements GObject::dispose.
85121
static void my_application_dispose(GObject* object) {
86122
MyApplication* self = MY_APPLICATION(object);
@@ -90,15 +126,23 @@ static void my_application_dispose(GObject* object) {
90126

91127
static void my_application_class_init(MyApplicationClass* klass) {
92128
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
93-
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
129+
G_APPLICATION_CLASS(klass)->local_command_line =
130+
my_application_local_command_line;
131+
G_APPLICATION_CLASS(klass)->startup = my_application_startup;
132+
G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
94133
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
95134
}
96135

97136
static void my_application_init(MyApplication* self) {}
98137

99138
MyApplication* my_application_new() {
139+
// Set the program name to the application ID, which helps various systems
140+
// like GTK and desktop environments map this running application to its
141+
// corresponding .desktop file. This ensures better integration by allowing
142+
// the application to be recognized beyond its binary name.
143+
g_set_prgname(APPLICATION_ID);
144+
100145
return MY_APPLICATION(g_object_new(my_application_get_type(),
101-
"application-id", APPLICATION_ID,
102-
"flags", G_APPLICATION_NON_UNIQUE,
103-
nullptr));
146+
"application-id", APPLICATION_ID, "flags",
147+
G_APPLICATION_NON_UNIQUE, nullptr));
104148
}

simple_live_app/linux/my_application.h renamed to simple_live_app/linux/runner/my_application.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
#include <gtk/gtk.h>
55

6-
G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
6+
G_DECLARE_FINAL_TYPE(MyApplication,
7+
my_application,
8+
MY,
9+
APPLICATION,
710
GtkApplication)
811

912
/**

simple_live_app/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: simple_live_app
2-
version: 1.11.1+11101
2+
version: 1.11.4+11104
33
publish_to: none
44
description: "Simple Live APP"
55
environment:
@@ -54,7 +54,7 @@ dependencies:
5454
screen_brightness: ^2.1.7 #亮度控制
5555
auto_orientation_v2: ^2.3.6 #屏幕方向
5656
wakelock_plus: ^1.4.0 #屏幕常亮
57-
file_picker: ^10.3.6 #文件选择
57+
file_picker: ^10.3.7 #文件选择
5858
window_manager: ^0.5.1 #窗口管理
5959
floating: ^6.0.0 #PIP画中画
6060
flutter_inappwebview: ^6.1.5 #WebView

0 commit comments

Comments
 (0)