return window_->IsVisibleOnAllWorkspaces();
}
+int32_t Window::ID() const {
+ return weak_map_id();
+}
+
v8::Local<v8::Value> Window::WebContents(v8::Isolate* isolate) {
if (web_contents_.IsEmpty()) {
auto handle =
.SetMethod("showDefinitionForSelection",
&Window::ShowDefinitionForSelection)
#endif
+ .SetProperty("id", &Window::ID)
.SetProperty("webContents", &Window::WebContents)
.SetProperty("devToolsWebContents", &Window::DevToolsWebContents);
}
namespace {
+using atom::api::Window;
+
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
- using atom::api::Window;
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Function> constructor = mate::CreateConstructor<Window>(
isolate, "BrowserWindow", base::Bind(&Window::New));
+ mate::Dictionary browser_window(isolate, constructor);
+ browser_window.SetMethod("fromId", &mate::TrackableObject::FromWeakMapID);
+
mate::Dictionary dict(isolate, exports);
- dict.Set("BrowserWindow", static_cast<v8::Local<v8::Value>>(constructor));
+ dict.Set("BrowserWindow", browser_window);
}
} // namespace
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/image/image.h"
+#include "atom/browser/api/trackable_object.h"
#include "atom/browser/native_window_observer.h"
-#include "atom/browser/api/event_emitter.h"
#include "native_mate/handle.h"
class GURL;
class WebContents;
-class Window : public mate::EventEmitter,
+class Window : public mate::TrackableObject,
public NativeWindowObserver {
public:
static mate::Wrappable* New(v8::Isolate* isolate,
void SetVisibleOnAllWorkspaces(bool visible);
bool IsVisibleOnAllWorkspaces();
+ int32_t ID() const;
v8::Local<v8::Value> WebContents(v8::Isolate* isolate);
v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate);
menu = app.getApplicationMenu()
@setMenu menu if menu?
- # Remember the window ID.
- Object.defineProperty this, 'id',
- value: BrowserWindow.windows.add(this)
- enumerable: true
-
# Make new windows requested by links behave like "window.open"
@on '-new-window', (event, url, frameName) =>
event.sender = @webContents
windows = BrowserWindow.getAllWindows()
return window for window in windows when window.devToolsWebContents?.equal webContents
-BrowserWindow.fromId = (id) ->
- BrowserWindow.windows.get id if BrowserWindow.windows.has id
-
# Helpers.
BrowserWindow::loadUrl = -> @webContents.loadUrl.apply @webContents, arguments
BrowserWindow::send = -> @webContents.send.apply @webContents, arguments
-Subproject commit cad1fa50a95ca4185c435846e4868d5bd6cc94df
+Subproject commit cc4e2fcd94b5a22e6720f0fba1c586a89640f1f6