mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 "core/application.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/power_save_blocker.h"
|
#include "base/power_save_blocker.h"
|
||||||
#include "base/event_filter.h"
|
|
||||||
#include "ui/platform/ui_platform_utility.h"
|
#include "ui/platform/ui_platform_utility.h"
|
||||||
#include "ui/platform/ui_platform_window_title.h"
|
#include "ui/platform/ui_platform_window_title.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
@ -351,7 +350,6 @@ void PipPanel::init() {
|
||||||
widget()->setMouseTracking(true);
|
widget()->setMouseTracking(true);
|
||||||
widget()->resize(0, 0);
|
widget()->resize(0, 0);
|
||||||
widget()->hide();
|
widget()->hide();
|
||||||
widget()->createWinId();
|
|
||||||
|
|
||||||
rp()->shownValue(
|
rp()->shownValue(
|
||||||
) | rpl::filter([=](bool shown) {
|
) | rpl::filter([=](bool shown) {
|
||||||
|
@ -368,30 +366,9 @@ void PipPanel::init() {
|
||||||
|
|
||||||
if (Platform::IsWayland()) {
|
if (Platform::IsWayland()) {
|
||||||
rp()->sizeValue(
|
rp()->sizeValue(
|
||||||
) | rpl::start_with_next([=](QSize size) {
|
) | rpl::skip(1) | rpl::start_with_next([=](QSize size) {
|
||||||
handleWaylandResize(size);
|
handleWaylandResize(size);
|
||||||
}, rp()->lifetime());
|
}, 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) {
|
void PipPanel::handleWaylandResize(QSize size) {
|
||||||
|
if (_inHandleWaylandResize) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_inHandleWaylandResize = true;
|
_inHandleWaylandResize = true;
|
||||||
_suggestedWaylandSize = size;
|
|
||||||
|
|
||||||
// Apply aspect ratio.
|
// Apply aspect ratio.
|
||||||
const auto max = std::max(size.width(), size.height());
|
const auto max = std::max(size.width(), size.height());
|
||||||
|
@ -632,6 +611,8 @@ void PipPanel::handleWaylandResize(QSize size) {
|
||||||
: scaled;
|
: scaled;
|
||||||
|
|
||||||
widget()->resize(normalized);
|
widget()->resize(normalized);
|
||||||
|
QResizeEvent e(normalized, size);
|
||||||
|
QCoreApplication::sendEvent(widget()->windowHandle(), &e);
|
||||||
_inHandleWaylandResize = false;
|
_inHandleWaylandResize = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,6 @@ private:
|
||||||
bool _useTransparency = true;
|
bool _useTransparency = true;
|
||||||
bool _dragDisabled = false;
|
bool _dragDisabled = false;
|
||||||
bool _inHandleWaylandResize = false;
|
bool _inHandleWaylandResize = false;
|
||||||
QSize _suggestedWaylandSize;
|
|
||||||
style::margins _padding;
|
style::margins _padding;
|
||||||
|
|
||||||
RectPart _overState = RectPart();
|
RectPart _overState = RectPart();
|
||||||
|
|
Loading…
Add table
Reference in a new issue