Skip to content

Commit

Permalink
fix(windows): window stretching #1553
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Jul 26, 2024
1 parent 359b918 commit 1441736
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
21 changes: 21 additions & 0 deletions lib/hooks/configurators/use_fix_window_stretching.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:spotube/utils/platform.dart';
import 'package:window_manager/window_manager.dart';

void useFixWindowStretching() {
useEffect(() {
if (!kIsWindows) return;
WidgetsBinding.instance.addPostFrameCallback((Duration timeStamp) async {
await Future<void>.delayed(const Duration(milliseconds: 100), () {
windowManager.getSize().then((Size value) {
windowManager.setSize(
Size(value.width + 1, value.height + 1),
);
});
});
});

return null;
}, []);
}
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:spotube/collections/intents.dart';
import 'package:spotube/hooks/configurators/use_close_behavior.dart';
import 'package:spotube/hooks/configurators/use_deep_linking.dart';
import 'package:spotube/hooks/configurators/use_disable_battery_optimizations.dart';
import 'package:spotube/hooks/configurators/use_fix_window_stretching.dart';
import 'package:spotube/hooks/configurators/use_get_storage_perms.dart';
import 'package:spotube/models/database/database.dart';
import 'package:spotube/provider/audio_player/audio_player_streams.dart';
Expand Down Expand Up @@ -134,6 +135,7 @@ class Spotube extends HookConsumerWidget {
ref.listen(serverProvider, (_, __) {});
ref.listen(trayManagerProvider, (_, __) {});

useFixWindowStretching();
useDisableBatteryOptimizations();
useDeepLinking(ref);
useCloseBehavior(ref);
Expand Down
5 changes: 2 additions & 3 deletions windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,

flutter::DartProject project(L"data");

std::vector<std::string> command_line_arguments =
GetCommandLineArguments();
std::vector<std::string> command_line_arguments = GetCommandLineArguments();

project.set_dart_entrypoint_arguments(std::move(command_line_arguments));

FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
Win32Window::Size size(1200, 800);
if (!window.CreateAndShow(L"spotube", origin, size)) {
return EXIT_FAILURE;
}
Expand Down

0 comments on commit 1441736

Please sign in to comment.