atom_api_screen.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) 2015 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef SHELL_BROWSER_API_ATOM_API_SCREEN_H_
  5. #define SHELL_BROWSER_API_ATOM_API_SCREEN_H_
  6. #include <vector>
  7. #include "native_mate/handle.h"
  8. #include "shell/browser/api/event_emitter.h"
  9. #include "ui/display/display_observer.h"
  10. #include "ui/display/screen.h"
  11. namespace gfx {
  12. class Point;
  13. class Rect;
  14. class Screen;
  15. } // namespace gfx
  16. namespace electron {
  17. namespace api {
  18. class Screen : public mate::EventEmitter<Screen>,
  19. public display::DisplayObserver {
  20. public:
  21. static v8::Local<v8::Value> Create(v8::Isolate* isolate);
  22. static void BuildPrototype(v8::Isolate* isolate,
  23. v8::Local<v8::FunctionTemplate> prototype);
  24. protected:
  25. Screen(v8::Isolate* isolate, display::Screen* screen);
  26. ~Screen() override;
  27. gfx::Point GetCursorScreenPoint();
  28. display::Display GetPrimaryDisplay();
  29. std::vector<display::Display> GetAllDisplays();
  30. display::Display GetDisplayNearestPoint(const gfx::Point& point);
  31. display::Display GetDisplayMatching(const gfx::Rect& match_rect);
  32. // display::DisplayObserver:
  33. void OnDisplayAdded(const display::Display& new_display) override;
  34. void OnDisplayRemoved(const display::Display& old_display) override;
  35. void OnDisplayMetricsChanged(const display::Display& display,
  36. uint32_t changed_metrics) override;
  37. private:
  38. display::Screen* screen_;
  39. DISALLOW_COPY_AND_ASSIGN(Screen);
  40. };
  41. } // namespace api
  42. } // namespace electron
  43. #endif // SHELL_BROWSER_API_ATOM_API_SCREEN_H_