Skip to content

Commit

Permalink
Support external menu content without enabled compositing.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Sep 2, 2022
1 parent 746eb80 commit f420e30
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ui/widgets/popup_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,14 @@ void PopupMenu::init() {
hide();

setAttribute(Qt::WA_NoSystemBackground, true);
setAttribute(Qt::WA_TranslucentBackground, true);

_useTransparency = Platform::TranslucentWindowsSupported();
if (_useTransparency) {
setAttribute(Qt::WA_TranslucentBackground, true);
} else {
setAttribute(Qt::WA_TranslucentBackground, false);
setAttribute(Qt::WA_OpaquePaintEvent, true);
}
}

not_null<PopupMenu*> PopupMenu::ensureSubmenu(
Expand Down Expand Up @@ -297,12 +304,15 @@ void PopupMenu::checkSubmenuShow() {

void PopupMenu::validateCompositingSupport() {
const auto line = st::lineWidth;
_useTransparency = Platform::TranslucentWindowsSupported();
const auto &additional = _additionalMenuPadding;
if (!_useTransparency) {
_padding = QMargins(line, line, line, line);
_padding = QMargins(
std::max(line, additional.left()),
std::max(line, additional.top()),
std::max(line, additional.right()),
std::max(line, additional.bottom()));
_extents = QMargins();
} else {
const auto &additional = _additionalMenuPadding;
_padding = QMargins(
std::max(_st.shadow.extend.left(), additional.left()),
std::max(_st.shadow.extend.top(), additional.top()),
Expand Down

0 comments on commit f420e30

Please sign in to comment.