Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[web] PointerBinding per view #48248

Merged
merged 8 commits into from
Dec 11, 2023
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
10 changes: 0 additions & 10 deletions lib/web_ui/lib/src/engine/embedder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import '../engine.dart' show buildMode, renderer;
import 'browser_detection.dart';
import 'configuration.dart';
import 'dom.dart';
import 'keyboard_binding.dart';
import 'platform_dispatcher.dart';
import 'pointer_binding.dart';
import 'text_editing/text_editing.dart';
import 'view_embedder/style_manager.dart';
import 'window.dart';
Expand Down Expand Up @@ -67,14 +65,6 @@ class FlutterViewEmbedder {

renderer.reset(this);

// TODO(mdebbar): Move these to `engine/initialization.dart`.

KeyboardBinding.initInstance();
PointerBinding.initInstance(
Comment on lines -72 to -73
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So little stuff remaining in this reset function!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I can't wait to get rid of it!

_flutterViewElement,
KeyboardBinding.instance!.converter,
);

window.onResize.listen(_metricsDidChange);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/web_ui/lib/src/engine/initialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ Future<void> initializeEngineUi() async {
_initializationState = DebugEngineInitializationState.initializingUi;

RawKeyboard.initialize(onMacOs: operatingSystem == OperatingSystem.macOs);
KeyboardBinding.initInstance();

if (!configuration.multiViewEnabled) {
ensureImplicitViewInitialized(hostElement: configuration.hostElement);
ensureFlutterViewEmbedderInitialized();
Expand Down
5 changes: 5 additions & 0 deletions lib/web_ui/lib/src/engine/keyboard_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ class KeyboardConverter {
bool _disposed = false;
void dispose() {
_disposed = true;
clearPressedKeys();
}

// On macOS, CapsLock behaves differently in that, a keydown event occurs when
Expand Down Expand Up @@ -699,4 +700,8 @@ class KeyboardConverter {
bool keyIsPressed(int physical) {
return _pressingRecords.containsKey(physical);
}

void clearPressedKeys() {
_pressingRecords.clear();
}
}
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
const StandardMessageCodec codec = StandardMessageCodec();
// TODO(yjbanov): Dispatch the announcement to the correct view?
// https://github.com/flutter/flutter/issues/137445
implicitView!.accessibilityAnnouncements.handleMessage(codec, data);
implicitView?.accessibilityAnnouncements.handleMessage(codec, data);
replyToPlatformMessage(callback, codec.encodeMessage(true));
return;

Expand Down
Loading