ntk 7.1.0 → 7.3.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/window.js CHANGED
@@ -435,6 +435,10 @@ export default class Window extends Drawable {
435
435
  this._updateRegion = 0;
436
436
  this._presentSerial = 0;
437
437
  this._presentEid = 0;
438
+ // A direct GL context's swap chain, when one is presenting on this window
439
+ // (see _setGenericEventSink)
440
+ this._geSink = null;
441
+ this._geSinkOpcode = 0;
438
442
  // The vblank clock (see _onPresentComplete): the period learnt from
439
443
  // completion events, the samples it is drawn from, and the latch the
440
444
  // watchdog sets when completions stop arriving.
@@ -612,7 +616,13 @@ export default class Window extends Drawable {
612
616
  // and a sub-type where a core event carries its code — the name table
613
617
  // below cannot see them, and they are not events user code asked for
614
618
  if (ev.type === 35) {
615
- if (this._presentExt && ev.extension === this._presentExt.majorOpcode) {
619
+ // A direct GL context presenting on this window selected these events
620
+ // itself and owns the pixmaps they name, so they are its to read — and
621
+ // it is the only user of Present there, a GL window having no backing
622
+ // store to blit.
623
+ if (this._geSink && ev.extension === this._geSinkOpcode) {
624
+ this._geSink.handleEvent(ev);
625
+ } else if (this._presentExt && ev.extension === this._presentExt.majorOpcode) {
616
626
  this._handlePresentEvent(ev);
617
627
  }
618
628
  return;
@@ -1256,6 +1266,24 @@ export default class Window extends Drawable {
1256
1266
  });
1257
1267
  }
1258
1268
 
1269
+ /**
1270
+ * Route this window's Generic Events for one extension to `sink`, ahead of
1271
+ * the built-in Present handling.
1272
+ *
1273
+ * The direct GL context is the caller: its swap chain selects Present's
1274
+ * CompleteNotify and IdleNotify for itself, because it needs to know when a
1275
+ * *specific* buffer came back — a question the window's own present path,
1276
+ * which owns exactly one grow-only pixmap, never has to ask. Pass `null` to
1277
+ * unregister.
1278
+ *
1279
+ * @param {number} majorOpcode the extension whose events to route
1280
+ * @param {{handleEvent: (ev: object) => void}|null} sink
1281
+ */
1282
+ _setGenericEventSink(majorOpcode, sink) {
1283
+ this._geSink = sink;
1284
+ this._geSinkOpcode = sink ? majorOpcode : 0;
1285
+ }
1286
+
1259
1287
  /**
1260
1288
  * Present's events, which are the ones the core event table cannot name:
1261
1289
  * they arrive as X Generic Events (type 35), carrying an extension opcode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ntk",
3
- "version": "7.1.0",
3
+ "version": "7.3.0",
4
4
  "description": "Desktop UI toolkit for X11 with canvas-like 2d and OpenGL rendering",
5
5
  "author": "Andrey Sidorov <sidorares@yandex.ru>",
6
6
  "license": "MIT",
@@ -48,9 +48,12 @@
48
48
  "parse-color": "^1.0.0",
49
49
  "pngjs": "^7.0.0",
50
50
  "postcss": "^8.5.23",
51
- "x11": "^3.8.0",
51
+ "x11": "^3.9.0",
52
52
  "yoga-layout": "^3.2.1"
53
53
  },
54
+ "optionalDependencies": {
55
+ "x11-dri": "^0.2.0"
56
+ },
54
57
  "scripts": {
55
58
  "test": "NTK_STRICT_COLORS=1 node --test",
56
59
  "check-release-message": "node scripts/check-release-message.mjs"