Use custom xdg-shell for shadows on Wayland
This commit is contained in:
parent
098eb59f2f
commit
43efd9e307
5 changed files with 51 additions and 49 deletions
|
|
@ -245,6 +245,11 @@ endif()
|
||||||
if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
|
if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
|
||||||
remove_target_sources(Telegram ${src_loc} ui/platform/linux/ui_linux_wayland_integration.cpp)
|
remove_target_sources(Telegram ${src_loc} ui/platform/linux/ui_linux_wayland_integration.cpp)
|
||||||
nice_target_sources(Telegram ${src_loc} PRIVATE ui/platform/linux/ui_linux_wayland_integration_dummy.cpp)
|
nice_target_sources(Telegram ${src_loc} PRIVATE ui/platform/linux/ui_linux_wayland_integration_dummy.cpp)
|
||||||
|
elseif(LINUX)
|
||||||
|
target_link_libraries(lib_ui
|
||||||
|
PUBLIC
|
||||||
|
desktop-app::lib_waylandshells
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(lib_ui
|
target_include_directories(lib_ui
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,21 @@
|
||||||
#include "base/platform/linux/base_linux_xcb_utilities.h"
|
#include "base/platform/linux/base_linux_xcb_utilities.h"
|
||||||
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
|
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
|
#include "waylandshells/xdg_shell.h"
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
|
|
||||||
#include <QtCore/QPoint>
|
#include <QtCore/QPoint>
|
||||||
#include <QtGui/QScreen>
|
#include <QtGui/QScreen>
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
#include <private/qguiapplication_p.h>
|
||||||
#include <qpa/qplatformnativeinterface.h>
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
|
#include <qpa/qplatformintegration.h>
|
||||||
|
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
|
#include <private/qwaylandintegration_p.h>
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QMargins);
|
Q_DECLARE_METATYPE(QMargins);
|
||||||
|
|
||||||
|
|
@ -285,10 +295,10 @@ std::optional<bool> XCBIsOverlapped(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetXCBFrameExtents(QWindow *window, const QMargins &extents) {
|
void SetXCBFrameExtents(QWindow *window, const QMargins &extents) {
|
||||||
const auto connection = base::Platform::XCB::GetConnectionFromQt();
|
const auto connection = base::Platform::XCB::GetConnectionFromQt();
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto frameExtentsAtom = base::Platform::XCB::GetAtom(
|
const auto frameExtentsAtom = base::Platform::XCB::GetAtom(
|
||||||
|
|
@ -296,7 +306,7 @@ bool SetXCBFrameExtents(QWindow *window, const QMargins &extents) {
|
||||||
kXCBFrameExtentsAtomName.utf16());
|
kXCBFrameExtentsAtomName.utf16());
|
||||||
|
|
||||||
if (!frameExtentsAtom.has_value()) {
|
if (!frameExtentsAtom.has_value()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto extentsVector = std::vector<uint>{
|
const auto extentsVector = std::vector<uint>{
|
||||||
|
|
@ -315,14 +325,12 @@ bool SetXCBFrameExtents(QWindow *window, const QMargins &extents) {
|
||||||
32,
|
32,
|
||||||
extentsVector.size(),
|
extentsVector.size(),
|
||||||
extentsVector.data());
|
extentsVector.data());
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UnsetXCBFrameExtents(QWindow *window) {
|
void UnsetXCBFrameExtents(QWindow *window) {
|
||||||
const auto connection = base::Platform::XCB::GetConnectionFromQt();
|
const auto connection = base::Platform::XCB::GetConnectionFromQt();
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto frameExtentsAtom = base::Platform::XCB::GetAtom(
|
const auto frameExtentsAtom = base::Platform::XCB::GetAtom(
|
||||||
|
|
@ -330,15 +338,13 @@ bool UnsetXCBFrameExtents(QWindow *window) {
|
||||||
kXCBFrameExtentsAtomName.utf16());
|
kXCBFrameExtentsAtomName.utf16());
|
||||||
|
|
||||||
if (!frameExtentsAtom.has_value()) {
|
if (!frameExtentsAtom.has_value()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_delete_property(
|
xcb_delete_property(
|
||||||
connection,
|
connection,
|
||||||
window->winId(),
|
window->winId(),
|
||||||
*frameExtentsAtom);
|
*frameExtentsAtom);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowXCBWindowMenu(QWindow *window) {
|
bool ShowXCBWindowMenu(QWindow *window) {
|
||||||
|
|
@ -460,11 +466,16 @@ std::optional<bool> IsOverlapped(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowExtentsSupported() {
|
bool WindowExtentsSupported() {
|
||||||
#ifdef DESKTOP_APP_QT_PATCHED
|
#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
if (::Platform::IsWayland()) {
|
if (::Platform::IsWayland()) {
|
||||||
return true;
|
// initialize shell integration before querying
|
||||||
|
using QtWaylandClient::QWaylandIntegration;
|
||||||
|
const auto integration = static_cast<QWaylandIntegration*>(
|
||||||
|
QGuiApplicationPrivate::platformIntegration());
|
||||||
|
integration->shellIntegration();
|
||||||
|
return WaylandShells::XdgShell();
|
||||||
}
|
}
|
||||||
#endif // DESKTOP_APP_QT_PATCHED
|
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
namespace XCB = base::Platform::XCB;
|
namespace XCB = base::Platform::XCB;
|
||||||
|
|
@ -477,42 +488,32 @@ bool WindowExtentsSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetWindowExtents(QWindow *window, const QMargins &extents) {
|
void SetWindowExtents(QWindow *window, const QMargins &extents) {
|
||||||
if (::Platform::IsWayland()) {
|
if (::Platform::IsWayland()) {
|
||||||
#ifdef DESKTOP_APP_QT_PATCHED
|
#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
window->setProperty("WaylandCustomMargins", QVariant::fromValue<QMargins>(extents));
|
window->setProperty(
|
||||||
return true;
|
"_desktopApp_waylandCustomMargins",
|
||||||
#else // DESKTOP_APP_QT_PATCHED
|
QVariant::fromValue<QMargins>(extents));
|
||||||
return false;
|
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
#endif // !DESKTOP_APP_QT_PATCHED
|
|
||||||
} else if (::Platform::IsX11()) {
|
} else if (::Platform::IsX11()) {
|
||||||
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
return SetXCBFrameExtents(window, extents);
|
SetXCBFrameExtents(window, extents);
|
||||||
#else // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
return false;
|
}
|
||||||
#endif // DESKTOP_APP_DISABLE_X11_INTEGRATION
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
void UnsetWindowExtents(QWindow *window) {
|
||||||
}
|
|
||||||
|
|
||||||
bool UnsetWindowExtents(QWindow *window) {
|
|
||||||
if (::Platform::IsWayland()) {
|
if (::Platform::IsWayland()) {
|
||||||
#ifdef DESKTOP_APP_QT_PATCHED
|
#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
window->setProperty("WaylandCustomMargins", QVariant());
|
window->setProperty(
|
||||||
return true;
|
"_desktopApp_waylandCustomMargins",
|
||||||
#else // DESKTOP_APP_QT_PATCHED
|
QVariant());
|
||||||
return false;
|
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||||
#endif // !DESKTOP_APP_QT_PATCHED
|
|
||||||
} else if (::Platform::IsX11()) {
|
} else if (::Platform::IsX11()) {
|
||||||
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
return UnsetXCBFrameExtents(window);
|
UnsetXCBFrameExtents(window);
|
||||||
#else // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
return false;
|
|
||||||
#endif // DESKTOP_APP_DISABLE_X11_INTEGRATION
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowWindowMenu(QWindow *window) {
|
bool ShowWindowMenu(QWindow *window) {
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,10 @@ inline bool WindowExtentsSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool SetWindowExtents(QWindow *window, const QMargins &extents) {
|
inline void SetWindowExtents(QWindow *window, const QMargins &extents) {
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool UnsetWindowExtents(QWindow *window) {
|
inline void UnsetWindowExtents(QWindow *window) {
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool ShowWindowMenu(QWindow *window) {
|
inline bool ShowWindowMenu(QWindow *window) {
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ void ClearTransientParent(not_null<QWidget*> widget);
|
||||||
void DrainMainQueue(); // Needed only if UseMainQueueGeneric() is false.
|
void DrainMainQueue(); // Needed only if UseMainQueueGeneric() is false.
|
||||||
|
|
||||||
[[nodiscard]] bool WindowExtentsSupported();
|
[[nodiscard]] bool WindowExtentsSupported();
|
||||||
bool SetWindowExtents(QWindow *window, const QMargins &extents);
|
void SetWindowExtents(QWindow *window, const QMargins &extents);
|
||||||
bool UnsetWindowExtents(QWindow *window);
|
void UnsetWindowExtents(QWindow *window);
|
||||||
bool ShowWindowMenu(QWindow *window);
|
bool ShowWindowMenu(QWindow *window);
|
||||||
|
|
||||||
[[nodiscard]] TitleControls::Layout TitleControlsLayout();
|
[[nodiscard]] TitleControls::Layout TitleControlsLayout();
|
||||||
|
|
|
||||||
|
|
@ -46,12 +46,10 @@ inline bool WindowExtentsSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool SetWindowExtents(QWindow *window, const QMargins &extents) {
|
inline void SetWindowExtents(QWindow *window, const QMargins &extents) {
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool UnsetWindowExtents(QWindow *window) {
|
inline void UnsetWindowExtents(QWindow *window) {
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue