xdotool 1.0.50 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.history/src/XdoTool_20220115190446.cpp +350 -0
- package/.history/src/XdoTool_20220115190504.cpp +350 -0
- package/.history/src/XdoTool_20220115190619.cpp +350 -0
- package/.history/src/tasks/ActivateWindow_20210721132815.h +15 -0
- package/.history/src/tasks/ActivateWindow_20210721133108.cpp +23 -0
- package/.history/src/tasks/ActivateWindow_20220115190504.cpp +23 -0
- package/.history/src/tasks/ActivateWindow_20220115190504.h +15 -0
- package/.history/src/tasks/ActivateWindow_20220115190527.h +19 -0
- package/.history/src/tasks/ActivateWindow_20220115190528.cpp +23 -0
- package/.history/src/tasks/GetViewportDimensions_20210721132156.h +17 -0
- package/.history/src/tasks/GetViewportDimensions_20210721132157.cpp +26 -0
- package/.history/src/tasks/GetViewportDimensions_20220115190619.cpp +26 -0
- package/.history/src/tasks/GetViewportDimensions_20220115190622.cpp +26 -0
- package/.history/src/tasks/GetViewportDimensions_20220115190623.h +21 -0
- package/CMakeLists.txt +9 -6
- package/build/cmake-js/CMakeFiles/3.22.1/CompilerIdC/CMakeCCompilerId.c +803 -0
- package/build/cmake-js/CMakeFiles/3.22.1/CompilerIdCXX/CMakeCXXCompilerId.cpp +791 -0
- package/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdC/CMakeCCompilerId.c +807 -0
- package/cmake-build-debug/CMakeFiles/3.21.1/CompilerIdCXX/CMakeCXXCompilerId.cpp +795 -0
- package/out/Keyboard.js +1 -1
- package/out/Screenshooter.d.ts +2 -2
- package/out/Screenshooter.d.ts.map +1 -1
- package/out/Screenshooter.js +3 -3
- package/out/xdo.d.ts +22 -12
- package/out/xdo.d.ts.map +1 -1
- package/out/xdo.js +12 -3
- package/package.json +2 -3
- package/src/Keyboard.cpp +6 -1
- package/src/Keyboard.h +1 -0
- package/src/Screenshooter.h +0 -2
- package/src/TypeConverter.cpp +10 -3
- package/src/TypeConverter.h +1 -0
- package/src/XService.cpp +0 -4
- package/src/XService.h +1 -2
- package/src/XdoTool.cpp +48 -8
- package/src/XdoTool.h +3 -0
- package/src/main.cpp +0 -1
- package/src/tasks/ActivateWindow.cpp +3 -3
- package/src/tasks/ActivateWindow.h +6 -2
- package/src/tasks/GetActiveKeysToKeycodeList.cpp +25 -0
- package/src/tasks/GetActiveKeysToKeycodeList.h +19 -0
- package/src/tasks/GetFocusedWindow.cpp +20 -0
- package/src/tasks/GetFocusedWindow.h +17 -0
- package/src/tasks/GetImage.cpp +1 -1
- package/src/tasks/GetViewportDimensions.cpp +3 -3
- package/src/tasks/GetViewportDimensions.h +6 -2
- package/src/tasks/GetWindowSize.cpp +19 -0
- package/src/tasks/GetWindowSize.h +22 -0
- package/src/tasks/QueryKeymap.cpp +1 -1
- package/src/tasks/Sync.cpp +17 -0
- package/src/tasks/Sync.h +19 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
#include "XdoTool.h"
|
|
2
|
+
#include "tasks/SearchWindows.h"
|
|
3
|
+
#include "tasks/GetMouseLocation.h"
|
|
4
|
+
#include "tasks/GetViewportDimensions.h"
|
|
5
|
+
#include "tasks/SendKeysequence.h"
|
|
6
|
+
#include "tasks/GetWindowPID.h"
|
|
7
|
+
#include "tasks/MoveMouse.h"
|
|
8
|
+
#include "tasks/ActivateWindow.h"
|
|
9
|
+
#include "tasks/EnterText.h"
|
|
10
|
+
#include "tasks/WindowHasProperty.h"
|
|
11
|
+
#include "ClassCreator.h"
|
|
12
|
+
#include "TypeConverter.h"
|
|
13
|
+
#include "XdoToolTaskWorker.h"
|
|
14
|
+
#include "tasks/Sync.h"
|
|
15
|
+
#include "tasks/GetFocusedWindow.h"
|
|
16
|
+
#include "tasks/GetWindowSize.h"
|
|
17
|
+
|
|
18
|
+
#include <iostream>
|
|
19
|
+
|
|
20
|
+
using v8::FunctionTemplate;
|
|
21
|
+
using v8::Function;
|
|
22
|
+
using v8::String;
|
|
23
|
+
using v8::Local;
|
|
24
|
+
using v8::Isolate;
|
|
25
|
+
using v8::Object;
|
|
26
|
+
using v8::Value;
|
|
27
|
+
using Nan::Set;
|
|
28
|
+
using Nan::To;
|
|
29
|
+
using Nan::GetCurrentContext;
|
|
30
|
+
using Nan::Callback;
|
|
31
|
+
using Nan::New;
|
|
32
|
+
using Nan::FunctionCallback;
|
|
33
|
+
|
|
34
|
+
Nan::Persistent<Function> XdoTool::constructor;
|
|
35
|
+
|
|
36
|
+
XdoTool::XdoTool(xdo_t* xdo): XService(xdo->xdpy), xdo(xdo) {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
XdoTool::~XdoTool() {
|
|
40
|
+
xdo_free(xdo);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
NAN_METHOD(XdoTool::GetViewportDimensions) {
|
|
44
|
+
int screen;
|
|
45
|
+
if(!TypeConverter::GetInt32(info[0], screen)){
|
|
46
|
+
Nan::ThrowError("First argument must be a valid integer");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
XdoTool* tool;
|
|
50
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
51
|
+
Nan::ThrowError("Method called in invalid context");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
auto task = new tasks::GetViewportDimensions(tool->xdo, screen);
|
|
55
|
+
auto callback = new Callback(To<Function>(info[1]).ToLocalChecked());
|
|
56
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
NAN_METHOD(XdoTool::GetWindowSize) {
|
|
60
|
+
XID window;
|
|
61
|
+
if(!TypeConverter::GetWindow(info[0], window)){
|
|
62
|
+
Nan::ThrowError("First argument must be a valid integer");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
XdoTool* tool;
|
|
66
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
67
|
+
Nan::ThrowError("Method called in invalid context");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
auto task = new tasks::GetWindowSize(tool->xdo, window);
|
|
71
|
+
auto callback = new Callback(To<Function>(info[1]).ToLocalChecked());
|
|
72
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
NAN_METHOD(XdoTool::SendKeysequence) {
|
|
76
|
+
XdoTool* tool = nullptr;
|
|
77
|
+
char* keySequence = nullptr;
|
|
78
|
+
Window window;
|
|
79
|
+
int32_t delay;
|
|
80
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
81
|
+
Nan::ThrowError("Method called in invalid context");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if(!TypeConverter::GetWindow(info[0],window)) {
|
|
85
|
+
Nan::ThrowError("First argument must be a valid window identifier");
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if(!TypeConverter::GetString(info[1], &keySequence)) {
|
|
89
|
+
Nan::ThrowError("Second parameter must be a valid string");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if(!TypeConverter::GetInt32(info[2], delay)) {
|
|
93
|
+
Nan::ThrowError("Third parameter must be a valid integer");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
auto callback = new Callback(To<Function>(info[3]).ToLocalChecked());
|
|
97
|
+
auto task = new XdoToolTask_SendKeysequence(tool->xdo, window, keySequence, delay);
|
|
98
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
NAN_METHOD(XdoTool::GetWindowPID) {
|
|
102
|
+
Window window;
|
|
103
|
+
if(!TypeConverter::GetWindow(info[0],window)) {
|
|
104
|
+
Nan::ThrowError("First argument must be a window");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
XdoTool* tool;
|
|
108
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
109
|
+
Nan::ThrowError("Method called in invalid context");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
auto task = new XdoToolTask_GetWindowPID(tool->xdo, window);
|
|
113
|
+
auto callback = new Callback(To<Function>(info[1]).ToLocalChecked());
|
|
114
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
NAN_METHOD(XdoTool::MoveMouse) {
|
|
118
|
+
if(info[0]->IsUndefined() || !info[0]->IsObject()) {
|
|
119
|
+
Nan::ThrowError("First argument must be a valid object");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
int x, y, screen = 0;
|
|
124
|
+
|
|
125
|
+
Local<Object> opts = info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
|
|
126
|
+
if(!TypeConverter::GetInt32(opts, "x", &x) || !TypeConverter::GetInt32(opts, "y", &y)) {
|
|
127
|
+
Nan::ThrowError("x and y properties must be defined");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
TypeConverter::GetInt32(opts, "screen_num", &screen);
|
|
131
|
+
|
|
132
|
+
XdoTool* tool;
|
|
133
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
134
|
+
Nan::ThrowError("Method called in invalid context");
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
auto task = new XdoToolTask_MoveMouse(tool->xdo, x, y, screen);
|
|
138
|
+
auto callback = new Callback(To<Function>(info[1]).ToLocalChecked());
|
|
139
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
NAN_METHOD(XdoTool::WindowHasProperty) {
|
|
143
|
+
Window window;
|
|
144
|
+
if(!TypeConverter::GetWindow(info[0],window)) {
|
|
145
|
+
Nan::ThrowError("First argument must be a valid window");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
std::string property;
|
|
149
|
+
if(!TypeConverter::GetString(info[1], property)) {
|
|
150
|
+
Nan::ThrowError("Second argument must be a valid string representing window property");
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
XdoTool* tool;
|
|
154
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
155
|
+
Nan::ThrowError("Method called in invalid context");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
auto task = new XdoToolTask_WindowHasProperty(tool->xdo, window, property);
|
|
159
|
+
auto callback = new Callback(To<Function>(info[2]).ToLocalChecked());
|
|
160
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
NAN_METHOD(XdoTool::ActivateWindow) {
|
|
164
|
+
Window window;
|
|
165
|
+
if(!TypeConverter::GetWindow(info[0],window)) {
|
|
166
|
+
Nan::ThrowError("First argument must be a valid string pointing to a Window object");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
XdoTool* tool;
|
|
170
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
171
|
+
Nan::ThrowError("Method called in invalid context");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
auto task = new tasks::ActivateWindow(tool->xdo, window);
|
|
175
|
+
auto callback = new Callback(To<Function>(info[1]).ToLocalChecked());
|
|
176
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
NAN_METHOD(XdoTool::EnterText) {
|
|
180
|
+
Window window;
|
|
181
|
+
std::string text;
|
|
182
|
+
int32_t delay;
|
|
183
|
+
if(!TypeConverter::GetWindow(info[0],window)) {
|
|
184
|
+
Nan::ThrowError("First argument must be a valid string pointing to a Window object");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if(!TypeConverter::GetString(info[1],text)) {
|
|
188
|
+
Nan::ThrowError("Second argument must be a string");
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if(!TypeConverter::GetInt32(info[2],delay)) {
|
|
192
|
+
Nan::ThrowError("Third argument must be an integer");
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
XdoTool* tool;
|
|
196
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
197
|
+
Nan::ThrowError("Method called in invalid context");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
auto task = new XdoToolTask_EnterText(tool->xdo, window, text, delay);
|
|
201
|
+
auto callback = new Callback(To<Function>(info[3]).ToLocalChecked());
|
|
202
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
NAN_METHOD(XdoTool::GetFocusedWindow) {
|
|
206
|
+
XdoTool* tool;
|
|
207
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
208
|
+
Nan::ThrowError("Method called in invalid context");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
auto task = new XdoToolTask_GetFocusedWindow(tool->xdo);
|
|
212
|
+
auto callback = new Callback(To<Function>(info[0]).ToLocalChecked());
|
|
213
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback,task));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
void XdoTool::Init(Local<Object> exports) {
|
|
217
|
+
std::map<std::string, FunctionCallback> methods {
|
|
218
|
+
{ "constructor", Constructor },
|
|
219
|
+
{ "getMouseLocation", GetMouseLocation },
|
|
220
|
+
{ "searchWindows", SearchWindows },
|
|
221
|
+
{ "getWindowPID", GetWindowPID },
|
|
222
|
+
{ "moveMouse", MoveMouse },
|
|
223
|
+
{ "getFocusedWindow", GetFocusedWindow },
|
|
224
|
+
{ "enterText", EnterText },
|
|
225
|
+
{ "sync", Sync },
|
|
226
|
+
{ "sendKeysequence", SendKeysequence },
|
|
227
|
+
{ "windowHasProperty", WindowHasProperty },
|
|
228
|
+
{ "activateWindow", ActivateWindow },
|
|
229
|
+
{ "getViewportDimensions", GetViewportDimensions }
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
Set(
|
|
233
|
+
exports,
|
|
234
|
+
Nan::New<String>("XdoTool").ToLocalChecked(),
|
|
235
|
+
ClassCreator::NewClass<XdoTool>("XdoTool", methods)
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
NAN_METHOD(XdoTool::Constructor) {
|
|
240
|
+
xdo_t* xdo = xdo_new(nullptr);
|
|
241
|
+
if(xdo == nullptr) {
|
|
242
|
+
Nan::ThrowError("Failed to create xdo_t instance. Please make sure X.org is running");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
auto* tool = new XdoTool(xdo);
|
|
247
|
+
printf("%p\n",tool);
|
|
248
|
+
tool->Wrap(info.This());
|
|
249
|
+
info.GetReturnValue().Set(info.This());
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
NAN_METHOD(XdoTool::SearchWindows) {
|
|
253
|
+
if(!info[0]->IsObject()) {
|
|
254
|
+
Nan::ThrowError("First argument must be a valid object");
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
auto search = (xdo_search_t*) calloc(1, sizeof(xdo_search_t)*1);
|
|
259
|
+
if(search == nullptr) {
|
|
260
|
+
Nan::ThrowError("Memory allocation failed");
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
search->require = xdo_search_t::SEARCH_ANY;
|
|
264
|
+
search->max_depth = -1;
|
|
265
|
+
|
|
266
|
+
XdoTool* tool;
|
|
267
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
268
|
+
Nan::ThrowError("Method called in invalid context");
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
auto task = new XdoToolTask_SearchWindows(tool->xdo, search);
|
|
272
|
+
Local<Object> search_obj = Nan::To<Object>(info[0]).ToLocalChecked();
|
|
273
|
+
|
|
274
|
+
task->AddResource(search);
|
|
275
|
+
|
|
276
|
+
char* string;
|
|
277
|
+
if(TypeConverter::GetString(search_obj, "title", &string)) {
|
|
278
|
+
search->title = string;
|
|
279
|
+
search->searchmask |= SEARCH_TITLE;
|
|
280
|
+
task->AddResource(string);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if(TypeConverter::GetString(search_obj, "winclass", &string)) {
|
|
284
|
+
search->winclass = string;
|
|
285
|
+
search->searchmask |= SEARCH_CLASS;
|
|
286
|
+
task->AddResource(string);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if(TypeConverter::GetString(search_obj, "winclassname", &string)) {
|
|
290
|
+
search->winclassname = string;
|
|
291
|
+
search->searchmask |= SEARCH_CLASSNAME;
|
|
292
|
+
task->AddResource(string);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if(TypeConverter::GetString(search_obj, "winname", &string)) {
|
|
296
|
+
search->winname = string;
|
|
297
|
+
search->searchmask |= SEARCH_NAME;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
int32_t int32_value;
|
|
301
|
+
if(TypeConverter::GetInt32(search_obj, "pid", &int32_value)) {
|
|
302
|
+
search->pid = int32_value;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if(TypeConverter::GetInt32(search_obj, "maxDepth", &int32_value)) {
|
|
306
|
+
search->max_depth = int32_value;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
bool boolean_value;
|
|
310
|
+
if(TypeConverter::GetBool(search_obj, "onlyVisible", &boolean_value)) {
|
|
311
|
+
search->only_visible = boolean_value ? 1 : 0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if(TypeConverter::GetInt32(search_obj, "screen", &int32_value)) {
|
|
315
|
+
search->screen = int32_value;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if(TypeConverter::GetInt32(search_obj, "desktop", &int32_value)) {
|
|
319
|
+
search->desktop = int32_value;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if(TypeConverter::GetInt32(search_obj, "limit", &int32_value)) {
|
|
323
|
+
search->limit = int32_value;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
auto callback = new Nan::Callback(Nan::To<Function>(info[1]).ToLocalChecked());
|
|
327
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
NAN_METHOD(XdoTool::GetMouseLocation) {
|
|
331
|
+
XdoTool* tool;
|
|
332
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
333
|
+
Nan::ThrowError("Method called in invalid context");
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
auto task = new XdoToolTask_GetMouseLocation(tool->xdo);
|
|
337
|
+
auto callback = new Nan::Callback(Nan::To<Function>(info[0]).ToLocalChecked());
|
|
338
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
NAN_METHOD(XdoTool::Sync) {
|
|
342
|
+
XdoTool* tool;
|
|
343
|
+
if(!TypeConverter::Unwrap(info.This(),&tool)) {
|
|
344
|
+
Nan::ThrowError("Method called in invalid context");
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
auto task = new XdoToolTask_Sync(tool->xdo->xdpy);
|
|
348
|
+
auto callback = new Nan::Callback(Nan::To<Function>(info[0]).ToLocalChecked());
|
|
349
|
+
AsyncQueueWorker(new XdoToolTaskWorker(callback, task));
|
|
350
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#ifndef NODE_XDOTOOL_ACTIVATE_WINDOW_TASK_H_
|
|
2
|
+
#define NODE_XDOTOOL_ACTIVATE_WINDOW_TASK_H_
|
|
3
|
+
|
|
4
|
+
#include "../XdoToolTask.h"
|
|
5
|
+
|
|
6
|
+
class XdoToolTask_ActivateWindow : public XdoToolTask {
|
|
7
|
+
public:
|
|
8
|
+
XdoToolTask_ActivateWindow(xdo_t*, Window);
|
|
9
|
+
void Execute() override;
|
|
10
|
+
v8::Local<v8::Value> GetResult() override;
|
|
11
|
+
private:
|
|
12
|
+
Window window;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
#endif // NODE_XDOTOOL_ACTIVATE_WINDOW_TASK_H_
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#include "ActivateWindow.h"
|
|
2
|
+
|
|
3
|
+
using v8::Local;
|
|
4
|
+
using v8::Value;
|
|
5
|
+
|
|
6
|
+
XdoToolTask_ActivateWindow::XdoToolTask_ActivateWindow(
|
|
7
|
+
xdo_t* xdo,
|
|
8
|
+
Window window
|
|
9
|
+
): XdoToolTask(xdo), window(window) {}
|
|
10
|
+
|
|
11
|
+
void XdoToolTask_ActivateWindow::Execute() {
|
|
12
|
+
if(xdo_activate_window(xdo, window) != XDO_SUCCESS) {
|
|
13
|
+
SetFailure("Failed to activate window");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if(xdo_wait_for_window_active(xdo, window, 1) != XDO_SUCCESS) {
|
|
17
|
+
SetFailure("Failed to wait for window to be active");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Local<Value> XdoToolTask_ActivateWindow::GetResult() {
|
|
22
|
+
return Nan::Undefined();
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#include "ActivateWindow.h"
|
|
2
|
+
|
|
3
|
+
using v8::Local;
|
|
4
|
+
using v8::Value;
|
|
5
|
+
|
|
6
|
+
tasks::ActivateWindow::tasks::ActivateWindow(
|
|
7
|
+
xdo_t* xdo,
|
|
8
|
+
Window window
|
|
9
|
+
): XdoToolTask(xdo), window(window) {}
|
|
10
|
+
|
|
11
|
+
void tasks::ActivateWindow::Execute() {
|
|
12
|
+
if(xdo_activate_window(xdo, window) != XDO_SUCCESS) {
|
|
13
|
+
SetFailure("Failed to activate window");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if(xdo_wait_for_window_active(xdo, window, 1) != XDO_SUCCESS) {
|
|
17
|
+
SetFailure("Failed to wait for window to be active");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Local<Value> tasks::ActivateWindow::GetResult() {
|
|
22
|
+
return Nan::Undefined();
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#ifndef NODE_XDOTOOL_ACTIVATE_WINDOW_TASK_H_
|
|
2
|
+
#define NODE_XDOTOOL_ACTIVATE_WINDOW_TASK_H_
|
|
3
|
+
|
|
4
|
+
#include "../XdoToolTask.h"
|
|
5
|
+
|
|
6
|
+
class tasks::ActivateWindow : public XdoToolTask {
|
|
7
|
+
public:
|
|
8
|
+
tasks::ActivateWindow(xdo_t*, Window);
|
|
9
|
+
void Execute() override;
|
|
10
|
+
v8::Local<v8::Value> GetResult() override;
|
|
11
|
+
private:
|
|
12
|
+
Window window;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
#endif // NODE_XDOTOOL_ACTIVATE_WINDOW_TASK_H_
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#ifndef NODE_XDOTOOL_ACTIVATE_WINDOW_TASK_H_
|
|
2
|
+
#define NODE_XDOTOOL_ACTIVATE_WINDOW_TASK_H_
|
|
3
|
+
|
|
4
|
+
#include "../XdoToolTask.h"
|
|
5
|
+
|
|
6
|
+
namespace tasks {
|
|
7
|
+
|
|
8
|
+
class ActivateWindow : public XdoToolTask {
|
|
9
|
+
public:
|
|
10
|
+
ActivateWindow(xdo_t*, Window);
|
|
11
|
+
void Execute() override;
|
|
12
|
+
v8::Local<v8::Value> GetResult() override;
|
|
13
|
+
private:
|
|
14
|
+
Window window;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#endif // NODE_XDOTOOL_ACTIVATE_WINDOW_TASK_H_
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#include "ActivateWindow.h"
|
|
2
|
+
|
|
3
|
+
using v8::Local;
|
|
4
|
+
using v8::Value;
|
|
5
|
+
|
|
6
|
+
tasks::ActivateWindow::ActivateWindow(
|
|
7
|
+
xdo_t* xdo,
|
|
8
|
+
Window window
|
|
9
|
+
): XdoToolTask(xdo), window(window) {}
|
|
10
|
+
|
|
11
|
+
void tasks::ActivateWindow::Execute() {
|
|
12
|
+
if(xdo_activate_window(xdo, window) != XDO_SUCCESS) {
|
|
13
|
+
SetFailure("Failed to activate window");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if(xdo_wait_for_window_active(xdo, window, 1) != XDO_SUCCESS) {
|
|
17
|
+
SetFailure("Failed to wait for window to be active");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Local<Value> tasks::ActivateWindow::GetResult() {
|
|
22
|
+
return Nan::Undefined();
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#ifndef NODE_XDOTOOL_GET_VIEWPORT_DIMENSIONS_H_
|
|
2
|
+
#define NODE_XDOTOOL_GET_VIEWPORT_DIMENSIONS_H_
|
|
3
|
+
|
|
4
|
+
#include "../XdoToolTask.h"
|
|
5
|
+
|
|
6
|
+
class XdoToolTask_GetViewportDimensions : public XdoToolTask {
|
|
7
|
+
public:
|
|
8
|
+
XdoToolTask_GetViewportDimensions(xdo_t*, int);
|
|
9
|
+
void Execute() override;
|
|
10
|
+
v8::Local<v8::Value> GetResult() override;
|
|
11
|
+
private:
|
|
12
|
+
int screen;
|
|
13
|
+
unsigned int width;
|
|
14
|
+
unsigned int height;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
#endif // NODE_XDOTOOL_GET_VIEWPORT_DIMENSIONS_H_
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include "GetViewportDimensions.h"
|
|
2
|
+
|
|
3
|
+
using Nan::New;
|
|
4
|
+
using Nan::Set;
|
|
5
|
+
using v8::Number;
|
|
6
|
+
using v8::String;
|
|
7
|
+
using v8::Local;
|
|
8
|
+
using v8::Value;
|
|
9
|
+
using v8::Object;
|
|
10
|
+
|
|
11
|
+
XdoToolTask_GetViewportDimensions::XdoToolTask_GetViewportDimensions(xdo_t* xdo, int screen): XdoToolTask(xdo), screen(screen) {
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void XdoToolTask_GetViewportDimensions::Execute() {
|
|
16
|
+
if(xdo_get_viewport_dimensions(xdo, &width, &height, screen) != XDO_SUCCESS) {
|
|
17
|
+
SetFailure("Failed to get viewport dimensions");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Local<Value> XdoToolTask_GetViewportDimensions::GetResult() {
|
|
22
|
+
Local<Object> obj = New<Object>();
|
|
23
|
+
Set(obj, New<String>("width").ToLocalChecked(), New<Number>(width));
|
|
24
|
+
Set(obj, New<String>("height").ToLocalChecked(), New<Number>(height));
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include "GetViewportDimensions.h"
|
|
2
|
+
|
|
3
|
+
using Nan::New;
|
|
4
|
+
using Nan::Set;
|
|
5
|
+
using v8::Number;
|
|
6
|
+
using v8::String;
|
|
7
|
+
using v8::Local;
|
|
8
|
+
using v8::Value;
|
|
9
|
+
using v8::Object;
|
|
10
|
+
|
|
11
|
+
tasks::GetViewportDimensions::tasks::GetViewportDimensions(xdo_t* xdo, int screen): XdoToolTask(xdo), screen(screen) {
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void tasks::GetViewportDimensions::Execute() {
|
|
16
|
+
if(xdo_get_viewport_dimensions(xdo, &width, &height, screen) != XDO_SUCCESS) {
|
|
17
|
+
SetFailure("Failed to get viewport dimensions");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Local<Value> tasks::GetViewportDimensions::GetResult() {
|
|
22
|
+
Local<Object> obj = New<Object>();
|
|
23
|
+
Set(obj, New<String>("width").ToLocalChecked(), New<Number>(width));
|
|
24
|
+
Set(obj, New<String>("height").ToLocalChecked(), New<Number>(height));
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include "GetViewportDimensions.h"
|
|
2
|
+
|
|
3
|
+
using Nan::New;
|
|
4
|
+
using Nan::Set;
|
|
5
|
+
using v8::Number;
|
|
6
|
+
using v8::String;
|
|
7
|
+
using v8::Local;
|
|
8
|
+
using v8::Value;
|
|
9
|
+
using v8::Object;
|
|
10
|
+
|
|
11
|
+
tasks::GetViewportDimensions::GetViewportDimensions(xdo_t* xdo, int screen): XdoToolTask(xdo), screen(screen) {
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void tasks::GetViewportDimensions::Execute() {
|
|
16
|
+
if(xdo_get_viewport_dimensions(xdo, &width, &height, screen) != XDO_SUCCESS) {
|
|
17
|
+
SetFailure("Failed to get viewport dimensions");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Local<Value> tasks::GetViewportDimensions::GetResult() {
|
|
22
|
+
Local<Object> obj = New<Object>();
|
|
23
|
+
Set(obj, New<String>("width").ToLocalChecked(), New<Number>(width));
|
|
24
|
+
Set(obj, New<String>("height").ToLocalChecked(), New<Number>(height));
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#ifndef NODE_XDOTOOL_GET_VIEWPORT_DIMENSIONS_H_
|
|
2
|
+
#define NODE_XDOTOOL_GET_VIEWPORT_DIMENSIONS_H_
|
|
3
|
+
|
|
4
|
+
#include "../XdoToolTask.h"
|
|
5
|
+
|
|
6
|
+
namespace tasks {
|
|
7
|
+
|
|
8
|
+
class GetViewportDimensions : public XdoToolTask {
|
|
9
|
+
public:
|
|
10
|
+
GetViewportDimensions(xdo_t*, int);
|
|
11
|
+
void Execute() override;
|
|
12
|
+
v8::Local<v8::Value> GetResult() override;
|
|
13
|
+
private:
|
|
14
|
+
int screen;
|
|
15
|
+
unsigned int width;
|
|
16
|
+
unsigned int height;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#endif // NODE_XDOTOOL_GET_VIEWPORT_DIMENSIONS_H_
|
package/CMakeLists.txt
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
project(node_xdotool)
|
|
2
2
|
cmake_minimum_required(VERSION 3.0)
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
option(NAN_INCLUDE_DIRECTORY "NAN bindings directory" ${CMAKE_CURRENT_SOURCE_DIR}/node_modules/nan)
|
|
5
|
+
option(NODE_INSTALL_DIR "Node.js path" "")
|
|
6
|
+
|
|
7
|
+
set(CMAKE_CXX_STANDARD 14)
|
|
5
8
|
set(NODE_XDOTOOL_COMPILE_OPTIONS -Wfatal-errors)
|
|
6
9
|
set(NODE_XDOTOOL_INCLUDE_DIRS ${CMAKE_JS_INC} ${NODE_INSTALL_DIR}/include/node ${NAN_INCLUDE_DIRECTORY} ${NODE_XDOTOOL_INCLUDE_DIRS})
|
|
7
10
|
set(NODE_XDOTOOL_LIBRARIES xdo ${CMAKE_JS_LIB})
|
|
8
11
|
|
|
9
|
-
option(NAN_INCLUDE_DIRECTORY "NAN bindings directory" "")
|
|
10
|
-
option(NODE_INSTALL_DIR "Node.js path" "")
|
|
11
|
-
|
|
12
12
|
set(NODE_XDOTOOL_SOURCE_FILES src/main.cpp
|
|
13
13
|
src/xdo_c.h
|
|
14
14
|
src/XdoTool.cpp
|
|
15
15
|
src/ResourceManager.cpp
|
|
16
16
|
src/XdoToolTaskWorker.cpp
|
|
17
17
|
src/XdoToolTask.cpp
|
|
18
|
-
|
|
18
|
+
src/TypeConverter.cpp
|
|
19
19
|
src/tasks/SendKeysequence.cpp
|
|
20
20
|
src/Screenshooter.cpp
|
|
21
21
|
src/XTask.cpp
|
|
@@ -32,7 +32,10 @@ set(NODE_XDOTOOL_SOURCE_FILES src/main.cpp
|
|
|
32
32
|
src/tasks/GetMouseLocation.cpp
|
|
33
33
|
src/tasks/ActivateWindow.cpp
|
|
34
34
|
src/tasks/SearchWindows.cpp
|
|
35
|
-
|
|
35
|
+
#src/tasks/GetActiveKeysToKeycodeList.cpp
|
|
36
|
+
#src/tasks/GetActiveKeysToKeycodeList.h
|
|
37
|
+
src/tasks/Sync.cpp
|
|
38
|
+
src/tasks/Sync.h src/tasks/GetFocusedWindow.cpp src/tasks/GetFocusedWindow.h src/tasks/GetWindowSize.cpp src/tasks/GetWindowSize.h)
|
|
36
39
|
|
|
37
40
|
add_library(node_xdotool SHARED ${NODE_XDOTOOL_SOURCE_FILES})
|
|
38
41
|
set_target_properties(node_xdotool PROPERTIES PREFIX "" SUFFIX ".node")
|