From 5142c33ac361d526fe6a5ad6a1defda6c2490361 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Tue, 1 Oct 2024 12:40:18 +0530 Subject: [PATCH] SDA-4675 - Add scale factor for 4k display issue --- src/renderer/notification-handler.ts | 14 +++++++++++--- src/renderer/notification.ts | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/renderer/notification-handler.ts b/src/renderer/notification-handler.ts index 962b8f29c..d3ef8f205 100644 --- a/src/renderer/notification-handler.ts +++ b/src/renderer/notification-handler.ts @@ -37,6 +37,7 @@ export default class NotificationHandler { public settings: ISettings; public callNotificationSettings: ICorner = { x: 0, y: 0 }; public nextInsertPos: ICorner = { x: 0, y: 0 }; + private scaleFactor: number = 1.0; private readonly eventHandlers = { onSetup: () => this.setupNotificationPosition(), @@ -69,7 +70,13 @@ export default class NotificationHandler { ) { if (window && !window.isDestroyed()) { try { - window.setPosition(parseInt(String(x), 10), parseInt(String(y), 10)); + // Adjust positions based on scale factor + const adjustedX = Math.round(x * this.scaleFactor); + const adjustedY = Math.round(y * this.scaleFactor); + window.setPosition( + parseInt(String(adjustedX), 10), + parseInt(String(adjustedY), 10), + ); window.moveTop(); } catch (err) { console.warn( @@ -96,6 +103,7 @@ export default class NotificationHandler { } const display = this.externalDisplay || screen.getPrimaryDisplay(); + this.scaleFactor = display.scaleFactor; this.settings.corner.x = display.workArea.x; this.settings.corner.y = display.workArea.y; this.callNotificationSettings.x = display.workArea.x; @@ -443,7 +451,7 @@ export default class NotificationHandler { this.setWindowPosition(notificationWindow, currentX, currentY); if (progress < 1) { - setTimeout(animateStep, 16); + setTimeout(animateStep, this.settings.animationStepMs); } else { // Ensure final position is set this.setWindowPosition(notificationWindow, newX, newY); @@ -451,7 +459,7 @@ export default class NotificationHandler { }; // Start the animation - setTimeout(animateStep, 16); + setTimeout(animateStep, this.settings.animationStepMs); } /** diff --git a/src/renderer/notification.ts b/src/renderer/notification.ts index 8b5b2f00f..17cc47949 100644 --- a/src/renderer/notification.ts +++ b/src/renderer/notification.ts @@ -57,8 +57,8 @@ const notificationSettings = { maxVisibleNotifications: 6, borderRadius: 8, displayTime: 5000, - animationSteps: 5, - animationStepMs: 5, + animationSteps: 60, + animationStepMs: 16, logging: true, spacing: 8, differentialHeight: 42,