mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Let PiP have custom buffer size on Wayland
This commit is contained in:
parent
543bfab24a
commit
9e63fc5acd
5 changed files with 65 additions and 2 deletions
|
@ -38,6 +38,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <private/qwidget_p.h>
|
||||
|
||||
#ifdef QT_WAYLAND_EGL_CLIENT_HW_INTEGRATION_LIB
|
||||
// private QtWaylandClient headers are using keywords :(
|
||||
#ifdef QT_NO_KEYWORDS
|
||||
#define signals Q_SIGNALS
|
||||
#define slots Q_SLOTS
|
||||
#endif // QT_NO_KEYWORDS
|
||||
|
||||
#include <private/qwaylandeglwindow_p.h>
|
||||
#endif // QT_WAYLAND_EGL_CLIENT_HW_INTEGRATION_LIB
|
||||
|
||||
namespace Media {
|
||||
namespace View {
|
||||
|
@ -572,6 +583,44 @@ void PipPanel::setGeometry(QRect geometry) {
|
|||
widget()->setGeometry(geometry);
|
||||
}
|
||||
|
||||
void PipPanel::handleResize(QSize size) {
|
||||
if (!Platform::IsWayland()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto d = dynamic_cast<QWidgetPrivate*>(rp()->rpPrivate());
|
||||
if (!d) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply aspect ratio.
|
||||
const auto max = std::max(size.width(), size.height());
|
||||
const auto scaled = (_ratio.width() > _ratio.height())
|
||||
? QSize(max, max * _ratio.height() / _ratio.width())
|
||||
: QSize(max * _ratio.width() / _ratio.height(), max);
|
||||
|
||||
// Buffer can't be bigger than surface size.
|
||||
const auto byWidth = (scaled.width() * size.height())
|
||||
> (scaled.height() * size.width());
|
||||
const auto normalized = (byWidth && scaled.width() > size.width())
|
||||
? QSize(size.width(), size.width() * scaled.height() / scaled.width())
|
||||
: (!byWidth && scaled.height() > size.height())
|
||||
? QSize(
|
||||
size.height() * scaled.width() / scaled.height(),
|
||||
size.height())
|
||||
: scaled;
|
||||
|
||||
d->data.crect = QRect(d->data.crect.topLeft(), normalized);
|
||||
|
||||
#ifdef QT_WAYLAND_EGL_CLIENT_HW_INTEGRATION_LIB
|
||||
using QtWaylandClient::QWaylandEglWindow;
|
||||
if (const auto waylandEglWindow = dynamic_cast<QWaylandEglWindow*>(
|
||||
widget()->windowHandle()->handle())) {
|
||||
waylandEglWindow->ensureSize();
|
||||
}
|
||||
#endif // QT_WAYLAND_EGL_CLIENT_HW_INTEGRATION_LIB
|
||||
}
|
||||
|
||||
void PipPanel::handleMousePress(QPoint position, Qt::MouseButton button) {
|
||||
if (button != Qt::LeftButton) {
|
||||
return;
|
||||
|
@ -904,6 +953,11 @@ void Pip::setupPanel() {
|
|||
break;
|
||||
}
|
||||
}, _panel.rp()->lifetime());
|
||||
|
||||
_panel.rp()->sizeValue(
|
||||
) | rpl::start_with_next([=](QSize size) {
|
||||
_panel.handleResize(size);
|
||||
}, _panel.rp()->lifetime());
|
||||
}
|
||||
|
||||
void Pip::handleClose() {
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
void setDragDisabled(bool disabled);
|
||||
[[nodiscard]] bool dragging() const;
|
||||
|
||||
void handleResize(QSize size);
|
||||
void handleMousePress(QPoint position, Qt::MouseButton button);
|
||||
void handleMouseRelease(QPoint position, Qt::MouseButton button);
|
||||
void handleMouseMove(QPoint position);
|
||||
|
|
|
@ -491,6 +491,7 @@ void start() {
|
|||
LOG(("Launcher filename: %1").arg(QGuiApplication::desktopFileName()));
|
||||
|
||||
#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||
qputenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION", "desktop-app-wayland-egl");
|
||||
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "desktop-app-xdg-shell;xdg-shell");
|
||||
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||
|
||||
|
@ -627,6 +628,13 @@ namespace ThirdParty {
|
|||
void start() {
|
||||
LOG(("Icon theme: %1").arg(QIcon::themeName()));
|
||||
LOG(("Fallback icon theme: %1").arg(QIcon::fallbackThemeName()));
|
||||
|
||||
#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||
InvokeQueued(qApp, [] {
|
||||
qunsetenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION");
|
||||
qunsetenv("QT_WAYLAND_SHELL_INTEGRATION");
|
||||
});
|
||||
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
||||
}
|
||||
|
||||
void finish() {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f27d756bcd7508250a3f7ff73bf6053308c18cd6
|
||||
Subproject commit 303947c78c27d8322dd1b9a6796a2eb13c0ba78a
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
|||
Subproject commit d8442d4d968f55e8804fea3cc2d2d84f60595982
|
||||
Subproject commit 3e6a8fc1924bea4d886867515b56003c88287867
|
Loading…
Add table
Reference in a new issue