Skip to content

Commit

Permalink
Support for Graphical Linux Systems
Browse files Browse the repository at this point in the history
  • Loading branch information
vednig committed Mar 10, 2024
1 parent 27a8979 commit 398de7f
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutter": "3.1.0",
"flavors": {}
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ doc/api/
# project includes source files written in JavaScript.
*.js_
*.js.deps
*.js.map
*.js.map

# FVM Version Cache
.fvm/
4 changes: 4 additions & 0 deletions Frontend/searchlight_gui/.fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutter": "3.1.0",
"flavors": {}
}
3 changes: 3 additions & 0 deletions Frontend/searchlight_gui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# FVM Version Cache
.fvm/
48 changes: 38 additions & 10 deletions Frontend/searchlight_gui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart' as material;
import 'package:flutter_platform_alert/flutter_platform_alert.dart';
// import 'package:flutter_window_close/flutter_window_close.dart';
// import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:fluent_ui/fluent_ui.dart' as fluent_ui;
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart';
import 'package:hotkey_manager/hotkey_manager.dart';
import 'package:window_manager/window_manager.dart';
// import 'package:flutter_window_close/flutter_window_close.dart' as fwc;

//import 'bg.dart';
Expand All @@ -19,17 +20,21 @@ void main() async {
HotKey _hotKey = HotKey(
KeyCode.keyZ,
modifiers: [KeyModifier.alt],

//-------- Set hotkey scope (default is HotKeyScope.system)--------
//scope: HotKeyScope.inapp, //------- Set as inapp-wide hotkey-------
scope: HotKeyScope.inapp, //------- Set as inapp-wide hotkey-------
);
await hotKeyManager.register(
_hotKey,
keyDownHandler: (hotKey) {
// if (appWindow.isVisible) {
// // print('Already Visible');
// } else {
// appWindow.show();
// }
//--------<>-------------
//Enable when in Production
//--------<>--------------
if (appWindow.isVisible) {
exit(0);
} else {
appWindow.show();
}
},
//----- Only works on macOS --------
//keyUpHandler: (hotKey){
Expand All @@ -47,7 +52,28 @@ void main() async {
//--------<>-------------
//Enable when in Production
//--------<>--------------
Window.enterFullscreen();
}
if( Platform.isLinux){
WidgetsFlutterBinding.ensureInitialized();
// Must add this line.

await windowManager.ensureInitialized();
// Window.enterFullscreen();

await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
await windowManager.setAsFrameless();
await windowManager.maximize();


// windowManager.waitUntilReadyToShow(windowOptions, () async {
// await windowManager.show();
// await windowManager.focus();
// });
// windowManager.waitUntilReadyToShow().then((_) async{
// await windowManager.setAsFrameless();
// });

}
runApp(const MyApp());
// focus
Expand Down Expand Up @@ -106,7 +132,7 @@ class MyHomePage extends StatefulWidget {

class _MyHomePageState extends State<MyHomePage> {
var systemTempDir =
Directory(Platform.environment['USERPROFILE'].toString() + '/Downloads');
Directory((Platform.environment['HOME'] ?? Platform.environment['USERPROFILE']).toString() + '/Downloads');

get contents =>
systemTempDir.listSync(recursive: true).map((e) => e.toString()).toList();
Expand Down Expand Up @@ -167,12 +193,14 @@ class _MyHomePageState extends State<MyHomePage> {
.replaceAll("'", "");
print(txt);
if (Platform.isLinux) {
appWindow.hide();
await Process.run("xdg-open", [
txt,
]);
// appWindow.hide();
exit(0);;

} else if (Platform.isWindows) {
// appWindow.hide();
appWindow.hide();
await Process.run(txt, [],
runInShell: true);
}
Expand Down
7 changes: 5 additions & 2 deletions Frontend/searchlight_gui/linux/my_application.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "my_application.h"

// #include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
#include <flutter_linux/flutter_linux.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
Expand Down Expand Up @@ -46,9 +46,12 @@ static void my_application_activate(GApplication* application) {
} else {
gtk_window_set_title(window, "searchlight_gui");
}

//-----------<>----------------<>-----------
//--------Commented Out Due to Bitmojo ----
gtk_window_set_default_size(window, 1280, 720);
gtk_widget_show(GTK_WIDGET(window));
gtk_widget_hide(GTK_WIDGET(window));
//-----------<>----------------<>-----------

g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
Expand Down
2 changes: 1 addition & 1 deletion Frontend/searchlight_gui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies:
flutter:
sdk: flutter


# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
Expand All @@ -54,6 +53,7 @@ dev_dependencies:
hotkey_manager: ^0.1.7
flutter_window_close: ^0.2.2
flutter_platform_alert: ^0.3.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

Expand Down

0 comments on commit 398de7f

Please sign in to comment.