mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-03 08:05:12 +00:00
Add support for showing window menu on Wayland
This commit is contained in:
@@ -585,6 +585,21 @@ bool StartWaylandResize(QWindow *window, Qt::Edges edges) {
|
|||||||
return false;
|
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) {
|
Window::Control GtkKeywordToWindowControl(const QString &keyword) {
|
||||||
if (keyword == qstr("minimize")) {
|
if (keyword == qstr("minimize")) {
|
||||||
return Window::Control::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() {
|
Window::ControlsLayout WindowControlsLayout() {
|
||||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||||
if (Libs::GtkSettingSupported()
|
if (Libs::GtkSettingSupported()
|
||||||
|
@@ -38,6 +38,10 @@ inline bool StartSystemResize(QWindow *window, Qt::Edges edges) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool ShowWindowMenu(QWindow *window) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool AutostartSupported() {
|
inline bool AutostartSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,7 @@ bool TrayIconSupported();
|
|||||||
QImage GetImageFromClipboard();
|
QImage GetImageFromClipboard();
|
||||||
bool StartSystemMove(QWindow *window);
|
bool StartSystemMove(QWindow *window);
|
||||||
bool StartSystemResize(QWindow *window, Qt::Edges edges);
|
bool StartSystemResize(QWindow *window, Qt::Edges edges);
|
||||||
|
bool ShowWindowMenu(QWindow *window);
|
||||||
Window::ControlsLayout WindowControlsLayout();
|
Window::ControlsLayout WindowControlsLayout();
|
||||||
|
|
||||||
namespace ThirdParty {
|
namespace ThirdParty {
|
||||||
|
@@ -418,6 +418,18 @@ bool AutostartSupported() {
|
|||||||
return !IsWindowsStoreBuild();
|
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 WindowControlsLayout() {
|
||||||
Window::ControlsLayout controls;
|
Window::ControlsLayout controls;
|
||||||
controls.right = {
|
controls.right = {
|
||||||
|
@@ -189,11 +189,11 @@ void TitleWidgetQt::resizeEvent(QResizeEvent *e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TitleWidgetQt::mousePressEvent(QMouseEvent *e) {
|
void TitleWidgetQt::mousePressEvent(QMouseEvent *e) {
|
||||||
if (e->button() != Qt::LeftButton) {
|
if (e->button() == Qt::LeftButton) {
|
||||||
return;
|
startMove();
|
||||||
|
} else if (e->button() == Qt::RightButton) {
|
||||||
|
Platform::ShowWindowMenu(window()->windowHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
startMove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleWidgetQt::mouseDoubleClickEvent(QMouseEvent *e) {
|
void TitleWidgetQt::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||||
|
Reference in New Issue
Block a user