This repository was archived by the owner on Jan 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
Mac async popup #161
Merged
Merged
Mac async popup #161
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,28 @@ | |
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <memory> | ||
|
||
#include "atom/browser/api/atom_api_menu_views.h" | ||
|
||
#include "atom/browser/native_window_views.h" | ||
#include "atom/browser/unresponsive_suppressor.h" | ||
#include "content/public/browser/render_widget_host_view.h" | ||
#include "ui/display/screen.h" | ||
#include "ui/views/controls/menu/menu_runner.h" | ||
|
||
using views::MenuRunner; | ||
|
||
namespace atom { | ||
|
||
namespace api { | ||
|
||
MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) | ||
: Menu(isolate, wrapper) { | ||
: Menu(isolate, wrapper), | ||
weak_factory_(this) { | ||
} | ||
|
||
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) { | ||
void MenuViews::PopupAt( | ||
Window* window, int x, int y, int positioning_item) { | ||
NativeWindow* native_window = static_cast<NativeWindow*>(window->window()); | ||
if (!native_window) | ||
return; | ||
|
@@ -38,21 +43,32 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) { | |
location = gfx::Point(origin.x() + x, origin.y() + y); | ||
} | ||
|
||
int flags = MenuRunner::CONTEXT_MENU | | ||
MenuRunner::HAS_MNEMONICS | | ||
MenuRunner::ASYNC; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ASYNC flag is redundant since 59 |
||
|
||
// Don't emit unresponsive event when showing menu. | ||
atom::UnresponsiveSuppressor suppressor; | ||
|
||
// Show the menu. | ||
views::MenuRunner menu_runner( | ||
model(), | ||
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS); | ||
ignore_result(menu_runner.RunMenuAt( | ||
int32_t window_id = window->ID(); | ||
auto close_callback = base::Bind( | ||
&MenuViews::ClosePopupAt, weak_factory_.GetWeakPtr(), window_id); | ||
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner( | ||
model(), flags, close_callback)); | ||
ignore_result(menu_runners_[window_id]->RunMenuAt( | ||
static_cast<NativeWindowViews*>(window->window())->widget(), | ||
NULL, | ||
gfx::Rect(location, gfx::Size()), | ||
views::MENU_ANCHOR_TOPLEFT, | ||
ui::MENU_SOURCE_MOUSE)); | ||
} | ||
|
||
void MenuViews::ClosePopupAt(int32_t window_id) { | ||
menu_runners_.erase(window_id); | ||
Destroy(); | ||
} | ||
|
||
// static | ||
mate::WrappableBase* Menu::New(mate::Arguments* args) { | ||
return new MenuViews(args->isolate(), args->GetThis()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -330,7 +330,8 @@ void URLBindings::Parse( | |
GURL gurl(url_string); | ||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); | ||
if (gurl.has_username()) | ||
dict.Set("auth", gurl.username() + (gurl.has_password() ? ":" + gurl.password() : "")); | ||
dict.Set("auth", gurl.username() + (gurl.has_password() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just saw this now- this just moves part of it onto the next line (since it went over 80 chars length, lint failed) |
||
? ":" + gurl.password() : "")); | ||
dict.Set("hash", gurl.ref()); | ||
dict.Set("hostname", gurl.host()); | ||
dict.Set("host", gurl.host() + ":" + gurl.port()); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes- it's needed per the comment here:
#161 (comment)