|
7 | 7 | #include "mouse.h"
|
8 | 8 | #include "screen.h"
|
9 | 9 | #include "screengrab.h"
|
| 10 | +#include "window_manager.h" |
10 | 11 |
|
11 | 12 | int mouseDelay = 10;
|
12 | 13 | int keyboardDelay = 10;
|
@@ -668,6 +669,32 @@ Napi::Number _highlight(const Napi::CallbackInfo &info)
|
668 | 669 | return Napi::Number::New(env, 1);
|
669 | 670 | }
|
670 | 671 |
|
| 672 | +Napi::Array _getWindows(const Napi::CallbackInfo &info) { |
| 673 | + Napi::Env env = info.Env(); |
| 674 | + |
| 675 | + std::vector<int32_t> windowHandles = getWindows(); |
| 676 | + auto arr = Napi::Array::New(env, windowHandles.size()); |
| 677 | + |
| 678 | + for (size_t idx = 0; idx < windowHandles.size(); ++idx) { |
| 679 | + arr[idx] = windowHandles[idx]; |
| 680 | + } |
| 681 | + |
| 682 | + return arr; |
| 683 | +} |
| 684 | + |
| 685 | +Napi::Object _getWindowRect(const Napi::CallbackInfo &info) { |
| 686 | + Napi::Env env = info.Env(); |
| 687 | + |
| 688 | + MMRect windowRect = getWindowRect(info[0].As<Napi::Number>().Int32Value()); |
| 689 | + Napi::Object obj = Napi::Object::New(env); |
| 690 | + obj.Set(Napi::String::New(env, "x"), Napi::Number::New(env, windowRect.origin.x)); |
| 691 | + obj.Set(Napi::String::New(env, "y"), Napi::Number::New(env, windowRect.origin.y)); |
| 692 | + obj.Set(Napi::String::New(env, "width"), Napi::Number::New(env, windowRect.size.width)); |
| 693 | + obj.Set(Napi::String::New(env, "height"), Napi::Number::New(env, windowRect.size.height)); |
| 694 | + |
| 695 | + return obj; |
| 696 | +} |
| 697 | + |
671 | 698 | Napi::Object _captureScreen(const Napi::CallbackInfo &info)
|
672 | 699 | {
|
673 | 700 | Napi::Env env = info.Env();
|
@@ -749,6 +776,8 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
749 | 776 |
|
750 | 777 | exports.Set(Napi::String::New(env, "getScreenSize"), Napi::Function::New(env, _getScreenSize));
|
751 | 778 | exports.Set(Napi::String::New(env, "highlight"), Napi::Function::New(env, _highlight));
|
| 779 | + exports.Set(Napi::String::New(env, "getWindows"), Napi::Function::New(env, _getWindows)); |
| 780 | + exports.Set(Napi::String::New(env, "getWindowRect"), Napi::Function::New(env, _getWindowRect)); |
752 | 781 | exports.Set(Napi::String::New(env, "captureScreen"), Napi::Function::New(env, _captureScreen));
|
753 | 782 | exports.Set(Napi::String::New(env, "getXDisplayName"), Napi::Function::New(env, _getXDisplayName));
|
754 | 783 | exports.Set(Napi::String::New(env, "setXDisplayName"), Napi::Function::New(env, _setXDisplayName));
|
|
0 commit comments