electron/atom/browser/api/atom_api_screen.cc

33 lines
1.2 KiB
C++
Raw Normal View History

// Copyright (c) 2013 GitHub, Inc.
2014-04-25 09:49:37 +00:00
// Use of this source code is governed by the MIT license that can be
2014-01-07 12:00:25 +00:00
// found in the LICENSE file.
2014-10-24 04:48:52 +00:00
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "base/bind.h"
#include "native_mate/dictionary.h"
#include "ui/gfx/screen.h"
#include "atom/common/node_includes.h"
2014-01-07 12:00:25 +00:00
namespace {
2014-01-07 12:15:55 +00:00
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
2015-01-14 00:28:12 +00:00
auto screen = base::Unretained(gfx::Screen::GetNativeScreen());
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("getCursorScreenPoint",
2015-01-14 00:28:12 +00:00
base::Bind(&gfx::Screen::GetCursorScreenPoint, screen));
dict.SetMethod("getPrimaryDisplay",
2015-01-14 00:28:12 +00:00
base::Bind(&gfx::Screen::GetPrimaryDisplay, screen));
dict.SetMethod("getAllDisplays",
base::Bind(&gfx::Screen::GetAllDisplays, screen));
dict.SetMethod("getDisplayNearestPoint",
base::Bind(&gfx::Screen::GetDisplayNearestPoint, screen));
dict.SetMethod("getDisplayMatching",
base::Bind(&gfx::Screen::GetDisplayMatching, screen));
2014-01-07 12:00:25 +00:00
}
} // namespace
2014-01-07 12:00:25 +00:00
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_screen, Initialize)