mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-13 11:09:17 +08:00
4a89469b84
# Conflicts: # Cargo.lock # Cargo.toml # build.rs # flutter/.gitignore # flutter/lib/common.dart # flutter/lib/mobile/pages/remote_page.dart # flutter/lib/models/model.dart # flutter/lib/models/native_model.dart # flutter/lib/models/server_model.dart # flutter/pubspec.lock # flutter/pubspec.yaml # src/client.rs # src/client/file_trait.rs # src/flutter.rs # src/mobile_ffi.rs # src/ui.rs
73 lines
1.8 KiB
Dart
73 lines
1.8 KiB
Dart
// ignore_for_file: avoid_web_libraries_in_flutter
|
|
|
|
import 'dart:convert';
|
|
import 'dart:typed_data';
|
|
import 'dart:js';
|
|
|
|
import '../common.dart';
|
|
import 'dart:html';
|
|
import 'dart:async';
|
|
|
|
final List<StreamSubscription<MouseEvent>> mouseListeners = [];
|
|
final List<StreamSubscription<KeyboardEvent>> keyListeners = [];
|
|
|
|
class PlatformFFI {
|
|
static String getByName(String name, [String arg = '']) {
|
|
return context.callMethod('getByName', [name, arg]);
|
|
}
|
|
|
|
static void setByName(String name, [String value = '']) {
|
|
context.callMethod('setByName', [name, value]);
|
|
}
|
|
|
|
static Future<Null> init() async {
|
|
isWeb = true;
|
|
isWebDesktop = !context.callMethod('isMobile');
|
|
context.callMethod('init');
|
|
version = getByName('version');
|
|
}
|
|
|
|
static void setEventCallback(void Function(Map<String, dynamic>) fun) {
|
|
context["onGlobalEvent"] = (String message) {
|
|
try {
|
|
Map<String, dynamic> event = json.decode(message);
|
|
fun(event);
|
|
} catch (e) {
|
|
print('json.decode fail(): $e');
|
|
}
|
|
};
|
|
}
|
|
|
|
static void setRgbaCallback(void Function(Uint8List) fun) {
|
|
context["onRgba"] = (Uint8List? rgba) {
|
|
if (rgba != null) {
|
|
fun(rgba);
|
|
}
|
|
};
|
|
}
|
|
|
|
static void startDesktopWebListener() {
|
|
mouseListeners.add(
|
|
window.document.onContextMenu.listen((evt) => evt.preventDefault()));
|
|
}
|
|
|
|
static void stopDesktopWebListener() {
|
|
mouseListeners.forEach((l) {
|
|
l.cancel();
|
|
});
|
|
mouseListeners.clear();
|
|
keyListeners.forEach((l) {
|
|
l.cancel();
|
|
});
|
|
keyListeners.clear();
|
|
}
|
|
|
|
static void setMethodCallHandler(FMethod callback) {}
|
|
|
|
static Future<bool> invokeMethod(String method, [dynamic arguments]) async {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
final localeName = window.navigator.language;
|