WindowManagerServerConnection.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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, u32 virtual_desktop_row, u32 virtual_desktop_column,
  20. bool is_active, bool is_minimized, bool is_modal, bool is_frameless, i32 window_type,
  21. String const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
  22. {
  23. if (auto* window = Window::from_window_id(wm_id))
  24. Core::EventLoop::current().post_event(*window, make<WMWindowStateChangedEvent>(client_id, window_id, parent_client_id, parent_window_id, title, rect, virtual_desktop_row, virtual_desktop_column, is_active, is_modal, static_cast<WindowType>(window_type), is_minimized, is_frameless, progress));
  25. }
  26. void WindowManagerServerConnection::applet_area_size_changed(i32 wm_id, const Gfx::IntSize& size)
  27. {
  28. if (auto* window = Window::from_window_id(wm_id))
  29. Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size));
  30. }
  31. void WindowManagerServerConnection::window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect const& rect)
  32. {
  33. if (auto* window = Window::from_window_id(wm_id))
  34. Core::EventLoop::current().post_event(*window, make<WMWindowRectChangedEvent>(client_id, window_id, rect));
  35. }
  36. void WindowManagerServerConnection::window_icon_bitmap_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::ShareableBitmap const& bitmap)
  37. {
  38. if (auto* window = Window::from_window_id(wm_id)) {
  39. Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(client_id, window_id, bitmap.bitmap()));
  40. }
  41. }
  42. void WindowManagerServerConnection::window_removed(i32 wm_id, i32 client_id, i32 window_id)
  43. {
  44. if (auto* window = Window::from_window_id(wm_id))
  45. Core::EventLoop::current().post_event(*window, make<WMWindowRemovedEvent>(client_id, window_id));
  46. }
  47. void WindowManagerServerConnection::super_key_pressed(i32 wm_id)
  48. {
  49. if (auto* window = Window::from_window_id(wm_id))
  50. Core::EventLoop::current().post_event(*window, make<WMSuperKeyPressedEvent>(wm_id));
  51. }
  52. void WindowManagerServerConnection::super_space_key_pressed(i32 wm_id)
  53. {
  54. if (auto* window = Window::from_window_id(wm_id))
  55. Core::EventLoop::current().post_event(*window, make<WMSuperSpaceKeyPressedEvent>(wm_id));
  56. }
  57. void WindowManagerServerConnection::virtual_desktop_changed(i32 wm_id, u32 row, u32 column)
  58. {
  59. if (auto* window = Window::from_window_id(wm_id))
  60. Core::EventLoop::current().post_event(*window, make<WMVirtualDesktopChangedEvent>(wm_id, row, column));
  61. }
  62. }