2
0

embedded_process.h 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**************************************************************************/
  2. /* embedded_process.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef EMBEDDED_PROCESS_H
  31. #define EMBEDDED_PROCESS_H
  32. #include "scene/gui/control.h"
  33. class EmbeddedProcess : public Control {
  34. GDCLASS(EmbeddedProcess, Control);
  35. bool application_has_focus = true;
  36. uint64_t last_application_focus_time = 0;
  37. OS::ProcessID focused_process_id = 0;
  38. OS::ProcessID current_process_id = 0;
  39. bool embedding_grab_focus = false;
  40. bool embedding_completed = false;
  41. uint64_t start_embedding_time = 0;
  42. bool updated_embedded_process_queued = false;
  43. bool last_updated_embedded_process_focused = false;
  44. Window *window = nullptr;
  45. Timer *timer_embedding = nullptr;
  46. Timer *timer_update_embedded_process = nullptr;
  47. const int embedding_timeout = 45000;
  48. bool keep_aspect = false;
  49. Size2i window_size;
  50. Ref<StyleBox> focus_style_box;
  51. Point2i margin_top_left;
  52. Point2i margin_bottom_right;
  53. Rect2i last_global_rect;
  54. void _try_embed_process();
  55. void _update_embedded_process();
  56. void _timer_embedding_timeout();
  57. void _timer_update_embedded_process_timeout();
  58. void _draw();
  59. void _check_mouse_over();
  60. void _check_focused_process_id();
  61. bool _is_embedded_process_updatable();
  62. Rect2i _get_global_embedded_window_rect();
  63. Window *_get_current_modal_window();
  64. protected:
  65. static void _bind_methods();
  66. void _notification(int p_what);
  67. public:
  68. void embed_process(OS::ProcessID p_pid);
  69. void reset();
  70. void request_close();
  71. void set_window_size(const Size2i p_window_size);
  72. void set_keep_aspect(bool p_keep_aspect);
  73. void queue_update_embedded_process();
  74. Rect2i get_adjusted_embedded_window_rect(Rect2i p_rect);
  75. Rect2i get_screen_embedded_window_rect();
  76. int get_margin_size(Side p_side) const;
  77. Size2 get_margins_size();
  78. bool is_embedding_in_progress();
  79. bool is_embedding_completed();
  80. int get_embedded_pid() const;
  81. EmbeddedProcess();
  82. ~EmbeddedProcess();
  83. };
  84. #endif // EMBEDDED_PROCESS_H