compose_show.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "chat_helpers/compose/compose_show.h"
  8. #include "core/application.h"
  9. #include "main/main_session.h"
  10. #include "window/window_controller.h"
  11. #include "window/window_session_controller.h"
  12. namespace ChatHelpers {
  13. rpl::producer<bool> Show::adjustShadowLeft() const {
  14. return rpl::single(false);
  15. }
  16. ResolveWindow ResolveWindowDefault() {
  17. return [](not_null<Main::Session*> session)
  18. -> Window::SessionController* {
  19. const auto check = [&](Window::Controller *window) {
  20. if (const auto controller = window->sessionController()) {
  21. if (&controller->session() == session) {
  22. return controller;
  23. }
  24. }
  25. return (Window::SessionController*)nullptr;
  26. };
  27. auto &app = Core::App();
  28. const auto account = not_null(&session->account());
  29. if (const auto a = check(app.activeWindow())) {
  30. return a;
  31. } else if (const auto b = check(app.activePrimaryWindow())) {
  32. return b;
  33. } else if (const auto c = check(app.windowFor(account))) {
  34. return c;
  35. } else if (const auto d = check(app.ensureSeparateWindowFor(
  36. account))) {
  37. return d;
  38. }
  39. return nullptr;
  40. };
  41. }
  42. Window::SessionController *Show::resolveWindow() const {
  43. return ResolveWindowDefault()(&session());
  44. }
  45. } // namespace ChatHelpers