Path: blob/master/platform/macos/editor/embedded_process_macos.h
10278 views
/**************************************************************************/1/* embedded_process_macos.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/run/embedded_process.h"3334class DisplayServerMacOS;35class EmbeddedProcessMacOS;3637class LayerHost final : public Control {38GDCLASS(LayerHost, Control);3940ScriptEditorDebugger *script_debugger = nullptr;41EmbeddedProcessMacOS *process = nullptr;42bool window_focused = true;4344struct CustomCursor {45Ref<Image> image;46Vector2 hotspot;47CustomCursor() {}48CustomCursor(const Ref<Image> &p_image, const Vector2 &p_hotspot) {49image = p_image;50hotspot = p_hotspot;51}52};53HashMap<DisplayServer::CursorShape, CustomCursor> custom_cursors;5455virtual void gui_input(const Ref<InputEvent> &p_event) override;5657protected:58void _notification(int p_what);5960public:61void cursor_set_custom_image(const Ref<Image> &p_image, DisplayServer::CursorShape p_shape, const Vector2 &p_hotspot);62void set_script_debugger(ScriptEditorDebugger *p_debugger) {63script_debugger = p_debugger;64}6566LayerHost(EmbeddedProcessMacOS *p_process);67};6869class EmbeddedProcessMacOS final : public EmbeddedProcessBase {70GDCLASS(EmbeddedProcessMacOS, EmbeddedProcessBase);7172enum class EmbeddingState {73IDLE,74IN_PROGRESS,75COMPLETED,76FAILED,77};7879DisplayServerMacOS *ds = nullptr;80EmbeddingState embedding_state = EmbeddingState::IDLE;81uint32_t context_id = 0;82ScriptEditorDebugger *script_debugger = nullptr;83LayerHost *layer_host = nullptr;84OS::ProcessID current_process_id = 0;8586// Embedded process state.8788// The last mouse mode sent by the embedded process.89DisplayServer::MouseMode mouse_mode = DisplayServer::MOUSE_MODE_VISIBLE;9091// Helper functions.9293void _try_embed_process();94void update_embedded_process();9596protected:97void _notification(int p_what);9899public:100// MARK: - Message Handlers101102void set_context_id(uint32_t p_context_id);103void mouse_set_mode(DisplayServer::MouseMode p_mode);104105uint32_t get_context_id() const { return context_id; }106void set_script_debugger(ScriptEditorDebugger *p_debugger) override;107108bool is_embedding_in_progress() const override {109return embedding_state == EmbeddingState::IN_PROGRESS;110}111112_FORCE_INLINE_ bool is_embedding_completed() const override {113return embedding_state == EmbeddingState::COMPLETED;114}115116bool is_process_focused() const override { return layer_host->has_focus(); }117void embed_process(OS::ProcessID p_pid) override;118int get_embedded_pid() const override { return current_process_id; }119void reset() override;120void request_close() override;121void queue_update_embedded_process() override { update_embedded_process(); }122123Rect2i get_adjusted_embedded_window_rect(const Rect2i &p_rect) const override;124125_FORCE_INLINE_ LayerHost *get_layer_host() const { return layer_host; }126127void display_state_changed();128129// MARK: - Embedded process state130_FORCE_INLINE_ DisplayServer::MouseMode get_mouse_mode() const { return mouse_mode; }131132EmbeddedProcessMacOS();133~EmbeddedProcessMacOS() override;134};135136137