bare-pointer 0.1.3 → 0.1.5

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/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() {
@@ -61,8 +65,25 @@ module.exports = class DarwinPointer {
61
65
  const window = view.window
62
66
  const point = view.convertPointToView(x, y, null)
63
67
 
64
- AppKitApplication.postEvent(this._event(TYPE.LEFT_MOUSE_DOWN, window, point))
65
- AppKitApplication.postEvent(this._event(TYPE.LEFT_MOUSE_UP, window, point))
68
+ // Ahead of anything already queued that could take the window off key, as
69
+ // the first press in a window that is not key only makes it key.
70
+ AppKitApplication.postEvent(this._event(TYPE.LEFT_MOUSE_UP, window, point), true)
71
+ AppKitApplication.postEvent(this._event(TYPE.LEFT_MOUSE_DOWN, window, point), true)
72
+ }
73
+
74
+ pending(view) {
75
+ const window = view.window
76
+
77
+ if (window === null) return false
78
+
79
+ const event = AppKitApplication.nextEventMatchingMask(
80
+ MASK.LEFT_MOUSE_DOWN | MASK.LEFT_MOUSE_UP,
81
+ null,
82
+ MODE,
83
+ false
84
+ )
85
+
86
+ return event !== null && event.windowNumber === window.windowNumber
66
87
  }
67
88
 
68
89
  destroy() {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-pointer",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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.1",
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",