Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ jobs:

- name: Install dependencies
run: |
sudo apt-get update

# For FastForge
sudo apt install locate
sudo apt-get install locate
wget -O appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod +x appimagetool
mv appimagetool /usr/local/bin/
Expand Down
4 changes: 2 additions & 2 deletions lib/application/objectbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class ObjectBox {
return path.join(snapUserData, 'scrcpy_buddy');
} else {
// Not running as snap, use default location
final docsDir = await getApplicationDocumentsDirectory();
return path.join(docsDir.path, "scrcpy_buddy");
final dir = await getApplicationSupportDirectory();
return path.join(dir.path, "scrcpy_buddy_db");
}
}
}
5 changes: 3 additions & 2 deletions lib/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ Future<void> init() async {
await flutter_acrylic.Window.setEffect(effect: flutter_acrylic.WindowEffect.acrylic);
}
await WindowManager.instance.ensureInitialized();
windowManager.setPreventClose(true);
if (kReleaseMode) {
windowManager.setPreventClose(true);
}
windowManager.waitUntilReadyToShow().then((_) async {
await windowManager.setMinimumSize(const Size(500, 600));
await windowManager.setTitle(_appName);
Expand All @@ -42,5 +44,4 @@ Future<void> init() async {
debugPrint(e.toString());
debugPrintStack(stackTrace: stack);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class _ConsoleViewWidgetState extends State<ConsoleViewWidget> {

void _scrollToBottom() {
try {
if (!_scrollController.hasClients) return;
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
duration: context.theme.fasterAnimationDuration,
Expand Down
7 changes: 6 additions & 1 deletion lib/presentation/home/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:scrcpy_buddy/application/model/scrcpy/scrcpy_error.dart';
Expand Down Expand Up @@ -77,7 +78,11 @@ class _HomeScreenState extends AppModuleState<HomeScreen> with WindowListener, T

@override
void onWindowClose() async {
windowManager.hide();
if (kReleaseMode) {
windowManager.hide();
} else {
_exitApp();
}
}

@override
Expand Down
14 changes: 14 additions & 0 deletions macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,18 @@ class AppDelegate: FlutterAppDelegate {
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}

// Handle opening the hidden window and restoring it upon dock icon click
override func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
if !flag {
for window in NSApp.windows {
if !window.isVisible {
window.setIsVisible(true)
}
window.makeKeyAndOrderFront(self)
NSApp.activate(ignoringOtherApps: true)
}
}
return true
}
}
7 changes: 7 additions & 0 deletions windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"scrcpy_buddy");
if (hwnd != NULL) {
::ShowWindow(hwnd, SW_NORMAL);
::SetForegroundWindow(hwnd);
return EXIT_FAILURE;
}

// Attach to console when present (e.g., 'flutter run') or create a
// new console when running with a debugger.
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
Expand Down
Loading