Skip to content

Commit

Permalink
improved window activation in os x
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Aug 12, 2015
1 parent 1b16064 commit afac237
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Telegram/SourceFiles/pspecific_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ void psClearInitLogs() {
}

void psActivateProcess(uint64 pid) {
objc_activateProgram();
if (!pid) {
objc_activateProgram(App::wnd() ? App::wnd()->winId() : 0);
}
}

QString psCurrentCountry() {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/pspecific_mac_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void objc_execTelegram();

void objc_registerCustomScheme();

void objc_activateProgram();
void objc_activateProgram(WId winId);
bool objc_moveFile(const QString &from, const QString &to);
void objc_deleteDir(const QString &dir);

Expand Down
6 changes: 5 additions & 1 deletion Telegram/SourceFiles/pspecific_mac_p.mm
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,12 @@ void objc_execTelegram() {
_execUpdater(NO);
}

void objc_activateProgram() {
void objc_activateProgram(WId winId) {
[NSApp activateIgnoringOtherApps:YES];
if (winId) {
NSWindow *w = [reinterpret_cast<NSView*>(winId) window];
[w makeKeyAndOrderFront:NSApp];
}
}

bool objc_moveFile(const QString &from, const QString &to) {
Expand Down

0 comments on commit afac237

Please sign in to comment.