mirror of https://github.com/procxx/kepka.git
Don't show PopupMenu for inactive window on macOS.
This is a fixup for 06bf67c146
.
This commit is contained in:
parent
4e0e472f97
commit
c8aa35d23c
|
@ -47,6 +47,10 @@ bool _psRunCommand(const QByteArray &command) {
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
|
bool IsApplicationActive() {
|
||||||
|
return static_cast<QApplication*>(QApplication::instance())->activeWindow() != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
QString CurrentExecutablePath(int argc, char *argv[]) {
|
QString CurrentExecutablePath(int argc, char *argv[]) {
|
||||||
constexpr auto kMaxPath = 1024;
|
constexpr auto kMaxPath = 1024;
|
||||||
char result[kMaxPath] = { 0 };
|
char result[kMaxPath] = { 0 };
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace Platform {
|
||||||
inline void SetWatchingMediaKeys(bool watching) {
|
inline void SetWatchingMediaKeys(bool watching) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsApplicationActive();
|
||||||
|
|
||||||
inline void StartTranslucentPaint(QPainter &p, QPaintEvent *e) {
|
inline void StartTranslucentPaint(QPainter &p, QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ namespace {
|
||||||
|
|
||||||
constexpr auto kIgnoreActivationTimeoutMs = 500;
|
constexpr auto kIgnoreActivationTimeoutMs = 500;
|
||||||
|
|
||||||
|
base::optional<bool> ApplicationIsActive;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
using Platform::Q2NSString;
|
using Platform::Q2NSString;
|
||||||
|
@ -85,6 +87,7 @@ using Platform::NS2QString;
|
||||||
- (BOOL) applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag;
|
- (BOOL) applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag;
|
||||||
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification;
|
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification;
|
||||||
- (void) applicationDidBecomeActive:(NSNotification *)aNotification;
|
- (void) applicationDidBecomeActive:(NSNotification *)aNotification;
|
||||||
|
- (void) applicationDidResignActive:(NSNotification *)aNotification;
|
||||||
- (void) receiveWakeNote:(NSNotification*)note;
|
- (void) receiveWakeNote:(NSNotification*)note;
|
||||||
|
|
||||||
- (void) setWatchingMediaKeys:(bool)watching;
|
- (void) setWatchingMediaKeys:(bool)watching;
|
||||||
|
@ -126,6 +129,7 @@ ApplicationDelegate *_sharedDelegate = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) applicationDidBecomeActive:(NSNotification *)aNotification {
|
- (void) applicationDidBecomeActive:(NSNotification *)aNotification {
|
||||||
|
ApplicationIsActive = true;
|
||||||
if (auto messenger = Messenger::InstancePointer()) {
|
if (auto messenger = Messenger::InstancePointer()) {
|
||||||
if (!_ignoreActivation) {
|
if (!_ignoreActivation) {
|
||||||
messenger->handleAppActivated();
|
messenger->handleAppActivated();
|
||||||
|
@ -138,6 +142,10 @@ ApplicationDelegate *_sharedDelegate = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) applicationDidResignActive:(NSNotification *)aNotification {
|
||||||
|
ApplicationIsActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) receiveWakeNote:(NSNotification*)aNotification {
|
- (void) receiveWakeNote:(NSNotification*)aNotification {
|
||||||
if (auto messenger = Messenger::InstancePointer()) {
|
if (auto messenger = Messenger::InstancePointer()) {
|
||||||
messenger->checkLocalTime();
|
messenger->checkLocalTime();
|
||||||
|
@ -187,6 +195,12 @@ void SetWatchingMediaKeys(bool watching) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsApplicationActive() {
|
||||||
|
return ApplicationIsActive
|
||||||
|
? *ApplicationIsActive
|
||||||
|
: (static_cast<QApplication*>(QApplication::instance())->activeWindow() != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void InitOnTopPanel(QWidget *panel) {
|
void InitOnTopPanel(QWidget *panel) {
|
||||||
Expects(!panel->windowHandle());
|
Expects(!panel->windowHandle());
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ void start();
|
||||||
void finish();
|
void finish();
|
||||||
|
|
||||||
void SetWatchingMediaKeys(bool watching);
|
void SetWatchingMediaKeys(bool watching);
|
||||||
|
bool IsApplicationActive();
|
||||||
bool TranslucentWindowsSupported(QPoint globalPosition);
|
bool TranslucentWindowsSupported(QPoint globalPosition);
|
||||||
void StartTranslucentPaint(QPainter &p, QPaintEvent *e);
|
void StartTranslucentPaint(QPainter &p, QPaintEvent *e);
|
||||||
void InitOnTopPanel(QWidget *panel);
|
void InitOnTopPanel(QWidget *panel);
|
||||||
|
|
|
@ -332,6 +332,10 @@ QString SystemCountry() {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsApplicationActive() {
|
||||||
|
return static_cast<QApplication*>(QApplication::instance())->activeWindow() != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
QString CurrentExecutablePath(int argc, char *argv[]) {
|
QString CurrentExecutablePath(int argc, char *argv[]) {
|
||||||
WCHAR result[MAX_PATH + 1] = { 0 };
|
WCHAR result[MAX_PATH + 1] = { 0 };
|
||||||
auto count = GetModuleFileName(nullptr, result, MAX_PATH + 1);
|
auto count = GetModuleFileName(nullptr, result, MAX_PATH + 1);
|
||||||
|
|
|
@ -14,6 +14,8 @@ namespace Platform {
|
||||||
inline void SetWatchingMediaKeys(bool watching) {
|
inline void SetWatchingMediaKeys(bool watching) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsApplicationActive();
|
||||||
|
|
||||||
inline bool TranslucentWindowsSupported(QPoint globalPosition) {
|
inline bool TranslucentWindowsSupported(QPoint globalPosition) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
bool InactiveMacApplication() {
|
||||||
|
return (cPlatform() == dbipMac || cPlatform() == dbipMacOld)
|
||||||
|
&& !Platform::IsApplicationActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
PopupMenu::PopupMenu(QWidget *parent, const style::PopupMenu &st)
|
PopupMenu::PopupMenu(QWidget *parent, const style::PopupMenu &st)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
|
@ -423,11 +431,16 @@ void PopupMenu::popup(const QPoint &p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource source) {
|
void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource source) {
|
||||||
if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
|
if (!parent && InactiveMacApplication()) {
|
||||||
if (!parent && !static_cast<QApplication*>(QApplication::instance())->activeWindow()) {
|
_hiding = false;
|
||||||
crl::on_main(this, [=] { show(); hideFast(); });
|
_a_opacity.finish();
|
||||||
return;
|
_a_show.finish();
|
||||||
|
_cache = QPixmap();
|
||||||
|
hide();
|
||||||
|
if (_deleteOnHide) {
|
||||||
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue