Cache title controls layout value
So it's not requested on every window width change and etc...
This commit is contained in:
parent
c3aab1bd14
commit
6abad69ca6
5 changed files with 35 additions and 12 deletions
|
|
@ -548,6 +548,8 @@ void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
|
|||
}
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
TitleControls::Layout TitleControlsLayout() {
|
||||
[[maybe_unused]] static const auto Inited = [] {
|
||||
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||
|
|
@ -634,5 +636,6 @@ TitleControls::Layout TitleControlsLayout() {
|
|||
};
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace Platform
|
||||
} // namespace Ui
|
||||
|
|
|
|||
|
|
@ -147,6 +147,8 @@ std::optional<bool> IsOverlapped(
|
|||
return false;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
TitleControls::Layout TitleControlsLayout() {
|
||||
return TitleControls::Layout{
|
||||
.left = {
|
||||
|
|
@ -157,5 +159,6 @@ TitleControls::Layout TitleControlsLayout() {
|
|||
};
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace Platform
|
||||
} // namespace Ui
|
||||
|
|
|
|||
|
|
@ -8,26 +8,33 @@
|
|||
|
||||
namespace Ui {
|
||||
namespace Platform {
|
||||
namespace internal {
|
||||
namespace {
|
||||
|
||||
rpl::event_stream<TitleControls::Layout> TitleControlsLayoutChanges;
|
||||
auto &CachedTitleControlsLayout() {
|
||||
using Layout = TitleControls::Layout;
|
||||
static rpl::variable<Layout> Result = TitleControlsLayout();
|
||||
return Result;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void NotifyTitleControlsLayoutChanged() {
|
||||
CachedTitleControlsLayout() = TitleControlsLayout();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
TitleControls::Layout TitleControlsLayout() {
|
||||
return internal::CachedTitleControlsLayout().current();
|
||||
}
|
||||
|
||||
rpl::producer<TitleControls::Layout> TitleControlsLayoutValue() {
|
||||
return rpl::single(
|
||||
TitleControlsLayout()
|
||||
) | rpl::then(
|
||||
TitleControlsLayoutChanged()
|
||||
);
|
||||
return internal::CachedTitleControlsLayout().value();
|
||||
}
|
||||
|
||||
rpl::producer<TitleControls::Layout> TitleControlsLayoutChanged() {
|
||||
return TitleControlsLayoutChanges.events();
|
||||
}
|
||||
|
||||
void NotifyTitleControlsLayoutChanged() {
|
||||
TitleControlsLayoutChanges.fire_copy(TitleControlsLayout());
|
||||
return internal::CachedTitleControlsLayout().changes();
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@ class PopupMenu;
|
|||
} // namespace Ui
|
||||
|
||||
namespace Ui::Platform {
|
||||
namespace internal {
|
||||
|
||||
// Actual requestor, cached by the public interface
|
||||
[[nodiscard]] TitleControls::Layout TitleControlsLayout();
|
||||
void NotifyTitleControlsLayoutChanged();
|
||||
|
||||
} // namespace internal
|
||||
|
||||
[[nodiscard]] bool IsApplicationActive();
|
||||
|
||||
|
|
@ -48,7 +55,6 @@ void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point);
|
|||
[[nodiscard]] TitleControls::Layout TitleControlsLayout();
|
||||
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutValue();
|
||||
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutChanged();
|
||||
void NotifyTitleControlsLayoutChanged();
|
||||
|
||||
void FixPopupMenuNativeEmojiPopup(not_null<PopupMenu*> menu);
|
||||
|
||||
|
|
|
|||
|
|
@ -134,6 +134,8 @@ void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
|
|||
MAKELPARAM(p.x, p.y));
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
TitleControls::Layout TitleControlsLayout() {
|
||||
return TitleControls::Layout{
|
||||
.right = {
|
||||
|
|
@ -144,6 +146,8 @@ TitleControls::Layout TitleControlsLayout() {
|
|||
};
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
void FixPopupMenuNativeEmojiPopup(not_null<PopupMenu*> menu) {
|
||||
// Windows native emoji selector, that can be called by Win+. shortcut,
|
||||
// is behaving strangely within an input field in a popup menu.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue