1 /* 2 This file is part of Telegram Desktop, 3 the official desktop application for the Telegram messaging service. 4 5 For license and copyright information please follow this link: 6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 7 */ 8 #pragma once 9 10 #include "platform/platform_main_window.h" 11 #include "base/platform/win/base_windows_h.h" 12 #include "base/flags.h" 13 14 namespace Ui { 15 class PopupMenu; 16 } // namespace Ui 17 18 namespace Platform { 19 20 class MainWindow : public Window::MainWindow { 21 public: 22 explicit MainWindow(not_null<Window::Controller*> controller); 23 24 void showFromTrayMenu() override; 25 26 HWND psHwnd() const; 27 28 void updateWindowIcon() override; 29 bool isActiveForTrayMenu() override; 30 31 void psRefreshTaskbarIcon(); 32 33 [[nodiscard]] static uint32 TaskbarCreatedMsgId(); 34 static void TaskbarCreated(); 35 36 // Custom shadows. 37 void shadowsActivate(); 38 void shadowsDeactivate(); 39 40 [[nodiscard]] bool hasTabletView() const; 41 42 void psShowTrayMenu(); 43 44 ~MainWindow(); 45 46 protected: 47 void initHook() override; 48 int32 screenNameChecksum(const QString &name) const override; 49 void unreadCounterChangedHook() override; 50 hasTrayIcon()51 bool hasTrayIcon() const override { 52 return trayIcon; 53 } 54 55 QSystemTrayIcon *trayIcon = nullptr; 56 Ui::PopupMenu *trayIconMenu = nullptr; 57 58 void psTrayMenuUpdated(); 59 void psSetupTrayIcon(); 60 61 void showTrayTooltip() override; 62 63 void workmodeUpdated(Core::Settings::WorkMode mode) override; 64 65 bool initGeometryFromSystem() override; 66 67 QRect computeDesktopRect() const override; 68 69 private: 70 struct Private; 71 72 void setupNativeWindowFrame(); 73 void updateIconCounters(); 74 void validateWindowTheme(bool native, bool night); 75 void psDestroyIcons(); 76 77 const std::unique_ptr<Private> _private; 78 79 bool _hasActiveFrame = false; 80 81 // Workarounds for activation from tray icon. 82 crl::time _lastDeactivateTime = 0; 83 rpl::lifetime _showFromTrayLifetime; 84 85 HWND ps_hWnd = nullptr; 86 HICON ps_iconBig = nullptr; 87 HICON ps_iconSmall = nullptr; 88 HICON ps_iconOverlay = nullptr; 89 90 const std::unique_ptr<QWindow> _taskbarHiderWindow; 91 92 }; 93 94 } // namespace Platform 95