Skip to content

Commit 80073dc

Browse files
committed
feat: setSize triggers WindowResizeEvent
1 parent 8b6cc9f commit 80073dc

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

Sources/Rendering/OpenGL/RenderWindow/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,15 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
10811081
model.activeFramebuffer = newActiveFramebuffer;
10821082
};
10831083

1084+
const superSetSize = publicAPI.setSize;
1085+
publicAPI.setSize = (width, height) => {
1086+
const modified = superSetSize(width, height);
1087+
if (modified) {
1088+
publicAPI.invokeWindowResizeEvent({ width, height });
1089+
}
1090+
return modified;
1091+
};
1092+
10841093
publicAPI.getGraphicsResourceForObject = (vtkObj) => {
10851094
if (!vtkObj) {
10861095
return null;
@@ -1133,12 +1142,6 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
11331142
glRen?.releaseGraphicsResources();
11341143
});
11351144
};
1136-
1137-
model._onSizeChanged = (_publicAPI, _model, newValue) =>
1138-
publicAPI.invokeWindowResizeEvent({
1139-
width: newValue[0],
1140-
height: newValue[1],
1141-
});
11421145
}
11431146

11441147
// ----------------------------------------------------------------------------

Sources/Rendering/WebGPU/RenderWindow/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,16 @@ function vtkWebGPURenderWindow(publicAPI, model) {
543543
return ret;
544544
};
545545

546+
const superSetSize = publicAPI.setSize;
547+
publicAPI.setSize = (width, height) => {
548+
const modified = superSetSize(width, height);
549+
if (modified) {
550+
publicAPI.invokeWindowResizeEvent({ width, height });
551+
}
552+
return modified;
553+
};
554+
546555
publicAPI.delete = macro.chain(publicAPI.delete, publicAPI.setViewStream);
547-
model._onSizeChanged = (_publicAPI, _model, newValue) =>
548-
publicAPI.invokeWindowResizeEvent({
549-
width: newValue[0],
550-
height: newValue[1],
551-
});
552556
}
553557

554558
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)