display_server_macos.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /**************************************************************************/
  2. /* display_server_macos.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 DISPLAY_SERVER_MACOS_H
  31. #define DISPLAY_SERVER_MACOS_H
  32. #include "core/input/input.h"
  33. #include "servers/display_server.h"
  34. #if defined(GLES3_ENABLED)
  35. #include "gl_manager_macos_angle.h"
  36. #include "gl_manager_macos_legacy.h"
  37. #endif // GLES3_ENABLED
  38. #if defined(VULKAN_ENABLED)
  39. #include "vulkan_context_macos.h"
  40. #include "drivers/vulkan/rendering_device_vulkan.h"
  41. #endif // VULKAN_ENABLED
  42. #define BitMap _QDBitMap // Suppress deprecated QuickDraw definition.
  43. #import <AppKit/AppKit.h>
  44. #import <AppKit/NSCursor.h>
  45. #import <ApplicationServices/ApplicationServices.h>
  46. #import <CoreVideo/CoreVideo.h>
  47. #import <Foundation/Foundation.h>
  48. #import <IOKit/pwr_mgt/IOPMLib.h>
  49. #undef BitMap
  50. #undef CursorShape
  51. class DisplayServerMacOS : public DisplayServer {
  52. // No need to register with GDCLASS, it's platform-specific and nothing is added.
  53. _THREAD_SAFE_CLASS_
  54. public:
  55. struct KeyEvent {
  56. WindowID window_id = INVALID_WINDOW_ID;
  57. unsigned int macos_state = false;
  58. bool pressed = false;
  59. bool echo = false;
  60. bool raw = false;
  61. Key keycode = Key::NONE;
  62. Key physical_keycode = Key::NONE;
  63. Key key_label = Key::NONE;
  64. uint32_t unicode = 0;
  65. };
  66. struct WindowData {
  67. id window_delegate;
  68. id window_object;
  69. id window_view;
  70. id window_button_view;
  71. Vector<Vector2> mpath;
  72. Point2i mouse_pos;
  73. Size2i min_size;
  74. Size2i max_size;
  75. Size2i size;
  76. Vector2i wb_offset = Vector2i(14, 14);
  77. NSRect last_frame_rect;
  78. bool im_active = false;
  79. Size2i im_position;
  80. Callable rect_changed_callback;
  81. Callable event_callback;
  82. Callable input_event_callback;
  83. Callable input_text_callback;
  84. Callable drop_files_callback;
  85. ObjectID instance_id;
  86. bool fs_transition = false;
  87. bool initial_size = true;
  88. WindowID transient_parent = INVALID_WINDOW_ID;
  89. bool exclusive = false;
  90. HashSet<WindowID> transient_children;
  91. bool layered_window = false;
  92. bool fullscreen = false;
  93. bool exclusive_fullscreen = false;
  94. bool on_top = false;
  95. bool borderless = false;
  96. bool resize_disabled = false;
  97. bool no_focus = false;
  98. bool is_popup = false;
  99. bool mpass = false;
  100. bool focused = false;
  101. bool is_visible = true;
  102. bool extend_to_title = false;
  103. Rect2i parent_safe_rect;
  104. };
  105. List<WindowID> popup_list;
  106. uint64_t time_since_popup = 0;
  107. private:
  108. #if defined(GLES3_ENABLED)
  109. GLManagerLegacy_MacOS *gl_manager_legacy = nullptr;
  110. GLManagerANGLE_MacOS *gl_manager_angle = nullptr;
  111. #endif
  112. #if defined(VULKAN_ENABLED)
  113. VulkanContextMacOS *context_vulkan = nullptr;
  114. RenderingDeviceVulkan *rendering_device_vulkan = nullptr;
  115. #endif
  116. String rendering_driver;
  117. NSMenu *apple_menu = nullptr;
  118. NSMenu *dock_menu = nullptr;
  119. struct MenuData {
  120. Callable open;
  121. Callable close;
  122. NSMenu *menu = nullptr;
  123. bool is_open = false;
  124. };
  125. HashMap<String, MenuData> submenu;
  126. HashMap<NSMenu *, String> submenu_inv;
  127. struct WarpEvent {
  128. NSTimeInterval timestamp;
  129. NSPoint delta;
  130. };
  131. List<WarpEvent> warp_events;
  132. NSTimeInterval last_warp = 0;
  133. bool ignore_warp = false;
  134. Vector<KeyEvent> key_event_buffer;
  135. int key_event_pos = 0;
  136. id tts = nullptr;
  137. id menu_delegate = nullptr;
  138. Point2i im_selection;
  139. String im_text;
  140. CGEventSourceRef event_source;
  141. MouseMode mouse_mode = MOUSE_MODE_VISIBLE;
  142. BitField<MouseButtonMask> last_button_state;
  143. bool drop_events = false;
  144. bool in_dispatch_input_event = false;
  145. struct LayoutInfo {
  146. String name;
  147. String code;
  148. };
  149. Vector<LayoutInfo> kbd_layouts;
  150. int current_layout = 0;
  151. bool keyboard_layout_dirty = true;
  152. WindowID window_mouseover_id = INVALID_WINDOW_ID;
  153. WindowID last_focused_window = INVALID_WINDOW_ID;
  154. WindowID window_id_counter = MAIN_WINDOW_ID;
  155. float display_max_scale = 1.f;
  156. Point2i origin;
  157. bool displays_arrangement_dirty = true;
  158. bool is_resizing = false;
  159. CursorShape cursor_shape = CURSOR_ARROW;
  160. NSCursor *cursors[CURSOR_MAX];
  161. HashMap<CursorShape, Vector<Variant>> cursors_cache;
  162. HashMap<WindowID, WindowData> windows;
  163. IOPMAssertionID screen_keep_on_assertion = kIOPMNullAssertionID;
  164. struct MenuCall {
  165. Variant tag;
  166. Callable callback;
  167. };
  168. List<MenuCall> deferred_menu_calls;
  169. const NSMenu *_get_menu_root(const String &p_menu_root) const;
  170. NSMenu *_get_menu_root(const String &p_menu_root);
  171. bool _is_menu_opened(NSMenu *p_menu) const;
  172. WindowID _create_window(WindowMode p_mode, VSyncMode p_vsync_mode, const Rect2i &p_rect);
  173. void _update_window_style(WindowData p_wd);
  174. void _update_displays_arrangement();
  175. Point2i _get_screens_origin() const;
  176. Point2i _get_native_screen_position(int p_screen) const;
  177. static void _displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplayChangeSummaryFlags flags, void *user_info);
  178. static void _dispatch_input_events(const Ref<InputEvent> &p_event);
  179. void _dispatch_input_event(const Ref<InputEvent> &p_event);
  180. void _push_input(const Ref<InputEvent> &p_event);
  181. void _process_key_events();
  182. void _update_keyboard_layouts();
  183. static void _keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info);
  184. NSImage *_convert_to_nsimg(Ref<Image> &p_image) const;
  185. static NSCursor *_cursor_from_selector(SEL p_selector, SEL p_fallback = nil);
  186. bool _has_help_menu() const;
  187. NSMenuItem *_menu_add_item(const String &p_menu_root, const String &p_label, Key p_accel, int p_index, int *r_out);
  188. public:
  189. NSMenu *get_dock_menu() const;
  190. void menu_callback(id p_sender);
  191. void menu_open(NSMenu *p_menu);
  192. void menu_close(NSMenu *p_menu);
  193. bool has_window(WindowID p_window) const;
  194. WindowData &get_window(WindowID p_window);
  195. void send_event(NSEvent *p_event);
  196. void send_window_event(const WindowData &p_wd, WindowEvent p_event);
  197. void release_pressed_events();
  198. void get_key_modifier_state(unsigned int p_macos_state, Ref<InputEventWithModifiers> r_state) const;
  199. void update_mouse_pos(WindowData &p_wd, NSPoint p_location_in_window);
  200. void push_to_key_event_buffer(const KeyEvent &p_event);
  201. void pop_last_key_event();
  202. void update_im_text(const Point2i &p_selection, const String &p_text);
  203. void set_last_focused_window(WindowID p_window);
  204. bool mouse_process_popups(bool p_close = false);
  205. void popup_open(WindowID p_window);
  206. void popup_close(WindowID p_window);
  207. void set_is_resizing(bool p_is_resizing);
  208. bool get_is_resizing() const;
  209. void reparent_check(WindowID p_window);
  210. WindowID _get_focused_window_or_popup() const;
  211. void mouse_enter_window(WindowID p_window);
  212. void mouse_exit_window(WindowID p_window);
  213. void update_presentation_mode();
  214. void window_destroy(WindowID p_window);
  215. void window_resize(WindowID p_window, int p_width, int p_height);
  216. void window_set_custom_window_buttons(WindowData &p_wd, bool p_enabled);
  217. void set_window_per_pixel_transparency_enabled(bool p_enabled, WindowID p_window);
  218. virtual bool has_feature(Feature p_feature) const override;
  219. virtual String get_name() const override;
  220. virtual void global_menu_set_popup_callbacks(const String &p_menu_root, const Callable &p_open_callback = Callable(), const Callable &p_close_callback = Callable()) override;
  221. virtual int global_menu_add_submenu_item(const String &p_menu_root, const String &p_label, const String &p_submenu, int p_index = -1) override;
  222. virtual int global_menu_add_item(const String &p_menu_root, const String &p_label, const Callable &p_callback = Callable(), const Callable &p_key_callback = Callable(), const Variant &p_tag = Variant(), Key p_accel = Key::NONE, int p_index = -1) override;
  223. virtual int global_menu_add_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback = Callable(), const Callable &p_key_callback = Callable(), const Variant &p_tag = Variant(), Key p_accel = Key::NONE, int p_index = -1) override;
  224. virtual int global_menu_add_icon_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback = Callable(), const Callable &p_key_callback = Callable(), const Variant &p_tag = Variant(), Key p_accel = Key::NONE, int p_index = -1) override;
  225. virtual int global_menu_add_icon_check_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback = Callable(), const Callable &p_key_callback = Callable(), const Variant &p_tag = Variant(), Key p_accel = Key::NONE, int p_index = -1) override;
  226. virtual int global_menu_add_radio_check_item(const String &p_menu_root, const String &p_label, const Callable &p_callback = Callable(), const Callable &p_key_callback = Callable(), const Variant &p_tag = Variant(), Key p_accel = Key::NONE, int p_index = -1) override;
  227. virtual int global_menu_add_icon_radio_check_item(const String &p_menu_root, const Ref<Texture2D> &p_icon, const String &p_label, const Callable &p_callback = Callable(), const Callable &p_key_callback = Callable(), const Variant &p_tag = Variant(), Key p_accel = Key::NONE, int p_index = -1) override;
  228. virtual int global_menu_add_multistate_item(const String &p_menu_root, const String &p_label, int p_max_states, int p_default_state, const Callable &p_callback = Callable(), const Callable &p_key_callback = Callable(), const Variant &p_tag = Variant(), Key p_accel = Key::NONE, int p_index = -1) override;
  229. virtual int global_menu_add_separator(const String &p_menu_root, int p_index = -1) override;
  230. virtual int global_menu_get_item_index_from_text(const String &p_menu_root, const String &p_text) const override;
  231. virtual int global_menu_get_item_index_from_tag(const String &p_menu_root, const Variant &p_tag) const override;
  232. virtual bool global_menu_is_item_checked(const String &p_menu_root, int p_idx) const override;
  233. virtual bool global_menu_is_item_checkable(const String &p_menu_root, int p_idx) const override;
  234. virtual bool global_menu_is_item_radio_checkable(const String &p_menu_root, int p_idx) const override;
  235. virtual Callable global_menu_get_item_callback(const String &p_menu_root, int p_idx) const override;
  236. virtual Callable global_menu_get_item_key_callback(const String &p_menu_root, int p_idx) const override;
  237. virtual Variant global_menu_get_item_tag(const String &p_menu_root, int p_idx) const override;
  238. virtual String global_menu_get_item_text(const String &p_menu_root, int p_idx) const override;
  239. virtual String global_menu_get_item_submenu(const String &p_menu_root, int p_idx) const override;
  240. virtual Key global_menu_get_item_accelerator(const String &p_menu_root, int p_idx) const override;
  241. virtual bool global_menu_is_item_disabled(const String &p_menu_root, int p_idx) const override;
  242. virtual bool global_menu_is_item_hidden(const String &p_menu_root, int p_idx) const override;
  243. virtual String global_menu_get_item_tooltip(const String &p_menu_root, int p_idx) const override;
  244. virtual int global_menu_get_item_state(const String &p_menu_root, int p_idx) const override;
  245. virtual int global_menu_get_item_max_states(const String &p_menu_root, int p_idx) const override;
  246. virtual Ref<Texture2D> global_menu_get_item_icon(const String &p_menu_root, int p_idx) const override;
  247. virtual int global_menu_get_item_indentation_level(const String &p_menu_root, int p_idx) const override;
  248. virtual void global_menu_set_item_checked(const String &p_menu_root, int p_idx, bool p_checked) override;
  249. virtual void global_menu_set_item_checkable(const String &p_menu_root, int p_idx, bool p_checkable) override;
  250. virtual void global_menu_set_item_radio_checkable(const String &p_menu_root, int p_idx, bool p_checkable) override;
  251. virtual void global_menu_set_item_callback(const String &p_menu_root, int p_idx, const Callable &p_callback) override;
  252. virtual void global_menu_set_item_key_callback(const String &p_menu_root, int p_idx, const Callable &p_key_callback) override;
  253. virtual void global_menu_set_item_hover_callbacks(const String &p_menu_root, int p_idx, const Callable &p_callback) override;
  254. virtual void global_menu_set_item_tag(const String &p_menu_root, int p_idx, const Variant &p_tag) override;
  255. virtual void global_menu_set_item_text(const String &p_menu_root, int p_idx, const String &p_text) override;
  256. virtual void global_menu_set_item_submenu(const String &p_menu_root, int p_idx, const String &p_submenu) override;
  257. virtual void global_menu_set_item_accelerator(const String &p_menu_root, int p_idx, Key p_keycode) override;
  258. virtual void global_menu_set_item_disabled(const String &p_menu_root, int p_idx, bool p_disabled) override;
  259. virtual void global_menu_set_item_hidden(const String &p_menu_root, int p_idx, bool p_hidden) override;
  260. virtual void global_menu_set_item_tooltip(const String &p_menu_root, int p_idx, const String &p_tooltip) override;
  261. virtual void global_menu_set_item_state(const String &p_menu_root, int p_idx, int p_state) override;
  262. virtual void global_menu_set_item_max_states(const String &p_menu_root, int p_idx, int p_max_states) override;
  263. virtual void global_menu_set_item_icon(const String &p_menu_root, int p_idx, const Ref<Texture2D> &p_icon) override;
  264. virtual void global_menu_set_item_indentation_level(const String &p_menu_root, int p_idx, int p_level) override;
  265. virtual int global_menu_get_item_count(const String &p_menu_root) const override;
  266. virtual void global_menu_remove_item(const String &p_menu_root, int p_idx) override;
  267. virtual void global_menu_clear(const String &p_menu_root) override;
  268. virtual bool tts_is_speaking() const override;
  269. virtual bool tts_is_paused() const override;
  270. virtual TypedArray<Dictionary> tts_get_voices() const override;
  271. virtual void tts_speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int p_utterance_id = 0, bool p_interrupt = false) override;
  272. virtual void tts_pause() override;
  273. virtual void tts_resume() override;
  274. virtual void tts_stop() override;
  275. virtual bool is_dark_mode_supported() const override;
  276. virtual bool is_dark_mode() const override;
  277. virtual Color get_accent_color() const override;
  278. virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) override;
  279. virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) override;
  280. virtual Error file_dialog_show(const String &p_title, const String &p_current_directory, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback) override;
  281. virtual void mouse_set_mode(MouseMode p_mode) override;
  282. virtual MouseMode mouse_get_mode() const override;
  283. bool update_mouse_wrap(WindowData &p_wd, NSPoint &r_delta, NSPoint &r_mpos, NSTimeInterval p_timestamp);
  284. virtual void warp_mouse(const Point2i &p_position) override;
  285. virtual Point2i mouse_get_position() const override;
  286. void mouse_set_button_state(BitField<MouseButtonMask> p_state);
  287. virtual BitField<MouseButtonMask> mouse_get_button_state() const override;
  288. virtual void clipboard_set(const String &p_text) override;
  289. virtual String clipboard_get() const override;
  290. virtual Ref<Image> clipboard_get_image() const override;
  291. virtual bool clipboard_has() const override;
  292. virtual bool clipboard_has_image() const override;
  293. virtual int get_screen_count() const override;
  294. virtual int get_primary_screen() const override;
  295. virtual int get_keyboard_focus_screen() const override;
  296. virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
  297. virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
  298. virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
  299. virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
  300. virtual float screen_get_max_scale() const override;
  301. virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
  302. virtual float screen_get_refresh_rate(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
  303. virtual Color screen_get_pixel(const Point2i &p_position) const override;
  304. virtual Ref<Image> screen_get_image(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
  305. virtual void screen_set_keep_on(bool p_enable) override;
  306. virtual bool screen_is_kept_on() const override;
  307. virtual Vector<int> get_window_list() const override;
  308. virtual WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i()) override;
  309. virtual void show_window(WindowID p_id) override;
  310. virtual void delete_sub_window(WindowID p_id) override;
  311. virtual WindowID window_get_active_popup() const override;
  312. virtual void window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) override;
  313. virtual Rect2i window_get_popup_safe_rect(WindowID p_window) const override;
  314. virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
  315. virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
  316. virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
  317. virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
  318. virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
  319. virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) override;
  320. virtual Size2i window_get_title_size(const String &p_title, WindowID p_window) const override;
  321. virtual void window_set_mouse_passthrough(const Vector<Vector2> &p_region, WindowID p_window = MAIN_WINDOW_ID) override;
  322. virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const override;
  323. virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override;
  324. virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override;
  325. virtual Point2i window_get_position_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
  326. virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
  327. virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
  328. virtual void window_set_exclusive(WindowID p_window, bool p_exclusive) override;
  329. virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
  330. virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override;
  331. virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
  332. virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override;
  333. virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
  334. virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override;
  335. virtual Size2i window_get_size_with_decorations(WindowID p_window = MAIN_WINDOW_ID) const override;
  336. virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override;
  337. virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override;
  338. virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const override;
  339. virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) override;
  340. virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override;
  341. virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override;
  342. virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override;
  343. virtual bool window_is_focused(WindowID p_window = MAIN_WINDOW_ID) const override;
  344. virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const override;
  345. virtual bool can_any_window_draw() const override;
  346. virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID) override;
  347. virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID) override;
  348. virtual WindowID get_window_at_screen_position(const Point2i &p_position) const override;
  349. virtual int64_t window_get_native_handle(HandleType p_handle_type, WindowID p_window = MAIN_WINDOW_ID) const override;
  350. virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) override;
  351. virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const override;
  352. virtual void gl_window_make_current(DisplayServer::WindowID p_window_id) override;
  353. virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override;
  354. virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override;
  355. virtual bool window_maximize_on_title_dbl_click() const override;
  356. virtual bool window_minimize_on_title_dbl_click() const override;
  357. virtual void window_set_window_buttons_offset(const Vector2i &p_offset, WindowID p_window = MAIN_WINDOW_ID) override;
  358. virtual Vector3i window_get_safe_title_margins(WindowID p_window = MAIN_WINDOW_ID) const override;
  359. virtual Point2i ime_get_selection() const override;
  360. virtual String ime_get_text() const override;
  361. void cursor_update_shape();
  362. virtual void cursor_set_shape(CursorShape p_shape) override;
  363. virtual CursorShape cursor_get_shape() const override;
  364. virtual void cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) override;
  365. virtual bool get_swap_cancel_ok() override;
  366. virtual int keyboard_get_layout_count() const override;
  367. virtual int keyboard_get_current_layout() const override;
  368. virtual void keyboard_set_current_layout(int p_index) override;
  369. virtual String keyboard_get_layout_language(int p_index) const override;
  370. virtual String keyboard_get_layout_name(int p_index) const override;
  371. virtual Key keyboard_get_keycode_from_physical(Key p_keycode) const override;
  372. virtual Key keyboard_get_label_from_physical(Key p_keycode) const override;
  373. virtual void process_events() override;
  374. virtual void force_process_and_drop_events() override;
  375. virtual void release_rendering_thread() override;
  376. virtual void make_rendering_thread() override;
  377. virtual void swap_buffers() override;
  378. virtual void set_native_icon(const String &p_filename) override;
  379. virtual void set_icon(const Ref<Image> &p_icon) override;
  380. static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Error &r_error);
  381. static Vector<String> get_rendering_drivers_func();
  382. static void register_macos_driver();
  383. DisplayServerMacOS(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Error &r_error);
  384. ~DisplayServerMacOS();
  385. };
  386. #endif // DISPLAY_SERVER_MACOS_H