bare-pointer 0.1.2 → 0.1.4
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/README.md +3 -1
- package/index.js +9 -0
- package/lib/darwin.js +32 -1
- package/lib/win32.js +13 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -32,7 +32,9 @@ pointer.destroy()
|
|
|
32
32
|
| Android | `bare-ndk` | Motion events dispatched to the root of the view |
|
|
33
33
|
| Windows | `bare-win-ui` | `SendInput()` through `bare-user32` |
|
|
34
34
|
|
|
35
|
-
On Linux
|
|
35
|
+
On Linux the input goes through the system, so the window of the view has to be the one on top at the point. On Windows it does too, and a window covered at the point is brought to the foreground first. On macOS, a control tracks the mouse until it is released, so press one with `tap()` rather than `down()`.
|
|
36
|
+
|
|
37
|
+
On Windows, a press that no element marks as handled can leave windows opened after it without pointer input once one of them has closed. Have something take every press, such as the root of each window.
|
|
36
38
|
|
|
37
39
|
## License
|
|
38
40
|
|
package/index.js
CHANGED
|
@@ -52,6 +52,15 @@ module.exports = class Pointer {
|
|
|
52
52
|
|
|
53
53
|
if (this._backend.tap) {
|
|
54
54
|
this._backend.tap(view, ...point)
|
|
55
|
+
|
|
56
|
+
// A tap can be posted to an event queue rather than delivered at once.
|
|
57
|
+
if (this._backend.pending !== undefined) {
|
|
58
|
+
for (let frames = 0; this._backend.pending(view); frames++) {
|
|
59
|
+
if (frames === 60) throw new Error('The tap was not delivered')
|
|
60
|
+
|
|
61
|
+
await this._frame(view)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
55
64
|
} else {
|
|
56
65
|
this._backend.down(view, ...point)
|
|
57
66
|
|
package/lib/darwin.js
CHANGED
|
@@ -2,7 +2,11 @@ const AnimationFrameProvider = require('bare-animation-frame')
|
|
|
2
2
|
const AppKitApplication = require('bare-app-kit/application')
|
|
3
3
|
const AppKitEvent = require('bare-app-kit/event')
|
|
4
4
|
|
|
5
|
-
const { TYPE } = AppKitEvent
|
|
5
|
+
const { TYPE, MASK } = AppKitEvent
|
|
6
|
+
|
|
7
|
+
// A run loop mode of its own, so that nothing else runs while the event queue
|
|
8
|
+
// is read.
|
|
9
|
+
const MODE = 'to.holepunch.bare.pointer'
|
|
6
10
|
|
|
7
11
|
module.exports = class DarwinPointer {
|
|
8
12
|
constructor() {
|
|
@@ -16,6 +20,18 @@ module.exports = class DarwinPointer {
|
|
|
16
20
|
return [width, height]
|
|
17
21
|
}
|
|
18
22
|
|
|
23
|
+
covered(view) {
|
|
24
|
+
const window = view.window
|
|
25
|
+
|
|
26
|
+
if (window.keyWindow || !window.canBecomeKeyWindow || !AppKitApplication.active) {
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
window.makeKeyAndOrderFront()
|
|
31
|
+
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
watch(view, onhidden) {
|
|
20
36
|
let request = null
|
|
21
37
|
|
|
@@ -53,6 +69,21 @@ module.exports = class DarwinPointer {
|
|
|
53
69
|
AppKitApplication.postEvent(this._event(TYPE.LEFT_MOUSE_UP, window, point))
|
|
54
70
|
}
|
|
55
71
|
|
|
72
|
+
pending(view) {
|
|
73
|
+
const window = view.window
|
|
74
|
+
|
|
75
|
+
if (window === null) return false
|
|
76
|
+
|
|
77
|
+
const event = AppKitApplication.nextEventMatchingMask(
|
|
78
|
+
MASK.LEFT_MOUSE_DOWN | MASK.LEFT_MOUSE_UP,
|
|
79
|
+
null,
|
|
80
|
+
MODE,
|
|
81
|
+
false
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return event !== null && event.windowNumber === window.windowNumber
|
|
85
|
+
}
|
|
86
|
+
|
|
56
87
|
destroy() {}
|
|
57
88
|
|
|
58
89
|
_send(type, view, x, y) {
|
package/lib/win32.js
CHANGED
|
@@ -16,10 +16,6 @@ const {
|
|
|
16
16
|
} = user32.constants
|
|
17
17
|
|
|
18
18
|
module.exports = class Win32Pointer {
|
|
19
|
-
constructor() {
|
|
20
|
-
this._point = null
|
|
21
|
-
}
|
|
22
|
-
|
|
23
19
|
size(view) {
|
|
24
20
|
return [view.actualWidth, view.actualHeight]
|
|
25
21
|
}
|
|
@@ -36,35 +32,32 @@ module.exports = class Win32Pointer {
|
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
hover(view, x, y) {
|
|
39
|
-
this.
|
|
40
|
-
this._send(0)
|
|
35
|
+
this._move(view, x, y)
|
|
41
36
|
}
|
|
42
37
|
|
|
43
38
|
down() {
|
|
44
|
-
this._send(MOUSEEVENTF_LEFTDOWN)
|
|
39
|
+
this._send({ flags: MOUSEEVENTF_LEFTDOWN })
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
move(view, x, y) {
|
|
48
|
-
this.
|
|
49
|
-
this._send(0)
|
|
43
|
+
this._move(view, x, y)
|
|
50
44
|
}
|
|
51
45
|
|
|
52
46
|
up() {
|
|
53
|
-
this._send(MOUSEEVENTF_LEFTUP)
|
|
47
|
+
this._send({ flags: MOUSEEVENTF_LEFTUP })
|
|
54
48
|
}
|
|
55
49
|
|
|
56
50
|
destroy() {}
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
])
|
|
52
|
+
_move(view, x, y) {
|
|
53
|
+
this._send({
|
|
54
|
+
...normalize(locate(view, x, y).screen),
|
|
55
|
+
flags: MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_send(mi) {
|
|
60
|
+
const sent = user32.sendInput([{ type: INPUT_MOUSE, mi }])
|
|
68
61
|
|
|
69
62
|
if (sent === 0) throw new Error('Input was blocked')
|
|
70
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-pointer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Simulated pointer input for testing Bare apps",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"homepage": "https://github.com/holepunchto/bare-pointer#readme",
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"bare-animation-frame": "^0.1.1",
|
|
51
|
-
"bare-app-kit": "^0.3.
|
|
51
|
+
"bare-app-kit": "^0.3.3",
|
|
52
52
|
"bare-ndk": "^0.3.4",
|
|
53
53
|
"bare-ui-kit-touch": "^0.1.0",
|
|
54
54
|
"bare-user32": "^0.1.1",
|