bare-pointer 0.1.2 → 0.1.3
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/lib/darwin.js +12 -0
- package/lib/win32.js +13 -20
- package/package.json +1 -1
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/lib/darwin.js
CHANGED
|
@@ -16,6 +16,18 @@ module.exports = class DarwinPointer {
|
|
|
16
16
|
return [width, height]
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
covered(view) {
|
|
20
|
+
const window = view.window
|
|
21
|
+
|
|
22
|
+
if (window.keyWindow || !window.canBecomeKeyWindow || !AppKitApplication.active) {
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
window.makeKeyAndOrderFront()
|
|
27
|
+
|
|
28
|
+
return true
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
watch(view, onhidden) {
|
|
20
32
|
let request = null
|
|
21
33
|
|
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
|
}
|