Skip to content

Commit 90865fa

Browse files
authored
chore: remove deprecated getTrafficLightPosition() / setTrafficLightPosition() (electron#39479)
chore: remove deprecated getTrafficLightPosition() / setTrafficLightPosition()
1 parent 3a91d1f commit 90865fa

4 files changed

Lines changed: 40 additions & 79 deletions

File tree

docs/api/browser-window.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,25 +1595,6 @@ Passing `null` will reset the position to default.
15951595
Returns `Point | null` - The custom position for the traffic light buttons in
15961596
frameless window, `null` will be returned when there is no custom position.
15971597

1598-
#### `win.setTrafficLightPosition(position)` _macOS_ _Deprecated_
1599-
1600-
* `position` [Point](structures/point.md)
1601-
1602-
Set a custom position for the traffic light buttons in frameless window.
1603-
Passing `{ x: 0, y: 0 }` will reset the position to default.
1604-
1605-
> **Note**
1606-
> This function is deprecated. Use [setWindowButtonPosition](#winsetwindowbuttonpositionposition-macos) instead.
1607-
1608-
#### `win.getTrafficLightPosition()` _macOS_ _Deprecated_
1609-
1610-
Returns `Point` - The custom position for the traffic light buttons in
1611-
frameless window, `{ x: 0, y: 0 }` will be returned when there is no custom
1612-
position.
1613-
1614-
> **Note**
1615-
> This function is deprecated. Use [getWindowButtonPosition](#wingetwindowbuttonposition-macos) instead.
1616-
16171598
#### `win.setTouchBar(touchBar)` _macOS_
16181599

16191600
* `touchBar` TouchBar | null

docs/breaking-changes.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,46 @@ This document uses the following convention to categorize breaking changes:
1212
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
1313
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
1414

15+
## Planned Breaking API Changes (28.0)
16+
17+
### Removed: `BrowserWindow.setTrafficLightPosition(position)`
18+
19+
`BrowserWindow.setTrafficLightPosition(position)` has been removed, the
20+
`BrowserWindow.setWindowButtonPosition(position)` API should be used instead
21+
which accepts `null` instead of `{ x: 0, y: 0 }` to reset the position to
22+
system default.
23+
24+
```js
25+
// Removed in Electron 28
26+
win.setTrafficLightPosition({ x: 10, y: 10 })
27+
win.setTrafficLightPosition({ x: 0, y: 0 })
28+
29+
// Replace with
30+
win.setWindowButtonPosition({ x: 10, y: 10 })
31+
win.setWindowButtonPosition(null)
32+
```
33+
34+
### Removed: `BrowserWindow.getTrafficLightPosition()`
35+
36+
`BrowserWindow.getTrafficLightPosition()` has been removed, the
37+
`BrowserWindow.getWindowButtonPosition()` API should be used instead
38+
which returns `null` instead of `{ x: 0, y: 0 }` when there is no custom
39+
position.
40+
41+
```js
42+
// Removed in Electron 28
43+
const pos = win.getTrafficLightPosition()
44+
if (pos.x === 0 && pos.y === 0) {
45+
// No custom position.
46+
}
47+
48+
// Replace with
49+
const ret = win.getWindowButtonPosition()
50+
if (ret === null) {
51+
// No custom position.
52+
}
53+
```
54+
1555
## Planned Breaking API Changes (27.0)
1656

1757
### Removed: macOS 10.13 / 10.14 support

lib/browser/api/base-window.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { EventEmitter } from 'events';
22
import type { BaseWindow as TLWT } from 'electron/main';
3-
import * as deprecate from '@electron/internal/common/deprecate';
43
const { BaseWindow } = process._linkedBinding('electron_browser_base_window') as { BaseWindow: typeof TLWT };
54

65
Object.setPrototypeOf(BaseWindow.prototype, EventEmitter.prototype);
@@ -16,25 +15,6 @@ BaseWindow.prototype._init = function () {
1615
}
1716
};
1817

19-
// Deprecation.
20-
const setTrafficLightPositionDeprecated = deprecate.warnOnce('setTrafficLightPosition', 'setWindowButtonPosition');
21-
// Converting to any as the methods are defined under BrowserWindow in our docs.
22-
(BaseWindow as any).prototype.setTrafficLightPosition = function (pos: Electron.Point) {
23-
setTrafficLightPositionDeprecated();
24-
if (typeof pos === 'object' && pos.x === 0 && pos.y === 0) {
25-
this.setWindowButtonPosition(null);
26-
} else {
27-
this.setWindowButtonPosition(pos);
28-
}
29-
};
30-
31-
const getTrafficLightPositionDeprecated = deprecate.warnOnce('getTrafficLightPosition', 'getWindowButtonPosition');
32-
(BaseWindow as any).prototype.getTrafficLightPosition = function () {
33-
getTrafficLightPositionDeprecated();
34-
const pos = this.getWindowButtonPosition();
35-
return pos === null ? { x: 0, y: 0 } : pos;
36-
};
37-
3818
// Properties
3919

4020
Object.defineProperty(BaseWindow.prototype, 'autoHideMenuBar', {

spec/api-browser-window-spec.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,46 +2580,6 @@ describe('BrowserWindow module', () => {
25802580
expect(w.getWindowButtonPosition()).to.deep.equal(newPos);
25812581
});
25822582
});
2583-
2584-
// The set/getTrafficLightPosition APIs are deprecated.
2585-
describe('BrowserWindow.getTrafficLightPosition(pos)', () => {
2586-
it('returns { x: 0, y: 0 } when there is no custom position', () => {
2587-
const w = new BrowserWindow({ show: false });
2588-
expect(w.getTrafficLightPosition()).to.deep.equal({ x: 0, y: 0 });
2589-
});
2590-
2591-
it('gets position property for "hidden" titleBarStyle', () => {
2592-
const w = new BrowserWindow({ show: false, titleBarStyle: 'hidden', trafficLightPosition: pos });
2593-
expect(w.getTrafficLightPosition()).to.deep.equal(pos);
2594-
});
2595-
2596-
it('gets position property for "customButtonsOnHover" titleBarStyle', () => {
2597-
const w = new BrowserWindow({ show: false, titleBarStyle: 'customButtonsOnHover', trafficLightPosition: pos });
2598-
expect(w.getTrafficLightPosition()).to.deep.equal(pos);
2599-
});
2600-
});
2601-
2602-
describe('BrowserWindow.setTrafficLightPosition(pos)', () => {
2603-
it('resets the position when { x: 0, y: 0 } is passed', () => {
2604-
const w = new BrowserWindow({ show: false, titleBarStyle: 'hidden', trafficLightPosition: pos });
2605-
w.setTrafficLightPosition({ x: 0, y: 0 });
2606-
expect(w.getTrafficLightPosition()).to.deep.equal({ x: 0, y: 0 });
2607-
});
2608-
2609-
it('sets position property for "hidden" titleBarStyle', () => {
2610-
const w = new BrowserWindow({ show: false, titleBarStyle: 'hidden', trafficLightPosition: pos });
2611-
const newPos = { x: 20, y: 20 };
2612-
w.setTrafficLightPosition(newPos);
2613-
expect(w.getTrafficLightPosition()).to.deep.equal(newPos);
2614-
});
2615-
2616-
it('sets position property for "customButtonsOnHover" titleBarStyle', () => {
2617-
const w = new BrowserWindow({ show: false, titleBarStyle: 'customButtonsOnHover', trafficLightPosition: pos });
2618-
const newPos = { x: 20, y: 20 };
2619-
w.setTrafficLightPosition(newPos);
2620-
expect(w.getTrafficLightPosition()).to.deep.equal(newPos);
2621-
});
2622-
});
26232583
});
26242584

26252585
ifdescribe(process.platform === 'win32')('BrowserWindow.setAppDetails(options)', () => {

0 commit comments

Comments
 (0)