From 072fd0691882fafd1bd68340ad1e4f0833f4b8c8 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Thu, 19 Sep 2024 04:11:25 -0400 Subject: [PATCH] cvmts: fix display event handler duplication By only adding event handlers when the display is first lazily initalized. --- cvmts/src/CollabVMServer.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cvmts/src/CollabVMServer.ts b/cvmts/src/CollabVMServer.ts index bb6ce1a..3dccc75 100644 --- a/cvmts/src/CollabVMServer.ts +++ b/cvmts/src/CollabVMServer.ts @@ -129,17 +129,17 @@ export default class CollabVMServer { if (newState == VMState.Started) { self.logger.info('VM started'); - // start the display + // start the display and add the events once if (self.VM.GetDisplay() == null) { self.VM.StartDisplay(); - } - self.VM.GetDisplay()?.on('connected', () => { - // well aware this sucks but whatever + self.logger.info('started display, adding events now'); + + // add events self.VM.GetDisplay()?.on('resize', (size: Size) => self.OnDisplayResized(size)); self.VM.GetDisplay()?.on('rect', (rect: Rect) => self.OnDisplayRectangle(rect)); self.VM.GetDisplay()?.on('frame', () => self.OnDisplayFrame()); - }); + } } if (newState == VMState.Stopped) {