os_server.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*************************************************************************/
  2. /* os_server.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef OS_SERVER_H
  31. #define OS_SERVER_H
  32. #include "drivers/dummy/texture_loader_dummy.h"
  33. #include "drivers/unix/os_unix.h"
  34. #include "main/input_default.h"
  35. #ifdef __APPLE__
  36. #include "platform/osx/crash_handler_osx.h"
  37. #include "platform/osx/power_osx.h"
  38. #else
  39. #include "platform/x11/crash_handler_x11.h"
  40. #include "platform/x11/power_x11.h"
  41. #endif
  42. #include "servers/audio_server.h"
  43. #include "servers/visual/rasterizer.h"
  44. #include "servers/visual_server.h"
  45. #undef CursorShape
  46. class OS_Server : public OS_Unix {
  47. VisualServer *visual_server;
  48. VideoMode current_videomode;
  49. List<String> args;
  50. MainLoop *main_loop;
  51. bool grab;
  52. virtual void delete_main_loop();
  53. bool force_quit;
  54. InputDefault *input;
  55. #ifdef __APPLE__
  56. PowerOSX *power_manager;
  57. #else
  58. PowerX11 *power_manager;
  59. #endif
  60. CrashHandler crash_handler;
  61. int video_driver_index;
  62. Ref<ResourceFormatDummyTexture> resource_loader_dummy;
  63. protected:
  64. virtual int get_video_driver_count() const;
  65. virtual const char *get_video_driver_name(int p_driver) const;
  66. virtual int get_current_video_driver() const;
  67. virtual int get_audio_driver_count() const;
  68. virtual const char *get_audio_driver_name(int p_driver) const;
  69. virtual void initialize_core();
  70. virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
  71. virtual void finalize();
  72. virtual void set_main_loop(MainLoop *p_main_loop);
  73. public:
  74. virtual String get_name() const;
  75. virtual void set_mouse_show(bool p_show);
  76. virtual void set_mouse_grab(bool p_grab);
  77. virtual bool is_mouse_grab_enabled() const;
  78. virtual Point2 get_mouse_position() const;
  79. virtual int get_mouse_button_state() const;
  80. virtual void set_window_title(const String &p_title);
  81. virtual MainLoop *get_main_loop() const;
  82. virtual bool can_draw() const;
  83. virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
  84. virtual VideoMode get_video_mode(int p_screen = 0) const;
  85. virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
  86. virtual Size2 get_window_size() const;
  87. virtual void move_window_to_foreground();
  88. void run();
  89. virtual OS::PowerState get_power_state();
  90. virtual int get_power_seconds_left();
  91. virtual int get_power_percent_left();
  92. virtual bool _check_internal_feature_support(const String &p_feature);
  93. virtual String get_config_path() const;
  94. virtual String get_data_path() const;
  95. virtual String get_cache_path() const;
  96. virtual String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const;
  97. void disable_crash_handler();
  98. bool is_disable_crash_handler() const;
  99. OS_Server();
  100. };
  101. #endif