diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 1ebf5e3ca..6cc1295f5 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -585,6 +585,21 @@ bool StartWaylandResize(QWindow *window, Qt::Edges edges) { return false; } +bool ShowWaylandWindowMenu(QWindow *window) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) || defined DESKTOP_APP_QT_PATCHED + if (const auto waylandWindow = static_cast( + window->handle())) { + if (const auto seat = waylandWindow->display()->lastInputDevice()) { + if (const auto shellSurface = waylandWindow->shellSurface()) { + return shellSurface->showWindowMenu(seat); + } + } + } +#endif // Qt >= 5.13 || DESKTOP_APP_QT_PATCHED + + return false; +} + Window::Control GtkKeywordToWindowControl(const QString &keyword) { if (keyword == qstr("minimize")) { return Window::Control::Minimize; @@ -956,6 +971,14 @@ bool StartSystemResize(QWindow *window, Qt::Edges edges) { } } +bool ShowWindowMenu(QWindow *window) { + if (IsWayland()) { + return ShowWaylandWindowMenu(window); + } + + return false; +} + Window::ControlsLayout WindowControlsLayout() { #ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (Libs::GtkSettingSupported() diff --git a/Telegram/SourceFiles/platform/mac/specific_mac.h b/Telegram/SourceFiles/platform/mac/specific_mac.h index 3260b183e..f74ad82e6 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac.h +++ b/Telegram/SourceFiles/platform/mac/specific_mac.h @@ -38,6 +38,10 @@ inline bool StartSystemResize(QWindow *window, Qt::Edges edges) { return false; } +inline bool ShowWindowMenu(QWindow *window) { + return false; +} + inline bool AutostartSupported() { return false; } diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h index efd75cd63..1939738e0 100644 --- a/Telegram/SourceFiles/platform/platform_specific.h +++ b/Telegram/SourceFiles/platform/platform_specific.h @@ -54,6 +54,7 @@ bool TrayIconSupported(); QImage GetImageFromClipboard(); bool StartSystemMove(QWindow *window); bool StartSystemResize(QWindow *window, Qt::Edges edges); +bool ShowWindowMenu(QWindow *window); Window::ControlsLayout WindowControlsLayout(); namespace ThirdParty { diff --git a/Telegram/SourceFiles/platform/win/specific_win.cpp b/Telegram/SourceFiles/platform/win/specific_win.cpp index df6d316e5..6481defde 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.cpp +++ b/Telegram/SourceFiles/platform/win/specific_win.cpp @@ -418,6 +418,18 @@ bool AutostartSupported() { return !IsWindowsStoreBuild(); } +bool ShowWindowMenu(QWindow *window) { + const auto pos = QCursor::pos(); + + SendMessage( + window->winId(), + WM_SYSCOMMAND, + SC_MOUSEMENU, + MAKELPARAM(pos.x(), pos.y())); + + return true; +} + Window::ControlsLayout WindowControlsLayout() { Window::ControlsLayout controls; controls.right = { diff --git a/Telegram/SourceFiles/window/window_title_qt.cpp b/Telegram/SourceFiles/window/window_title_qt.cpp index 02cd57498..891484681 100644 --- a/Telegram/SourceFiles/window/window_title_qt.cpp +++ b/Telegram/SourceFiles/window/window_title_qt.cpp @@ -189,11 +189,11 @@ void TitleWidgetQt::resizeEvent(QResizeEvent *e) { } void TitleWidgetQt::mousePressEvent(QMouseEvent *e) { - if (e->button() != Qt::LeftButton) { - return; + if (e->button() == Qt::LeftButton) { + startMove(); + } else if (e->button() == Qt::RightButton) { + Platform::ShowWindowMenu(window()->windowHandle()); } - - startMove(); } void TitleWidgetQt::mouseDoubleClickEvent(QMouseEvent *e) {