Skip to content

Commit 43152b7

Browse files
fix: windows and macos exceptions
1 parent d8082e3 commit 43152b7

16 files changed

Lines changed: 77 additions & 54 deletions

File tree

flutter-lib/lib/src/comm/comm_ws.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'dart:io';
33

44
import '../gen/widgets.dart';
55
import '../gen/widget.dart';
6+
import '../impl/widget_config.dart';
67
import 'comm_api.dart';
78

89
class EquoCommService {
@@ -246,7 +247,9 @@ class _EquoComm implements _EquoCommI {
246247
'error': userEvent.error,
247248
'callbackId': callback?.id,
248249
});
249-
print("ws about to send: $event");
250+
if (!userEvent.actionId.contains('MouseMove') || (getConfigFlags().print_move ?? false)) {
251+
print("ws about to send: $event");
252+
}
250253
return ws.then((ws) {
251254
// print("ws sent");
252255
ws.add(event);

flutter-lib/lib/src/impl/config_flags.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class ConfigFlags {
2020
bool? preserve_icon_colors;
2121
bool? show_scaling_control;
2222
String? decorations_align;
23+
bool? print_move;
2324

2425
factory ConfigFlags.fromJson(Map<String, dynamic> json) =>
2526
_$ConfigFlagsFromJson(json);

flutter-lib/lib/src/impl/config_flags.g.dart

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flutter-lib/lib/src/impl/gcdrawer_evolve.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,10 @@ class GCDrawer extends GCDrawerBase {
436436
final f = ImageShape.fromVImageDetailed(o.image!, o, capturedClipping);
437437
_pendingImages.add(f);
438438
f.then((s) {
439-
shapes[idx] = s;
440-
onShapesUpdated?.call(shapes);
439+
if (idx < shapes.length) {
440+
shapes[idx] = s;
441+
onShapesUpdated?.call(shapes);
442+
}
441443
});
442444
}
443445

swt_native/src/macos/java/org/eclipse/swt/widgets/DartComposite.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,9 @@ int traversalCode(int key, Object theEvent) {
10301030
void updateBackgroundColor() {
10311031
super.updateBackgroundColor();
10321032
Control[] children = _getChildren();
1033-
for (int i = 0; i < children.length; i++) {
1034-
if ((children[i].state & PARENT_BACKGROUND) != 0) {
1035-
((DartControl) children[i].getImpl()).updateBackgroundColor();
1033+
for (Control child : children) {
1034+
if ((child.state & PARENT_BACKGROUND) != 0 && child.getImpl() instanceof DartControl dc) {
1035+
dc.updateBackgroundColor();
10361036
}
10371037
}
10381038
}
@@ -1041,9 +1041,9 @@ void updateBackgroundColor() {
10411041
void updateBackgroundImage() {
10421042
super.updateBackgroundImage();
10431043
Control[] children = _getChildren();
1044-
for (int i = 0; i < children.length; i++) {
1045-
if ((children[i].state & PARENT_BACKGROUND) != 0) {
1046-
((DartControl) children[i].getImpl()).updateBackgroundImage();
1044+
for (Control child : children) {
1045+
if ((child.state & PARENT_BACKGROUND) != 0 && child.getImpl() instanceof DartControl dc) {
1046+
dc.updateBackgroundImage();
10471047
}
10481048
}
10491049
}

swt_native/src/macos/java/org/eclipse/swt/widgets/SwtControl.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3956,7 +3956,7 @@ public void setCursor(Cursor cursor) {
39563956
this.cursor = cursor;
39573957
if (!isEnabled())
39583958
return;
3959-
if (!getApi().view.window().areCursorRectsEnabled())
3959+
if (getApi().view.window() == null || !getApi().view.window().areCursorRectsEnabled())
39603960
return;
39613961
((SwtDisplay) display.getImpl()).setCursor(((SwtDisplay) display.getImpl()).currentControl);
39623962
}
@@ -4649,8 +4649,13 @@ void setZOrder() {
46494649
NSView topView = topView();
46504650
if (parent.getImpl() instanceof SwtControl) {
46514651
((SwtControl) parent.getImpl()).contentView().addSubview(topView, OS.NSWindowBelow, null);
4652-
} else
4653-
((NSView) ((DartComposite) parent.getImpl()).contentView()).addSubview(topView, OS.NSWindowBelow, null);
4652+
} else if (parent.getImpl() instanceof DartComposite) {
4653+
Object cv = ((DartComposite) parent.getImpl()).contentView();
4654+
if (cv instanceof NSView nsView) {
4655+
nsView.addSubview(topView, OS.NSWindowBelow, null);
4656+
}
4657+
// else: Flutter-backed composite has no native NSView; skip native z-ordering
4658+
}
46544659
}
46554660

46564661
@Override

swt_native/src/macos/java/org/eclipse/swt/widgets/SwtFlutterBridge.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ public void setZOrder(DartControl control, Control sibling, boolean above) {
110110
if (parent.getImpl() instanceof SwtComposite) {
111111
((SwtComposite) parent.getImpl()).contentView().addSubview(topView, above ? org.eclipse.swt.internal.cocoa.OS.NSWindowAbove : org.eclipse.swt.internal.cocoa.OS.NSWindowBelow, otherView);
112112
} else if (parent.getImpl() instanceof DartComposite) {
113-
((org.eclipse.swt.internal.cocoa.NSView) ((DartComposite) parent.getImpl()).contentView()).addSubview(topView, above ? org.eclipse.swt.internal.cocoa.OS.NSWindowAbove : org.eclipse.swt.internal.cocoa.OS.NSWindowBelow, otherView);
113+
Object cv = ((DartComposite) parent.getImpl()).contentView();
114+
if (cv instanceof org.eclipse.swt.internal.cocoa.NSView nsView) {
115+
nsView.addSubview(topView, above ? org.eclipse.swt.internal.cocoa.OS.NSWindowAbove : org.eclipse.swt.internal.cocoa.OS.NSWindowBelow, otherView);
116+
}
117+
// else: Flutter-backed composite has no native NSView; z-order is managed by Flutter
114118
}
115119
topView.release();
116120
}

swt_native/src/main/java/dev/equo/swt/Config.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public enum Impl {eclipse, equo, force_equo}
6363
entry(Tree.class, Impl.equo),
6464
entry(TreeItem.class, Impl.equo),
6565
entry(TreeColumn.class, Impl.equo),
66-
entry(Canvas.class, Impl.equo),
67-
entry(Cursor.class, Impl.equo),
66+
entry(Canvas.class, Impl.equo)
67+
//entry(Cursor.class, Impl.equo),
6868
//entry(ScrolledComposite.class, Impl.equo)
6969
//entry(Menu.class, Impl.equo)
7070
//entry(MenuItem.class, Impl.equo),
@@ -77,7 +77,7 @@ public enum Impl {eclipse, equo, force_equo}
7777
//entry(Spinner.class, Impl.equo),
7878
//entry(ToolTip.class, Impl.equo),
7979
//entry(Shell.class, Impl.equo),
80-
entry(Composite.class, Impl.equo)
80+
//entry(Composite.class, Impl.equo)
8181
//entry(DateTime.class, Impl.equo),
8282
//entry(Tray.class, Impl.equo),
8383
//entry(TrayItem.class, Impl.equo)
@@ -333,8 +333,10 @@ public static boolean isEquo(Class<?> clazz, Widget parent) {
333333
return false;
334334
if (parent != null && parent.getImpl().getClass().getSimpleName().startsWith(DART) && !isSwtCTabFolderBody(clazz, parent))
335335
return true;
336-
if (isSwtCTabFolderBody(clazz, parent))
336+
if (clazz == ToolItem.class && parent != null && !(parent.getImpl() instanceof DartToolBar))
337337
return false;
338+
if (isSwtCTabFolderBody(clazz, parent))
339+
return false; // Hybrid
338340
if (isSplash(parent))
339341
return false;
340342
return isEquo(clazz);
@@ -373,7 +375,7 @@ static boolean isStatusToolbarComposite(Class<Composite> clazz, Composite parent
373375
return id.equals("/Shell/0/Composite/3") && isInStackTrace(E4_TOOLBAR_CLASS, E4_TOOLBAR_METHOD);
374376
}
375377

376-
private static boolean isMainComposite(Class<?> clazz, Composite parent) {
378+
static boolean isMainComposite(Class<?> clazz, Composite parent) {
377379
String id = getId(clazz, parent);
378380
return id.equals("/Shell/0/Composite/1/Composite/1/Composite/1/Composite/1");
379381
}
@@ -444,7 +446,7 @@ private static boolean isInStackTraceAtSkip(String className, String methodName,
444446
private static final String E4_CLASS = "org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer";
445447
private static final String E4_METHOD = "addTopRight";
446448

447-
private static boolean isToolBar() {
449+
public static boolean isToolBar() {
448450
return isInStackTrace(E4_CLASS, E4_METHOD);
449451
}
450452

@@ -517,6 +519,7 @@ public static ConfigFlags getConfigFlags() {
517519
configFlags.show_theme_color_palette = Boolean.getBoolean("swt.evolve.show_theme_color_palette");
518520
configFlags.show_scaling_control = Boolean.getBoolean("swt.evolve.show_scaling_control");
519521
configFlags.decorations_align = System.getProperty("swt.evolve.decorations_align");
522+
configFlags.print_move = Boolean.getBoolean("dev.equo.swt.printMove");
520523
configFlags.force_theme = System.getProperty("swt.evolve.force_theme");
521524
configFlags.theme_name = System.getProperty("swt.evolve.theme_name");
522525
configFlags.theme_color = System.getProperty("swt.evolve.theme_color");

swt_native/src/main/java/dev/equo/swt/ConfigDyn.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ public class ConfigDyn {
1313
static final Pattern IDREGEX = Pattern.compile("\\([^)]*\\)");
1414

1515
public static IWidget getCompositeImpl(Composite parent, int style, Composite composite) {
16-
if (dynEnabled && ("dyn".equals(parent != null ? parent.getData(Config.getKey(Composite.class)) : null) || mustBeDynComposite(composite))) {
16+
if (dynEnabled && ("dyn".equals(parent != null ? parent.getData(Config.getKey(Composite.class)) : null) || mustBeDynComposite(composite)))
1717
return new DynComposite(parent, style, composite);
18-
}
1918
if (mainToolbarImpl == Impl.equo && isMainToolbarComposite(Composite.class, parent))
2019
return new DartMainToolbar(parent, style, composite);
2120
if (sideBarImpl == Impl.equo && isSideToolbarComposite(Composite.class, parent))
2221
return new DartSideBar(parent, style, composite);
2322
if (statusBarImpl == Impl.equo && isStatusToolbarComposite(Composite.class, parent))
2423
return new DartStatusBar(parent, style, composite);
25-
// In eclipse mode, always use SWT implementation without any special handling
24+
if (mainCompositeImpl == Impl.equo && isMainComposite(Composite.class, parent))
25+
return new DartMainComposite(parent, style, composite);
26+
if (defaultImpl == Impl.eclipse || forceEclipse)
27+
return new SwtComposite(parent, style, composite);
2628
if (Config.isEquo(composite.getClass(), parent))
2729
return new DartComposite(parent, style, composite);
28-
if (defaultImpl == Impl.eclipse || forceEclipse)
30+
else
2931
return new SwtComposite(parent, style, composite);
30-
return new SwtComposite(parent, style, composite);
3132
}
3233

3334
private static boolean mustBeDynComposite(Composite composite) {

swt_native/src/main/java/dev/equo/swt/ConfigFlags.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class ConfigFlags {
3030
public boolean show_scaling_control;
3131
public String decorations_align;
3232

33+
public boolean print_move;
34+
3335
public static ConfigFlags use_swt_fonts(boolean v) {
3436
ConfigFlags configFlags = new ConfigFlags();
3537
configFlags.use_swt_fonts = v;

0 commit comments

Comments
 (0)