parent
					
						
							
								e3bad233e9
							
						
					
				
			
			
				commit
				
					
						335cd79b37
					
				
			
		
					 1 changed files with 27 additions and 7 deletions
				
			
		| 
						 | 
					@ -2,21 +2,41 @@
 | 
				
			||||||
// Use of this source code is governed by the MIT license that can be
 | 
					// Use of this source code is governed by the MIT license that can be
 | 
				
			||||||
// found in the LICENSE file.
 | 
					// found in the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "atom/browser/browser.h"
 | 
				
			||||||
#include "atom/common/native_mate_converters/gfx_converter.h"
 | 
					#include "atom/common/native_mate_converters/gfx_converter.h"
 | 
				
			||||||
#include "atom/common/node_includes.h"
 | 
					#include "atom/common/node_includes.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace {
 | 
					namespace {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char* kRequireAppReadyMessage =
 | 
				
			||||||
 | 
					    "APIs of \"screen\" module can only be used after the \"ready\" event of "
 | 
				
			||||||
 | 
					    "\"app\" module gets emitted.";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					gfx::Point GetCursorScreenPoint(mate::Arguments* args) {
 | 
				
			||||||
 | 
					  if (!atom::Browser::Get()->is_ready()) {
 | 
				
			||||||
 | 
					    args->ThrowError(kRequireAppReadyMessage);
 | 
				
			||||||
 | 
					    return gfx::Point();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gfx::Screen* screen = gfx::Screen::GetNativeScreen();
 | 
				
			||||||
 | 
					  return screen->GetCursorScreenPoint();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					gfx::Display GetPrimaryDisplay(mate::Arguments* args) {
 | 
				
			||||||
 | 
					  if (!atom::Browser::Get()->is_ready()) {
 | 
				
			||||||
 | 
					    args->ThrowError(kRequireAppReadyMessage);
 | 
				
			||||||
 | 
					    return gfx::Display();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  gfx::Screen* screen = gfx::Screen::GetNativeScreen();
 | 
				
			||||||
 | 
					  return screen->GetPrimaryDisplay();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
 | 
					void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
 | 
				
			||||||
                v8::Handle<v8::Context> context, void* priv) {
 | 
					                v8::Handle<v8::Context> context, void* priv) {
 | 
				
			||||||
  gfx::Screen* screen = gfx::Screen::GetNativeScreen();
 | 
					 | 
				
			||||||
  mate::Dictionary dict(context->GetIsolate(), exports);
 | 
					  mate::Dictionary dict(context->GetIsolate(), exports);
 | 
				
			||||||
  dict.SetMethod("getCursorScreenPoint",
 | 
					  dict.SetMethod("getCursorScreenPoint", &GetCursorScreenPoint);
 | 
				
			||||||
                 base::Bind(&gfx::Screen::GetCursorScreenPoint,
 | 
					  dict.SetMethod("getPrimaryDisplay", &GetPrimaryDisplay);
 | 
				
			||||||
                            base::Unretained(screen)));
 | 
					 | 
				
			||||||
  dict.SetMethod("getPrimaryDisplay",
 | 
					 | 
				
			||||||
                 base::Bind(&gfx::Screen::GetPrimaryDisplay,
 | 
					 | 
				
			||||||
                            base::Unretained(screen)));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}  // namespace
 | 
					}  // namespace
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue