WindowManagerServerConnection.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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::handshake()
  19. {
  20. // :^)
  21. }
  22. void WindowManagerServerConnection::window_state_changed(i32 wm_id, i32 client_id, i32 window_id,
  23. i32 parent_client_id, i32 parent_window_id, bool is_active, bool is_minimized, bool is_modal,
  24. bool is_frameless, i32 window_type, String const& title, Gfx::IntRect const& rect, Optional<i32> const& progress)
  25. {
  26. if (auto* window = Window::from_window_id(wm_id))
  27. 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));
  28. }
  29. void WindowManagerServerConnection::applet_area_size_changed(i32 wm_id, const Gfx::IntSize& size)
  30. {
  31. if (auto* window = Window::from_window_id(wm_id))
  32. Core::EventLoop::current().post_event(*window, make<WMAppletAreaSizeChangedEvent>(size));
  33. }
  34. void WindowManagerServerConnection::window_rect_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::IntRect const& rect)
  35. {
  36. if (auto* window = Window::from_window_id(wm_id))
  37. Core::EventLoop::current().post_event(*window, make<WMWindowRectChangedEvent>(client_id, window_id, rect));
  38. }
  39. void WindowManagerServerConnection::window_icon_bitmap_changed(i32 wm_id, i32 client_id, i32 window_id, Gfx::ShareableBitmap const& bitmap)
  40. {
  41. if (auto* window = Window::from_window_id(wm_id)) {
  42. Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(client_id, window_id, bitmap.bitmap()));
  43. }
  44. }
  45. void WindowManagerServerConnection::window_removed(i32 wm_id, i32 client_id, i32 window_id)
  46. {
  47. if (auto* window = Window::from_window_id(wm_id))
  48. Core::EventLoop::current().post_event(*window, make<WMWindowRemovedEvent>(client_id, window_id));
  49. }
  50. void WindowManagerServerConnection::super_key_pressed(i32 wm_id)
  51. {
  52. if (auto* window = Window::from_window_id(wm_id))
  53. Core::EventLoop::current().post_event(*window, make<WMSuperKeyPressedEvent>(wm_id));
  54. }
  55. }