Browse Source

deprecate screen.getMenuBarHeight

Shelley Vohr 7 years ago
parent
commit
199cf31b9e
2 changed files with 10 additions and 0 deletions
  1. 1 0
      atom/browser/api/atom_api_screen_mac.mm
  2. 9 0
      lib/browser/api/screen.js

+ 1 - 0
atom/browser/api/atom_api_screen_mac.mm

@@ -9,6 +9,7 @@ namespace atom {
 
 namespace api {
 
+//TODO(codebytere): deprecated; remove in 3.0
 int Screen::getMenuBarHeight() {
   return [[NSApp mainMenu] menuBarHeight];
 }

+ 9 - 0
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