ntk 3.6.0 → 3.7.0
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/lib/events_map.js +8 -0
- package/lib/window.js +71 -2
- package/package.json +1 -1
package/lib/events_map.js
CHANGED
|
@@ -9,6 +9,10 @@ eventName[5] = 'mouseup';
|
|
|
9
9
|
eventName[6] = 'mousemove';
|
|
10
10
|
eventName[7] = 'mouseover';
|
|
11
11
|
eventName[8] = 'mouseout';
|
|
12
|
+
// FocusIn/FocusOut: keyboard focus arriving at or leaving this window,
|
|
13
|
+
// usually because the window manager moved it
|
|
14
|
+
eventName[9] = 'focus';
|
|
15
|
+
eventName[10] = 'blur';
|
|
12
16
|
eventName[12] = 'expose';
|
|
13
17
|
eventName[17] = 'destroy';
|
|
14
18
|
eventName[18] = 'unmap';
|
|
@@ -40,6 +44,8 @@ export const mask = {
|
|
|
40
44
|
resize: x11.eventMask.StructureNotify,
|
|
41
45
|
reparent: x11.eventMask.StructureNotify,
|
|
42
46
|
keydown: x11.eventMask.KeyPress,
|
|
47
|
+
focus: x11.eventMask.FocusChange,
|
|
48
|
+
blur: x11.eventMask.FocusChange,
|
|
43
49
|
expose: x11.eventMask.Exposure,
|
|
44
50
|
map_request: x11.eventMask.SubstructureRedirect,
|
|
45
51
|
configure_request: x11.eventMask.SubstructureRedirect,
|
|
@@ -74,6 +80,8 @@ export const toSnake = {
|
|
|
74
80
|
onResize: 'resize',
|
|
75
81
|
onReparent: 'reparent',
|
|
76
82
|
onKeyDown: 'keydown',
|
|
83
|
+
onFocus: 'focus',
|
|
84
|
+
onBlur: 'blur',
|
|
77
85
|
onExpose: 'expose',
|
|
78
86
|
onMapRequest: 'map_request',
|
|
79
87
|
onConfigureRequest: 'configure_request',
|
package/lib/window.js
CHANGED
|
@@ -922,8 +922,77 @@ export default class Window extends Drawable {
|
|
|
922
922
|
return this;
|
|
923
923
|
}
|
|
924
924
|
|
|
925
|
-
|
|
926
|
-
|
|
925
|
+
/**
|
|
926
|
+
* Take the keyboard focus (X SetInputFocus). `revertTo` says where focus
|
|
927
|
+
* goes if this window becomes unviewable: 0 None, 1 PointerRoot,
|
|
928
|
+
* 2 Parent (the default, and the sane choice for a child window).
|
|
929
|
+
*
|
|
930
|
+
* Note a window manager may take focus back — the authority is the
|
|
931
|
+
* 'focus'/'blur' events, not the request.
|
|
932
|
+
*/
|
|
933
|
+
focus(revertTo = 2) {
|
|
934
|
+
safeRelease(this.X, () => this.X.SetInputFocus(this.id, revertTo));
|
|
935
|
+
return this;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/** Which window the server currently gives keyboard input to. */
|
|
939
|
+
queryFocus(callback) {
|
|
940
|
+
this.X.GetInputFocus(callback);
|
|
941
|
+
return this;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Take a pointer grab (X GrabPointer). This is how menus work on X: while
|
|
946
|
+
* the grab is held, presses anywhere on the screen are reported to this
|
|
947
|
+
* window instead of going to the window under the pointer — including the
|
|
948
|
+
* window manager's frames — so a click outside can dismiss the menu.
|
|
949
|
+
*
|
|
950
|
+
* With `ownerEvents` (the default) events over the client's *own* windows
|
|
951
|
+
* are still delivered to them normally, so a submenu keeps working.
|
|
952
|
+
*
|
|
953
|
+
* @param {object} [options] { ownerEvents, events, cursor, confineTo, time }
|
|
954
|
+
* @param {function} [callback] cb(err, status) — 0 is Success, 1 is
|
|
955
|
+
* AlreadyGrabbed by another client
|
|
956
|
+
*/
|
|
957
|
+
grabPointer(options = {}, callback) {
|
|
958
|
+
const {
|
|
959
|
+
ownerEvents = true,
|
|
960
|
+
events = x11.eventMask.ButtonPress | x11.eventMask.ButtonRelease | x11.eventMask.PointerMotion,
|
|
961
|
+
pointerMode = 1, // Asynchronous
|
|
962
|
+
keyboardMode = 1,
|
|
963
|
+
confineTo = 0,
|
|
964
|
+
cursor = 0,
|
|
965
|
+
time = 0 // CurrentTime
|
|
966
|
+
} = options;
|
|
967
|
+
this.X.GrabPointer(
|
|
968
|
+
this.id,
|
|
969
|
+
ownerEvents,
|
|
970
|
+
events,
|
|
971
|
+
pointerMode,
|
|
972
|
+
keyboardMode,
|
|
973
|
+
confineTo,
|
|
974
|
+
cursor,
|
|
975
|
+
time,
|
|
976
|
+
callback ?? (() => {})
|
|
977
|
+
);
|
|
978
|
+
return this;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
ungrabPointer(time = 0) {
|
|
982
|
+
safeRelease(this.X, () => this.X.UngrabPointer(time));
|
|
983
|
+
return this;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/** Keyboard counterpart: keys go here while the grab is held. */
|
|
987
|
+
grabKeyboard(options = {}, callback) {
|
|
988
|
+
const { ownerEvents = true, pointerMode = 1, keyboardMode = 1, time = 0 } = options;
|
|
989
|
+
this.X.GrabKeyboard(this.id, ownerEvents, time, pointerMode, keyboardMode, callback ?? (() => {}));
|
|
990
|
+
return this;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
ungrabKeyboard(time = 0) {
|
|
994
|
+
safeRelease(this.X, () => this.X.UngrabKeyboard(time));
|
|
995
|
+
return this;
|
|
927
996
|
}
|
|
928
997
|
|
|
929
998
|
reparentTo(newParent, x, y) {
|