Use native child window in group calls on Windows.

This commit is contained in:
John Preston 2021-06-20 10:36:23 +04:00
parent 858c575782
commit b70276912e
4 changed files with 68 additions and 15 deletions

View file

@ -1082,11 +1082,11 @@ groupCallMenuVolumePadding: margins(17px, 6px, 17px, 5px);
groupCallMenuVolumeMargin: margins(55px, 0px, 15px, 0px);
groupCallMenuVolumeSlider: MediaSlider(defaultContinuousSlider) {
activeFg: groupCallMembersFg;
inactiveFg: groupCallMemberInactiveIcon;
inactiveFg: groupCallMembersBgOver;
activeFgOver: groupCallMembersFg;
inactiveFgOver: groupCallMemberInactiveIcon;
activeFgDisabled: groupCallMemberInactiveIcon;
receivedTillFg: groupCallMemberInactiveIcon;
inactiveFgOver: groupCallMembersBgOver;
activeFgDisabled: groupCallMembersBgOver;
receivedTillFg: groupCallMembersBgOver;
width: 7px;
seekSize: size(7px, 7px);
}

View file

@ -76,6 +76,7 @@ constexpr auto kMicrophoneTooltipAfterLoudCount = 3;
constexpr auto kDropLoudAfterQuietCount = 5;
constexpr auto kMicrophoneTooltipLevelThreshold = 0.2;
constexpr auto kMicrophoneTooltipCheckInterval = crl::time(500);
constexpr auto kUseNativeChild = Platform::IsWindows();
} // namespace
@ -135,11 +136,13 @@ void Panel::MicLevelTester::check() {
Panel::Panel(not_null<GroupCall*> call)
: _call(call)
, _peer(call->peer())
, _window(createWindow())
, _layerBg(std::make_unique<Ui::LayerManager>(_window->body()))
, _window(std::make_unique<Ui::Window>())
, _nativeBodyWindow(createBodyWidget())
, _body(_nativeBodyWindow ? _nativeBodyWindow.get() : _window->body().get())
, _layerBg(std::make_unique<Ui::LayerManager>(widget()))
#ifndef Q_OS_MAC
, _controls(std::make_unique<Ui::Platform::TitleControls>(
_window->body(),
widget(),
st::groupCallTitle))
#endif // !Q_OS_MAC
, _viewport(std::make_unique<Viewport>(widget(), PanelMode::Wide, _backend))
@ -190,21 +193,68 @@ Panel::~Panel() {
std::unique_ptr<Ui::Window> Panel::createWindow() {
auto result = std::make_unique<Ui::Window>();
if constexpr (!kUseNativeChild) {
const auto capabilities = Ui::GL::CheckCapabilities(result.get());
const auto use = Platform::IsMac()
? true
: Platform::IsWindows()
? capabilities.supported
: capabilities.transparency;
LOG(("OpenGL: %1 (Calls::Group::Panel)").arg(Logs::b(use)));
_backend = use ? Ui::GL::Backend::OpenGL : Ui::GL::Backend::Raster;
if (!use) {
// We have to create a new window, if OpenGL initialization failed.
result = std::make_unique<Ui::Window>();
}
}
return result;
}
std::unique_ptr<Ui::RpWidget> Panel::createBodyWidget() {
if constexpr (!kUseNativeChild) {
return nullptr;
}
const auto create = [] {
auto result = std::make_unique<Ui::RpWidget>();
result->setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
result->setAttribute(Qt::WA_NativeWindow);
result->setAttribute(Qt::WA_DontCreateNativeAncestors);
result->setAttribute(Qt::WA_OpaquePaintEvent);
result->setAttribute(Qt::WA_NoSystemBackground);
return result;
};
auto result = create();
const auto capabilities = Ui::GL::CheckCapabilities(result.get());
const auto use = Platform::IsMac()
? true
: Platform::IsWindows()
? capabilities.supported
: capabilities.transparency;
LOG(("OpenGL: %1 (Calls::Group::Viewport)").arg(Logs::b(use)));
LOG(("OpenGL: %1 (Calls::Group::Panel)").arg(Logs::b(use)));
_backend = use ? Ui::GL::Backend::OpenGL : Ui::GL::Backend::Raster;
if (use) {
return result;
if (!use) {
// We have to create a new window, if OpenGL initialization failed.
result = create();
}
// We have to create a new window, if OpenGL initialization failed.
return std::make_unique<Ui::Window>();
const auto raw = result.get();
raw->setParent(_window->body());
raw->show();
raw->update();
_window->sizeValue(
) | rpl::start_with_next([=](QSize size) {
raw->setGeometry(QRect(QPoint(), size));
}, raw->lifetime());
_window->body()->paintRequest(
) | rpl::start_with_next([=](QRect clip) {
QPainter(_window->body()).fillRect(clip, QColor(255, 0, 0));
}, _window->body()->lifetime());
return result;
}
void Panel::setupRealCallViewers() {
@ -2234,7 +2284,7 @@ bool Panel::handleClose() {
}
not_null<Ui::RpWidget*> Panel::widget() const {
return _window->body();
return _body.get();
}
} // namespace Calls::Group

View file

@ -97,7 +97,8 @@ private:
};
class MicLevelTester;
std::unique_ptr<Ui::Window> createWindow();
[[nodiscard]] std::unique_ptr<Ui::Window> createWindow();
[[nodiscard]] std::unique_ptr<Ui::RpWidget> createBodyWidget();
[[nodiscard]] not_null<Ui::RpWidget*> widget() const;
[[nodiscard]] PanelMode mode() const;
@ -179,6 +180,8 @@ private:
Ui::GL::Backend _backend = Ui::GL::Backend();
const std::unique_ptr<Ui::Window> _window;
const std::unique_ptr<Ui::RpWidget> _nativeBodyWindow;
const not_null<Ui::RpWidget*> _body;
const std::unique_ptr<Ui::LayerManager> _layerBg;
rpl::variable<PanelMode> _mode;

@ -1 +1 @@
Subproject commit 825ef11f1a5c6b00cd571c24525c84dca431eaa2
Subproject commit bd989cb67f5076b07556e8422cf6f8be6ba8d8ae