2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/**************************************************************************/
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								/*  display_server_macos.mm                                               */
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/**************************************************************************/
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                         This file is part of:                          */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                             GODOT ENGINE                               */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                        https://godotengine.org                         */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/**************************************************************************/
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                                                                        */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* Permission is hereby granted, free of charge, to any person obtaining  */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* a copy of this software and associated documentation files (the        */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* "Software"), to deal in the Software without restriction, including    */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* without limitation the rights to use, copy, modify, merge, publish,    */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* distribute, sublicense, and/or sell copies of the Software, and to     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* permit persons to whom the Software is furnished to do so, subject to  */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* the following conditions:                                              */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                                                                        */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* The above copyright notice and this permission notice shall be         */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* included in all copies or substantial portions of the Software.        */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*                                                                        */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/**************************************************************************/
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 21:03:20 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#import "display_server_macos.h"
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_application.h"
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_application_delegate.h"
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 21:03:20 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_button_view.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_content_view.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_menu_delegate.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_menu_item.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_open_save_delegate.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_status_item.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_window.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import "godot_window_delegate.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import "key_mapping_macos.h"
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#import "macos_quartz_core_spi.h"
							 
						 
					
						
							
								
									
										
										
										
											2025-01-05 21:03:20 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#import "os_macos.h"
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 14:33:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 10:38:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#include "core/config/project_settings.h"
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#include "core/io/marshalls.h"
							 
						 
					
						
							
								
									
										
										
										
											2020-06-29 12:31:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#include "core/math/geometry_2d.h"
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#include "core/os/keyboard.h"
							 
						 
					
						
							
								
									
										
										
										
											2022-08-02 14:05:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#include "drivers/png/png_driver_common.h"
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#include "main/main.h"
							 
						 
					
						
							
								
									
										
										
										
											2023-07-11 22:29:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#include "scene/resources/image_texture.h"
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-13 12:42:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef TOOLS_ENABLED
							 
						 
					
						
							
								
									
										
										
										
											2025-05-20 09:37:35 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#import "display_server_embedded.h"
							 
						 
					
						
							
								
									
										
										
										
											2025-05-13 12:42:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#import "editor/embedded_process_macos.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#include <AppKit/AppKit.h>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#include "servers/rendering/dummy/rasterizer_dummy.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-26 08:18:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-02 12:27:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#include "drivers/gles3/rasterizer_gles3.h"
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(RD_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2020-12-04 15:26:24 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
							 
						 
					
						
							
								
									
										
										
										
											2020-04-26 21:17:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(ACCESSKIT_ENABLED)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#include "drivers/accesskit/accessibility_driver_accesskit.h"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 14:51:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#import <Carbon/Carbon.h>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import <Cocoa/Cocoa.h>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import <IOKit/IOCFPlugIn.h>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import <IOKit/IOKitLib.h>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import <IOKit/hid/IOHIDKeys.h>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#import <IOKit/hid/IOHIDLib.h>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServerMacOS::WindowID DisplayServerMacOS::_create_window(WindowMode p_mode, VSyncMode p_vsync_mode, const Rect2i &p_rect) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const float scale = screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowID id = window_id_counter;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										WindowData &wd = windows[id];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-20 09:37:35 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										wd.window_delegate = [[GodotWindowDelegate alloc] initWithDisplayServer:this];
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 11:40:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_NULL_V_MSG(wd.window_delegate, INVALID_WINDOW_ID, "Can't create a window delegate");
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_delegate setWindowID:id];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										int rq_screen = get_screen_from_rect(p_rect);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (rq_screen < 0) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rq_screen = get_primary_screen(); // Requested window rect is outside any screen bounds.
							 
						 
					
						
							
								
									
										
										
										
											2022-12-08 20:34:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Rect2i srect = screen_get_usable_rect(rq_screen);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2i wpos = p_rect.position;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (srect != Rect2i()) {
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 12:49:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											wpos = wpos.clamp(srect.position, srect.position + srect.size - p_rect.size / 3);
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2023-03-12 16:48:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// macOS native y-coordinate relative to _get_screens_origin() is negative,
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Godot passes a positive value.
							 
						 
					
						
							
								
									
										
										
										
											2022-12-08 20:34:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										wpos.y *= -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										wpos += _get_screens_origin();
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										wpos /= scale;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
										// initWithContentRect uses bottom-left corner of the window’ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										wd.window_object = [[GodotWindow alloc]
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 12:37:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												initWithContentRect:NSMakeRect(100, 100, MAX(1, p_rect.size.width / scale), MAX(1, p_rect.size.height / scale))
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														  styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															backing:NSBackingStoreBuffered
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															  defer:NO];
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 11:40:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_NULL_V_MSG(wd.window_object, INVALID_WINDOW_ID, "Can't create a window");
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setWindowID:id];
							 
						 
					
						
							
								
									
										
										
										
											2024-02-02 07:06:53 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setReleasedWhenClosed:NO];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										wd.window_view = [[GodotContentView alloc] init];
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (wd.window_view == nil) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											windows.erase(id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											ERR_FAIL_V_MSG(INVALID_WINDOW_ID, "Can't create a window view");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_view setWindowID:id];
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_view setWantsLayer:TRUE];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setContentView:wd.window_view];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setDelegate:wd.window_delegate];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setAcceptsMouseMovedEvents:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setRestorable:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setColorSpace:[NSColorSpace sRGBColorSpace]];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef ACCESSKIT_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (accessibility_driver && !accessibility_driver->window_create(id, (__bridge void *)wd.window_object)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (OS::get_singleton()->is_stdout_verbose()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												ERR_PRINT("Can't create an accessibility adapter for window, accessibility support disabled!");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											memdelete(accessibility_driver);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											accessibility_driver = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if ([wd.window_object respondsToSelector:@selector(setTabbingMode:)]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setTabbingMode:NSWindowTabbingModeDisallowed];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CALayer *layer = [wd.window_view layer];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (layer) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											layer.contentsScale = scale;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-13 00:02:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										NSColor *bg_color = [NSColor windowBackgroundColor];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Color _bg_color;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (_get_window_early_clear_override(_bg_color)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bg_color = [NSColor colorWithCalibratedRed:_bg_color.r green:_bg_color.g blue:_bg_color.b alpha:1.f];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setBackgroundColor:bg_color];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (layer) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[layer setBackgroundColor:bg_color.CGColor];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(RD_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (rendering_context) {
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											union {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef VULKAN_ENABLED
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												RenderingContextDriverVulkanMacOS::WindowPlatformData vulkan;
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 05:52:00 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef METAL_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												RenderingContextDriverMetal::WindowPlatformData metal;
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} wpd;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef VULKAN_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (rendering_driver == "vulkan") {
							 
						 
					
						
							
								
									
										
										
										
											2024-02-05 23:50:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												wpd.vulkan.layer_ptr = (CAMetalLayer *const *)&layer;
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 05:52:00 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef METAL_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (rendering_driver == "metal") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												wpd.metal.layer = (CAMetalLayer *)layer;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Error err = rendering_context->window_create(window_id_counter, &wpd);
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef ACCESSKIT_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (err != OK && accessibility_driver) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												accessibility_driver->window_destroy(id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, vformat("Can't create a %s context", rendering_driver));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rendering_context->window_set_size(window_id_counter, p_rect.size.width, p_rect.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rendering_context->window_set_vsync_mode(window_id_counter, p_vsync_mode);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										bool gl_failed = false;
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Error err = gl_manager_legacy->window_create(window_id_counter, wd.window_view, p_rect.size.width, p_rect.size.height);
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (err != OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												gl_failed = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (gl_manager_angle) {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-05 22:12:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Error err = gl_manager_angle->window_create(window_id_counter, nullptr, (__bridge void *)layer, p_rect.size.width, p_rect.size.height);
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (err != OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												gl_failed = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (gl_failed) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef ACCESSKIT_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (accessibility_driver) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												accessibility_driver->window_destroy(id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											windows.erase(id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											ERR_FAIL_V_MSG(INVALID_WINDOW_ID, "Can't create an OpenGL context.");
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										window_set_vsync_mode(p_vsync_mode, id);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2022-06-10 14:02:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_view updateLayerDelegate];
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const NSRect contentRect = [wd.window_view frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const NSRect windowRect = [wd.window_object frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const NSRect nsrect = [wd.window_object convertRectToScreen:contentRect];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2i offset;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										offset.x = (nsrect.origin.x - windowRect.origin.x);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										offset.y = (nsrect.origin.y + nsrect.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										offset.y -= (windowRect.origin.y + windowRect.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setFrameTopLeftPoint:NSMakePoint(wpos.x - offset.x, wpos.y - offset.y)];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									window_id_counter++;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[id];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									window_set_mode(p_mode, id);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect contentRect = [wd.window_view frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.size.width = contentRect.size.width * scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.size.height = contentRect.size.height * scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:02:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CALayer *layer = [(NSView *)wd.window_view layer];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (layer) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										layer.contentsScale = scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-26 08:18:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_legacy->window_resize(id, wd.size.width, wd.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_angle->window_resize(id, wd.size.width, wd.size.height);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return id;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-10 01:35:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_update_window_style(WindowData p_wd, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool borderless_full = false;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-30 16:18:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_wd.borderless) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSRect frameRect = [p_wd.window_object frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSRect screenRect = [[p_wd.window_object screen] frame];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Check if our window covers up the screen.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (frameRect.origin.x <= screenRect.origin.x && frameRect.origin.y <= frameRect.origin.y &&
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												frameRect.size.width >= screenRect.size.width && frameRect.size.height >= screenRect.size.height) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											borderless_full = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-30 16:18:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (borderless_full) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// If the window covers up the screen set the level to above the main menu and hide on deactivate.
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:02:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[(NSWindow *)p_wd.window_object setLevel:NSMainMenuWindowLevel + 1];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[(NSWindow *)p_wd.window_object setHidesOnDeactivate:YES];
							 
						 
					
						
							
								
									
										
										
										
											2021-08-08 22:27:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Reset these when our window is not a borderless window that covers up the screen.
							 
						 
					
						
							
								
									
										
										
										
											2024-12-10 01:35:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (is_always_on_top_recursive(p_window) && !p_wd.fullscreen) {
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:02:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											[(NSWindow *)p_wd.window_object setLevel:NSFloatingWindowLevel];
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:02:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											[(NSWindow *)p_wd.window_object setLevel:NSNormalWindowLevel];
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:02:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[(NSWindow *)p_wd.window_object setHidesOnDeactivate:NO];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-30 16:18:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-10 01:35:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::is_always_on_top_recursive(WindowID p_window) const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), false);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.on_top) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.transient_parent != INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return is_always_on_top_recursive(wd.transient_parent);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::set_window_per_pixel_transparency_enabled(bool p_enabled, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (!OS::get_singleton()->is_layered_allowed()) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-30 16:18:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_enabled) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setOpaque:NO];
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 16:28:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (wd.borderless) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setBackgroundColor:[NSColor clearColor]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setHasShadow:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Note: transparent and not borderless - set alpha to non-zero value to ensure window shadow is rendered correctly.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setBackgroundColor:[NSColor colorWithCalibratedRed:0 green:0 blue:0 alpha:0.004f]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setHasShadow:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CALayer *layer = [(NSView *)wd.window_view layer];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (layer) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[layer setBackgroundColor:[NSColor clearColor].CGColor];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[layer setOpaque:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2021-11-02 12:27:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											gl_manager_legacy->window_set_per_pixel_transparency_enabled(p_window, true);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSColor *bg_color = [NSColor windowBackgroundColor];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Color _bg_color;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (_get_window_early_clear_override(_bg_color)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bg_color = [NSColor colorWithCalibratedRed:_bg_color.r green:_bg_color.g blue:_bg_color.b alpha:1.f];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setBackgroundColor:bg_color];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setOpaque:YES];
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 16:28:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (!wd.borderless) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setHasShadow:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CALayer *layer = [(NSView *)wd.window_view layer];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (layer) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[layer setBackgroundColor:bg_color.CGColor];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[layer setOpaque:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2021-10-26 08:18:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											gl_manager_legacy->window_set_per_pixel_transparency_enabled(p_window, false);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_update_displays_arrangement() const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									origin = Point2i();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for (int i = 0; i < get_screen_count(); i++) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2i position = _get_native_screen_position(i);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (position.x < origin.x) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											origin.x = position.x;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (position.y > origin.y) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											origin.y = position.y;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									displays_arrangement_dirty = false;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-27 22:09:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::set_menu_delegate(NSMenu *p_menu) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[p_menu setDelegate:menu_delegate];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Point2i DisplayServerMacOS::_get_screens_origin() const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Returns the native top-left screen coordinate of the smallest rectangle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// that encompasses all screens. Needed in get_screen_position(),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// window_get_position, and window_set_position()
							 
						 
					
						
							
								
									
										
										
										
											2023-03-12 16:48:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// to convert between macOS native screen coordinates and the ones expected by Godot.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (displays_arrangement_dirty) {
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										_update_displays_arrangement();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return origin;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Point2i DisplayServerMacOS::_get_native_screen_position(int p_screen) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSArray *screenArray = [NSScreen screens];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ((NSUInteger)p_screen < [screenArray count]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
							 
						 
					
						
							
								
									
										
										
										
											2023-03-12 16:48:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Return the top-left corner of the screen, for macOS the y starts at the bottom.
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return Point2i(nsrect.origin.x, nsrect.origin.y + nsrect.size.height) * screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return Point2i();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplayChangeSummaryFlags flags, void *user_info) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (ds) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ds->displays_arrangement_dirty = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-07 19:31:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer::WindowID DisplayServerMacOS::_get_focused_window_or_popup() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const List<WindowID>::Element *E = popup_list.back();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (E) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return E->get();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return last_focused_window;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-09 10:23:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::mouse_enter_window(WindowID p_window) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (window_mouseover_id != p_window) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (window_mouseover_id != INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											send_window_event(windows[window_mouseover_id], WINDOW_EVENT_MOUSE_EXIT);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										window_mouseover_id = p_window;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (p_window != INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											send_window_event(windows[p_window], WINDOW_EVENT_MOUSE_ENTER);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::mouse_exit_window(WindowID p_window) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (window_mouseover_id == p_window && p_window != INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										send_window_event(windows[p_window], WINDOW_EVENT_MOUSE_EXIT);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									window_mouseover_id = INVALID_WINDOW_ID;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_dispatch_input_events(const Ref<InputEvent> &p_event) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									((DisplayServerMacOS *)(get_singleton()))->_dispatch_input_event(p_event);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_dispatch_input_event(const Ref<InputEvent> &p_event) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (!in_dispatch_input_event) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										in_dispatch_input_event = true;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										{
							 
						 
					
						
							
								
									
										
										
										
											2022-04-13 09:58:38 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											List<WindowID>::Element *E = popup_list.back();
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (E && Object::cast_to<InputEventKey>(*p_event)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Redirect keyboard input to active popup.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (windows.has(E->get())) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													Callable callable = windows[E->get()].input_event_callback;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if (callable.is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2023-07-11 16:18:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														callable.call(p_event);
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												in_dispatch_input_event = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref<InputEventFromWindow> event_from_window = p_event;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (event_from_window.is_valid() && event_from_window->get_window_id() != INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Send to a window.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (windows.has(event_from_window->get_window_id())) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if (callable.is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2023-07-11 16:18:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													callable.call(p_event);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-02-18 15:16:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Send to all windows. Copy all pending callbacks, since callback can erase window.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector<Callable> cbs;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for (KeyValue<WindowID, WindowData> &E : windows) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Callable callable = E.value.input_event_callback;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (callable.is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2025-02-18 15:16:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													cbs.push_back(callable);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2025-02-18 15:16:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											for (const Callable &cb : cbs) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												cb.call(p_event);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										in_dispatch_input_event = false;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_push_input(const Ref<InputEvent> &p_event) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref<InputEvent> ev = p_event;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Input::get_singleton()->parse_input_event(ev);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_process_key_events() {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref<InputEventKey> k;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (int i = 0; i < key_event_pos; i++) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const KeyEvent &ke = key_event_buffer[i];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (ke.raw) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Non IME input - no composite characters, pass events as is.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k.instantiate();
							 
						 
					
						
							
								
									
										
										
										
											2020-07-02 15:55:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											k->set_window_id(ke.window_id);
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											get_key_modifier_state(ke.macos_state, k);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											k->set_pressed(ke.pressed);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_echo(ke.echo);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_keycode(ke.keycode);
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 01:21:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											k->set_physical_keycode(ke.physical_keycode);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_key_label(ke.key_label);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											k->set_unicode(ke.unicode);
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 15:18:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											k->set_location(ke.location);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_push_input(k);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// IME input.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if ((i == 0 && ke.keycode == Key::NONE) || (i > 0 && key_event_buffer[i - 1].keycode == Key::NONE)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												k.instantiate();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												k->set_window_id(ke.window_id);
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												get_key_modifier_state(ke.macos_state, k);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												k->set_pressed(ke.pressed);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												k->set_echo(ke.echo);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												k->set_keycode(Key::NONE);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												k->set_physical_keycode(Key::NONE);
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 01:21:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												k->set_key_label(Key::NONE);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												k->set_unicode(ke.unicode);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_push_input(k);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (ke.keycode != Key::NONE) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												k.instantiate();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												k->set_window_id(ke.window_id);
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												get_key_modifier_state(ke.macos_state, k);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												k->set_pressed(ke.pressed);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												k->set_echo(ke.echo);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												k->set_keycode(ke.keycode);
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 01:21:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												k->set_physical_keycode(ke.physical_keycode);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												k->set_key_label(ke.key_label);
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 15:18:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												k->set_location(ke.location);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == Key::NONE) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													k->set_unicode(key_event_buffer[i + 1].unicode);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												_push_input(k);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_event_pos = 0;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								NSImage *DisplayServerMacOS::_convert_to_nsimg(Ref<Image> &p_image) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 11:26:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_image->convert(Image::FORMAT_RGBA8);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc]
							 
						 
					
						
							
								
									
										
										
										
											2024-03-12 09:40:40 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											initWithBitmapDataPlanes:nullptr
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 11:26:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
														  pixelsWide:p_image->get_width()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														  pixelsHigh:p_image->get_height()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													   bitsPerSample:8
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													 samplesPerPixel:4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															hasAlpha:YES
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															isPlanar:NO
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													  colorSpaceName:NSDeviceRGBColorSpace
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														 bytesPerRow:int(p_image->get_width()) * 4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														bitsPerPixel:32];
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 11:40:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_NULL_V(imgrep, nil);
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 11:26:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									uint8_t *pixels = [imgrep bitmapData];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int len = p_image->get_width() * p_image->get_height();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const uint8_t *r = p_image->get_data().ptr();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									/* Premultiply the alpha channel */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (int i = 0; i < len; i++) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										uint8_t alpha = r[i * 4 + 3];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										pixels[i * 4 + 0] = (uint8_t)(((uint16_t)r[i * 4 + 0] * alpha) / 255);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										pixels[i * 4 + 1] = (uint8_t)(((uint16_t)r[i * 4 + 1] * alpha) / 255);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										pixels[i * 4 + 2] = (uint8_t)(((uint16_t)r[i * 4 + 2] * alpha) / 255);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										pixels[i * 4 + 3] = alpha;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSImage *nsimg = [[NSImage alloc] initWithSize:NSMakeSize(p_image->get_width(), p_image->get_height())];
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 11:40:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_NULL_V(nsimg, nil);
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 11:26:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[nsimg addRepresentation:imgrep];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return nsimg;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								NSCursor *DisplayServerMacOS::_cursor_from_selector(SEL p_selector, SEL p_fallback) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if ([NSCursor respondsToSelector:p_selector]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										id object = [NSCursor performSelector:p_selector];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if ([object isKindOfClass:[NSCursor class]]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return object;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_fallback) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Fallback should be a reasonable default, no need to check.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return [NSCursor performSelector:p_fallback];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return [NSCursor arrowCursor];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::menu_callback(id p_sender) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (![p_sender representedObject]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									GodotMenuItem *value = [p_sender representedObject];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (value) {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-13 10:12:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (value->callback.is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 23:57:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											MenuCall mc;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											mc.tag = value->meta;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											mc.callback = value->callback;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											deferred_menu_calls.push_back(mc);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Do not run callback from here! If it is opening a new window or calling process_events, it will corrupt OS event queue and crash.
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::has_window(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return windows.has(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServerMacOS::WindowData &DisplayServerMacOS::get_window(WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::send_event(NSEvent *p_event) {
							 
						 
					
						
							
								
									
										
										
										
											2024-02-14 21:55:21 +04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Special case handling of shortcuts that don't arrive at the regular keyDown handler
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if ([p_event type] == NSEventTypeKeyDown) {
							 
						 
					
						
							
								
									
										
										
										
											2024-02-14 21:55:21 +04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										NSEventModifierFlags flags = [p_event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Command-period
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if ((flags == NSEventModifierFlagCommand) && [p_event keyCode] == 0x2f) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Ref<InputEventKey> k;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k.instantiate();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											get_key_modifier_state([p_event modifierFlags], k);
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											k->set_window_id(DisplayServerMacOS::INVALID_WINDOW_ID);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											k->set_pressed(true);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_keycode(Key::PERIOD);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_physical_keycode(Key::PERIOD);
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 01:21:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											k->set_key_label(Key::PERIOD);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											k->set_echo([p_event isARepeat]);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Input::get_singleton()->parse_input_event(k);
							 
						 
					
						
							
								
									
										
										
										
											2024-02-14 21:55:21 +04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Ctrl+Tab and Ctrl+Shift+Tab
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (((flags == NSEventModifierFlagControl) || (flags == (NSEventModifierFlagControl | NSEventModifierFlagShift))) && [p_event keyCode] == 0x30) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Ref<InputEventKey> k;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k.instantiate();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											get_key_modifier_state([p_event modifierFlags], k);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_window_id(DisplayServerMacOS::INVALID_WINDOW_ID);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_pressed(true);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_keycode(Key::TAB);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_physical_keycode(Key::TAB);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_key_label(Key::TAB);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											k->set_echo([p_event isARepeat]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Input::get_singleton()->parse_input_event(k);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::send_window_event(const WindowData &wd, WindowEvent p_event) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-11 16:18:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.event_callback.is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Variant event = int(p_event);
							 
						 
					
						
							
								
									
										
										
										
											2023-07-11 16:18:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										wd.event_callback.call(event);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::release_pressed_events() {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (Input::get_singleton()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Input::get_singleton()->release_pressed_events();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-26 12:18:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::sync_mouse_state() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (Input::get_singleton()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector2i pos = Input::get_singleton()->get_mouse_position();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										BitField<MouseButtonMask> in_mask = Input::get_singleton()->get_mouse_button_mask();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										BitField<MouseButtonMask> ds_mask = mouse_get_button_state();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for (int btn = (int)MouseButton::LEFT; btn <= (int)MouseButton::MB_XBUTTON2; btn++) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											MouseButtonMask mbm = mouse_button_to_mask(MouseButton(btn));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (in_mask.has_flag(mbm) && !ds_mask.has_flag(mbm)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Ref<InputEventMouseButton> mb;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb.instantiate();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_button_index(MouseButton(btn));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_pressed(false);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_position(pos);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_global_position(pos);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_button_mask(ds_mask);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Input::get_singleton()->parse_input_event(mb);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (!in_mask.has_flag(mbm) && ds_mask.has_flag(mbm)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Ref<InputEventMouseButton> mb;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb.instantiate();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_button_index(MouseButton(btn));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_pressed(true);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_position(pos);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_global_position(pos);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												mb->set_button_mask(ds_mask);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Input::get_singleton()->parse_input_event(mb);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::get_key_modifier_state(unsigned int p_macos_state, Ref<InputEventWithModifiers> r_state) const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									r_state->set_shift_pressed((p_macos_state & NSEventModifierFlagShift));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									r_state->set_ctrl_pressed((p_macos_state & NSEventModifierFlagControl));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									r_state->set_alt_pressed((p_macos_state & NSEventModifierFlagOption));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									r_state->set_meta_pressed((p_macos_state & NSEventModifierFlagCommand));
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::update_mouse_pos(DisplayServerMacOS::WindowData &p_wd, NSPoint p_location_in_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect content_rect = [p_wd.window_view frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const float scale = screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p_wd.mouse_pos.x = p_location_in_window.x * scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p_wd.mouse_pos.y = (content_rect.size.height - p_location_in_window.y) * scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Input::get_singleton()->set_mouse_position(p_wd.mouse_pos);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-10-13 18:58:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 01:21:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::pop_last_key_event() {
							 
						 
					
						
							
								
									
										
										
										
											2023-11-28 17:20:33 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Does not pop last key event when it is an IME key event.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (key_event_pos > 0 && key_event_buffer[key_event_pos - 1].raw) {
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 01:21:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										key_event_pos--;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::push_to_key_event_buffer(const DisplayServerMacOS::KeyEvent &p_event) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (key_event_pos >= key_event_buffer.size()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										key_event_buffer.resize(1 + key_event_pos);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									key_event_buffer.write[key_event_pos++] = p_event;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::update_im_text(const Point2i &p_selection, const String &p_text) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									im_selection = p_selection;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									im_text = p_text;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::set_last_focused_window(WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									last_focused_window = p_window;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::set_is_resizing(bool p_is_resizing) {
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 10:25:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									is_resizing = p_is_resizing;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::get_is_resizing() const {
							 
						 
					
						
							
								
									
										
										
										
											2022-03-04 10:25:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return is_resizing;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_destroy(WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_legacy->window_destroy(p_window);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef RD_ENABLED
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_device) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_device->screen_free(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_context) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_context->window_destroy(p_window);
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef ACCESSKIT_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (accessibility_driver) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										accessibility_driver->window_destroy(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									windows.erase(p_window);
							 
						 
					
						
							
								
									
										
										
										
											2024-12-20 09:40:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (last_focused_window == p_window) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										last_focused_window = INVALID_WINDOW_ID;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 09:01:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									update_presentation_mode();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_resize(WindowID p_window, int p_width, int p_height) {
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(RD_ENABLED)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_context) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_context->window_set_size(p_window, p_width, p_height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_legacy->window_resize(p_window, p_width, p_height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_angle->window_resize(p_window, p_width, p_height);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::has_feature(Feature p_feature) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch (p_feature) {
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifndef DISABLE_DEPRECATED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_GLOBAL_MENU: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return (native_menu && native_menu->has_feature(NativeMenu::FEATURE_GLOBAL_MENU));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_SUBWINDOWS:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										//case FEATURE_TOUCHSCREEN:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_MOUSE:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_MOUSE_WARP:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_CLIPBOARD:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_CURSOR_SHAPE:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_CUSTOM_CURSOR_SHAPE:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_NATIVE_DIALOG:
							 
						 
					
						
							
								
									
										
										
										
											2024-03-26 15:18:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_NATIVE_DIALOG_INPUT:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_NATIVE_DIALOG_FILE:
							 
						 
					
						
							
								
									
										
										
										
											2024-10-21 14:13:44 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_NATIVE_DIALOG_FILE_EXTRA:
							 
						 
					
						
							
								
									
										
										
										
											2024-11-17 12:25:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_NATIVE_DIALOG_FILE_MIME:
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_IME:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_WINDOW_TRANSPARENCY:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_HIDPI:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_ICON:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_NATIVE_ICON:
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										//case FEATURE_KEEP_SCREEN_ON:
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_SWAP_BUFFERS:
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 14:33:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_TEXT_TO_SPEECH:
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_EXTEND_TO_TITLE:
							 
						 
					
						
							
								
									
										
										
										
											2023-02-27 20:36:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_SCREEN_CAPTURE:
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_STATUS_INDICATOR:
							 
						 
					
						
							
								
									
										
										
										
											2023-10-22 14:29:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_NATIVE_HELP:
							 
						 
					
						
							
								
									
										
										
										
											2024-11-24 19:27:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_WINDOW_DRAG:
							 
						 
					
						
							
								
									
										
										
										
											2025-01-08 10:32:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_SCREEN_EXCLUDE_FROM_CAPTURE:
							 
						 
					
						
							
								
									
										
										
										
											2025-01-02 13:27:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_EMOJI_AND_SYMBOL_PICKER:
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_WINDOW_EMBEDDING:
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return true;
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef ACCESSKIT_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case FEATURE_ACCESSIBILITY_SCREEN_READER: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return (accessibility_driver != nullptr);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										default: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								String DisplayServerMacOS::get_name() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return "macOS";
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-22 14:29:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::help_set_search_callbacks(const Callable &p_search_callback, const Callable &p_action_callback) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									help_search_callback = p_search_callback;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									help_action_callback = p_action_callback;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Callable DisplayServerMacOS::_help_get_search_callback() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return help_search_callback;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Callable DisplayServerMacOS::_help_get_action_callback() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return help_action_callback;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 11:24:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::is_dark_mode_supported() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (@available(macOS 10.14, *)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::is_dark_mode() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (@available(macOS 10.14, *)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (![[NSUserDefaults standardUserDefaults] objectForKey:@"AppleInterfaceStyle"]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"] isEqual:@"Dark"]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Color DisplayServerMacOS::get_accent_color() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (@available(macOS 10.14, *)) {
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 20:46:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										__block NSColor *color = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (@available(macOS 11.0, *)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[NSApp.effectiveAppearance performAsCurrentDrawingAppearance:^{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												color = [[NSColor controlAccentColor] colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSAppearance *saved_appearance = [NSAppearance currentAppearance];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[NSAppearance setCurrentAppearance:[NSApp effectiveAppearance]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											color = [[NSColor controlAccentColor] colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[NSAppearance setCurrentAppearance:saved_appearance];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (color) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											CGFloat components[4];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[color getRed:&components[0] green:&components[1] blue:&components[2] alpha:&components[3]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return Color(components[0], components[1], components[2], components[3]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return Color(0, 0, 0, 0);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return Color(0, 0, 0, 0);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Color DisplayServerMacOS::get_base_color() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (@available(macOS 10.14, *)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										__block NSColor *color = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (@available(macOS 11.0, *)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[NSApp.effectiveAppearance performAsCurrentDrawingAppearance:^{
							 
						 
					
						
							
								
									
										
										
										
											2024-08-01 21:49:11 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												color = [[NSColor windowBackgroundColor] colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]];
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 20:46:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSAppearance *saved_appearance = [NSAppearance currentAppearance];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[NSAppearance setCurrentAppearance:[NSApp effectiveAppearance]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											color = [[NSColor controlColor] colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[NSAppearance setCurrentAppearance:saved_appearance];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 11:24:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (color) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											CGFloat components[4];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[color getRed:&components[0] green:&components[1] blue:&components[2] alpha:&components[3]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return Color(components[0], components[1], components[2], components[3]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return Color(0, 0, 0, 0);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return Color(0, 0, 0, 0);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 20:46:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::set_system_theme_change_callback(const Callable &p_callable) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									system_theme_changed = p_callable;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::emit_system_theme_changed() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (system_theme_changed.is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2024-03-01 09:52:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										system_theme_changed.callp(nullptr, 0, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											ERR_PRINT(vformat("Failed to execute system theme changed callback: %s.", Variant::get_callable_error_text(system_theme_changed, nullptr, 0, ce)));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 20:46:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Error DisplayServerMacOS::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSAlert *window = [[NSAlert alloc] init];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSString *ns_description = [NSString stringWithUTF8String:p_description.utf8().get_data()];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (int i = 0; i < p_buttons.size(); i++) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSString *ns_button = [NSString stringWithUTF8String:p_buttons[i].utf8().get_data()];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[window addButtonWithTitle:ns_button];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window setMessageText:ns_title];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window setInformativeText:ns_description];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window setAlertStyle:NSAlertStyleInformational];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Variant button_pressed;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSInteger ret = [window runModal];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (ret == NSAlertFirstButtonReturn) {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										button_pressed = int64_t(0);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else if (ret == NSAlertSecondButtonReturn) {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										button_pressed = int64_t(1);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else if (ret == NSAlertThirdButtonReturn) {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										button_pressed = int64_t(2);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										button_pressed = int64_t(2 + (ret - NSAlertThirdButtonReturn));
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-27 11:56:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_callback.is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const Variant *args[1] = { &button_pressed };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										p_callback.callp(args, 1, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
									
										
										
										
											2023-11-11 22:59:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ERR_PRINT(vformat("Failed to execute dialog callback: %s.", Variant::get_callable_error_text(p_callback, args, 1, ce)));
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return OK;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-30 12:19:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Error DisplayServerMacOS::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, WindowID p_window_id) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return _file_dialog_with_options_show(p_title, p_current_directory, String(), p_filename, p_show_hidden, p_mode, p_filters, TypedArray<Dictionary>(), p_callback, false, p_window_id);
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-30 12:19:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Error DisplayServerMacOS::file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, WindowID p_window_id) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return _file_dialog_with_options_show(p_title, p_current_directory, p_root, p_filename, p_show_hidden, p_mode, p_filters, p_options, p_callback, true, p_window_id);
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-30 12:19:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Error DisplayServerMacOS::_file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, bool p_options_in_cb, WindowID p_window_id) {
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX_V(int(p_mode), FILE_DIALOG_MODE_SAVE_MAX, FAILED);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSString *url = [NSString stringWithUTF8String:p_current_directory.utf8().get_data()];
							 
						 
					
						
							
								
									
										
										
										
											2024-09-30 12:19:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSWindow *nswindow = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (windows.has(p_window_id) && !windows[p_window_id].is_popup) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										nswindow = windows[p_window_id].window_object;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-13 12:37:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									GodotOpenSaveDelegate *panel_delegate = [[GodotOpenSaveDelegate alloc] init];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_root.length() > 0) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel_delegate setRootPath:p_root];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Callable callback = p_callback; // Make a copy for async completion handler.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_mode == FILE_DIALOG_MODE_SAVE_FILE) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSSavePanel *panel = [NSSavePanel savePanel];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setDirectoryURL:[NSURL fileURLWithPath:url]];
							 
						 
					
						
							
								
									
										
										
										
											2023-10-13 12:37:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[panel_delegate makeAccessoryView:panel filters:p_filters options:p_options];
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[panel setExtensionHidden:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setCanSelectHiddenExtension:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setCanCreateDirectories:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setShowsHiddenFiles:p_show_hidden];
							 
						 
					
						
							
								
									
										
										
										
											2023-10-13 12:37:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[panel setDelegate:panel_delegate];
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (p_filename != "") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSString *fileurl = [NSString stringWithUTF8String:p_filename.utf8().get_data()];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[panel setNameFieldStringValue:fileurl];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-30 12:19:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										void (^completion_handler)(NSInteger ret) = ^(NSInteger ret) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (ret == NSModalResponseOK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Save bookmark for folder.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (OS::get_singleton()->is_sandboxed()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													NSArray *bookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:@"sec_bookmarks"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													bool skip = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													for (id bookmark in bookmarks) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														NSError *error = nil;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														BOOL isStale = NO;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														NSURL *exurl = [NSURL URLByResolvingBookmarkData:bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (!error && !isStale && ([[exurl path] compare:[[panel directoryURL] path]] == NSOrderedSame)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															skip = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if (!skip) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														NSError *error = nil;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														NSData *bookmark = [[panel directoryURL] bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:nil relativeToURL:nil error:&error];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (!error) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															NSArray *new_bookmarks = [bookmarks arrayByAddingObject:bookmark];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															[[NSUserDefaults standardUserDefaults] setObject:new_bookmarks forKey:@"sec_bookmarks"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Callback.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Vector<String> files;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												String url;
							 
						 
					
						
							
								
									
										
										
										
											2025-03-24 12:25:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												url.append_utf8([[[panel URL] path] UTF8String]);
							 
						 
					
						
							
								
									
										
										
										
											2024-09-30 12:19:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												files.push_back(url);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (callback.is_valid()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if (p_options_in_cb) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_result = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_files = files;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_index = [panel_delegate getIndex];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_opt = [panel_delegate getSelection];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														const Variant *args[4] = { &v_result, &v_files, &v_index, &v_opt };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														callback.callp(args, 4, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															ERR_PRINT(vformat("Failed to execute file dialog callback: %s.", Variant::get_callable_error_text(callback, args, 4, ce)));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_result = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_files = files;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_index = [panel_delegate getIndex];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														const Variant *args[3] = { &v_result, &v_files, &v_index };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														callback.callp(args, 3, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															ERR_PRINT(vformat("Failed to execute file dialog callback: %s.", Variant::get_callable_error_text(callback, args, 3, ce)));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (callback.is_valid()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if (p_options_in_cb) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_result = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_files = Vector<String>();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_index = [panel_delegate getIndex];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_opt = [panel_delegate getSelection];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														const Variant *args[4] = { &v_result, &v_files, &v_index, &v_opt };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														callback.callp(args, 4, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															ERR_PRINT(vformat("Failed to execute file dialog callback: %s.", Variant::get_callable_error_text(callback, args, 4, ce)));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_result = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_files = Vector<String>();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_index = [panel_delegate getIndex];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														const Variant *args[3] = { &v_result, &v_files, &v_index };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														callback.callp(args, 3, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															ERR_PRINT(vformat("Failed to execute file dialog callback: %s.", Variant::get_callable_error_text(callback, args, 3, ce)));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (p_window_id != INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												callable_mp(DisplayServer::get_singleton(), &DisplayServer::window_move_to_foreground).call_deferred(p_window_id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (nswindow) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[panel beginSheetModalForWindow:nswindow completionHandler:completion_handler];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[panel beginWithCompletionHandler:completion_handler];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSOpenPanel *panel = [NSOpenPanel openPanel];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setDirectoryURL:[NSURL fileURLWithPath:url]];
							 
						 
					
						
							
								
									
										
										
										
											2023-10-13 12:37:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[panel_delegate makeAccessoryView:panel filters:p_filters options:p_options];
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[panel setExtensionHidden:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setCanSelectHiddenExtension:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setCanCreateDirectories:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setCanChooseFiles:(p_mode != FILE_DIALOG_MODE_OPEN_DIR)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setCanChooseDirectories:(p_mode == FILE_DIALOG_MODE_OPEN_DIR || p_mode == FILE_DIALOG_MODE_OPEN_ANY)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setShowsHiddenFiles:p_show_hidden];
							 
						 
					
						
							
								
									
										
										
										
											2023-10-13 12:37:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[panel setDelegate:panel_delegate];
							 
						 
					
						
							
								
									
										
										
										
											2023-08-21 10:54:24 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (p_filename != "") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSString *fileurl = [NSString stringWithUTF8String:p_filename.utf8().get_data()];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[panel setNameFieldStringValue:fileurl];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[panel setAllowsMultipleSelection:(p_mode == FILE_DIALOG_MODE_OPEN_FILES)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-30 12:19:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										void (^completion_handler)(NSInteger ret) = ^(NSInteger ret) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (ret == NSModalResponseOK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Save bookmark for folder.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												NSArray *urls = [(NSOpenPanel *)panel URLs];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (OS::get_singleton()->is_sandboxed()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													NSArray *bookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:@"sec_bookmarks"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													NSMutableArray *new_bookmarks = [bookmarks mutableCopy];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													for (NSUInteger i = 0; i != [urls count]; ++i) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														bool skip = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														for (id bookmark in bookmarks) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															NSError *error = nil;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															BOOL isStale = NO;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															NSURL *exurl = [NSURL URLByResolvingBookmarkData:bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															if (!error && !isStale && ([[exurl path] compare:[[urls objectAtIndex:i] path]] == NSOrderedSame)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																skip = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (!skip) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															NSError *error = nil;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															NSData *bookmark = [[urls objectAtIndex:i] bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:nil relativeToURL:nil error:&error];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															if (!error) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																[new_bookmarks addObject:bookmark];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[[NSUserDefaults standardUserDefaults] setObject:new_bookmarks forKey:@"sec_bookmarks"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												// Callback.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												Vector<String> files;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												for (NSUInteger i = 0; i != [urls count]; ++i) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													String url;
							 
						 
					
						
							
								
									
										
										
										
											2025-03-24 12:25:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													url.append_utf8([[[urls objectAtIndex:i] path] UTF8String]);
							 
						 
					
						
							
								
									
										
										
										
											2024-09-30 12:19:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													files.push_back(url);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (callback.is_valid()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if (p_options_in_cb) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_result = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_files = files;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_index = [panel_delegate getIndex];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_opt = [panel_delegate getSelection];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														const Variant *args[4] = { &v_result, &v_files, &v_index, &v_opt };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														callback.callp(args, 4, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															ERR_PRINT(vformat("Failed to execute file dialog callback: %s.", Variant::get_callable_error_text(callback, args, 4, ce)));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_result = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_files = files;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_index = [panel_delegate getIndex];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														const Variant *args[3] = { &v_result, &v_files, &v_index };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														callback.callp(args, 3, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															ERR_PRINT(vformat("Failed to execute file dialog callback: %s.", Variant::get_callable_error_text(callback, args, 3, ce)));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (callback.is_valid()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if (p_options_in_cb) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_result = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_files = Vector<String>();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_index = [panel_delegate getIndex];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_opt = [panel_delegate getSelection];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														const Variant *args[4] = { &v_result, &v_files, &v_index, &v_opt };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														callback.callp(args, 4, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															ERR_PRINT(vformat("Failed to execute file dialog callback: %s.", Variant::get_callable_error_text(callback, args, 4, ce)));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_result = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_files = Vector<String>();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant v_index = [panel_delegate getIndex];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														const Variant *args[3] = { &v_result, &v_files, &v_index };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														callback.callp(args, 3, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															ERR_PRINT(vformat("Failed to execute file dialog callback: %s.", Variant::get_callable_error_text(callback, args, 3, ce)));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (p_window_id != INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												callable_mp(DisplayServer::get_singleton(), &DisplayServer::window_move_to_foreground).call_deferred(p_window_id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (nswindow) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[panel beginSheetModalForWindow:nswindow completionHandler:completion_handler];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[panel beginWithCompletionHandler:completion_handler];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2021-03-30 15:42:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return OK;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-17 22:40:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::beep() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSBeep();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Error DisplayServerMacOS::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSAlert *window = [[NSAlert alloc] init];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSString *ns_description = [NSString stringWithUTF8String:p_description.utf8().get_data()];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 250, 30)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window addButtonWithTitle:@"OK"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window setMessageText:ns_title];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window setInformativeText:ns_description];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window setAlertStyle:NSAlertStyleInformational];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[input setStringValue:[NSString stringWithUTF8String:p_partial.utf8().get_data()]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window setAccessoryView:input];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window runModal];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									String ret;
							 
						 
					
						
							
								
									
										
										
										
											2025-03-24 12:25:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ret.append_utf8([[input stringValue] UTF8String]);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-27 11:56:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_callback.is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Variant v_result = ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const Variant *args[1] = { &v_result };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										p_callback.callp(args, 1, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
									
										
										
										
											2023-11-11 22:59:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ERR_PRINT(vformat("Failed to execute input dialog callback: %s.", Variant::get_callable_error_text(p_callback, args, 1, ce)));
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return OK;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_mouse_update_mode() {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									MouseMode wanted_mouse_mode = mouse_mode_override_enabled
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											? mouse_mode_override
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											: mouse_mode_base;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (wanted_mouse_mode == mouse_mode) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-07 19:31:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									WindowID window_id = _get_focused_window_or_popup();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (!windows.has(window_id)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										window_id = MAIN_WINDOW_ID;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-02-01 03:49:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[window_id];
							 
						 
					
						
							
								
									
										
										
										
											2022-11-10 18:23:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool show_cursor = (wanted_mouse_mode == MOUSE_MODE_VISIBLE || wanted_mouse_mode == MOUSE_MODE_CONFINED);
							 
						 
					
						
							
								
									
										
										
										
											2022-11-10 18:23:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool previously_shown = (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (show_cursor && !previously_shown) {
							 
						 
					
						
							
								
									
										
										
										
											2023-05-11 12:32:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										window_id = get_window_at_screen_position(mouse_get_position());
							 
						 
					
						
							
								
									
										
										
										
											2023-08-09 10:23:57 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										mouse_enter_window(window_id);
							 
						 
					
						
							
								
									
										
										
										
											2022-11-10 18:23:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (wanted_mouse_mode == MOUSE_MODE_CAPTURED) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Apple Docs state that the display parameter is not used.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// "This parameter is not used. By default, you may pass kCGDirectMainDisplay."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html
							 
						 
					
						
							
								
									
										
										
										
											2022-11-10 18:23:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (previously_shown) {
							 
						 
					
						
							
								
									
										
										
										
											2020-06-22 11:38:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CGDisplayHideCursor(kCGDirectMainDisplay);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGAssociateMouseAndMouseCursorPosition(false);
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 14:02:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setMovable:NO];
							 
						 
					
						
							
								
									
										
										
										
											2020-09-25 08:55:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const NSRect contentRect = [wd.window_view frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSRect pointInWindowRect = NSMakeRect(contentRect.size.width / 2, contentRect.size.height / 2, 0, 0);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSPoint pointOnScreen = [[wd.window_view window] convertRectToScreen:pointInWindowRect].origin;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGWarpMouseCursorPosition(lMouseWarpPos);
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else if (wanted_mouse_mode == MOUSE_MODE_HIDDEN) {
							 
						 
					
						
							
								
									
										
										
										
											2022-11-10 18:23:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (previously_shown) {
							 
						 
					
						
							
								
									
										
										
										
											2020-06-22 11:38:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CGDisplayHideCursor(kCGDirectMainDisplay);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 14:02:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setMovable:YES];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGAssociateMouseAndMouseCursorPosition(true);
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else if (wanted_mouse_mode == MOUSE_MODE_CONFINED) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-02 15:55:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CGDisplayShowCursor(kCGDirectMainDisplay);
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 14:02:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setMovable:NO];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-02 15:55:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CGAssociateMouseAndMouseCursorPosition(false);
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else if (wanted_mouse_mode == MOUSE_MODE_CONFINED_HIDDEN) {
							 
						 
					
						
							
								
									
										
										
										
											2022-11-10 18:23:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (previously_shown) {
							 
						 
					
						
							
								
									
										
										
										
											2021-03-30 18:35:08 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CGDisplayHideCursor(kCGDirectMainDisplay);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 14:02:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setMovable:NO];
							 
						 
					
						
							
								
									
										
										
										
											2021-03-30 18:35:08 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CGAssociateMouseAndMouseCursorPosition(false);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else { // MOUSE_MODE_VISIBLE
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGDisplayShowCursor(kCGDirectMainDisplay);
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 14:02:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setMovable:YES];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGAssociateMouseAndMouseCursorPosition(true);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									last_warp = [[NSProcessInfo processInfo] systemUptime];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ignore_warp = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									warp_events.clear();
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									mouse_mode = wanted_mouse_mode;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-10 18:23:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (show_cursor) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										cursor_update_shape();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::mouse_set_mode(MouseMode p_mode) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX(p_mode, MouseMode::MOUSE_MODE_MAX);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_mode == mouse_mode_base) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									mouse_mode_base = p_mode;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_mouse_update_mode();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer::MouseMode DisplayServerMacOS::mouse_get_mode() const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return mouse_mode;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-22 10:44:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::mouse_set_mode_override(MouseMode p_mode) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX(p_mode, MouseMode::MOUSE_MODE_MAX);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_mode == mouse_mode_override) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									mouse_mode_override = p_mode;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_mouse_update_mode();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer::MouseMode DisplayServerMacOS::mouse_get_mode_override() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return mouse_mode_override;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::mouse_set_mode_override_enabled(bool p_override_enabled) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_override_enabled == mouse_mode_override_enabled) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									mouse_mode_override_enabled = p_override_enabled;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_mouse_update_mode();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::mouse_is_mode_override_enabled() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return mouse_mode_override_enabled;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::update_mouse_wrap(WindowData &p_wd, NSPoint &r_delta, NSPoint &r_mpos, NSTimeInterval p_timestamp) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (ignore_warp) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Discard late events, before warp.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (p_timestamp < last_warp) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ignore_warp = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (mouse_mode == DisplayServer::MOUSE_MODE_CONFINED || mouse_mode == DisplayServer::MOUSE_MODE_CONFINED_HIDDEN) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Discard late events.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (p_timestamp < last_warp) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Warp affects next event delta, subtract previous warp deltas.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										List<WarpEvent>::Element *F = warp_events.front();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										while (F) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (F->get().timestamp < p_timestamp) {
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												List<DisplayServerMacOS::WarpEvent>::Element *E = F;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												r_delta.x -= E->get().delta.x;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												r_delta.y -= E->get().delta.y;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												F = F->next();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												warp_events.erase(E);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												F = F->next();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Confine mouse position to the window, and update delta.
							 
						 
					
						
							
								
									
										
										
										
											2024-02-18 23:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										NSRect frame = [p_wd.window_view frame];
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										NSPoint conf_pos = r_mpos;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										conf_pos.x = CLAMP(conf_pos.x + r_delta.x, 0.f, frame.size.width);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										conf_pos.y = CLAMP(conf_pos.y - r_delta.y, 0.f, frame.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										r_delta.x = conf_pos.x - r_mpos.x;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										r_delta.y = r_mpos.y - conf_pos.y;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										r_mpos = conf_pos;
							 
						 
					
						
							
								
									
										
										
										
											2021-06-23 10:51:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Move mouse cursor.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSRect point_in_window_rect = NSMakeRect(conf_pos.x, conf_pos.y, 0, 0);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										conf_pos = [[p_wd.window_view window] convertRectToScreen:point_in_window_rect].origin;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										conf_pos.y = CGDisplayBounds(CGMainDisplayID()).size.height - conf_pos.y;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGWarpMouseCursorPosition(conf_pos);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Save warp data.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										last_warp = [[NSProcessInfo processInfo] systemUptime];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										DisplayServerMacOS::WarpEvent ev;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ev.timestamp = last_warp;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ev.delta = r_delta;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										warp_events.push_back(ev);
							 
						 
					
						
							
								
									
										
										
										
											2021-06-23 10:51:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return false;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::warp_mouse(const Point2i &p_position) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (mouse_mode != MOUSE_MODE_CAPTURED) {
							 
						 
					
						
							
								
									
										
										
										
											2022-09-07 19:31:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										WindowID window_id = _get_focused_window_or_popup();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (!windows.has(window_id)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											window_id = MAIN_WINDOW_ID;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-02-01 03:49:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										WindowData &wd = windows[window_id];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Local point in window coords.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const NSRect contentRect = [wd.window_view frame];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const float scale = screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2023-02-21 08:30:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										NSRect pointInWindowRect = NSMakeRect(p_position.x / scale, contentRect.size.height - (p_position.y / scale), scale, scale);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSPoint pointOnScreen = [[wd.window_view window] convertRectToScreen:pointInWindowRect].origin;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-11 23:01:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Point in screen coords.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Do the warping.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGAssociateMouseAndMouseCursorPosition(false);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGWarpMouseCursorPosition(lMouseWarpPos);
							 
						 
					
						
							
								
									
										
										
										
											2021-03-30 18:35:08 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (mouse_mode != MOUSE_MODE_CONFINED && mouse_mode != MOUSE_MODE_CONFINED_HIDDEN) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-02 15:55:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CGAssociateMouseAndMouseCursorPosition(true);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Point2i DisplayServerMacOS::mouse_get_position() const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSPoint mouse_pos = [NSEvent mouseLocation];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const float scale = screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (NSScreen *screen in [NSScreen screens]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSRect frame = [screen frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (NSMouseInRect(mouse_pos, frame, NO)) {
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 18:04:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Vector2i pos = Vector2i((int)mouse_pos.x, (int)mouse_pos.y);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pos *= scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pos -= _get_screens_origin();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pos.y *= -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return pos;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return Vector2i();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-08 00:55:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								BitField<MouseButtonMask> DisplayServerMacOS::mouse_get_button_state() const {
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 09:50:44 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									BitField<MouseButtonMask> last_button_state = MouseButtonMask::NONE;
							 
						 
					
						
							
								
									
										
										
										
											2024-05-27 10:52:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSUInteger buttons = [NSEvent pressedMouseButtons];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (buttons & (1 << 0)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										last_button_state.set_flag(MouseButtonMask::LEFT);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (buttons & (1 << 1)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										last_button_state.set_flag(MouseButtonMask::RIGHT);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (buttons & (1 << 2)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										last_button_state.set_flag(MouseButtonMask::MIDDLE);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (buttons & (1 << 3)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										last_button_state.set_flag(MouseButtonMask::MB_XBUTTON1);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (buttons & (1 << 4)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										last_button_state.set_flag(MouseButtonMask::MB_XBUTTON2);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return last_button_state;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								int DisplayServerMacOS::get_screen_count() const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSArray *screenArray = [NSScreen screens];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return [screenArray count];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								int DisplayServerMacOS::get_primary_screen() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return 0;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-21 13:08:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								int DisplayServerMacOS::get_keyboard_focus_screen() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSUInteger index = [[NSScreen screens] indexOfObject:[NSScreen mainScreen]];
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return (index == NSNotFound) ? get_primary_screen() : index;
							 
						 
					
						
							
								
									
										
										
										
											2023-03-21 13:08:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Point2i DisplayServerMacOS::screen_get_position(int p_screen) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-21 13:08:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_screen = _get_screen_index(p_screen);
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									int screen_count = get_screen_count();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX_V(p_screen, screen_count, Point2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2i position = _get_native_screen_position(p_screen) - _get_screens_origin();
							 
						 
					
						
							
								
									
										
										
										
											2023-03-12 16:48:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// macOS native y-coordinate relative to _get_screens_origin() is negative,
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Godot expects a positive value.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position.y *= -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return position;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Size2i DisplayServerMacOS::screen_get_size(int p_screen) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-21 13:08:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_screen = _get_screen_index(p_screen);
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									int screen_count = get_screen_count();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX_V(p_screen, screen_count, Size2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSArray *screenArray = [NSScreen screens];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ((NSUInteger)p_screen < [screenArray count]) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Note: Use frame to get the whole screen size.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return Size2i(nsrect.size.width, nsrect.size.height) * screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return Size2i();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								int DisplayServerMacOS::screen_get_dpi(int p_screen) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-21 13:08:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_screen = _get_screen_index(p_screen);
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									int screen_count = get_screen_count();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX_V(p_screen, screen_count, 72);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSArray *screenArray = [NSScreen screens];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ((NSUInteger)p_screen < [screenArray count]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSDictionary *description = [[screenArray objectAtIndex:p_screen] deviceDescription];
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 22:52:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const CGSize displayPhysicalSize = CGDisplayScreenSize([[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										float scale = [[screenArray objectAtIndex:p_screen] backingScaleFactor];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										float den2 = (displayPhysicalSize.width / 25.4f) * (displayPhysicalSize.width / 25.4f) + (displayPhysicalSize.height / 25.4f) * (displayPhysicalSize.height / 25.4f);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (den2 > 0.0f) {
							 
						 
					
						
							
								
									
										
										
										
											2025-03-19 14:18:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return std::ceil(std::sqrt(displayPixelSize.width * displayPixelSize.width + displayPixelSize.height * displayPixelSize.height) / std::sqrt(den2) * scale);
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 22:52:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-01 22:52:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return 72;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								float DisplayServerMacOS::screen_get_scale(int p_screen) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-21 13:08:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_screen = _get_screen_index(p_screen);
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									int screen_count = get_screen_count();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX_V(p_screen, screen_count, 1.0f);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (OS::get_singleton()->is_hidpi_allowed()) {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										NSArray<NSScreen *> *screens = NSScreen.screens;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSUInteger index = (NSUInteger)p_screen;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (index < screens.count) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return std::fmax(1.0f, screens[index].backingScaleFactor);
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return 1.f;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								float DisplayServerMacOS::screen_get_max_scale() const {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Note: Do not update max display scale on screen configuration change, existing editor windows can't be rescaled on the fly.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return display_max_scale;
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Rect2i DisplayServerMacOS::screen_get_usable_rect(int p_screen) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-21 13:08:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_screen = _get_screen_index(p_screen);
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									int screen_count = get_screen_count();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX_V(p_screen, screen_count, Rect2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSArray *screenArray = [NSScreen screens];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ((NSUInteger)p_screen < [screenArray count]) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										const float scale = screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSRect nsrect = [[screenArray objectAtIndex:p_screen] visibleFrame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Point2i position = Point2i(nsrect.origin.x, nsrect.origin.y + nsrect.size.height) * scale - _get_screens_origin();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										position.y *= -1;
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2i size = Size2i(nsrect.size.width, nsrect.size.height) * scale;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return Rect2i(position, size);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return Rect2i();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-27 20:36:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Color DisplayServerMacOS::screen_get_pixel(const Point2i &p_position) const {
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									HashSet<CGWindowID> exclude_windows;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (HashMap<WindowID, WindowData>::ConstIterator E = windows.begin(); E; ++E) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (E->value.hide_from_capture) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											exclude_windows.insert([E->value.window_object windowNumber]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CFArrayRef on_screen_windows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CFMutableArrayRef capture_windows = CFArrayCreateMutableCopy(nullptr, 0, on_screen_windows);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (long i = CFArrayGetCount(on_screen_windows) - 1; i >= 0; i--) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGWindowID window = (CGWindowID)(uintptr_t)CFArrayGetValueAtIndex(capture_windows, i);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (exclude_windows.has(window)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											CFArrayRemoveValueAtIndex(capture_windows, i);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2i position = p_position - Vector2i(1, 1);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position -= screen_get_position(0); // Note: coordinates where the screen origin is in the upper-left corner of the main display and y-axis values increase downward.
							 
						 
					
						
							
								
									
										
										
										
											2023-02-27 20:36:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									position /= screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 11:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Color color;
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CGImageRef image = CGWindowListCreateImageFromArray(CGRectMake(position.x, position.y, 1, 1), capture_windows, kCGWindowListOptionAll);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (image) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (color_space) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											uint8_t img_data[4];
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 10:05:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CGContextRef context = CGBitmapContextCreate(img_data, 1, 1, 8, 4, color_space, (uint32_t)kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (context) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												CGContextDrawImage(context, CGRectMake(0, 0, 1, 1), image);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												color = Color(img_data[0] / 255.0f, img_data[1] / 255.0f, img_data[2] / 255.0f, img_data[3] / 255.0f);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												CGContextRelease(context);
							 
						 
					
						
							
								
									
										
										
										
											2023-02-27 20:36:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CGColorSpaceRelease(color_space);
							 
						 
					
						
							
								
									
										
										
										
											2023-02-27 20:36:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CGImageRelease(image);
							 
						 
					
						
							
								
									
										
										
										
											2023-02-27 20:36:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2024-02-13 11:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return color;
							 
						 
					
						
							
								
									
										
										
										
											2023-02-27 20:36:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 23:26:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Ref<Image> DisplayServerMacOS::screen_get_image(int p_screen) const {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_screen = _get_screen_index(p_screen);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int screen_count = get_screen_count();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX_V(p_screen, screen_count, Ref<Image>());
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 23:26:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									HashSet<CGWindowID> exclude_windows;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (HashMap<WindowID, WindowData>::ConstIterator E = windows.begin(); E; ++E) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (E->value.hide_from_capture) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											exclude_windows.insert([E->value.window_object windowNumber]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CFArrayRef on_screen_windows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CFMutableArrayRef capture_windows = CFArrayCreateMutableCopy(nullptr, 0, on_screen_windows);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (long i = CFArrayGetCount(on_screen_windows) - 1; i >= 0; i--) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGWindowID window = (CGWindowID)(uintptr_t)CFArrayGetValueAtIndex(capture_windows, i);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (exclude_windows.has(window)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											CFArrayRemoveValueAtIndex(capture_windows, i);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2i position = screen_get_position(p_screen);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position -= screen_get_position(0); // Note: coordinates where the screen origin is in the upper-left corner of the main display and y-axis values increase downward.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position /= screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Size2i size = screen_get_size(p_screen);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									size /= screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Ref<Image> img;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CGImageRef image = CGWindowListCreateImageFromArray(CGRectMake(position.x, position.y, size.width, size.height), capture_windows, kCGWindowListOptionAll);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (image) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (color_space) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSUInteger width = CGImageGetWidth(image);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSUInteger height = CGImageGetHeight(image);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector<uint8_t> img_data;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											img_data.resize(height * width * 4);
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 10:05:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CGContextRef context = CGBitmapContextCreate(img_data.ptrw(), width, height, 8, 4 * width, color_space, (uint32_t)kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (context) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												CGContextDrawImage(context, CGRectMake(0, 0, width, height), image);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												img = Image::create_from_data(width, height, false, Image::FORMAT_RGBA8, img_data);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												CGContextRelease(context);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												img->resize(screen_get_size(p_screen).x, screen_get_size(p_screen).y, Image::INTERPOLATE_NEAREST);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											CGColorSpaceRelease(color_space);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGImageRelease(image);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return img;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Ref<Image> DisplayServerMacOS::screen_get_image_rect(const Rect2i &p_rect) const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									HashSet<CGWindowID> exclude_windows;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (HashMap<WindowID, WindowData>::ConstIterator E = windows.begin(); E; ++E) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (E->value.hide_from_capture) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											exclude_windows.insert([E->value.window_object windowNumber]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CFArrayRef on_screen_windows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CFMutableArrayRef capture_windows = CFArrayCreateMutableCopy(nullptr, 0, on_screen_windows);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (long i = CFArrayGetCount(on_screen_windows) - 1; i >= 0; i--) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGWindowID window = (CGWindowID)(uintptr_t)CFArrayGetValueAtIndex(capture_windows, i);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (exclude_windows.has(window)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											CFArrayRemoveValueAtIndex(capture_windows, i);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 23:26:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Point2i position = p_rect.position;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position -= screen_get_position(0); // Note: coordinates where the screen origin is in the upper-left corner of the main display and y-axis values increase downward.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position /= screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Size2i size = p_rect.size;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									size /= screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 23:26:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref<Image> img;
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CGImageRef image = CGWindowListCreateImageFromArray(CGRectMake(position.x, position.y, size.width, size.height), capture_windows, kCGWindowListOptionAll);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (image) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (color_space) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSUInteger width = CGImageGetWidth(image);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSUInteger height = CGImageGetHeight(image);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Vector<uint8_t> img_data;
							 
						 
					
						
							
								
									
										
										
										
											2025-05-23 00:20:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											img_data.resize_initialized(height * width * 4);
							 
						 
					
						
							
								
									
										
										
										
											2025-04-26 10:05:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CGContextRef context = CGBitmapContextCreate(img_data.ptrw(), width, height, 8, 4 * width, color_space, (uint32_t)kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (context) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												CGContextDrawImage(context, CGRectMake(0, 0, width, height), image);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												img = Image::create_from_data(width, height, false, Image::FORMAT_RGBA8, img_data);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												CGContextRelease(context);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												img->resize(p_rect.size.x, p_rect.size.y, Image::INTERPOLATE_NEAREST);
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 23:26:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											CGColorSpaceRelease(color_space);
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 23:26:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										CGImageRelease(image);
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 23:26:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return img;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								float DisplayServerMacOS::screen_get_refresh_rate(int p_screen) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 13:46:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-21 13:08:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									p_screen = _get_screen_index(p_screen);
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									int screen_count = get_screen_count();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX_V(p_screen, screen_count, SCREEN_REFRESH_RATE_FALLBACK);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 13:46:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSArray *screenArray = [NSScreen screens];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ((NSUInteger)p_screen < [screenArray count]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSDictionary *description = [[screenArray objectAtIndex:p_screen] deviceDescription];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const CGDisplayModeRef displayMode = CGDisplayCopyDisplayMode([[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const double displayRefreshRate = CGDisplayModeGetRefreshRate(displayMode);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return (float)displayRefreshRate;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-02-10 12:00:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_PRINT("An error occurred while trying to get the screen refresh rate.");
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 13:46:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return SCREEN_REFRESH_RATE_FALLBACK;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-05 13:14:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::screen_is_kept_on() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return (screen_keep_on_assertion);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 10:38:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::screen_set_keep_on(bool p_enable) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (screen_keep_on_assertion) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										IOPMAssertionRelease(screen_keep_on_assertion);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										screen_keep_on_assertion = kIOPMNullAssertionID;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_enable) {
							 
						 
					
						
							
								
									
										
										
										
											2022-10-18 16:43:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										String app_name_string = GLOBAL_GET("application/config/name");
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 10:38:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										NSString *name = [NSString stringWithUTF8String:(app_name_string.is_empty() ? "Godot Engine" : app_name_string.utf8().get_data())];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSString *reason = @"Godot Engine running with display/window/energy_saving/keep_screen_on = true";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										IOPMAssertionCreateWithDescription(kIOPMAssertPreventUserIdleDisplaySleep, (__bridge CFStringRef)name, (__bridge CFStringRef)reason, (__bridge CFStringRef)reason, nullptr, 0, nullptr, &screen_keep_on_assertion);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector<DisplayServer::WindowID> DisplayServerMacOS::get_window_list() const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Vector<int> ret;
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for (const KeyValue<WindowID, WindowData> &E : windows) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ret.push_back(E.key);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-25 00:20:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer::WindowID DisplayServerMacOS::create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect, bool p_exclusive, WindowID p_transient_parent) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									WindowID id = _create_window(p_mode, p_vsync_mode, p_rect);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (int i = 0; i < WINDOW_FLAG_MAX; i++) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (p_flags & (1 << i)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											window_set_flag(WindowFlags(i), true, id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef RD_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_device) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_device->screen_create(id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2024-07-25 00:20:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									window_set_exclusive(id, p_exclusive);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_transient_parent != INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										window_set_transient(id, p_transient_parent);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-21 09:39:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return id;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::show_window(WindowID p_id) {
							 
						 
					
						
							
								
									
										
										
										
											2020-08-21 09:39:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_id];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-20 09:21:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_id == MAIN_WINDOW_ID) {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[GodotApp setActivationPolicy:NSApplicationActivationPolicyRegular];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[GodotApp activateApplication];
							 
						 
					
						
							
								
									
										
										
										
											2025-03-20 09:21:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									popup_open(p_id);
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 10:05:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if ([wd.window_object isMiniaturized]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
									
										
										
										
											2023-06-09 08:03:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else if (wd.no_focus) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object orderFront:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object makeKeyAndOrderFront:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::delete_sub_window(WindowID p_id) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_id));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_MSG(p_id == MAIN_WINDOW_ID, "Main window can't be deleted");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_id];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[wd.window_object setContentView:nil];
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// This will cause the delegate to release the window.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[wd.window_object close];
							 
						 
					
						
							
								
									
										
										
										
											2025-03-18 15:25:03 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									mouse_enter_window(get_window_at_screen_position(mouse_get_position()));
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.rect_changed_callback = p_callable;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.event_callback = p_callable;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_input_event_callback(const Callable &p_callable, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.input_event_callback = p_callable;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_input_text_callback(const Callable &p_callable, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.input_text_callback = p_callable;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_drop_files_callback(const Callable &p_callable, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.drop_files_callback = p_callable;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_title(const String &p_title, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[wd.window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-08 11:31:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Size2i DisplayServerMacOS::window_get_title_size(const String &p_title, WindowID p_window) const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Size2i size;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), size);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.fullscreen || wd.borderless) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return size;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ([wd.window_object respondsToSelector:@selector(isMiniaturized)]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if ([wd.window_object isMiniaturized]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return size;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									float scale = screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.window_button_view) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										size.x = ([wd.window_button_view getOffset].x + [wd.window_button_view frame].size.width);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										size.y = ([wd.window_button_view getOffset].y + [wd.window_button_view frame].size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSButton *cb = [wd.window_object standardWindowButton:NSWindowCloseButton];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSButton *mb = [wd.window_object standardWindowButton:NSWindowMiniaturizeButton];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										float cb_frame = NSMinX([cb frame]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										float mb_frame = NSMinX([mb frame]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										bool is_rtl = ([wd.window_object windowTitlebarLayoutDirection] == NSUserInterfaceLayoutDirectionRightToLeft);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										float window_buttons_spacing = (is_rtl) ? (cb_frame - mb_frame) : (mb_frame - cb_frame);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										size.x = window_buttons_spacing * 4;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										size.y = [cb frame].origin.y + [cb frame].size.height;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont titleBarFontOfSize:0], NSFontAttributeName, nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSSize text_size = [[[NSAttributedString alloc] initWithString:[NSString stringWithUTF8String:p_title.utf8().get_data()] attributes:attributes] size];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									size.x += text_size.width;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									size.y = MAX(size.y, text_size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return size * scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_mouse_passthrough(const Vector<Vector2> &p_region, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.mpath = p_region;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								int DisplayServerMacOS::window_get_current_screen(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), INVALID_SCREEN);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSUInteger index = [[NSScreen screens] indexOfObject:[wd.window_object screen]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return (index == NSNotFound) ? 0 : index;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_current_screen(int p_screen, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p_screen = _get_screen_index(p_screen);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int screen_count = get_screen_count();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX(p_screen, screen_count);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-19 12:26:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (window_get_current_screen(p_window) == p_screen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-02 10:16:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
									
										
										
										
											2022-07-19 12:26:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool was_fullscreen = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Temporary exit fullscreen mode to move window.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object toggleFullScreen:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										was_fullscreen = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-03 10:38:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool was_maximized = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (!was_fullscreen && NSEqualRects([wd.window_object frame], [[wd.window_object screen] visibleFrame])) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object zoom:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										was_maximized = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-08 20:34:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Rect2i srect = screen_get_usable_rect(p_screen);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2i wpos = window_get_position(p_window) - screen_get_position(window_get_current_screen(p_window));
							 
						 
					
						
							
								
									
										
										
										
											2022-12-08 20:34:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Size2i wsize = window_get_size(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wpos += srect.position;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 12:49:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									wpos = wpos.clamp(srect.position, srect.position + srect.size - wsize / 3);
							 
						 
					
						
							
								
									
										
										
										
											2022-12-08 20:34:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									window_set_position(wpos, p_window);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-03 10:38:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (was_maximized) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object zoom:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (was_fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Re-enter fullscreen mode.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object toggleFullScreen:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:25:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::reparent_check(WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:25:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSScreen *screen = [wd.window_object screen];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-20 09:37:35 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_window_update_display_id(&wd);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:25:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.transient_parent != INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										WindowData &wd_parent = windows[wd.transient_parent];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSScreen *parent_screen = [wd_parent.window_object screen];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (parent_screen == screen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (![[wd_parent.window_object childWindows] containsObject:wd.window_object]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[wd_parent.window_object addChildWindow:wd.window_object ordered:NSWindowAbove];
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:25:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if ([[wd_parent.window_object childWindows] containsObject:wd.window_object]) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[wd_parent.window_object removeChildWindow:wd.window_object];
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:25:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object orderFront:nil];
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:25:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (const WindowID &child : wd.transient_children) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										WindowData &wd_child = windows[child];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSScreen *child_screen = [wd_child.window_object screen];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (child_screen == screen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (![[wd.window_object childWindows] containsObject:wd_child.window_object]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (wd_child.fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[wd_child.window_object toggleFullScreen:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd_child.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object addChildWindow:wd_child.window_object ordered:NSWindowAbove];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if ([[wd.window_object childWindows] containsObject:wd_child.window_object]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object removeChildWindow:wd_child.window_object];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd_child.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_exclusive(WindowID p_window, bool p_exclusive) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.exclusive != p_exclusive) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										wd.exclusive = p_exclusive;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										reparent_check(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Point2i DisplayServerMacOS::window_get_position(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), Point2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Use content rect position (without titlebar / window border).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect contentRect = [wd.window_view frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect nsrect = [wd.window_object convertRectToScreen:contentRect];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2i pos;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-12 16:48:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Return the position of the top-left corner, for macOS the y starts at the bottom.
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const float scale = screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos.x = nsrect.origin.x;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos.y = (nsrect.origin.y + nsrect.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos *= scale;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos -= _get_screens_origin();
							 
						 
					
						
							
								
									
										
										
										
											2023-03-12 16:48:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// macOS native y-coordinate relative to _get_screens_origin() is negative,
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Godot expects a positive value.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos.y *= -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return pos;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 10:28:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Point2i DisplayServerMacOS::window_get_position_with_decorations(WindowID p_window) const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), Point2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect nsrect = [wd.window_object frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2i pos;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-12 16:48:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Return the position of the top-left corner, for macOS the y starts at the bottom.
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 10:28:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const float scale = screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos.x = nsrect.origin.x;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos.y = (nsrect.origin.y + nsrect.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos *= scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos -= _get_screens_origin();
							 
						 
					
						
							
								
									
										
										
										
											2023-03-12 16:48:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// macOS native y-coordinate relative to _get_screens_origin() is negative,
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 10:28:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Godot expects a positive value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									pos.y *= -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return pos;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_position(const Point2i &p_position, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-31 19:54:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.fullscreen) {
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 10:05:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2i position = p_position;
							 
						 
					
						
							
								
									
										
										
										
											2023-03-12 16:48:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// macOS native y-coordinate relative to _get_screens_origin() is negative,
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Godot passes a positive value.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position.y *= -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position += _get_screens_origin();
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									position /= screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Remove titlebar / window border size.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect contentRect = [wd.window_view frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect windowRect = [wd.window_object frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect nsrect = [wd.window_object convertRectToScreen:contentRect];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Point2i offset;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									offset.x = (nsrect.origin.x - windowRect.origin.x);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									offset.y = (nsrect.origin.y + nsrect.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									offset.y -= (windowRect.origin.y + windowRect.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[wd.window_object setFrameTopLeftPoint:NSMakePoint(position.x - offset.x, position.y - offset.y)];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-10 01:35:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_update_window_style(wd, p_window);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									update_mouse_pos(wd, [wd.window_object mouseLocationOutsideOfEventStream]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_transient(WindowID p_window, WindowID p_parent) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(p_window == p_parent);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd_window = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(wd_window.transient_parent == p_parent);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_MSG(wd_window.on_top, "Windows with the 'on top' can't become transient.");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_parent == INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Remove transient.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_COND(wd_window.transient_parent == INVALID_WINDOW_ID);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_COND(!windows.has(wd_window.transient_parent));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										WindowData &wd_parent = windows[wd_window.transient_parent];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										wd_window.transient_parent = INVALID_WINDOW_ID;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										wd_parent.transient_children.erase(p_window);
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:25:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if ([[wd_parent.window_object childWindows] containsObject:wd_window.window_object]) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											[wd_parent.window_object removeChildWindow:wd_window.window_object];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:25:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd_window.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_COND(!windows.has(p_parent));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_COND_MSG(wd_window.transient_parent != INVALID_WINDOW_ID, "Window already has a transient parent");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										WindowData &wd_parent = windows[p_parent];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										wd_window.transient_parent = p_parent;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										wd_parent.transient_children.insert(p_window);
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:25:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										reparent_check(p_window);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_max_size(const Size2i p_size, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ((p_size != Size2i()) && ((p_size.x < wd.min_size.x) || (p_size.y < wd.min_size.y))) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_PRINT("Maximum window size can't be smaller than minimum window size!");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.max_size = p_size;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ((wd.max_size != Size2i()) && !wd.fullscreen) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2i size = wd.max_size / screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setContentMaxSize:NSMakeSize(size.x, size.y)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setContentMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Size2i DisplayServerMacOS::window_get_max_size(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return wd.max_size;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 09:01:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::update_presentation_mode() {
							 
						 
					
						
							
								
									
										
										
										
											2024-04-01 21:57:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool has_fs_windows = false;
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 09:01:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for (const KeyValue<WindowID, WindowData> &wd : windows) {
							 
						 
					
						
							
								
									
										
										
										
											2024-04-01 21:57:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (wd.value.fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.value.exclusive_fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												has_fs_windows = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 09:01:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2024-04-01 21:57:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (has_fs_windows) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[NSApp setPresentationOptions:NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock | NSApplicationPresentationFullScreen];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[NSApp setPresentationOptions:NSApplicationPresentationDefault];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 09:01:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_min_size(const Size2i p_size, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ((p_size != Size2i()) && (wd.max_size != Size2i()) && ((p_size.x > wd.max_size.x) || (p_size.y > wd.max_size.y))) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_PRINT("Minimum window size can't be larger than maximum window size!");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.min_size = p_size;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ((wd.min_size != Size2i()) && !wd.fullscreen) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Size2i size = wd.min_size / screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setContentMinSize:NSMakeSize(size.x, size.y)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object setContentMinSize:NSMakeSize(0, 0)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Size2i DisplayServerMacOS::window_get_min_size(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return wd.min_size;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_size(const Size2i p_size, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 11:34:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (NSEqualRects([wd.window_object frame], [[wd.window_object screen] visibleFrame])) {
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 10:05:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Size2i size = p_size / screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-14 15:09:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSPoint top_left;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSRect old_frame = [wd.window_object frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									top_left.x = old_frame.origin.x;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									top_left.y = NSMaxY(old_frame);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-21 12:37:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSRect new_frame = NSMakeRect(0, 0, MAX(1, size.x), MAX(1, size.y));
							 
						 
					
						
							
								
									
										
										
										
											2020-07-14 15:09:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									new_frame = [wd.window_object frameRectForContentRect:new_frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									new_frame.origin.x = top_left.x;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									new_frame.origin.y = top_left.y - new_frame.size.height;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-14 15:09:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[wd.window_object setFrame:new_frame display:YES];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-10 01:35:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_update_window_style(wd, p_window);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Size2i DisplayServerMacOS::window_get_size(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return wd.size;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 10:28:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Size2i DisplayServerMacOS::window_get_size_with_decorations(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSRect frame = [wd.window_object frame];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return Size2i(frame.size.width, frame.size.height) * screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_mode(WindowMode p_mode, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowMode old_mode = window_get_mode(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (old_mode == p_mode) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return; // Do nothing.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch (old_mode) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_WINDOWED: {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Do nothing.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_MINIMIZED: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object deminiaturize:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-28 11:19:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_FULLSCREEN: {
							 
						 
					
						
							
								
									
										
										
										
											2023-11-08 21:23:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN || p_mode == WINDOW_MODE_FULLSCREEN) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													const NSUInteger presentationOptions = NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[NSApp setPresentationOptions:presentationOptions];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													wd.exclusive_fullscreen = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													wd.exclusive_fullscreen = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													update_presentation_mode();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:02:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											[(NSWindow *)wd.window_object setLevel:NSNormalWindowLevel];
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.resize_disabled) { // Restore resize disabled.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskResizable];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 17:38:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setEnabled:!wd.no_min_btn];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowZoomButton] setEnabled:!wd.no_max_btn];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setHidden:(wd.no_min_btn && wd.no_max_btn)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowZoomButton] setHidden:(wd.no_min_btn && wd.no_max_btn)];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.min_size != Size2i()) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Size2i size = wd.min_size / screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setContentMinSize:NSMakeSize(size.x, size.y)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.max_size != Size2i()) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												Size2i size = wd.max_size / screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setContentMaxSize:NSMakeSize(size.x, size.y)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object toggleFullScreen:nil];
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 16:23:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (old_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 09:01:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												update_presentation_mode();
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 16:23:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.fullscreen = false;
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 16:23:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											wd.exclusive_fullscreen = false;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_MAXIMIZED: {
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 11:34:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (NSEqualRects([wd.window_object frame], [[wd.window_object screen] visibleFrame])) {
							 
						 
					
						
							
								
									
										
										
										
											2025-05-30 00:13:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if (wd.borderless) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													if (wd.pre_zoom_rect.size.width > 0 && wd.pre_zoom_rect.size.height > 0) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														[wd.window_object setFrame:wd.pre_zoom_rect display:NO animate:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[wd.window_object zoom:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch (p_mode) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_WINDOWED: {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Do nothing.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_MINIMIZED: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object performMiniaturize:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-28 11:19:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_FULLSCREEN: {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.resize_disabled) { // Fullscreen window should be resizable to work.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setStyleMask:[wd.window_object styleMask] | NSWindowStyleMaskResizable];
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setContentMinSize:NSMakeSize(0, 0)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setContentMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object toggleFullScreen:nil];
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 16:23:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.fullscreen = true;
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 16:23:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												const NSUInteger presentationOptions = NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[NSApp setPresentationOptions:presentationOptions];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												wd.exclusive_fullscreen = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												wd.exclusive_fullscreen = false;
							 
						 
					
						
							
								
									
										
										
										
											2023-11-08 21:23:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												update_presentation_mode();
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 16:23:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_MODE_MAXIMIZED: {
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 11:34:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (!NSEqualRects([wd.window_object frame], [[wd.window_object screen] visibleFrame])) {
							 
						 
					
						
							
								
									
										
										
										
											2025-05-30 00:13:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												wd.pre_zoom_rect = [wd.window_object frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (wd.borderless) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[wd.window_object setFrame:[[wd.window_object screen] visibleFrame] display:NO animate:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[wd.window_object zoom:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer::WindowMode DisplayServerMacOS::window_get_mode(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), WINDOW_MODE_WINDOWED);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.fullscreen) { // If fullscreen, it's not in another mode.
							 
						 
					
						
							
								
									
										
										
										
											2022-11-04 16:23:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (wd.exclusive_fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return WINDOW_MODE_EXCLUSIVE_FULLSCREEN;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return WINDOW_MODE_FULLSCREEN;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-11-30 11:34:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (NSEqualRects([wd.window_object frame], [[wd.window_object screen] visibleFrame])) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return WINDOW_MODE_MAXIMIZED;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ([wd.window_object respondsToSelector:@selector(isMiniaturized)]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if ([wd.window_object isMiniaturized]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return WINDOW_MODE_MINIMIZED;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// All other discarded, return windowed.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return WINDOW_MODE_WINDOWED;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::window_is_maximize_allowed(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 17:38:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), false);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return [wd.window_object standardWindowButton:NSWindowZoomButton].enabled;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::window_maximize_on_title_dbl_click() const {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSString *value = [NSUserDefaults.standardUserDefaults stringForKey:@"AppleActionOnDoubleClick"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return [value isEqualToString:@"Maximize"];
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::window_minimize_on_title_dbl_click() const {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSString *value = [NSUserDefaults.standardUserDefaults stringForKey:@"AppleActionOnDoubleClick"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return [value isEqualToString:@"Minimize"];
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-24 19:27:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_start_drag(WindowID p_window) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSEvent *event = [NSEvent mouseEventWithType:NSEventTypeLeftMouseDown location:((NSWindow *)wd.window_object).mouseLocationOutsideOfEventStream modifierFlags:0 timestamp:[[NSProcessInfo processInfo] systemUptime] windowNumber:((NSWindow *)wd.window_object).windowNumber context:nil eventNumber:0 clickCount:1 pressure:1.0f];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[wd.window_object performWindowDragWithEvent:event];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-17 20:01:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_start_resize(WindowResizeEdge p_edge, WindowID p_window) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX(int(p_edge), WINDOW_EDGE_MAX);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.edge = p_edge;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 11:12:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_window_buttons_offset(const Vector2i &p_offset, WindowID p_window) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 10:32:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									float scale = screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.wb_offset = p_offset / scale;
							 
						 
					
						
							
								
									
										
										
										
											2024-03-03 14:37:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									wd.wb_offset = wd.wb_offset.maxi(12);
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 10:32:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.window_button_view) {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_button_view setOffset:NSMakePoint(wd.wb_offset.x, wd.wb_offset.y)];
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 10:32:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 11:12:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 10:32:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector3i DisplayServerMacOS::window_get_safe_title_margins(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 10:32:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), Vector3i());
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:06:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (!wd.window_button_view) {
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 10:32:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return Vector3i();
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 10:32:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									float scale = screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									float max_x = [wd.window_button_view getOffset].x + [wd.window_button_view frame].size.width;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									float max_y = [wd.window_button_view getOffset].y + [wd.window_button_view frame].size.height;
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:06:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if ([wd.window_object windowTitlebarLayoutDirection] == NSUserInterfaceLayoutDirectionRightToLeft) {
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 10:32:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return Vector3i(0, max_x * scale, max_y * scale);
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:06:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 10:32:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										return Vector3i(max_x * scale, 0, max_y * scale);
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:06:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 11:15:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_custom_window_buttons(WindowData &p_wd, bool p_enabled) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_wd.window_button_view) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[p_wd.window_button_view removeFromSuperview];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										p_wd.window_button_view = nil;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_enabled) {
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:06:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										float cb_frame = NSMinX([[p_wd.window_object standardWindowButton:NSWindowCloseButton] frame]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										float mb_frame = NSMinX([[p_wd.window_object standardWindowButton:NSWindowMiniaturizeButton] frame]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										bool is_rtl = ([p_wd.window_object windowTitlebarLayoutDirection] == NSUserInterfaceLayoutDirectionRightToLeft);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										float window_buttons_spacing = (is_rtl) ? (cb_frame - mb_frame) : (mb_frame - cb_frame);
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 11:15:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-23 08:13:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[p_wd.window_object setTitlebarAppearsTransparent:YES];
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 11:15:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[p_wd.window_object setTitleVisibility:NSWindowTitleHidden];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[[p_wd.window_object standardWindowButton:NSWindowZoomButton] setHidden:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[[p_wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[[p_wd.window_object standardWindowButton:NSWindowCloseButton] setHidden:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										p_wd.window_button_view = [[GodotButtonView alloc] initWithFrame:NSZeroRect];
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:06:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[p_wd.window_button_view initButtons:window_buttons_spacing offset:NSMakePoint(p_wd.wb_offset.x, p_wd.wb_offset.y) rtl:is_rtl];
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 11:15:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[p_wd.window_view addSubview:p_wd.window_button_view];
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 17:38:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[[p_wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setHidden:(p_wd.no_min_btn && p_wd.no_max_btn)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[[p_wd.window_object standardWindowButton:NSWindowZoomButton] setHidden:(p_wd.no_min_btn && p_wd.no_max_btn)];
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 11:15:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[p_wd.window_object setTitleVisibility:NSWindowTitleVisible];
							 
						 
					
						
							
								
									
										
										
										
											2025-04-23 08:13:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[p_wd.window_object setTitlebarAppearsTransparent:NO];
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 17:38:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[[p_wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setHidden:(p_wd.no_min_btn && p_wd.no_max_btn)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[[p_wd.window_object standardWindowButton:NSWindowZoomButton] setHidden:(p_wd.no_min_btn && p_wd.no_max_btn)];
							 
						 
					
						
							
								
									
										
										
										
											2025-04-23 08:13:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[[p_wd.window_object standardWindowButton:NSWindowCloseButton] setHidden:NO];
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 11:15:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch (p_flag) {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 17:38:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_MINIMIZE_DISABLED: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.no_min_btn = p_enabled;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setEnabled:!p_enabled];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setHidden:(wd.no_min_btn && wd.no_max_btn)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowZoomButton] setHidden:(wd.no_min_btn && wd.no_max_btn)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_MAXIMIZE_DISABLED: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.no_max_btn = p_enabled;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowZoomButton] setEnabled:!p_enabled];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setHidden:(wd.no_min_btn && wd.no_max_btn)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowZoomButton] setHidden:(wd.no_min_btn && wd.no_max_btn)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_RESIZE_DISABLED: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.resize_disabled = p_enabled;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.fullscreen) { // Fullscreen window should be resizable, style will be applied on exiting fullscreen.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return;
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (p_enabled) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskResizable];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setStyleMask:[wd.window_object styleMask] | NSWindowStyleMaskResizable];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 17:38:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setEnabled:!wd.no_min_btn];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowZoomButton] setEnabled:!wd.no_max_btn];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setHidden:(wd.no_min_btn && wd.no_max_btn)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[wd.window_object standardWindowButton:NSWindowZoomButton] setHidden:(wd.no_min_btn && wd.no_max_btn)];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_EXTEND_TO_TITLE: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSRect rect = [wd.window_object frame];
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											wd.extend_to_title = p_enabled;
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (p_enabled) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setStyleMask:[wd.window_object styleMask] | NSWindowStyleMaskFullSizeContentView];
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 11:12:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 11:15:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if (!wd.fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													window_set_custom_window_buttons(wd, true);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskFullSizeContentView];
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 11:12:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 11:15:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if (!wd.fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													window_set_custom_window_buttons(wd, false);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setFrame:rect display:YES];
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:06:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_TITLEBAR_CHANGE);
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_BORDERLESS: {
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// OrderOut prevents a lose focus bug with the window.
							 
						 
					
						
							
								
									
										
										
										
											2023-09-26 11:55:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											bool was_visible = false;
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 15:46:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if ([wd.window_object isVisible]) {
							 
						 
					
						
							
								
									
										
										
										
											2023-09-26 11:55:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												was_visible = true;
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 15:46:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object orderOut:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.borderless = p_enabled;
							 
						 
					
						
							
								
									
										
										
										
											2025-05-30 00:13:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											bool was_maximized = (NSEqualRects([wd.window_object frame], [[wd.window_object screen] visibleFrame]));
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (p_enabled) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setStyleMask:NSWindowStyleMaskBorderless];
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 16:28:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setHasShadow:NO];
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if (wd.layered_window) {
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 16:28:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													[wd.window_object setBackgroundColor:[NSColor clearColor]];
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 16:28:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (wd.extend_to_title ? NSWindowStyleMaskFullSizeContentView : 0) | (wd.resize_disabled ? 0 : NSWindowStyleMaskResizable)];
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 17:38:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[[wd.window_object standardWindowButton:NSWindowMiniaturizeButton] setEnabled:!wd.no_min_btn];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[wd.window_object standardWindowButton:NSWindowZoomButton] setEnabled:!wd.no_max_btn];
							 
						 
					
						
							
								
									
										
										
										
											2025-03-08 16:28:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setHasShadow:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (wd.layered_window) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													// Note: transparent and not borderless - set alpha to non-zero value to ensure window shadow is rendered correctly.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[wd.window_object setBackgroundColor:[NSColor colorWithCalibratedRed:0 green:0 blue:0 alpha:0.004f]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												// Force update of the window styles.
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												NSRect frameRect = [wd.window_object frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setFrame:frameRect display:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2024-12-10 01:35:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											_update_window_style(wd, p_window);
							 
						 
					
						
							
								
									
										
										
										
											2023-09-26 11:55:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (was_visible || [wd.window_object isVisible]) {
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 10:05:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if ([wd.window_object isMiniaturized]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													return;
							 
						 
					
						
							
								
									
										
										
										
											2023-06-09 08:03:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												} else if (wd.no_focus) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 15:46:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
													[wd.window_object orderFront:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[wd.window_object makeKeyAndOrderFront:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2025-05-30 00:13:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (was_maximized) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setFrame:[[wd.window_object screen] visibleFrame] display:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_ALWAYS_ON_TOP: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.on_top = p_enabled;
							 
						 
					
						
							
								
									
										
										
										
											2021-05-24 10:53:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (p_enabled) {
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:02:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[(NSWindow *)wd.window_object setLevel:NSFloatingWindowLevel];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
									
										
										
										
											2022-05-10 21:02:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[(NSWindow *)wd.window_object setLevel:NSNormalWindowLevel];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_TRANSPARENT: {
							 
						 
					
						
							
								
									
										
										
										
											2023-11-09 23:25:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.fullscreen) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.layered_window = p_enabled;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											set_window_per_pixel_transparency_enabled(p_enabled, p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Force update of the window styles.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSRect frameRect = [wd.window_object frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[wd.window_object setFrame:frameRect display:NO];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_NO_FOCUS: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.no_focus = p_enabled;
							 
						 
					
						
							
								
									
										
										
										
											2023-10-15 20:52:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSWindow *w = wd.window_object;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											w.excludedFromWindowsMenu = wd.is_popup || wd.no_focus;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_EXCLUDE_FROM_CAPTURE: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (p_enabled) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setSharingType:NSWindowSharingNone];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setSharingType:NSWindowSharingReadWrite];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.hide_from_capture = p_enabled;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2023-01-15 12:05:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_MOUSE_PASSTHROUGH: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											wd.mpass = p_enabled;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_POPUP: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											ERR_FAIL_COND_MSG(p_window == MAIN_WINDOW_ID, "Main window can't be popup.");
							 
						 
					
						
							
								
									
										
										
										
											2022-03-08 11:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ERR_FAIL_COND_MSG([wd.window_object isVisible] && (wd.is_popup != p_enabled), "Popup flag can't changed while window is opened.");
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											wd.is_popup = p_enabled;
							 
						 
					
						
							
								
									
										
										
										
											2023-10-15 20:52:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSWindow *w = wd.window_object;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											w.excludedFromWindowsMenu = wd.is_popup || wd.no_focus;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										default: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::window_get_flag(WindowFlags p_flag, WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), false);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch (p_flag) {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 17:38:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_MAXIMIZE_DISABLED: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return wd.no_max_btn;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_MINIMIZE_DISABLED: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return wd.no_min_btn;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_RESIZE_DISABLED: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return wd.resize_disabled;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 13:40:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_EXTEND_TO_TITLE: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return [wd.window_object styleMask] & NSWindowStyleMaskFullSizeContentView;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_BORDERLESS: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return [wd.window_object styleMask] == NSWindowStyleMaskBorderless;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_ALWAYS_ON_TOP: {
							 
						 
					
						
							
								
									
										
										
										
											2024-12-10 01:35:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return wd.on_top;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_TRANSPARENT: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return wd.layered_window;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_NO_FOCUS: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return wd.no_focus;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_EXCLUDE_FROM_CAPTURE: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return wd.hide_from_capture;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2023-01-15 12:05:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_MOUSE_PASSTHROUGH: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return wd.mpass;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_FLAG_POPUP: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return wd.is_popup;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} break;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										default: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_request_attention(WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// It's app global, ignore window id.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[NSApp requestUserAttention:NSCriticalRequest];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_move_to_foreground(WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.no_focus || wd.is_popup) {
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 15:46:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object orderFront:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_object makeKeyAndOrderFront:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-15 10:53:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::window_is_focused(WindowID p_window) const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), false);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return wd.focused;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-22 17:50:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServerMacOS::WindowID DisplayServerMacOS::get_focused_window() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return last_focused_window;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::window_can_draw(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-10 12:06:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return windows[p_window].is_visible;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::can_any_window_draw() const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for (const KeyValue<WindowID, WindowData> &E : windows) {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-10 12:06:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (E.value.is_visible) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_ime_active(const bool p_active, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.im_active = p_active;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (!p_active) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd.window_view cancelComposition];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_ime_position(const Point2i &p_pos, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.im_position = p_pos;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer::WindowID DisplayServerMacOS::get_window_at_screen_position(const Point2i &p_position) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Point2i position = p_position;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position.y *= -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position += _get_screens_origin();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									position /= screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSInteger wnum = [NSWindow windowNumberAtPoint:NSMakePoint(position.x, position.y) belowWindowWithWindowNumber:0 /*topmost*/];
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for (const KeyValue<WindowID, WindowData> &E : windows) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if ([E.value.window_object windowNumber] == wnum) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return E.key;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return INVALID_WINDOW_ID;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								int64_t DisplayServerMacOS::window_get_native_handle(HandleType p_handle_type, WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), 0);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									switch (p_handle_type) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case DISPLAY_HANDLE: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return 0; // Not supported.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_HANDLE: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return (int64_t)windows[p_window].window_object;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case WINDOW_VIEW: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return (int64_t)windows[p_window].window_view;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-10-22 20:29:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef GLES3_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case OPENGL_CONTEXT: {
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return (int64_t)gl_manager_legacy->get_context(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return (int64_t)gl_manager_angle->get_context(p_window);
							 
						 
					
						
							
								
									
										
										
										
											2022-11-13 07:06:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return 0;
							 
						 
					
						
							
								
									
										
										
										
											2022-10-22 20:29:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2024-10-03 10:24:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										case EGL_DISPLAY: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return (int64_t)gl_manager_angle->get_display(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return 0;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										case EGL_CONFIG: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return (int64_t)gl_manager_angle->get_config(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return 0;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-10-22 20:29:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										default: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											return 0;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_attach_instance_id(ObjectID p_instance, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									windows[p_window].instance_id = p_instance;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								ObjectID DisplayServerMacOS::window_get_attached_instance_id(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), ObjectID());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return windows[p_window].instance_id;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::gl_window_make_current(DisplayServer::WindowID p_window_id) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_legacy->window_make_current(p_window_id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_angle->window_make_current(p_window_id);
							 
						 
					
						
							
								
									
										
										
										
											2023-01-21 00:20:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_angle->set_use_vsync(p_vsync_mode != DisplayServer::VSYNC_DISABLED);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_legacy->set_use_vsync(p_vsync_mode != DisplayServer::VSYNC_DISABLED);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 05:52:00 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(RD_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_context) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_context->window_set_vsync_mode(p_window, p_vsync_mode);
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer::VSyncMode DisplayServerMacOS::window_get_vsync_mode(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return (gl_manager_angle->is_using_vsync() ? DisplayServer::VSyncMode::VSYNC_ENABLED : DisplayServer::VSyncMode::VSYNC_DISABLED);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return (gl_manager_legacy->is_using_vsync() ? DisplayServer::VSyncMode::VSYNC_ENABLED : DisplayServer::VSyncMode::VSYNC_DISABLED);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 05:52:00 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(RD_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_context) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return rendering_context->window_get_vsync_mode(p_window);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return DisplayServer::VSYNC_ENABLED;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								int DisplayServerMacOS::accessibility_should_increase_contrast() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return [(GodotApplicationDelegate *)[[NSApplication sharedApplication] delegate] getHighContrast];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								int DisplayServerMacOS::accessibility_should_reduce_animation() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return [(GodotApplicationDelegate *)[[NSApplication sharedApplication] delegate] getReduceMotion];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								int DisplayServerMacOS::accessibility_should_reduce_transparency() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return [(GodotApplicationDelegate *)[[NSApplication sharedApplication] delegate] getReduceTransparency];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								int DisplayServerMacOS::accessibility_screen_reader_active() const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return [(GodotApplicationDelegate *)[[NSApplication sharedApplication] delegate] getVoiceOver];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Point2i DisplayServerMacOS::ime_get_selection() const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return im_selection;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								String DisplayServerMacOS::ime_get_text() const {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return im_text;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::cursor_update_shape() {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (cursors[cursor_shape] != nullptr) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[cursors[cursor_shape] set];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										switch (cursor_shape) {
							 
						 
					
						
							
								
									
										
										
										
											2020-05-10 13:00:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_ARROW:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor arrowCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_IBEAM:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor IBeamCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_POINTING_HAND:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor pointingHandCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_CROSS:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor crosshairCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_WAIT:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor arrowCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_BUSY:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor arrowCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_DRAG:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor closedHandCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_CAN_DROP:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor openHandCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_FORBIDDEN:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor operationNotAllowedCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_VSIZE:
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[_cursor_from_selector(@selector(_windowResizeNorthSouthCursor), @selector(resizeUpDownCursor)) set];
							 
						 
					
						
							
								
									
										
										
										
											2020-05-10 13:00:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_HSIZE:
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[_cursor_from_selector(@selector(_windowResizeEastWestCursor), @selector(resizeLeftRightCursor)) set];
							 
						 
					
						
							
								
									
										
										
										
											2020-05-10 13:00:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_BDIAGSIZE:
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[_cursor_from_selector(@selector(_windowResizeNorthEastSouthWestCursor)) set];
							 
						 
					
						
							
								
									
										
										
										
											2020-05-10 13:00:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_FDIAGSIZE:
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[_cursor_from_selector(@selector(_windowResizeNorthWestSouthEastCursor)) set];
							 
						 
					
						
							
								
									
										
										
										
											2020-05-10 13:00:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_MOVE:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor arrowCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_VSPLIT:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor resizeUpDownCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_HSPLIT:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[[NSCursor resizeLeftRightCursor] set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											case CURSOR_HELP:
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												[_cursor_from_selector(@selector(_helpCursor)) set];
							 
						 
					
						
							
								
									
										
										
										
											2020-05-10 13:00:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											default: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::cursor_set_shape(CursorShape p_shape) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (cursor_shape == p_shape) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									cursor_shape = p_shape;
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (mouse_mode != MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									cursor_update_shape();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServerMacOS::CursorShape DisplayServerMacOS::cursor_get_shape() const {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return cursor_shape;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 14:17:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_INDEX(p_shape, CURSOR_MAX);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_cursor.is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										HashMap<CursorShape, Vector<Variant>>::Iterator cursor_c = cursors_cache.find(p_shape);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (cursor_c) {
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (cursor_c->value[0] == p_cursor && cursor_c->value[1] == p_hotspot) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												cursor_set_shape(p_shape);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											cursors_cache.erase(p_shape);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-02 22:05:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref<Image> image = _get_cursor_image_from_resource(p_cursor, p_hotspot);
							 
						 
					
						
							
								
									
										
										
										
											2024-02-28 18:38:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_COND(image.is_null());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector2i texture_size = image->get_size();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc]
							 
						 
					
						
							
								
									
										
										
										
											2021-10-12 14:30:55 +07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												initWithBitmapDataPlanes:nullptr
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															  pixelsWide:int(texture_size.width)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															  pixelsHigh:int(texture_size.height)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														   bitsPerSample:8
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														 samplesPerPixel:4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																hasAlpha:YES
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																isPlanar:NO
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														  colorSpaceName:NSDeviceRGBColorSpace
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															 bytesPerRow:int(texture_size.width) * 4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															bitsPerPixel:32];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 11:40:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_NULL(imgrep);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										uint8_t *pixels = [imgrep bitmapData];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										int len = int(texture_size.width * texture_size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for (int i = 0; i < len; i++) {
							 
						 
					
						
							
								
									
										
										
										
											2025-03-19 14:18:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											int row_index = std::floor(i / texture_size.width);
							 
						 
					
						
							
								
									
										
										
										
											2024-06-02 22:05:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											int column_index = i % int(texture_size.width);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											uint32_t color = image->get_pixel(column_index, row_index).to_argb32();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											uint8_t alpha = (color >> 24) & 0xFF;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pixels[i * 4 + 0] = ((color >> 16) & 0xFF) * alpha / 255;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pixels[i * 4 + 1] = ((color >> 8) & 0xFF) * alpha / 255;
							 
						 
					
						
							
								
									
										
										
										
											2024-02-28 14:25:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											pixels[i * 4 + 2] = ((color) & 0xFF) * alpha / 255;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pixels[i * 4 + 3] = alpha;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSImage *nsimage = [[NSImage alloc] initWithSize:NSMakeSize(texture_size.width, texture_size.height)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[nsimage addRepresentation:imgrep];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSCursor *cursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSMakePoint(p_hotspot.x, p_hotspot.y)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										cursors[p_shape] = cursor;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Vector<Variant> params;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										params.push_back(p_cursor);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										params.push_back(p_hotspot);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										cursors_cache.insert(p_shape, params);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (p_shape == cursor_shape) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[cursor set];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Reset to default system cursor.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 11:47:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (cursors[p_shape] != nullptr) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											cursors[p_shape] = nullptr;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										cursors_cache.erase(p_shape);
							 
						 
					
						
							
								
									
										
										
										
											2023-03-06 22:00:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										cursor_update_shape();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::get_swap_cancel_ok() {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return false;
							 
						 
					
						
							
								
									
										
										
										
											2020-06-11 12:27:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::enable_for_stealing_focus(OS::ProcessID pid) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#define GET_OR_FAIL_V(m_val, m_map, m_key, m_retval) \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									m_val = m_map.getptr(m_key);                     \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (m_val == nullptr) {                          \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_V(m_retval);                        \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-20 09:37:35 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								uint32_t DisplayServerMacOS::window_get_display_id(WindowID p_window) const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData *wd;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									GET_OR_FAIL_V(wd, windows, p_window, -1);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return wd->display_id;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_window_update_display_id(WindowData *p_wd) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSScreen *screen = [p_wd->window_object screen];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CGDirectDisplayID display_id = [[screen deviceDescription][@"NSScreenNumber"] unsignedIntValue];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_wd->display_id == display_id) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									p_wd->display_id = display_id;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef TOOLS_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Notify any embedded processes of the new display ID, so that they can potentially update their vsync.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (KeyValue<OS::ProcessID, EmbeddedProcessData> &E : embedded_processes) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (E.value.wd == p_wd) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											E.value.process->display_state_changed();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-13 12:42:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef TOOLS_ENABLED
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-20 09:37:35 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Error DisplayServerMacOS::embed_process_update(WindowID p_window, EmbeddedProcessMacOS *p_process) {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData *wd;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									GET_OR_FAIL_V(wd, windows, p_window, FAILED);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									OS::ProcessID p_pid = p_process->get_embedded_pid();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[CATransaction begin];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[CATransaction setDisableActions:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EmbeddedProcessData *ed = embedded_processes.getptr(p_pid);
							 
						 
					
						
							
								
									
										
										
										
											2025-05-08 18:51:28 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CGFloat scale = screen_get_max_scale();
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (ed == nil) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ed = &embedded_processes.insert(p_pid, EmbeddedProcessData())->value;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ed->process = p_process;
							 
						 
					
						
							
								
									
										
										
										
											2025-05-20 09:37:35 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ed->wd = wd;
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										CALayerHost *host = [CALayerHost new];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										uint32_t p_context_id = p_process->get_context_id();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										host.contextId = static_cast<CAContextID>(p_context_id);
							 
						 
					
						
							
								
									
										
										
										
											2025-05-08 18:51:28 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										host.contentsScale = scale;
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										host.contentsGravity = kCAGravityCenter;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ed->layer_host = host;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[wd->window_view.layer addSublayer:host];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Rect2i p_rect = p_process->get_screen_embedded_window_rect();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CGRect rect = CGRectMake(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y);
							 
						 
					
						
							
								
									
										
										
										
											2025-05-08 18:51:28 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									rect = CGRectApplyAffineTransform(rect, CGAffineTransformInvert(CGAffineTransformMakeScale(scale, scale)));
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 07:01:27 +10:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CGFloat height = wd->window_view.frame.size.height;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CGFloat x = rect.origin.x;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CGFloat y = (height - rect.origin.y);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ed->layer_host.position = CGPointMake(x, y);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ed->layer_host.hidden = !p_process->is_visible_in_tree();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[CATransaction commit];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return OK;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Error DisplayServerMacOS::request_close_embedded_process(OS::ProcessID p_pid) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return OK;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Error DisplayServerMacOS::remove_embedded_process(OS::ProcessID p_pid) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									EmbeddedProcessData *ed;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									GET_OR_FAIL_V(ed, embedded_processes, p_pid, ERR_DOES_NOT_EXIST);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[ed->layer_host removeFromSuperlayer];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									embedded_processes.erase(p_pid);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return OK;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::process_events() {
							 
						 
					
						
							
								
									
										
										
										
											2025-03-20 09:21:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_process_events(true);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::_process_events(bool p_pump) {
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 18:17:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!Thread::is_main_thread());
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-20 09:21:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_pump) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										while (true) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											NSEvent *event = [NSApp
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													nextEventMatchingMask:NSEventMaskAny
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																untilDate:[NSDate distantPast]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																   inMode:NSDefaultRunLoopMode
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																  dequeue:YES];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-20 09:21:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											if (event == nil) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-20 09:21:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											[NSApp sendEvent:event];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 23:57:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Process "menu_callback"s.
							 
						 
					
						
							
								
									
										
										
										
											2023-03-23 13:26:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									while (List<MenuCall>::Element *call_p = deferred_menu_calls.front()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										MenuCall call = call_p->get();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										deferred_menu_calls.pop_front(); // Remove before call to avoid infinite loop in case callback is using `process_events` (e.g. EditorProgress).
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Variant ret;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Callable::CallError ce;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const Variant *args[1] = { &call.tag };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										call.callback.callp(args, 1, ret, ce);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (ce.error != Callable::CallError::CALL_OK) {
							 
						 
					
						
							
								
									
										
										
										
											2023-11-11 22:59:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ERR_PRINT(vformat("Failed to execute menu callback: %s.", Variant::get_callable_error_text(call.callback, args, 1, ce)));
							 
						 
					
						
							
								
									
										
										
										
											2023-10-12 08:27:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 23:57:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (!drop_events) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										_process_key_events();
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 00:38:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Input::get_singleton()->flush_buffered_events();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 18:17:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_LOCK_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for (KeyValue<WindowID, WindowData> &E : windows) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										WindowData &wd = E.value;
							 
						 
					
						
							
								
									
										
										
										
											2023-01-15 12:05:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (wd.mpass) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (![wd.window_object ignoresMouseEvents]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setIgnoresMouseEvents:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else if (wd.mpath.size() > 0) {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											update_mouse_pos(wd, [wd.window_object mouseLocationOutsideOfEventStream]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (Geometry2D::is_point_in_polygon(wd.mouse_pos, wd.mpath)) {
							 
						 
					
						
							
								
									
										
										
										
											2020-06-29 12:31:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												if ([wd.window_object ignoresMouseEvents]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[wd.window_object setIgnoresMouseEvents:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												if (![wd.window_object ignoresMouseEvents]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													[wd.window_object setIgnoresMouseEvents:YES];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if ([wd.window_object ignoresMouseEvents]) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												[wd.window_object setIgnoresMouseEvents:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2024-04-09 11:47:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_UNLOCK_
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::force_process_and_drop_events() {
							 
						 
					
						
							
								
									
										
										
										
											2024-04-15 18:17:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!Thread::is_main_thread());
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									drop_events = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									process_events();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									drop_events = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::release_rendering_thread() {
							 
						 
					
						
							
								
									
										
										
										
											2024-04-09 11:47:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_angle->release_current();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_legacy->release_current();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::swap_buffers() {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_angle->swap_buffers();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_legacy->swap_buffers();
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 09:56:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::set_native_icon(const String &p_filename) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 11:08:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Ref<FileAccess> f = FileAccess::open(p_filename, FileAccess::READ);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(f.is_null());
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Vector<uint8_t> data;
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 07:58:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									uint64_t len = f->get_length();
							 
						 
					
						
							
								
									
										
										
										
											2023-07-04 09:09:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_MSG(len < 8, "Error reading icon data."); // "icns" + 32-bit length
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									data.resize(len);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									f->get_buffer((uint8_t *)&data.write[0], len);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-04 09:09:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									@try {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSData *icon_data = [[NSData alloc] initWithBytes:&data.write[0] length:len];
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 17:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_NULL_MSG(icon_data, "Error reading icon data.");
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-04 09:09:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										NSImage *icon = [[NSImage alloc] initWithData:icon_data];
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 17:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_NULL_MSG(icon, "Error loading icon.");
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-04 09:09:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[NSApp setApplicationIconImage:icon];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} @catch (NSException *exception) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_MSG("NSException: " + String::utf8([exception reason].UTF8String));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::set_icon(const Ref<Image> &p_icon) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-19 16:18:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_icon.is_valid()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_COND(p_icon->get_width() <= 0 || p_icon->get_height() <= 0);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-19 16:18:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref<Image> img = p_icon->duplicate();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										img->convert(Image::FORMAT_RGBA8);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-19 16:18:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												initWithBitmapDataPlanes:nullptr
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															  pixelsWide:img->get_width()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															  pixelsHigh:img->get_height()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														   bitsPerSample:8
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														 samplesPerPixel:4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																hasAlpha:YES
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
																isPlanar:NO
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
														  colorSpaceName:NSDeviceRGBColorSpace
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															 bytesPerRow:img->get_width() * 4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															bitsPerPixel:32];
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 11:40:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_NULL(imgrep);
							 
						 
					
						
							
								
									
										
										
										
											2023-06-19 16:18:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										uint8_t *pixels = [imgrep bitmapData];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-19 16:18:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										int len = img->get_width() * img->get_height();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										const uint8_t *r = img->get_data().ptr();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-19 16:18:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										/* Premultiply the alpha channel */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										for (int i = 0; i < len; i++) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											uint8_t alpha = r[i * 4 + 3];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pixels[i * 4 + 0] = (uint8_t)(((uint16_t)r[i * 4 + 0] * alpha) / 255);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pixels[i * 4 + 1] = (uint8_t)(((uint16_t)r[i * 4 + 1] * alpha) / 255);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pixels[i * 4 + 2] = (uint8_t)(((uint16_t)r[i * 4 + 2] * alpha) / 255);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											pixels[i * 4 + 3] = alpha;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSImage *nsimg = [[NSImage alloc] initWithSize:NSMakeSize(img->get_width(), img->get_height())];
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 11:40:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										ERR_FAIL_NULL(nsimg);
							 
						 
					
						
							
								
									
										
										
										
											2023-06-19 16:18:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[nsimg addRepresentation:imgrep];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[NSApp setApplicationIconImage:nsimg];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[NSApp setApplicationIconImage:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 23:14:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer::IndicatorID DisplayServerMacOS::create_status_indicator(const Ref<Texture2D> &p_icon, const String &p_tooltip, const Callable &p_callback) {
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSImage *nsimg = nullptr;
							 
						 
					
						
							
								
									
										
										
										
											2024-06-05 20:19:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_icon.is_valid() && p_icon->get_width() > 0 && p_icon->get_height() > 0 && p_icon->get_image().is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 23:14:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref<Image> img = p_icon->get_image();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										img = img->duplicate();
							 
						 
					
						
							
								
									
										
										
										
											2024-06-05 20:19:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (img->is_compressed()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											img->decompress();
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2024-06-05 20:19:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										nsimg = _convert_to_nsimg(img);
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									IndicatorData idat;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 23:14:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSStatusItem *item = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									idat.item = item;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									idat.delegate = [[GodotStatusItemDelegate alloc] init];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[idat.delegate setCallback:p_callback];
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 23:14:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									item.button.image = nsimg;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									item.button.imagePosition = NSImageOnly;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									item.button.imageScaling = NSImageScaleProportionallyUpOrDown;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									item.button.target = idat.delegate;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									item.button.action = @selector(click:);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[item.button sendActionOn:(NSEventMaskLeftMouseDown | NSEventMaskRightMouseDown | NSEventMaskOtherMouseDown)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									item.button.toolTip = [NSString stringWithUTF8String:p_tooltip.utf8().get_data()];
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									IndicatorID iid = indicator_id_counter++;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									indicators[iid] = idat;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return iid;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 23:14:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::status_indicator_set_icon(IndicatorID p_id, const Ref<Texture2D> &p_icon) {
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!indicators.has(p_id));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSImage *nsimg = nullptr;
							 
						 
					
						
							
								
									
										
										
										
											2024-06-05 20:19:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_icon.is_valid() && p_icon->get_width() > 0 && p_icon->get_height() > 0 && p_icon->get_image().is_valid()) {
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 23:14:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Ref<Image> img = p_icon->get_image();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										img = img->duplicate();
							 
						 
					
						
							
								
									
										
										
										
											2024-06-05 20:19:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (img->is_compressed()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											img->decompress();
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2024-06-05 20:19:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										nsimg = _convert_to_nsimg(img);
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 23:14:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSStatusItem *item = indicators[p_id].item;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									item.button.image = nsimg;
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::status_indicator_set_tooltip(IndicatorID p_id, const String &p_tooltip) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!indicators.has(p_id));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 23:14:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSStatusItem *item = indicators[p_id].item;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									item.button.toolTip = [NSString stringWithUTF8String:p_tooltip.utf8().get_data()];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::status_indicator_set_menu(IndicatorID p_id, const RID &p_menu_rid) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!indicators.has(p_id));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSStatusItem *item = indicators[p_id].item;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (p_menu_rid.is_valid() && native_menu->has_menu(p_menu_rid)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										NSMenu *menu = native_menu->get_native_menu_handle(p_menu_rid);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										item.menu = menu;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										item.menu = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::status_indicator_set_callback(IndicatorID p_id, const Callable &p_callback) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!indicators.has(p_id));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-16 23:14:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[indicators[p_id].delegate setCallback:p_callback];
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-08 09:24:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Rect2 DisplayServerMacOS::status_indicator_get_rect(IndicatorID p_id) const {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!indicators.has(p_id), Rect2());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSStatusItem *item = indicators[p_id].item;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSView *v = item.button;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect contentRect = [v frame];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const NSRect nsrect = [v.window convertRectToScreen:contentRect];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									Rect2 rect;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Return the position of the top-left corner, for macOS the y starts at the bottom.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const float scale = screen_get_max_scale();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rect.size.x = nsrect.size.width;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rect.size.y = nsrect.size.height;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rect.size *= scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rect.position.x = nsrect.origin.x;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rect.position.y = (nsrect.origin.y + nsrect.size.height);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rect.position *= scale;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rect.position -= _get_screens_origin();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// macOS native y-coordinate relative to _get_screens_origin() is negative,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									// Godot expects a positive value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rect.position.y *= -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return rect;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::delete_status_indicator(IndicatorID p_id) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!indicators.has(p_id));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[[NSStatusBar systemStatusBar] removeStatusItem:indicators[p_id].item];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									indicators.erase(p_id);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-03 11:48:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::is_window_transparency_available() const {
							 
						 
					
						
							
								
									
										
										
										
											2024-05-25 21:08:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(RD_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2024-05-03 11:48:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_device && !rendering_device->is_composite_alpha_supported()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2024-05-25 21:08:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2024-05-03 11:48:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return OS::get_singleton()->is_layered_allowed();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-25 16:57:23 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer *DisplayServerMacOS::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, Context p_context, int64_t p_parent_window, Error &r_error) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									DisplayServer *ds = memnew(DisplayServerMacOS(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_position, p_resolution, p_screen, p_context, p_parent_window, r_error));
							 
						 
					
						
							
								
									
										
										
										
											2020-07-13 19:24:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (r_error != OK) {
							 
						 
					
						
							
								
									
										
										
										
											2022-10-17 10:47:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (p_rendering_driver == "vulkan") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											String executable_command;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (OS::get_singleton()->get_bundle_resource_dir() == OS::get_singleton()->get_executable_path().get_base_dir()) {
							 
						 
					
						
							
								
									
										
										
										
											2023-03-08 22:27:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												executable_command = vformat("\"%s\" --rendering-driver opengl3", OS::get_singleton()->get_executable_path());
							 
						 
					
						
							
								
									
										
										
										
											2022-10-17 10:47:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
									
										
										
										
											2023-03-08 22:27:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												executable_command = vformat("open \"%s\" --args --rendering-driver opengl3", OS::get_singleton()->get_bundle_resource_dir().path_join("../..").simplify_path());
							 
						 
					
						
							
								
									
										
										
										
											2022-10-17 10:47:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2023-01-17 15:26:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											OS::get_singleton()->alert(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													vformat("Your video card drivers seem not to support the required Vulkan version.\n\n"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															"If possible, consider updating your macOS version or using the OpenGL 3 driver.\n\n"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
															"You can enable the OpenGL 3 driver by starting the engine from the\n"
							 
						 
					
						
							
								
									
										
										
										
											2023-03-08 22:27:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															"command line with the command:\n\n    %s",
							 
						 
					
						
							
								
									
										
										
										
											2023-01-17 15:26:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
															executable_command),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													"Unable to initialize Vulkan video driver");
							 
						 
					
						
							
								
									
										
										
										
											2022-10-17 10:47:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
									
										
										
										
											2023-01-17 15:26:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											OS::get_singleton()->alert(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													"Your video card drivers seem not to support the required OpenGL 3.3 version.\n\n"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													"If possible, consider updating your macOS version.",
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
													"Unable to initialize OpenGL video driver");
							 
						 
					
						
							
								
									
										
										
										
											2022-10-17 10:47:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2020-07-13 19:24:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return ds;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector<String> DisplayServerMacOS::get_rendering_drivers_func() {
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Vector<String> drivers;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(VULKAN_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									drivers.push_back("vulkan");
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 05:52:00 +11:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(METAL_ENABLED)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									drivers.push_back("metal");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2021-10-26 08:18:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									drivers.push_back("opengl3");
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									drivers.push_back("opengl3_angle");
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									drivers.push_back("dummy");
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return drivers;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::register_macos_driver() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									register_create_function("macos", create_func, get_rendering_drivers_func);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServer::WindowID DisplayServerMacOS::window_get_active_popup() const {
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									const List<WindowID>::Element *E = popup_list.back();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (E) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return E->get();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										return INVALID_WINDOW_ID;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::window_set_popup_safe_rect(WindowID p_window, const Rect2i &p_rect) {
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!windows.has(p_window));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									wd.parent_safe_rect = p_rect;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Rect2i DisplayServerMacOS::window_get_popup_safe_rect(WindowID p_window) const {
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND_V(!windows.has(p_window), Rect2i());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									const WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									return wd.parent_safe_rect;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::popup_open(WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-15 14:22:58 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool has_popup_ancestor = false;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									WindowID transient_root = p_window;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									while (true) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										WindowID parent = windows[transient_root].transient_parent;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (parent == INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											transient_root = parent;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (windows[parent].is_popup) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												has_popup_ancestor = true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 20:00:05 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Detect tooltips and other similar popups that shouldn't block input to their parent.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool ignores_input = window_get_flag(WINDOW_FLAG_NO_FOCUS, p_window) && window_get_flag(WINDOW_FLAG_MOUSE_PASSTHROUGH, p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									WindowData &wd = windows[p_window];
							 
						 
					
						
							
								
									
										
										
										
											2024-06-06 20:00:05 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (wd.is_popup || (has_popup_ancestor && !ignores_input)) {
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										bool was_empty = popup_list.is_empty();
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Find current popup parent, or root popup if new window is not transient.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										List<WindowID>::Element *C = nullptr;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										List<WindowID>::Element *E = popup_list.back();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										while (E) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (wd.transient_parent != E->get() || wd.transient_parent == INVALID_WINDOW_ID) {
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												C = E;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												E = E->prev();
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (C) {
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											send_window_event(windows[C->get()], DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST);
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (was_empty && popup_list.is_empty()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Inform OS that popup was opened, to close other native popups.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.HIToolbox.beginMenuTrackingNotification" object:@"org.godotengine.godot.popup_window"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										time_since_popup = OS::get_singleton()->get_ticks_msec();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										popup_list.push_back(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								void DisplayServerMacOS::popup_close(WindowID p_window) {
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool was_empty = popup_list.is_empty();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									List<WindowID>::Element *E = popup_list.find(p_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									while (E) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										List<WindowID>::Element *F = E->next();
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										WindowID win_id = E->get();
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										popup_list.erase(E);
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-28 09:41:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (win_id != p_window) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Only request close on related windows, not this window.  We are already processing it.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											send_window_event(windows[win_id], DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										E = F;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (!was_empty && popup_list.is_empty()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Inform OS that all popups are closed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.HIToolbox.endMenuTrackingNotification" object:@"org.godotengine.godot.popup_window"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool DisplayServerMacOS::mouse_process_popups(bool p_close) {
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									_THREAD_SAFE_METHOD_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool was_empty = popup_list.is_empty();
							 
						 
					
						
							
								
									
										
										
										
											2022-05-30 11:06:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									bool closed = false;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_close) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										// Close all popups.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										List<WindowID>::Element *E = popup_list.front();
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (E) {
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											send_window_event(windows[E->get()], DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST);
							 
						 
					
						
							
								
									
										
										
										
											2022-05-30 11:06:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											closed = true;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (!was_empty) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Inform OS that all popups are closed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.HIToolbox.endMenuTrackingNotification" object:@"org.godotengine.godot.popup_window"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										uint64_t delta = OS::get_singleton()->get_ticks_msec() - time_since_popup;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (delta < 250) {
							 
						 
					
						
							
								
									
										
										
										
											2022-05-30 11:06:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											return false;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										Point2i pos = mouse_get_position();
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										List<WindowID>::Element *C = nullptr;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										List<WindowID>::Element *E = popup_list.back();
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										// Find top popup to close.
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										while (E) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Popup window area.
							 
						 
					
						
							
								
									
										
										
										
											2023-07-14 09:16:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											Rect2i win_rect = Rect2i(window_get_position_with_decorations(E->get()), window_get_size_with_decorations(E->get()));
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											// Area of the parent window, which responsible for opening sub-menu.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											Rect2i safe_rect = window_get_popup_safe_rect(E->get());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (win_rect.has_point(pos)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else if (safe_rect != Rect2i() && safe_rect.has_point(pos)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												break;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												C = E;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												E = E->prev();
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (C) {
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											send_window_event(windows[C->get()], DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST);
							 
						 
					
						
							
								
									
										
										
										
											2022-05-30 11:06:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											closed = true;
							 
						 
					
						
							
								
									
										
										
										
											2022-04-05 12:34:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (!was_empty && popup_list.is_empty()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											// Inform OS that all popups are closed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.HIToolbox.endMenuTrackingNotification" object:@"org.godotengine.godot.popup_window"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2022-05-30 11:06:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									return closed;
							 
						 
					
						
							
								
									
										
										
										
											2022-02-24 11:21:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-25 16:57:23 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServerMacOS::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, Context p_context, int64_t p_parent_window, Error &r_error) {
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 01:21:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									KeyMappingMacOS::initialize();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 15:19:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									r_error = OK;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									memset(cursors, 0, sizeof(cursors));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									event_source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(!event_source);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CGEventSourceSetLocalEventsSuppressionInterval(event_source, 0.0);
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									int screen_count = get_screen_count();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (int i = 0; i < screen_count; i++) {
							 
						 
					
						
							
								
									
										
										
										
											2025-03-19 14:18:09 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										display_max_scale = std::fmax(display_max_scale, screen_get_scale(i));
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 20:47:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Register to be notified on displays arrangement changes.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									CGDisplayRegisterReconfigurationCallback(_displays_arrangement_changed, nullptr);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									native_menu = memnew(NativeMenuMacOS);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef ACCESSKIT_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (accessibility_get_mode() != DisplayServer::AccessibilityMode::ACCESSIBILITY_DISABLED) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										accessibility_driver = memnew(AccessibilityDriverAccessKit);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (accessibility_driver->init() != OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											memdelete(accessibility_driver);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											accessibility_driver = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSMenuItem *menu_item;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSString *title;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (nsappname == nil) {
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										nsappname = [[NSProcessInfo processInfo] processName];
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-11 11:17:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									menu_delegate = [[GodotMenuDelegate alloc] init];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Setup Dock menu.
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSMenu *dock_menu = [[NSMenu alloc] initWithTitle:@"_dock"];
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 11:26:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[dock_menu setAutoenablesItems:NO];
							 
						 
					
						
							
								
									
										
										
										
											2023-07-11 11:17:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[dock_menu setDelegate:menu_delegate];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Setup Apple menu.
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSMenu *application_menu = [[NSMenu alloc] initWithTitle:@""];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									title = [NSString stringWithFormat:NSLocalizedString(@"About %@", nil), nsappname];
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu addItemWithTitle:title action:@selector(showAbout:) keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu setAutoenablesItems:NO];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu setDelegate:menu_delegate];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu addItem:[NSMenuItem separatorItem]];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [application_menu addItemWithTitle:@"_start_" action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
									
										
										
										
											2023-10-15 20:52:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.hidden = YES;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.tag = MENU_TAG_START;
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [application_menu addItemWithTitle:@"_end_" action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
									
										
										
										
											2023-10-15 20:52:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.hidden = YES;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.tag = MENU_TAG_END;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									NSMenu *services = [[NSMenu alloc] initWithTitle:@""];
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [application_menu addItemWithTitle:NSLocalizedString(@"Services", nil) action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu setSubmenu:services forItem:menu_item];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[NSApp setServicesMenu:services];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu addItem:[NSMenuItem separatorItem]];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									title = [NSString stringWithFormat:NSLocalizedString(@"Hide %@", nil), nsappname];
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [application_menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[menu_item setKeyEquivalentModifierMask:(NSEventModifierFlagOption | NSEventModifierFlagCommand)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu addItemWithTitle:NSLocalizedString(@"Show all", nil) action:@selector(unhideAllApplications:) keyEquivalent:@""];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu addItem:[NSMenuItem separatorItem]];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 22:27:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									title = [NSString stringWithFormat:NSLocalizedString(@"Quit %@", nil), nsappname];
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[application_menu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSMenu *window_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Window", nil)];
							 
						 
					
						
							
								
									
										
										
										
											2023-10-15 20:52:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[window_menu addItemWithTitle:NSLocalizedString(@"Minimize", nil) action:@selector(performMiniaturize:) keyEquivalent:@"m"];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window_menu addItemWithTitle:NSLocalizedString(@"Zoom", nil) action:@selector(performZoom:) keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window_menu addItem:[NSMenuItem separatorItem]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window_menu addItemWithTitle:NSLocalizedString(@"Bring All to Front", nil) action:@selector(bringAllToFront:) keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[window_menu addItem:[NSMenuItem separatorItem]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [window_menu addItemWithTitle:@"_start_" action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.hidden = YES;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.tag = MENU_TAG_START;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [window_menu addItemWithTitle:@"_end_" action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.hidden = YES;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.tag = MENU_TAG_END;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSMenu *help_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Help", nil)];
							 
						 
					
						
							
								
									
										
										
										
											2023-10-15 20:52:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [help_menu addItemWithTitle:@"_start_" action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.hidden = YES;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.tag = MENU_TAG_START;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [help_menu addItemWithTitle:@"_end_" action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.hidden = YES;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item.tag = MENU_TAG_END;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[NSApp setWindowsMenu:window_menu];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[NSApp setHelpMenu:help_menu];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Add items to the menu bar.
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 19:23:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									NSMenu *main_menu = [NSApp mainMenu];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[main_menu setSubmenu:application_menu forItem:menu_item];
							 
						 
					
						
							
								
									
										
										
										
											2023-10-15 20:52:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [main_menu addItemWithTitle:NSLocalizedString(@"Window", nil) action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[main_menu setSubmenu:window_menu forItem:menu_item];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									menu_item = [main_menu addItemWithTitle:NSLocalizedString(@"Help", nil) action:nil keyEquivalent:@""];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									[main_menu setSubmenu:help_menu forItem:menu_item];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-22 11:26:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									[main_menu setAutoenablesItems:NO];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									native_menu->_register_system_menus(main_menu, application_menu, window_menu, help_menu, dock_menu);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									//!!!!!!!!!!!!!!!!!!!!!!!!!!
							 
						 
					
						
							
								
									
										
										
										
											2021-09-27 01:07:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									//TODO - do Vulkan and OpenGL support checks, driver selection and fallback
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									rendering_driver = p_rendering_driver;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-28 13:08:07 +07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(RD_ENABLED)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(VULKAN_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2025-02-03 05:24:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(__x86_64__)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									bool fallback_to_vulkan = GLOBAL_GET("rendering/rendering_device/fallback_to_vulkan");
							 
						 
					
						
							
								
									
										
										
											
												Fix cross-platform configuration of rendering driver settings
Simpler alternative to #103026 which avoids breaking compatibility.
Instead of introducing a new `auto` default value, we ensure that all
supported drivers are registered regardless of the editor's host platform,
and that the defaults are the intended ones.
This solves the following issues:
- macOS exports are meant to default to Metal in 4.4, but they would
  default to Vulkan if exported from Linux, Windows, or Android editors.
- Windows exports couldn't be made with Direct3D 12 from Linux, macOS, or
  Android editors, as the option couldn't be selected outside Windows.
Unlike #103026, it doesn't solve the issue of not always saving the
rendering drivers to `project.godot`, but now the defaults are at least
consistent between editor platforms.
Co-authored-by: Pāvels Nadtočajevs <7645683+bruvzg@users.noreply.github.com>
											 
										 
										
											2025-02-23 00:42:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (!fallback_to_vulkan) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										WARN_PRINT("Metal is not supported on Intel Macs, switching to Vulkan.");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-02-03 05:24:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Metal rendering driver not available on Intel.
							 
						 
					
						
							
								
									
										
										
											
												Fix cross-platform configuration of rendering driver settings
Simpler alternative to #103026 which avoids breaking compatibility.
Instead of introducing a new `auto` default value, we ensure that all
supported drivers are registered regardless of the editor's host platform,
and that the defaults are the intended ones.
This solves the following issues:
- macOS exports are meant to default to Metal in 4.4, but they would
  default to Vulkan if exported from Linux, Windows, or Android editors.
- Windows exports couldn't be made with Direct3D 12 from Linux, macOS, or
  Android editors, as the option couldn't be selected outside Windows.
Unlike #103026, it doesn't solve the issue of not always saving the
rendering drivers to `project.godot`, but now the defaults are at least
consistent between editor platforms.
Co-authored-by: Pāvels Nadtočajevs <7645683+bruvzg@users.noreply.github.com>
											 
										 
										
											2025-02-23 00:42:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_driver == "metal") {
							 
						 
					
						
							
								
									
										
										
										
											2025-02-03 05:24:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rendering_driver = "vulkan";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2024-10-28 13:08:07 +07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_driver == "vulkan") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_context = memnew(RenderingContextDriverVulkanMacOS);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(METAL_ENABLED)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_driver == "metal") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_context = memnew(RenderingContextDriverMetal);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_context) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (rendering_context->initialize() != OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											memdelete(rendering_context);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											rendering_context = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool fallback_to_opengl3 = GLOBAL_GET("rendering/rendering_device/fallback_to_opengl3");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (fallback_to_opengl3 && rendering_driver != "opengl3") {
							 
						 
					
						
							
								
									
										
										
										
											2025-08-19 18:32:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												WARN_PRINT("Your device does not seem to support MoltenVK or Metal, switching to OpenGL 3.");
							 
						 
					
						
							
								
									
										
										
										
											2024-10-28 13:08:07 +07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												rendering_driver = "opengl3";
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												OS::get_singleton()->set_current_rendering_method("gl_compatibility");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											} else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												r_error = ERR_CANT_CREATE;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												ERR_FAIL_MSG("Could not initialize " + rendering_driver);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-26 08:18:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2023-10-21 22:08:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_driver == "opengl3_angle") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_angle = memnew(GLManagerANGLE_MacOS);
							 
						 
					
						
							
								
									
										
										
										
											2023-11-01 08:34:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										if (gl_manager_angle->initialize() != OK || gl_manager_angle->open_display(nullptr) != OK) {
							 
						 
					
						
							
								
									
										
										
										
											2023-10-21 22:08:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											memdelete(gl_manager_angle);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											gl_manager_angle = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											bool fallback = GLOBAL_GET("rendering/gl_compatibility/fallback_to_native");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											if (fallback) {
							 
						 
					
						
							
								
									
										
										
										
											2024-08-22 09:46:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef EGL_STATIC
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												WARN_PRINT("Your video card drivers seem not to support GLES3 / ANGLE, switching to native OpenGL.");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												WARN_PRINT("Your video card drivers seem not to support GLES3 / ANGLE or ANGLE dynamic libraries (libEGL.dylib and libGLESv2.dylib) are missing, switching to native OpenGL.");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2023-10-21 22:08:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												rendering_driver = "opengl3";
							 
						 
					
						
							
								
									
										
										
										
											2024-08-21 09:56:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
							 
						 
					
						
							
								
									
										
										
										
											2023-10-21 22:08:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											} else {
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 12:17:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
												r_error = ERR_UNAVAILABLE;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
												ERR_FAIL_MSG("Could not initialize ANGLE OpenGL.");
							 
						 
					
						
							
								
									
										
										
										
											2023-10-21 22:08:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-02 12:27:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_driver == "opengl3") {
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_legacy = memnew(GLManagerLegacy_MacOS);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (gl_manager_legacy->initialize() != OK) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											memdelete(gl_manager_legacy);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											gl_manager_legacy = nullptr;
							 
						 
					
						
							
								
									
										
										
										
											2021-11-02 12:27:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											r_error = ERR_UNAVAILABLE;
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 12:17:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
											ERR_FAIL_MSG("Could not initialize native OpenGL.");
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									Point2i window_position;
							 
						 
					
						
							
								
									
										
										
										
											2022-10-23 18:34:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (p_position != nullptr) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										window_position = *p_position;
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (p_screen == SCREEN_OF_MAIN_WINDOW) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											p_screen = SCREEN_PRIMARY;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2023-03-30 11:37:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										Rect2i scr_rect = screen_get_usable_rect(p_screen);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										window_position = scr_rect.position + (scr_rect.size - p_resolution) / 2;
							 
						 
					
						
							
								
									
										
										
										
											2022-10-23 18:34:41 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 00:00:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									WindowID main_window = _create_window(p_mode, p_vsync_mode, Rect2i(window_position, p_resolution));
							 
						 
					
						
							
								
									
										
										
										
											2020-07-13 19:24:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									ERR_FAIL_COND(main_window == INVALID_WINDOW_ID);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									for (int i = 0; i < WINDOW_FLAG_MAX; i++) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										if (p_flags & (1 << i)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
											window_set_flag(WindowFlags(i), true, main_window);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2023-01-29 13:18:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									force_process_and_drop_events();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_driver == "dummy") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										RasterizerDummy::make_current();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-26 08:18:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-02 12:27:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_driver == "opengl3") {
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										RasterizerGLES3::make_current(true);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_driver == "opengl3_angle") {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										RasterizerGLES3::make_current(false);
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(RD_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_context) {
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rendering_device = memnew(RenderingDevice);
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										rendering_device->initialize(rendering_context, MAIN_WINDOW_ID);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_device->screen_create(MAIN_WINDOW_ID);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-04 15:26:24 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										RendererCompositorRD::make_current();
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 10:38:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 22:10:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									screen_set_keep_on(GLOBAL_GET("display/window/energy_saving/keep_screen_on"));
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 09:28:22 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								DisplayServerMacOS::~DisplayServerMacOS() {
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 10:38:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (screen_keep_on_assertion) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										IOPMAssertionRelease(screen_keep_on_assertion);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										screen_keep_on_assertion = kIOPMNullAssertionID;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Destroy all status indicators.
							 
						 
					
						
							
								
									
										
										
										
											2024-02-27 22:19:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for (HashMap<IndicatorID, IndicatorData>::Iterator E = indicators.begin(); E; ++E) {
							 
						 
					
						
							
								
									
										
										
										
											2023-08-03 12:45:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
										[[NSStatusBar systemStatusBar] removeStatusItem:E->value.item];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-19 19:41:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Destroy native menu.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (native_menu) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										memdelete(native_menu);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										native_menu = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Destroy all windows.
							 
						 
					
						
							
								
									
										
										
										
											2022-05-13 15:04:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									for (HashMap<WindowID, WindowData>::Iterator E = windows.begin(); E;) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										HashMap<WindowID, WindowData>::Iterator F = E;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										++E;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[F->value.window_object setContentView:nil];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										[F->value.window_object close];
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									// Destroy drivers.
							 
						 
					
						
							
								
									
										
										
										
											2021-10-26 08:18:39 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(GLES3_ENABLED)
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 14:49:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_legacy) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										memdelete(gl_manager_legacy);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_legacy = nullptr;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (gl_manager_angle) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										memdelete(gl_manager_angle);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										gl_manager_angle = nullptr;
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 13:06:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 12:48:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#if defined(RD_ENABLED)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_device) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										memdelete(rendering_device);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_device = nullptr;
							 
						 
					
						
							
								
									
										
										
										
											2021-11-02 12:27:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-19 14:57:56 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									if (rendering_context) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										memdelete(rendering_context);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										rendering_context = nullptr;
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2025-03-21 09:54:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#ifdef ACCESSKIT_ENABLED
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									if (accessibility_driver) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
										memdelete(accessibility_driver);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#endif
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 11:01:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
									CGDisplayRemoveReconfigurationCallback(_displays_arrangement_changed, nullptr);
							 
						 
					
						
							
								
									
										
										
										
											2020-03-07 18:02:54 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
									cursors_cache.clear();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}