-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
1187 lines (1062 loc) · 35.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//'use strict';
// nvm use lts/*
// Contribution and Inspirations
// https://github.com/jordansissel/xdotool
// https://github.com/jordansissel/xdotool/blob/master/xdo.h <-- sourced from here
// https://github.com/node-ffi/node-ffi/wiki/Node-FFI-Tutorial#common-usage
// https://stackabuse.com/how-to-create-c-cpp-addons-in-node/
const ref = require('ref-napi');
//const CString = ref.types.CString;
const Struct = require('ref-struct-di')(ref);
//const ArrayType = require('ref-array');
const ffi = require('ffi-napi');
/**
* @mainpage
*
* libxdo helps you send fake mouse and keyboard input, search for windows,
* perform various window management tasks such as desktop changes, window
* movement, etc.
*
* For examples on libxdo usage, the xdotool source code is a good reference.
*
* @see xdo_new
*/
// +++++++++++++++++++++++++++++++++++++++
// CONSTS AND STRUCTS
// +++++++++++++++++++++++++++++++++++++++
/**
* When issuing a window size change, giving this flag will make the size
* change be relative to the size hints of the window. For terminals, this
* generally means that the window size will be relative to the font size,
* allowing you to change window sizes based on character rows and columns
* instead of pixels.
*/
const SIZE_USEHINTS = (1 << 0);
const SIZE_USEHINTS_X = (1 << 1);
const SIZE_USEHINTS_Y = (1 << 2);
/**
* CURRENTWINDOW is a special identify for xdo input faking (mouse and
* keyboard) functions like xdo_send_keysequence_window that indicate we should target the
* current window, not a specific window.
*
* Generally, this means we will use XTEST instead of XSendEvent when sending
* events.
*/
const CURRENTWINDOW = (0);
/**
* @internal
* Map character to whatever information we need to be able to send
* this key (keycode, modifiers, group, etc)
*/
const struct_charcodemap_t = Struct({
'key' : 'char', // wchar_t
'code' : 'char', // KeyCode
'symbol' : 'char', // KeySym
'group' : 'int',
'modmask' : 'int',
'needs_binding' : 'int',
});
const p_struct_charcodemap_t = ref.refType(struct_charcodemap_t);
//typedef enum {
// XDO_FEATURE_XTEST, /** Is XTest available? */
//} XDO_FEATURES;
/**
* The main context.
*/
const struct_xdo_t = Struct({
/** The Display for Xlib */
'xdpy' : ref.refType('int'), // Display*
/** The display name, if any. NULL if not specified. */
'display_name' : 'char *',
/** @internal Array of known keys/characters */
'charcodes' : p_struct_charcodemap_t,
/** @internal Length of charcodes array */
'charcodes_len' : 'int',
/** @internal highest keycode value */
'keycode_high' : 'int',
/** @internal lowest keycode value */
'keycode_low' : 'int',
/** @internal number of keysyms per keycode */
'keysyms_per_keycode' : 'int',
/** Should we close the display when calling xdo_free? */
'close_display_when_freed' : 'int',
/** Be extra quiet? (omits some error/message output) */
'quiet' : 'int',
/** Enable debug output? */
'debug' : 'int',
/** Feature flags, such as XDO_FEATURE_XTEST, etc... */
'features_mask' : 'int',
});
const p_struct_xdo_t = ref.refType(struct_xdo_t);
/**
* Search only window title. DEPRECATED - Use SEARCH_NAME
* @see xdo_search_windows
*/
const SEARCH_TITLE = (1 << 0);
/**
* Search only window class.
* @see xdo_search_windows
*/
const SEARCH_CLASS = (1 << 1);
/**
* Search only window name.
* @see xdo_search_windows
*/
const SEARCH_NAME = (1 << 2);
/**
* Search only window pid.
* @see xdo_search_windows
*/
const SEARCH_PID = (1 << 3);
/**
* Search only visible windows.
* @see xdo_search_windows
*/
const SEARCH_ONLYVISIBLE = (1 << 4);
/**
* Search only a specific screen.
* @see xdo_search.screen
* @see xdo_search_windows
*/
const SEARCH_SCREEN = (1 << 5);
/**
* Search only window class name.
* @see xdo_search
*/
const SEARCH_CLASSNAME = (1 << 6);
/**
* Search a specific desktop
* @see xdo_search.screen
* @see xdo_search_windows
*/
const SEARCH_DESKTOP = (1 << 7);
/**
* The window search query structure.
*
* @see xdo_search_windows
*/
const struct_xdo_search_t = Struct({
/** pattern to test against a window title */
'title' : 'string', // const char *
/** pattern to test against a window class */
'winclass' : 'string', // const char *
/** pattern to test against a window class */
'winclassname' : 'string', // const char *
/** pattern to test against a window name */
'winname' : 'string', // const char *
/** window pid (From window atom _NET_WM_PID) */
'pid' : 'int',
/** depth of search. 1 means only toplevel windows */
'max_depth' : 'long',
/** boolean; set true to search only visible windows */
'only_visible' : 'int',
/** what screen to search, if any. If none given, search all screens */
'screen' : 'int',
});
const p_struct_xdo_search_t = ref.refType(struct_xdo_search_t);
const XDO_ERROR = 1;
const XDO_SUCCESS = 0;
// For xdo_wait_for_window_size param to_or_from
const SIZE_TO = 0;
const SIZE_FROM = 1;
// For xdo_window_state param action
const _NET_WM_STATE_REMOVE = 0; // remove/unset property
const _NET_WM_STATE_ADD = 1; // add/set property
const _NET_WM_STATE_TOGGLE = 2; // toggle property
// For xdo_find_window_client param direction
/**
* Find a client window that is a parent of the window given
*/
const XDO_FIND_PARENTS = (0);
/**
* Find a client window that is a child of the window given
*/
const XDO_FIND_CHILDREN = (1);
// +++++++++++++++++++++++++++++++++++++++
// FUNCTION DEFINITION
// +++++++++++++++++++++++++++++++++++++++
module.exports = ffi.Library('libxdo', {
/**
* Create a new xdo_t instance.
*
* @param display the string display name, such as ":0". If null, uses the
* environment variable DISPLAY just like XOpenDisplay(NULL).
*
* @return Pointer to a new xdo_t or NULL on failure
*/
'xdo_new' : [ p_struct_xdo_t, [
'string', // const char *display
] ],
/**
* Create a new xdo_t instance with an existing X11 Display instance.
*
* @param xdpy the Display pointer given by a previous XOpenDisplay()
* @param display the string display name
* @param close_display_when_freed If true, we will close the display when
* xdo_free is called. Otherwise, we leave it open.
*/
'xdo_new_with_opened_display' : [ p_struct_xdo_t , [
ref.refType('int'), // Display *xdpy
'string', // const char *display
'int', // int close_display_when_freed
] ],
/**
* Return a string representing the version of this library
*/
'xdo_version' : [ 'string' /* const char* */, [ /* void */ ] ],
/**
* Free and destroy an xdo_t instance.
*
* If close_display_when_freed is set, then we will also close the Display.
*/
'xdo_free' : [ 'void', [
p_struct_xdo_t, // xdo_t *xdo
] ],
/**
* Move the mouse to a specific location.
*
* @param x the target X coordinate on the screen in pixels.
* @param y the target Y coordinate on the screen in pixels.
* @param screen the screen (number) you want to move on.
*/
'xdo_move_mouse' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // int x
'int', // int y
'int', // int screen
] ],
/**
* Move the mouse to a specific location relative to the top-left corner
* of a window.
*
* @param x the target X coordinate on the screen in pixels.
* @param y the target Y coordinate on the screen in pixels.
*/
'xdo_move_mouse_relative_to_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // int x
'int', // int y
] ],
/**
* Move the mouse relative to it's current position.
*
* @param x the distance in pixels to move on the X axis.
* @param y the distance in pixels to move on the Y axis.
*/
'xdo_move_mouse_relative' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // int x
'int', // int y
] ],
/**
* Send a mouse press (aka mouse down) for a given button at the current mouse
* location.
*
* @param window The window you want to send the event to or CURRENTWINDOW
* @param button The mouse button. Generally, 1 is left, 2 is middle, 3 is
* right, 4 is wheel up, 5 is wheel down.
*/
'xdo_mouse_down' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // int button
] ],
/**
* Send a mouse release (aka mouse up) for a given button at the current mouse
* location.
*
* @param window The window you want to send the event to or CURRENTWINDOW
* @param button The mouse button. Generally, 1 is left, 2 is middle, 3 is
* right, 4 is wheel up, 5 is wheel down.
*/
'xdo_mouse_up' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // int button
] ],
/**
* Get the current mouse location (coordinates and screen number).
*
* @param x integer pointer where the X coordinate will be stored
* @param y integer pointer where the Y coordinate will be stored
* @param screen_num integer pointer where the screen number will be stored
*/
'xdo_get_mouse_location' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
ref.refType('int'), // int *x
ref.refType('int'), // int *y
ref.refType('int'), // int *screen_num
] ],
/**
* Get the window the mouse is currently over
*
* @param window_ret Winter pointer where the window will be stored.
*/
'xdo_get_window_at_mouse' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
ref.refType('int'), // Window *window_ret
] ],
/**
* Get all mouse location-related data.
*
* If null is passed for any parameter, we simply do not store it.
* Useful if you only want the 'y' coordinate, for example.
*
* @param x integer pointer where the X coordinate will be stored
* @param y integer pointer where the Y coordinate will be stored
* @param screen_num integer pointer where the screen number will be stored
* @param window Window pointer where the window/client the mouse is over
* will be stored.
*/
'xdo_get_mouse_location2' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
ref.refType('int'), // int *x_ret
ref.refType('int'), // int *y_ret
ref.refType('int'), // int *screen_num_ret
ref.refType('int'), // int *window_ret
] ],
/**
* Wait for the mouse to move from a location. This function will block
* until the condition has been satisfied.
*
* @param origin_x the X position you expect the mouse to move from
* @param origin_y the Y position you expect the mouse to move from
*/
'xdo_wait_for_mouse_move_from' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // int origin_x
'int', // int origin_y
] ],
/**
* Wait for the mouse to move to a location. This function will block
* until the condition has been satisfied.
*
* @param dest_x the X position you expect the mouse to move to
* @param dest_y the Y position you expect the mouse to move to
*/
'xdo_wait_for_mouse_move_to' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // int dest_x
'int', // int dest_y
] ],
/**
* Send a click for a specific mouse button at the current mouse location.
*
* @param window The window you want to send the event to or CURRENTWINDOW
* @param button The mouse button. Generally, 1 is left, 2 is middle, 3 is
* right, 4 is wheel up, 5 is wheel down.
*/
'xdo_click_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // int button
] ],
/**
* Send a one or more clicks for a specific mouse button at the current mouse
* location.
*
* @param window The window you want to send the event to or CURRENTWINDOW
* @param button The mouse button. Generally, 1 is left, 2 is middle, 3 is
* right, 4 is wheel up, 5 is wheel down.
*/
'xdo_click_window_multiple' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // int button
'int', // int repeat
'int', // useconds_t delay
] ],
/**
* Type a string to the specified window.
*
* If you want to send a specific key or key sequence, such as "alt+l", you
* want instead xdo_send_keysequence_window(...).
*
* @param window The window you want to send keystrokes to or CURRENTWINDOW
* @param string The string to type, like "Hello world!"
* @param delay The delay between keystrokes in microseconds. 12000 is a decent
* choice if you don't have other plans.
*/
'xdo_enter_text_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'string', // const char *string
'int', // useconds_t delay
] ],
/**
* Send a keysequence to the specified window.
*
* This allows you to send keysequences by symbol name. Any combination
* of X11 KeySym names separated by '+' are valid. Single KeySym names
* are valid, too.
*
* Examples:
* "l"
* "semicolon"
* "alt+Return"
* "Alt_L+Tab"
*
* If you want to type a string, such as "Hello world." you want to instead
* use xdo_enter_text_window.
*
* @param window The window you want to send the keysequence to or
* CURRENTWINDOW
* @param keysequence The string keysequence to send.
* @param delay The delay between keystrokes in microseconds.
*/
'xdo_send_keysequence_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'string', // const char *keysequence
'int', // useconds_t delay
] ],
/**
* Send key release (up) events for the given key sequence.
*
* @see xdo_send_keysequence_window
*/
'xdo_send_keysequence_window_up' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'string', // const char *keysequence
'int', // useconds_t delay
] ],
/**
* Send key press (down) events for the given key sequence.
*
* @see xdo_send_keysequence_window
*/
'xdo_send_keysequence_window_down' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'string', // const char *keysequence
'int', // useconds_t delay
] ],
/**
* Send a series of keystrokes.
*
* @param window The window to send events to or CURRENTWINDOW
* @param keys The array of charcodemap_t entities to send.
* @param nkeys The length of the keys parameter
* @param pressed 1 for key press, 0 for key release.
* @param modifier Pointer to integer to record the modifiers activated by
* the keys being pressed. If NULL, we don't save the modifiers.
* @param delay The delay between keystrokes in microseconds.
*/
'xdo_send_keysequence_window_list_do' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
p_struct_charcodemap_t, // charcodemap_t *keys
'int', // int nkeys
'int', // int pressed
ref.refType('int'), // int *modifier
'int', // useconds_t delay
] ],
/**
* Wait for a window to have a specific map state.
*
* State possibilities:
* IsUnmapped - window is not displayed.
* IsViewable - window is mapped and shown (though may be clipped by windows
* on top of it)
* IsUnviewable - window is mapped but a parent window is unmapped.
*
* @param wid the window you want to wait for.
* @param map_state the state to wait for.
*/
'xdo_wait_for_window_map_state' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
'int', // int map_state
] ],
/**
*
*/
'xdo_wait_for_window_size' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // unsigned int width
'int', // unsigned int height
'int', // int flags
'int', // int to_or_from
] ],
/**
* Move a window to a specific location.
*
* The top left corner of the window will be moved to the x,y coordinate.
*
* @param wid the window to move
* @param x the X coordinate to move to.
* @param y the Y coordinate to move to.
*/
'xdo_move_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
'int', // int x
'int', // int y
] ],
/**
* Apply a window's sizing hints (if any) to a given width and height.
*
* This function wraps XGetWMNormalHints() and applies any
* resize increment and base size to your given width and height values.
*
* @param window the window to use
* @param width the unit width you want to translate
* @param height the unit height you want to translate
* @param width_ret the return location of the translated width
* @param height_ret the return location of the translated height
*/
'xdo_translate_window_with_sizehint' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // unsigned int width
'int', // unsigned int height
ref.refType('int'), // unsigned int *width_ret
ref.refType('int'), // unsigned int *height_ret
] ],
/**
* Change the window size.
*
* @param wid the window to resize
* @param w the new desired width
* @param h the new desired height
* @param flags if 0, use pixels for units. If SIZE_USEHINTS, then
* the units will be relative to the window size hints.
*/
'xdo_set_window_size' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
'int', // int w
'int', // int h
'int', // int flags
] ],
/**
* Change a window property.
*
* Example properties you can change are WM_NAME, WM_ICON_NAME, etc.
*
* @param wid The window to change a property of.
* @param property the string name of the property.
* @param value the string value of the property.
*/
'xdo_set_window_property' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
'string', // const char *property
'string', // const char *value
] ],
/**
* Change the window's classname and or class.
*
* @param name The new class name. If NULL, no change.
* @param _class The new class. If NULL, no change.
*/
'xdo_set_window_class' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
'string', // const char *name
'string', // const char *_class
] ],
/**
* Sets the urgency hint for a window.
*/
'xdo_set_window_urgency' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
'int', // int urgency
] ],
/**
* Set the override_redirect value for a window. This generally means
* whether or not a window manager will manage this window.
*
* If you set it to 1, the window manager will usually not draw borders on the
* window, etc. If you set it to 0, the window manager will see it like a
* normal application window.
*
*/
'xdo_set_window_override_redirect' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
'int', // int override_redirect
] ],
/**
* Focus a window.
*
* @see xdo_activate_window
* @param wid the window to focus.
*/
'xdo_focus_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
] ],
/**
* Raise a window to the top of the window stack. This is also sometimes
* termed as bringing the window forward.
*
* @param wid The window to raise.
*/
'xdo_raise_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
] ],
/**
* Get the window currently having focus.
*
* @param window_ret Pointer to a window where the currently-focused window
* will be stored.
*/
'xdo_get_focused_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
ref.refType('int'), // Window *window_ret
] ],
/**
* Wait for a window to have or lose focus.
*
* @param window The window to wait on
* @param want_focus If 1, wait for focus. If 0, wait for loss of focus.
*/
'xdo_focus_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // int want_focus
] ],
/**
* Get the PID owning a window. Not all applications support this.
* It looks at the _NET_WM_PID property of the window.
*
* @param window the window to query.
* @return the process id or 0 if no pid found.
*/
'xdo_get_pid_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
] ],
/**
* Like xdo_get_focused_window, but return the first ancestor-or-self window *
* having a property of WM_CLASS. This allows you to get the "real" or
* top-level-ish window having focus rather than something you may not expect
* to be the window having focused.
*
* @param window_ret Pointer to a window where the currently-focused window
* will be stored.
*/
'xdo_get_focused_window_sane' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
ref.refType('int'), // Window *window_ret
] ],
/**
* Activate a window. This is generally a better choice than xdo_focus_window
* for a variety of reasons, but it requires window manager support:
* - If the window is on another desktop, that desktop is switched to.
* - It moves the window forward rather than simply focusing it
*
* Requires your window manager to support this.
* Uses _NET_ACTIVE_WINDOW from the EWMH spec.
*
* @param wid the window to activate
*/
'xdo_activate_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
] ],
/**
* Wait for a window to be active or not active.
*
* Requires your window manager to support this.
* Uses _NET_ACTIVE_WINDOW from the EWMH spec.
*
* @param window the window to wait on
* @param active If 1, wait for active. If 0, wait for inactive.
*/
'xdo_wait_for_window_active' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // Window active
] ],
/**
* Map a window. This mostly means to make the window visible if it is
* not currently mapped.
*
* @param wid the window to map.
*/
'xdo_map_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
] ],
/**
* Unmap a window
*
* @param wid the window to unmap
*/
'xdo_unmap_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
] ],
/**
* Minimize a window.
*/
'xdo_minimize_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
] ],
// /**
// * Change window state
// * @param action the _NET_WM_STATE action
// */
// 'xdo_window_state' : [ 'int', [
// p_struct_xdo_t, // const xdo_t *xdo
// 'int', // Window window
// 'long', // unsigned long action
// 'string', // const char *property
// ] ],
/**
* Reparents a window
*
* @param wid_source the window to reparent
* @param wid_target the new parent window
*/
'xdo_reparent_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid_source
'int', // Window wid_target
] ],
/**
* Get a window's location.
*
* @param wid the window to query
* @param x_ret pointer to int where the X location is stored. If NULL, X is
* ignored.
* @param y_ret pointer to int where the Y location is stored. If NULL, X is
* ignored.
* @param screen_ret Pointer to Screen* where the Screen* the window on is
* stored. If NULL, this parameter is ignored.
*/
'xdo_get_window_location' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
ref.refType('int'), // int *x_ret
ref.refType('int'), // int *y_ret
ref.refType(ref.refType('int')), // Screen **screen_ret
] ],
/**
* Get a window's size.
*
* @param wid the window to query
* @param width_ret pointer to unsigned int where the width is stored.
* @param height_ret pointer to unsigned int where the height is stored.
*/
'xdo_get_window_size' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
ref.refType('int'), // unsigned int *width_ret
ref.refType('int'), // unsigned int *height_ret
] ],
/* pager-like behaviors */
/**
* Get the currently-active window.
* Requires your window manager to support this.
* Uses _NET_ACTIVE_WINDOW from the EWMH spec.
*
* @param window_ret Pointer to Window where the active window is stored.
*/
'xdo_get_active_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
ref.refType('int'), // Window *window_ret
] ],
/**
* Get a window ID by clicking on it. This function blocks until a selection
* is made.
*
* @param window_ret Pointer to Window where the selected window is stored.
*/
'xdo_select_window_with_click' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
ref.refType('int'), // Window *window_ret
] ],
/**
* Set the number of desktops.
* Uses _NET_NUMBER_OF_DESKTOPS of the EWMH spec.
*
* @param ndesktops the new number of desktops to set.
*/
'xdo_set_number_of_desktops' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'long', // long ndesktops
] ],
/**
* Get the current number of desktops.
* Uses _NET_NUMBER_OF_DESKTOPS of the EWMH spec.
*
* @param ndesktops pointer to long where the current number of desktops is
* stored
*/
'xdo_get_number_of_desktops' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
ref.refType('long'), // long *ndesktops
] ],
/**
* Switch to another desktop.
* Uses _NET_CURRENT_DESKTOP of the EWMH spec.
*
* @param desktop The desktop number to switch to.
*/
'xdo_set_current_desktop' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'long', // long desktop
] ],
/**
* Get the current desktop.
* Uses _NET_CURRENT_DESKTOP of the EWMH spec.
*
* @param desktop pointer to long where the current desktop number is stored.
*/
'xdo_get_current_desktop' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
ref.refType('long'), // long *desktop
] ],
/**
* Move a window to another desktop
* Uses _NET_WM_DESKTOP of the EWMH spec.
*
* @param wid the window to move
* @param desktop the desktop destination for the window
*/
'xdo_set_desktop_for_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
'long', // long desktop
] ],
/**
* Get the desktop a window is on.
* Uses _NET_WM_DESKTOP of the EWMH spec.
*
* If your desktop does not support _NET_WM_DESKTOP, then '*desktop' remains
* unmodified.
*
* @param wid the window to query
* @param deskto pointer to long where the desktop of the window is stored
*/
'xdo_get_desktop_for_window' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window wid
ref.refType('long'), // long *desktop
] ],
/**
* Search for windows.
*
* @param search the search query.
* @param windowlist_ret the list of matching windows to return
* @param nwindows_ret the number of windows (length of windowlist_ret)
* @see xdo_search_t
*/
'xdo_search_windows' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
p_struct_xdo_search_t, // const xdo_search_t *search
ref.refType(ref.refType('int')), // Window **windowlist_ret
ref.refType('int'), // unsigned int *nwindows_ret
] ],
/**
* Generic property fetch.
*
* @param window the window to query
* @param atom the Atom to request
* @param nitems the number of items
* @param type the type of the return
* @param size the size of the type
* @return data consisting of 'nitems' items of size 'size' and type 'type'
* will need to be cast to the type before using.
*/
'xdo_get_window_property_by_atom' : [ 'char *' /* unsigned char* */, [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window
'int', // Atom atom
ref.refType('long'), // long *nitems
ref.refType('int'), // Atom *type
ref.refType('int'), // int *size
] ],
/**
* Get property of window by name of atom.
*
* @param window the window to query
* @param property the name of the atom
* @param nitems the number of items
* @param type the type of the return
* @param size the size of the type
* @return data consisting of 'nitems' items of size 'size' and type 'type'
* will need to be cast to the type before using.
*/
'xdo_get_window_property' : [ 'int', [
p_struct_xdo_t, // const xdo_t *xdo
'int', // Window window