mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Add support for showing window menu on Wayland
This commit is contained in:
parent
08b67e383e
commit
dc9d0aae54
5 changed files with 44 additions and 4 deletions
|
@ -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<QWaylandWindow*>(
|
||||
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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue