Workaround menu click-through on macOS 14.1.

This commit is contained in:
John Preston 2023-11-07 12:39:17 +04:00
parent 0837a6364d
commit d28afffcb9
5 changed files with 25 additions and 0 deletions

View file

@ -29,6 +29,9 @@ inline void UpdateOverlayed(not_null<QWidget*> widget) {
inline void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
}
inline void AcceptAllMouseInput(not_null<QWidget*> widget) {
}
inline void DisableSystemWindowResize(not_null<QWidget*> widget, QSize ratio) {
}

View file

@ -77,6 +77,23 @@ void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
}
}
void AcceptAllMouseInput(not_null<QWidget*> widget) {
// https://github.com/telegramdesktop/tdesktop/issues/27025
//
// By default system clicks through fully transparent pixels,
// and starting with macOS 14.1 it counts the transparency
// incorrectly (as if `y` is mirrored), so when clicking
// on a reactions strip outside of the menu column the click
// is ignored and made on the underlying window, because at the
// bottom of the menu in the same place there is nothing, empty.
//
// We explicitly request all the input to disable this behavior.
//
// See https://stackoverflow.com/a/29451199 and comments.
NSWindow *window = [reinterpret_cast<NSView*>(widget->winId()) window];
[window setIgnoresMouseEvents:NO];
}
void DrainMainQueue() {
#ifndef OS_MAC_STORE
_dispatch_main_queue_callback_4CF(nullptr);

View file

@ -28,6 +28,7 @@ void UpdateOverlayed(not_null<QWidget*> widget);
void ShowOverAll(not_null<QWidget*> widget, bool canFocus = true);
void IgnoreAllActivation(not_null<QWidget*> widget);
void ClearTransientParent(not_null<QWidget*> widget);
void AcceptAllMouseInput(not_null<QWidget*> widget);
void DisableSystemWindowResize(not_null<QWidget*> widget, QSize ratio);

View file

@ -32,6 +32,9 @@ inline void ReInitOnTopPanel(not_null<QWidget*> panel) {
inline void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
}
inline void AcceptAllMouseInput(not_null<QWidget*> widget) {
}
inline void ClearTransientParent(not_null<QWidget*> widget) {
}

View file

@ -490,6 +490,7 @@ void PopupMenu::paintEvent(QPaintEvent *e) {
PostponeCall(this, [=] {
showChildren();
_animatePhase = AnimatePhase::Shown;
Platform::AcceptAllMouseInput(this);
});
} else {
paintBg(p);