mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Simplify PipPanel::handleWaylandResize
This commit is contained in:
parent
eea50ed6b0
commit
c1bc7e6ab1
2 changed files with 6 additions and 26 deletions
|
@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/application.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/power_save_blocker.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "ui/platform/ui_platform_utility.h"
|
||||
#include "ui/platform/ui_platform_window_title.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
|
@ -351,7 +350,6 @@ void PipPanel::init() {
|
|||
widget()->setMouseTracking(true);
|
||||
widget()->resize(0, 0);
|
||||
widget()->hide();
|
||||
widget()->createWinId();
|
||||
|
||||
rp()->shownValue(
|
||||
) | rpl::filter([=](bool shown) {
|
||||
|
@ -368,30 +366,9 @@ void PipPanel::init() {
|
|||
|
||||
if (Platform::IsWayland()) {
|
||||
rp()->sizeValue(
|
||||
) | rpl::start_with_next([=](QSize size) {
|
||||
) | rpl::skip(1) | rpl::start_with_next([=](QSize size) {
|
||||
handleWaylandResize(size);
|
||||
}, rp()->lifetime());
|
||||
|
||||
base::install_event_filter(widget(), [=](not_null<QEvent*> event) {
|
||||
if (event->type() == QEvent::Resize && _inHandleWaylandResize) {
|
||||
return base::EventFilterResult::Cancel;
|
||||
}
|
||||
return base::EventFilterResult::Continue;
|
||||
});
|
||||
|
||||
base::install_event_filter(widget()->windowHandle(), [=](not_null<QEvent*> event) {
|
||||
if (event->type() == QEvent::Resize) {
|
||||
if (_inHandleWaylandResize) {
|
||||
return base::EventFilterResult::Cancel;
|
||||
}
|
||||
const auto newSize = static_cast<QResizeEvent*>(event.get())->size();
|
||||
if (_suggestedWaylandSize == newSize) {
|
||||
handleWaylandResize(newSize);
|
||||
return base::EventFilterResult::Cancel;
|
||||
}
|
||||
}
|
||||
return base::EventFilterResult::Continue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,8 +587,10 @@ void PipPanel::setGeometry(QRect geometry) {
|
|||
}
|
||||
|
||||
void PipPanel::handleWaylandResize(QSize size) {
|
||||
if (_inHandleWaylandResize) {
|
||||
return;
|
||||
}
|
||||
_inHandleWaylandResize = true;
|
||||
_suggestedWaylandSize = size;
|
||||
|
||||
// Apply aspect ratio.
|
||||
const auto max = std::max(size.width(), size.height());
|
||||
|
@ -632,6 +611,8 @@ void PipPanel::handleWaylandResize(QSize size) {
|
|||
: scaled;
|
||||
|
||||
widget()->resize(normalized);
|
||||
QResizeEvent e(normalized, size);
|
||||
QCoreApplication::sendEvent(widget()->windowHandle(), &e);
|
||||
_inHandleWaylandResize = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,6 @@ private:
|
|||
bool _useTransparency = true;
|
||||
bool _dragDisabled = false;
|
||||
bool _inHandleWaylandResize = false;
|
||||
QSize _suggestedWaylandSize;
|
||||
style::margins _padding;
|
||||
|
||||
RectPart _overState = RectPart();
|
||||
|
|
Loading…
Add table
Reference in a new issue