ConnectionToWindowManagerServer.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (c) 2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGUI/ConnectionToWindowManagerServer.h>
  7. #include <LibGUI/Event.h>
  8. #include <LibGUI/Window.h>
  9. namespace GUI {
  10. ConnectionToWindowManagerServer& ConnectionToWindowManagerServer::the()
  11. {
  12. static RefPtr<ConnectionToWindowManagerServer> s_connection = nullptr;
  13. if (!s_connection)
  14. s_connection = ConnectionToWindowManagerServer::try_create().release_value_but_fixme_should_propagate_errors();
  15. return *s_connection;
  16. }
  17. void ConnectionToWindowManagerServer::window_state_changed(i32 wm_id, i32 client_id, i32 window_id,
  18. u32 workspace_row, u32 workspace_column, bool is_active, bool is_blocked, bool is_minimized, bool is_frameless,
  19. i32 window_type, DeprecatedString const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
  20. {
  21. if (auto* window = Window::from_window_id(wm_id))
  22. Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, title, rect, workspace_row, workspace_column, is_active, is_blocked, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress));
  23. }
  24. void ConnectionToWindowManagerServer::applet_area_size_changed(i32 wm_id, Gfx::IntSize size)
  25. {
  26. if (auto* window = Window::from_window_id(wm_id))
  27. Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size));
  28. }
  29. void ConnectionToWindowManagerServer::window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect const& rect)
  30. {
  31. if (auto* window = Window::from_window_id(wm_id))
  32. Core::EventLoop::current().post_event(*window, make<WMWindowRectChangedEvent>(client_id, window_id, rect));
  33. }
  34. void ConnectionToWindowManagerServer::window_icon_bitmap_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::ShareableBitmap const& bitmap)
  35. {
  36. if (auto* window = Window::from_window_id(wm_id)) {
  37. Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(client_id, window_id, bitmap.bitmap()));
  38. }
  39. }
  40. void ConnectionToWindowManagerServer::window_removed(i32 wm_id, i32 client_id, i32 window_id)
  41. {
  42. if (auto* window = Window::from_window_id(wm_id))
  43. Core::EventLoop::current().post_event(*window, make<WMWindowRemovedEvent>(client_id, window_id));
  44. }
  45. void ConnectionToWindowManagerServer::super_key_pressed(i32 wm_id)
  46. {
  47. if (auto* window = Window::from_window_id(wm_id))
  48. Core::EventLoop::current().post_event(*window, make<WMSuperKeyPressedEvent>(wm_id));
  49. }
  50. void ConnectionToWindowManagerServer::super_space_key_pressed(i32 wm_id)
  51. {
  52. if (auto* window = Window::from_window_id(wm_id))
  53. Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
  54. }
  55. void ConnectionToWindowManagerServer::super_d_key_pressed(i32 wm_id)
  56. {
  57. if (auto* window = Window::from_window_id(wm_id))
  58. Core::EventLoop::current().post_event(*window, make<WMSuperDKeyPressedEvent>(wm_id));
  59. }
  60. void ConnectionToWindowManagerServer::super_digit_key_pressed(i32 wm_id, u8 digit)
  61. {
  62. if (auto* window = Window::from_window_id(wm_id))
  63. Core::EventLoop::current().post_event(*window, make<WMSuperDigitKeyPressedEvent>(wm_id, digit));
  64. }
  65. void ConnectionToWindowManagerServer::workspace_changed(i32 wm_id, u32 row, u32 column)
  66. {
  67. if (auto* window = Window::from_window_id(wm_id))
  68. Core::EventLoop::current().post_event(*window, make<WMWorkspaceChangedEvent>(wm_id, row, column));
  69. }
  70. void ConnectionToWindowManagerServer::keymap_changed(i32 wm_id, DeprecatedString const& keymap)
  71. {
  72. if (auto* window = Window::from_window_id(wm_id))
  73. Core::EventLoop::current().post_event(*window, make<WMKeymapChangedEvent>(wm_id, keymap));
  74. }
  75. }