feat: add force option to app.focus() (#22612)
This commit is contained in:
parent
75cef84877
commit
b724fbc0ed
5 changed files with 26 additions and 6 deletions
|
@ -21,6 +21,8 @@
|
|||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "shell/common/gin_helper/arguments.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/error_thrower.h"
|
||||
#include "shell/common/gin_helper/promise.h"
|
||||
#include "shell/common/platform_util.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
@ -32,8 +34,20 @@ void Browser::SetShutdownHandler(base::Callback<bool()> handler) {
|
|||
[[AtomApplication sharedApplication] setShutdownHandler:std::move(handler)];
|
||||
}
|
||||
|
||||
void Browser::Focus() {
|
||||
[[AtomApplication sharedApplication] activateIgnoringOtherApps:NO];
|
||||
void Browser::Focus(gin_helper::Arguments* args) {
|
||||
gin_helper::Dictionary opts;
|
||||
bool steal_focus = false;
|
||||
|
||||
if (args->GetNext(&opts)) {
|
||||
gin_helper::ErrorThrower thrower(args->isolate());
|
||||
if (!opts.Get("steal", &steal_focus)) {
|
||||
thrower.ThrowError(
|
||||
"Expected options object to contain a 'steal' boolean property");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[[AtomApplication sharedApplication] activateIgnoringOtherApps:steal_focus];
|
||||
}
|
||||
|
||||
void Browser::Hide() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue