Skip to content

Commit e3a6d30

Browse files
committed
fix: handy window
1 parent c30daee commit e3a6d30

File tree

5 files changed

+72
-69
lines changed

5 files changed

+72
-69
lines changed

lib/chat/bootstrap/bootstrap_model.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ class BootstrapModel extends SafeChangeNotifier {
1818
final Client _client;
1919
final FlutterSecureStorage _secureStorage;
2020

21-
Future<bool> isBootrapNeeded() async {
21+
Future<bool> isBootrapNeeded() async =>
22+
_client.isUnknownSession && _client.encryption!.crossSigning.enabled;
23+
24+
Future<bool> isBootrapNeededFull() async {
2225
if (!_client.encryptionEnabled) return true;
2326
await _client.accountDataLoading;
2427
await _client.userDeviceKeysLoading;

lib/chat/view/events/chat_message_bubble.dart

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import '../../chat_model.dart';
1111
import '../chat_avatar.dart';
1212
import '../chat_profile_dialog.dart';
1313
import 'chat_event_status_icon.dart';
14+
import 'chat_html_message.dart';
1415
import 'chat_message_attachment_indicator.dart';
1516
import 'chat_message_bubble_shape.dart';
1617
import 'chat_message_media_avatar.dart';
@@ -196,13 +197,19 @@ class _ChatMessageBubbleContent extends StatelessWidget {
196197
decoration: TextDecoration.lineThrough,
197198
),
198199
)
199-
: SelectableText.rich(
200-
TextSpan(
201-
style: messageStyle,
202-
text: displayEvent.body,
203-
),
204-
style: messageStyle,
205-
),
200+
: event.isRichMessage
201+
? HtmlMessage(
202+
html: html,
203+
room: timeline.room,
204+
defaultTextColor: context.colorScheme.onSurface,
205+
)
206+
: SelectableText.rich(
207+
TextSpan(
208+
style: messageStyle,
209+
text: displayEvent.body,
210+
),
211+
style: messageStyle,
212+
),
206213
),
207214
const SizedBox(
208215
height: kBigPadding,

lib/main.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:io';
2+
13
import 'package:flutter/material.dart';
24
import 'package:window_manager/window_manager.dart';
35
import 'package:yaru/yaru.dart';
@@ -12,10 +14,12 @@ void main() async {
1214
WidgetsFlutterBinding.ensureInitialized();
1315
} else {
1416
await YaruWindowTitleBar.ensureInitialized();
15-
windowManager.waitUntilReadyToShow(windowOptions, () async {
16-
await windowManager.show();
17-
await windowManager.focus();
18-
});
17+
if (Platform.isMacOS) {
18+
windowManager.waitUntilReadyToShow(windowOptions, () async {
19+
await windowManager.show();
20+
await windowManager.focus();
21+
});
22+
}
1923
}
2024

2125
registerDependencies();

linux/CMakeLists.txt

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,14 @@
1-
# Project-level configuration.
21
cmake_minimum_required(VERSION 3.10)
32
project(runner LANGUAGES CXX)
43

5-
# The name of the executable created for the application. Change this to change
6-
# the on-disk name of your application.
74
set(BINARY_NAME "nebuchadnezzar")
8-
# The unique GTK application identifier for this application. See:
9-
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
10-
set(APPLICATION_ID "org.feichtmeier.nebuchadnezzar")
5+
set(APPLICATION_ID "org.feichtmeier.Nebuchadnezzar")
116

12-
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13-
# versions of CMake.
147
cmake_policy(SET CMP0063 NEW)
158

16-
set(USE_LIBHANDY ON)
17-
18-
# Load bundled libraries from the lib/ directory relative to the binary.
199
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
2010

21-
# Root filesystem for cross-building.
22-
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
23-
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
24-
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
25-
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
26-
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
27-
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
28-
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
29-
endif()
30-
31-
# Define build configuration options.
11+
# Configure build options.
3212
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
3313
set(CMAKE_BUILD_TYPE "Debug" CACHE
3414
STRING "Flutter build mode" FORCE)
@@ -37,19 +17,16 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
3717
endif()
3818

3919
# Compilation settings that should be applied to most targets.
40-
#
41-
# Be cautious about adding new options here, as plugins use this function by
42-
# default. In most cases, you should add new options to specific targets instead
43-
# of modifying this function.
4420
function(APPLY_STANDARD_SETTINGS TARGET)
4521
target_compile_features(${TARGET} PUBLIC cxx_std_14)
4622
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
4723
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
4824
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
4925
endfunction()
5026

51-
# Flutter library and tool build rules.
5227
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
28+
29+
# Flutter library and tool build rules.
5330
add_subdirectory(${FLUTTER_MANAGED_DIR})
5431

5532
# System-level dependencies.
@@ -58,27 +35,16 @@ pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
5835

5936
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
6037

61-
# Define the application target. To change its name, change BINARY_NAME above,
62-
# not the value here, or `flutter run` will no longer work.
63-
#
64-
# Any new source files that you add to the application should be added here.
38+
# Application build
6539
add_executable(${BINARY_NAME}
6640
"main.cc"
6741
"my_application.cc"
6842
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
6943
)
70-
71-
# Apply the standard set of build settings. This can be removed for applications
72-
# that need different build settings.
7344
apply_standard_settings(${BINARY_NAME})
74-
75-
# Add dependency libraries. Add any application-specific dependencies here.
7645
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
7746
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
78-
79-
# Run the Flutter tool portions of the build. This must not be removed.
8047
add_dependencies(${BINARY_NAME} flutter_assemble)
81-
8248
# Only the install-generated bundle's copy of the executable will launch
8349
# correctly, since the resources must in the right relative locations. To avoid
8450
# people trying to run the unbundled copy, put it in a subdirectory instead of
@@ -88,11 +54,11 @@ set_target_properties(${BINARY_NAME}
8854
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
8955
)
9056

91-
9257
# Generated plugin build rules, which manage building the plugins and adding
9358
# them to the application.
9459
include(flutter/generated_plugins.cmake)
9560

61+
target_link_libraries(${BINARY_NAME} PRIVATE ${MIMALLOC_LIB})
9662

9763
# === Installation ===
9864
# By default, "installing" just makes a relocatable bundle in the build
@@ -119,17 +85,11 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}
11985
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
12086
COMPONENT Runtime)
12187

