WindowManagerServerConnection.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGUI/Event.h>
  7. #include <LibGUI/Window.h>
  8. #include <LibGUI/WindowManagerServerConnection.h>
  9. #include <WindowServer/Window.h>
  10. namespace GUI {
  11. WindowManagerServerConnection& WindowManagerServerConnection::the()
  12. {
  13. static WindowManagerServerConnection* s_connection = nullptr;
  14. if (!s_connection)
  15. s_connection = new WindowManagerServerConnection;
  16. return *s_connection;
  17. }
  18. void WindowManagerServerConnection::window_state_changed(i32 wm_id, i32 client_id, i32 window_id,
  19. i32 parent_client_id, i32 parent_window_id, bool is_active, bool is_minimized, bool is_modal,
  20. bool is_frameless, i32 window_type, String const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
  21. {
  22. if (auto* window = Window::from_window_id(wm_id))
  23. Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, parent_client_id, parent_window_id, title, rect, is_active, is_modal, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress));
  24. }
  25. void WindowManagerServerConnection::applet_area_size_changed(i32 wm_id, const Gfx::IntSize& size)
  26. {
  27. if (auto* window = Window::from_window_id(wm_id))
  28. Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size));
  29. }
  30. void WindowManagerServerConnection::window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect const& rect)
  31. {
  32. if (auto* window = Window::from_window_id(wm_id))
  33. Core::EventLoop::current().post_event(*window, make<WMWindowRectChangedEvent>(client_id, window_id, rect));
  34. }
  35. void WindowManagerServerConnection::window_icon_bitmap_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::ShareableBitmap const& bitmap)
  36. {
  37. if (auto* window = Window::from_window_id(wm_id)) {
  38. Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(client_id, window_id, bitmap.bitmap()));
  39. }
  40. }
  41. void WindowManagerServerConnection::window_removed(i32 wm_id, i32 client_id, i32 window_id)
  42. {
  43. if (auto* window = Window::from_window_id(wm_id))
  44. Core::EventLoop::current().post_event(*window, make<WMWindowRemovedEvent>(client_id, window_id));
  45. }
  46. void WindowManagerServerConnection::super_key_pressed(i32 wm_id)
  47. {
  48. if (auto* window = Window::from_window_id(wm_id))
  49. Core::EventLoop::current().post_event(*window, make<WMSuperKeyPressedEvent>(wm_id));
  50. }
  51. void WindowManagerServerConnection::super_space_key_pressed(i32 wm_id)
  52. {
  53. if (auto* window = Window::from_window_id(wm_id))
  54. Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
  55. }
  56. }