main_window_win.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #pragma once
  8. #include "platform/platform_main_window.h"
  9. #include "base/flags.h"
  10. #include <windows.h>
  11. namespace Ui {
  12. class PopupMenu;
  13. } // namespace Ui
  14. namespace Platform {
  15. class MainWindow : public Window::MainWindow {
  16. public:
  17. explicit MainWindow(not_null<Window::Controller*> controller);
  18. HWND psHwnd() const;
  19. void updateWindowIcon() override;
  20. bool isActiveForTrayMenu() override;
  21. // Custom shadows.
  22. void shadowsActivate();
  23. void shadowsDeactivate();
  24. [[nodiscard]] bool hasTabletView() const;
  25. void destroyedFromSystem();
  26. bool setDwmThumbnail(QSize size);
  27. bool setDwmPreview(QSize size, int radius);
  28. ~MainWindow();
  29. protected:
  30. void initHook() override;
  31. void unreadCounterChangedHook() override;
  32. void workmodeUpdated(Core::Settings::WorkMode mode) override;
  33. bool initGeometryFromSystem() override;
  34. bool nativeEvent(
  35. const QByteArray &eventType,
  36. void *message,
  37. native_event_filter_result *result) override;
  38. private:
  39. struct Private;
  40. class BitmapPointer {
  41. public:
  42. BitmapPointer(HBITMAP value = nullptr);
  43. BitmapPointer(BitmapPointer &&other);
  44. BitmapPointer& operator=(BitmapPointer &&other);
  45. ~BitmapPointer();
  46. [[nodiscard]] HBITMAP get() const;
  47. [[nodiscard]] explicit operator bool() const;
  48. void release();
  49. void reset(HBITMAP value = nullptr);
  50. private:
  51. HBITMAP _value = nullptr;
  52. };
  53. void setupNativeWindowFrame();
  54. void setupPreviewPasscodeLock();
  55. void updateTaskbarAndIconCounters();
  56. void validateWindowTheme(bool native, bool night);
  57. void forceIconRefresh();
  58. void destroyCachedIcons();
  59. void validateDwmPreviewColors();
  60. const std::unique_ptr<Private> _private;
  61. const std::unique_ptr<QWindow> _taskbarHiderWindow;
  62. HWND _hWnd = nullptr;
  63. HICON _iconBig = nullptr;
  64. HICON _iconSmall = nullptr;
  65. HICON _iconOverlay = nullptr;
  66. BitmapPointer _dwmThumbnail;
  67. BitmapPointer _dwmPreview;
  68. QSize _dwmThumbnailSize;
  69. QSize _dwmPreviewSize;
  70. QColor _dwmBackground;
  71. int _dwmPreviewRadius = 0;
  72. // Workarounds for activation from tray icon.
  73. crl::time _lastDeactivateTime = 0;
  74. bool _hasActiveFrame = false;
  75. };
  76. [[nodiscard]] int32 ScreenNameChecksum(const QString &name);
  77. } // namespace Platform