'common/api/lib/clipboard.coffee',
'common/api/lib/crash-reporter.coffee',
'common/api/lib/id-weak-map.coffee',
+ 'common/api/lib/screen.coffee',
'common/api/lib/shell.coffee',
'renderer/lib/init.coffee',
'renderer/api/lib/ipc.coffee',
'common/api/atom_api_event_emitter.h',
'common/api/atom_api_id_weak_map.cc',
'common/api/atom_api_id_weak_map.h',
+ 'common/api/atom_api_screen.cc',
+ 'common/api/atom_api_screen.h',
'common/api/atom_api_shell.cc',
'common/api/atom_api_shell.h',
'common/api/atom_api_v8_util.cc',
--- /dev/null
+// Copyright (c) 2013 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "common/api/atom_api_screen.h"
+
+#include "common/v8/native_type_conversions.h"
+#include "ui/gfx/screen.h"
+
+#include "common/v8/node_common.h"
+
+#define UNWRAP_SCREEN_AND_CHECK \
+ Screen* self = ObjectWrap::Unwrap<Screen>(args.This()); \
+ if (self == NULL) \
+ return node::ThrowError("Screen is already destroyed")
+
+namespace atom {
+
+namespace api {
+
+Screen::Screen(v8::Handle<v8::Object> wrapper)
+ : EventEmitter(wrapper),
+ screen_(gfx::Screen::GetNativeScreen()) {
+}
+
+Screen::~Screen() {
+}
+
+// static
+void Screen::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::HandleScope scope(args.GetIsolate());
+
+ if (!args.IsConstructCall())
+ return node::ThrowError("Require constructor call");
+
+ new Screen(args.This());
+}
+
+// static
+void Screen::GetCursorScreenPoint(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ UNWRAP_SCREEN_AND_CHECK;
+ args.GetReturnValue().Set(ToV8Value(self->screen_->GetCursorScreenPoint()));
+}
+
+// static
+void Screen::Initialize(v8::Handle<v8::Object> target) {
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
+
+ v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
+ t->InstanceTemplate()->SetInternalFieldCount(1);
+ t->SetClassName(v8::String::NewSymbol("Screen"));
+
+ NODE_SET_PROTOTYPE_METHOD(t, "getCursorScreenPoint", GetCursorScreenPoint);
+
+ target->Set(v8::String::NewSymbol("Screen"), t->GetFunction());
+}
+
+} // namespace api
+
+} // namespace atom
+
+NODE_MODULE(atom_common_screen, atom::api::Screen::Initialize)
--- /dev/null
+// Copyright (c) 2013 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_COMMON_API_ATOM_API_SCREEN_H_
+#define ATOM_COMMON_API_ATOM_API_SCREEN_H_
+
+#include "common/api/atom_api_event_emitter.h"
+
+namespace gfx {
+class Screen;
+}
+
+namespace atom {
+
+namespace api {
+
+class Screen : public EventEmitter {
+ public:
+ virtual ~Screen();
+
+ static void Initialize(v8::Handle<v8::Object> target);
+
+ protected:
+ explicit Screen(v8::Handle<v8::Object> wrapper);
+
+ private:
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
+
+ static void GetCursorScreenPoint(
+ const v8::FunctionCallbackInfo<v8::Value>& args);
+
+ gfx::Screen* screen_;
+
+ DISALLOW_COPY_AND_ASSIGN(Screen);
+};
+
+} // namespace api
+
+} // namespace atom
+
+#endif // ATOM_COMMON_API_ATOM_API_SCREEN_H_
NODE_EXT_LIST_ITEM(atom_common_clipboard)
NODE_EXT_LIST_ITEM(atom_common_crash_reporter)
NODE_EXT_LIST_ITEM(atom_common_id_weak_map)
+NODE_EXT_LIST_ITEM(atom_common_screen)
NODE_EXT_LIST_ITEM(atom_common_shell)
NODE_EXT_LIST_ITEM(atom_common_v8_util)
--- /dev/null
+{Screen} = process.atomBinding 'screen'
+
+module.exports = new Screen
--- /dev/null
+assert = require 'assert'
+screen = require 'screen'
+
+describe 'screen module', ->
+ describe 'screen.getCursorScreenPoint()', ->
+ it 'returns a point object', ->
+ point = screen.getCursorScreenPoint()
+ assert typeof(point.x), 'number'
+ assert typeof(point.y), 'number'