Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix traffic light centering on macOS #212471

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

klaussner
Copy link

Fixes #208226.

This PR makes two changes to the traffic light centering logic for macOS (see the linked issue for a screenshot of the problem):

  • The traffic light icons have a height of 12px. A margin of 2px is added at the top and bottom, so the total height for centering is 16px.
  • If the title bar height is odd (i.e., if the command center is enabled), the result of (options.height - 16) / 2 is also odd. In this case, Electron rounds up the value. To make the offset look better, the value is rounded down instead.

@klaussner
Copy link
Author

Here are two screenshots showing the result (with and without command center enabled):

Fix with command center Fix without command center

@@ -377,7 +377,7 @@ export abstract class BaseWindow extends Disposable implements IBaseWindow {

// macOS: traffic lights
else if (isMacintosh && options.height !== undefined) {
const verticalOffset = (options.height - 15) / 2; // 15px is the height of the traffic lights
const verticalOffset = Math.floor((options.height - 16) / 2); // 16px is the height of the traffic lights

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set traffic light height as const. Useless comment that could be explained in code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Traffic lights on macOS are not centered
3 participants