Skip to content

Commit

Permalink
Merge pull request #12137 from electron/deprecate-getMenuBatHeight-2.0.x
Browse files Browse the repository at this point in the history
Deprecate screen.getMenuBarHeight (2.0.x)
  • Loading branch information
codebytere committed Mar 6, 2018
2 parents 4bb10c1 + c0076d9 commit 5a210f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions atom/browser/api/atom_api_screen_mac.mm
Expand Up @@ -9,6 +9,7 @@

namespace api {

//TODO(codebytere): deprecated; remove in 3.0
int Screen::getMenuBarHeight() {
return [[NSApp mainMenu] menuBarHeight];
}
Expand Down
9 changes: 9 additions & 0 deletions lib/browser/api/screen.js
@@ -1,8 +1,17 @@
const {EventEmitter} = require('events')
const {deprecate} = require('electron')
const {screen, Screen} = process.atomBinding('screen')

// Screen is an EventEmitter.
Object.setPrototypeOf(Screen.prototype, EventEmitter.prototype)
EventEmitter.call(screen)

const nativeFn = screen.getMenuBarHeight
screen.getMenuBarHeight = function () {
if (!process.noDeprecations) {
deprecate.warn('screen.getMenuBarHeight', 'screen.getPrimaryDisplay().workArea')
}
return nativeFn.call(this)
}

module.exports = screen
13 changes: 0 additions & 13 deletions spec/api-screen-spec.js
Expand Up @@ -18,17 +18,4 @@ describe('screen module', () => {
assert(display.size.height > 0)
})
})

describe('screen.getMenuBarHeight()', () => {
before(function () {
if (process.platform !== 'darwin') {
this.skip()
}
})

it('returns an integer', () => {
const screenHeight = screen.getMenuBarHeight()
assert.equal(typeof screenHeight, 'number')
})
})
})

0 comments on commit 5a210f3

Please sign in to comment.