Add API to get top bar height on macOS
This commit is contained in:
parent
a6e11d3b63
commit
b2f1cdfbae
5 changed files with 28 additions and 1 deletions
|
@ -120,6 +120,9 @@ void Screen::BuildPrototype(
|
||||||
.SetMethod("getPrimaryDisplay", &Screen::GetPrimaryDisplay)
|
.SetMethod("getPrimaryDisplay", &Screen::GetPrimaryDisplay)
|
||||||
.SetMethod("getAllDisplays", &Screen::GetAllDisplays)
|
.SetMethod("getAllDisplays", &Screen::GetAllDisplays)
|
||||||
.SetMethod("getDisplayNearestPoint", &Screen::GetDisplayNearestPoint)
|
.SetMethod("getDisplayNearestPoint", &Screen::GetDisplayNearestPoint)
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
.SetMethod("getMenuBarHeight", &Screen::getMenuBarHeight)
|
||||||
|
#endif
|
||||||
.SetMethod("getDisplayMatching", &Screen::GetDisplayMatching);
|
.SetMethod("getDisplayMatching", &Screen::GetDisplayMatching);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,9 @@ class Screen : public mate::EventEmitter<Screen>,
|
||||||
std::vector<display::Display> GetAllDisplays();
|
std::vector<display::Display> GetAllDisplays();
|
||||||
display::Display GetDisplayNearestPoint(const gfx::Point& point);
|
display::Display GetDisplayNearestPoint(const gfx::Point& point);
|
||||||
display::Display GetDisplayMatching(const gfx::Rect& match_rect);
|
display::Display GetDisplayMatching(const gfx::Rect& match_rect);
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
int getMenuBarHeight();
|
||||||
|
#endif
|
||||||
// display::DisplayObserver:
|
// display::DisplayObserver:
|
||||||
void OnDisplayAdded(const display::Display& new_display) override;
|
void OnDisplayAdded(const display::Display& new_display) override;
|
||||||
void OnDisplayRemoved(const display::Display& old_display) override;
|
void OnDisplayRemoved(const display::Display& old_display) override;
|
||||||
|
|
15
atom/browser/api/atom_api_screen_mac.mm
Normal file
15
atom/browser/api/atom_api_screen_mac.mm
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#import "atom/browser/api/atom_api_screen.h"
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
namespace api {
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
int Screen::getMenuBarHeight(){
|
||||||
|
return [[NSApp mainMenu] menuBarHeight];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}// namespace api
|
||||||
|
|
||||||
|
}// namespace atom
|
|
@ -95,6 +95,12 @@ Returns [`Point`](structures/point.md)
|
||||||
|
|
||||||
The current absolute position of the mouse pointer.
|
The current absolute position of the mouse pointer.
|
||||||
|
|
||||||
|
### `screen.getMenuBarHeight()`
|
||||||
|
|
||||||
|
Returns [`Integer`] - Height
|
||||||
|
|
||||||
|
The height of toolbar in pixels.
|
||||||
|
|
||||||
### `screen.getPrimaryDisplay()`
|
### `screen.getPrimaryDisplay()`
|
||||||
|
|
||||||
Returns [`Display`](structures/display.md) - The primary display.
|
Returns [`Display`](structures/display.md) - The primary display.
|
||||||
|
|
|
@ -135,6 +135,7 @@
|
||||||
'atom/browser/api/atom_api_protocol.h',
|
'atom/browser/api/atom_api_protocol.h',
|
||||||
'atom/browser/api/atom_api_render_process_preferences.cc',
|
'atom/browser/api/atom_api_render_process_preferences.cc',
|
||||||
'atom/browser/api/atom_api_render_process_preferences.h',
|
'atom/browser/api/atom_api_render_process_preferences.h',
|
||||||
|
'atom/browser/api/atom_api_screen_mac.mm',
|
||||||
'atom/browser/api/atom_api_screen.cc',
|
'atom/browser/api/atom_api_screen.cc',
|
||||||
'atom/browser/api/atom_api_screen.h',
|
'atom/browser/api/atom_api_screen.h',
|
||||||
'atom/browser/api/atom_api_session.cc',
|
'atom/browser/api/atom_api_session.cc',
|
||||||
|
|
Loading…
Reference in a new issue