122-
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
123-
install(FILES "${bundled_library}"
88+
if(PLUGIN_BUNDLED_LIBRARIES)
89+
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
12490
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
12591
COMPONENT Runtime)
126-
endforeach(bundled_library)
127-
128-
# Copy the native assets provided by the build.dart from all packages.
129-
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
130-
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
131-
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
132-
COMPONENT Runtime)
92+
endif()
13393

13494
# Fully re-copy the assets directory on each build to avoid having stale files
13595
# from a previous install.
@@ -144,4 +104,4 @@ install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
144104
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
145105
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
146106
COMPONENT Runtime)
147-
endif()
107+
endif()

linux/my_application.cc

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include "my_application.h"
22

3-
#include <handy.h>
3+
#include <flutter_linux/flutter_linux.h>
4+
#ifdef GDK_WINDOWING_X11
5+
#include <gdk/gdkx.h>
6+
#endif
47

58
#include "flutter/generated_plugin_registrant.h"
69

@@ -14,21 +17,47 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
1417
// Implements GApplication::activate.
1518
static void my_application_activate(GApplication* application) {
1619
MyApplication* self = MY_APPLICATION(application);
17-
GtkWindow* window = GTK_WINDOW(hdy_application_window_new());
18-
gtk_window_set_application(window, GTK_APPLICATION(application));
20+
GtkWindow* window =
21+
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22+
23+
// Use a header bar when running in GNOME as this is the common style used
24+
// by applications and is the setup most users will be using (e.g. Ubuntu
25+
// desktop).
26+
// If running on X and not using GNOME then just use a traditional title bar
27+
// in case the window manager does more exotic layout, e.g. tiling.
28+
// If running on Wayland assume the header bar will work (may need changing
29+
// if future cases occur).
30+
gboolean use_header_bar = TRUE;
31+
#ifdef GDK_WINDOWING_X11
32+
GdkScreen* screen = gtk_window_get_screen(window);
33+
if (GDK_IS_X11_SCREEN(screen)) {
34+
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35+
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36+
use_header_bar = FALSE;
37+
}
38+
}
39+
#endif
40+
if (use_header_bar) {
1941

20-
gtk_window_set_default_size(window, 800, 600);
21-
gtk_widget_show(GTK_WIDGET(window));
42+
} else {
43+
gtk_window_set_title(window, "Nebuchadnezzar");
44+
}
45+
GdkGeometry geometry_min;
46+
geometry_min.min_width = 500;
47+
geometry_min.min_height = 700;
48+
gtk_window_set_geometry_hints(window, nullptr, &geometry_min, GDK_HINT_MIN_SIZE);
49+
gtk_window_set_default_size(window, 950, 820);
2250

2351
g_autoptr(FlDartProject) project = fl_dart_project_new();
2452
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
2553

2654
FlView* view = fl_view_new(project);
27-
gtk_widget_show(GTK_WIDGET(view));
2855
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
2956

3057
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
3158

59+
gtk_widget_show(GTK_WIDGET(window));
60+
gtk_widget_show(GTK_WIDGET(view));
3261
gtk_widget_grab_focus(GTK_WIDGET(view));
3362
}
3463

@@ -91,4 +120,4 @@ MyApplication* my_application_new() {
91120
"application-id", APPLICATION_ID,
92121
"flags", G_APPLICATION_NON_UNIQUE,
93122
nullptr));
94-
}
123+
}

0 commit comments

Comments
 (0)