Skip to content

Commit

Permalink
SDA-4675 - Add scale factor for 4k display issue
Browse files Browse the repository at this point in the history
  • Loading branch information
KiranNiranjan committed Oct 1, 2024
1 parent 9558aa1 commit 5142c33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/renderer/notification-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(
Expand All @@ -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;
Expand Down Expand Up @@ -443,15 +451,15 @@ 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);
}
};

// Start the animation
setTimeout(animateStep, 16);
setTimeout(animateStep, this.settings.animationStepMs);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5142c33

Please sign in to comment.