@kmamal/sdl 0.6.9 → 0.7.1

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 CHANGED
@@ -47,11 +47,11 @@ window.on('*', console.log)
47
47
  ### Canvas
48
48
  ```js
49
49
  import sdl from '@kmamal/sdl'
50
- import canvas from 'canvas'
50
+ import { createCanvas } from 'canvas'
51
51
 
52
52
  const window = sdl.video.createWindow({ title: "Canvas" })
53
53
  const { width, height } = window
54
- const canvas = canvas.createCanvas(width, height)
54
+ const canvas = createCanvas(width, height)
55
55
  const ctx = canvas.getContext('2d')
56
56
 
57
57
  // Clear screen to red
@@ -84,8 +84,6 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
84
84
  ## Contents
85
85
 
86
86
  * [sdl](#sdl)
87
- * [Event: 'beforeQuit'](#event-beforequit)
88
- * [Event: 'quit'](#event-quit)
89
87
  * [sdl.info](#sdlinfo)
90
88
  * [sdl.video](#sdlvideo)
91
89
  * [Image data](#image-data)
@@ -138,6 +136,7 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
138
136
  * [window.resizable](#windowresizable)
139
137
  * [window.setResizable(resizable)](#windowsetresizableresizable)
140
138
  * [window.borderless](#windowborderless)
139
+ * [window.alwaysOnTop](#windowalwaysontop)
141
140
  * [window.setBorderless(borderless)](#windowsetborderlessborderless)
142
141
  * [window.accelerated](#windowaccelerated)
143
142
  * [window.setAccelerated(accelerated)](#windowsetacceleratedaccelerated)
@@ -153,6 +152,10 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
153
152
  * [window.focused](#windowfocused)
154
153
  * [window.focus()](#windowfocus)
155
154
  * [window.hovered](#windowhovered)
155
+ * [window.skipTaskbar](#windowskiptaskbar)
156
+ * [window.popupMenu](#windowpopupmenu)
157
+ * [window.tooltip](#windowtooltip)
158
+ * [window.utility](#windowutility)
156
159
  * [window.render(width, height, stride, format, buffer)](#windowrenderwidth-height-stride-format-buffer)
157
160
  * [window.setIcon(width, height, stride, format, buffer)](#windowseticonwidth-height-stride-format-buffer)
158
161
  * [window.destroyed](#windowdestroyed)
@@ -287,20 +290,6 @@ There are more examples [in the `examples/` folder](https://github.com/kmamal/no
287
290
 
288
291
  ## sdl
289
292
 
290
- ### Event: 'beforeQuit'
291
-
292
- * `prevent: <function (void) => void>` Call this to prevent the application from closing.
293
-
294
- Fired to indicate that the user has requested the application to close (usually by closing the last window).
295
- If you need to display any confirmation dialogs you should call `event.prevent()` and handle termination manually.
296
- If `prevent` is not called, then this event will be followed by a [`'quit'`](#event-quit) event.
297
-
298
- ### Event: 'quit'
299
-
300
- Indicates that the application is about to close.
301
- Handle any cleanup here.
302
- This event will be followed by a call to `process.exit()`.
303
-
304
293
  ### sdl.info
305
294
 
306
295
  * `<object>`
@@ -498,9 +487,14 @@ The window that the mouse is hovered over, or `null` if the mouse is not over a
498
487
  * `fullscreen: <boolean>` Set to `true` to create the window in fullscreen mode. Default: `false`
499
488
  * `resizable: <boolean>` Set to `true` to allow resizing the window by dragging its borders. Default: `false`
500
489
  * `borderless: <boolean>` Set to `true` to completely hide the window's borders and title bar. Default: `false`
490
+ * `alwaysOnTop: <boolean>` Set to `true` to always show this window above others. Default: `false`
501
491
  * `accelerated: <boolean>` Set to `false` to disable hardware accelerated rendering. Default: `true`
502
492
  * `vsync: <boolean>` Set to `false` to disable frame rate synchronization. Default: `true`
503
493
  * `opengl: <boolean>` Set to `true` to create an OpenGL-compatible window (for use with [@kmamal/gl](https://github.com/kmamal/headless-gl#readme)). Default: `false`
494
+ * `skipTaskbar: <boolean>` X11 only. Set to `true` to not add this window to the taskbar. Default: `false`
495
+ * `popupMenu: <boolean>` X11 only. Set to `true` to treat this window like a popup menu. Default: `false`
496
+ * `tooltip: <boolean>` X11 only. Set to `true` to treat this window like a tooltip. Default: `false`
497
+ * `utility: <boolean>` X11 only. Set to `true` to treat this window like a utility window. Default: `false`
504
498
  * Returns: [`<Window>`](#class-window) an object representing the new window.
505
499
 
506
500
  Creates a new window.
@@ -584,7 +578,6 @@ If `prevent` is not called, then this event will be followed by a [`'close'`](#e
584
578
 
585
579
  Indicates that the window is about to be destroyed.
586
580
  Handle any cleanup here.
587
- This event will be followed by a call to [`window.destroy()`](#windowdestroy).
588
581
 
589
582
  ### Event: 'keyDown'
590
583
 
@@ -790,6 +783,13 @@ A borderless window has no borders or title bar.
790
783
 
791
784
  Changes the window's borderless property.
792
785
 
786
+ ### window.alwaysOnTop
787
+
788
+ * `<boolean>`
789
+
790
+ Will be `true` if the window was created with `alwaysOnTop: true`.
791
+ Such a window will always be shown above other windows.
792
+
793
793
  ### window.accelerated
794
794
 
795
795
  * `<boolean>`
@@ -871,6 +871,38 @@ Gives the window the keyboard focus.
871
871
 
872
872
  Will be `true` if the mouse is over the window.
873
873
 
874
+ ### window.skipTaskbar
875
+
876
+ * `<boolean>`
877
+
878
+ X11 only.
879
+ Will be `true` if the window was created with `skipTaskbar: true`.
880
+ Such a window will not be added to the taskbar.
881
+
882
+ ### window.popupMenu
883
+
884
+ * `<boolean>`
885
+
886
+ X11 only.
887
+ Will be `true` if the window was created with `popupMenu: true`.
888
+ Such a window will always be treated as a popup menu.
889
+
890
+ ### window.tooltip
891
+
892
+ * `<boolean>`
893
+
894
+ X11 only.
895
+ Will be `true` if the window was created with `tooltip: true`.
896
+ Such a window will always be treated as a tooltip.
897
+
898
+ ### window.utility
899
+
900
+ * `<boolean>`
901
+
902
+ X11 only.
903
+ Will be `true` if the window was created with `utility: true`.
904
+ Such a window will always be treated as a utility window.
905
+
874
906
  ### window.render(width, height, stride, format, buffer)
875
907
 
876
908
  * `width, height, stride, format, buffer: `[`<Image>`](#image-data) The image to display on the window.
@@ -1734,7 +1766,7 @@ The controller's serial number, or `null` if it's not available.
1734
1766
 
1735
1767
  ### controllerInstance.axes
1736
1768
 
1737
- * `axes: <object>`
1769
+ * `<object>`
1738
1770
  * `leftStickX: <number>` Left stick horizontal position
1739
1771
  * `leftStickY: <number>` Left stick vertical position
1740
1772
  * `rightStickX: <number>` Right stick horizontal position
@@ -1748,7 +1780,7 @@ It may be necessary to impose certain tolerances on these values to account for
1748
1780
 
1749
1781
  ### controllerInstance.buttons
1750
1782
 
1751
- * `buttons: <object>`
1783
+ * `<object>`
1752
1784
  * `dpadLeft: <boolean>` D-Pad left pressed
1753
1785
  * `dpadRight: <boolean>` D-Pad right pressed
1754
1786
  * `dpadUp: <boolean>` D-Pad up pressed
@@ -1865,7 +1897,7 @@ The samples in a frame are arranged as follows:
1865
1897
  * For 4 channels (quad) the layout is front-left, front-right, rear-left, rear-right.
1866
1898
  * For 6 channels (5.1) the layout is front-left, front-right, center, low-freq, rear-left, rear-right.
1867
1899
 
1868
- So for example, to fill a buffer with 3 seconds of a 440Hz sine wave, you could do:
1900
+ So for example, to play 3 seconds of a 440Hz sine wave, you could do:
1869
1901
 
1870
1902
  ```js
1871
1903
  const TWO_PI = 2 * Math.PI
@@ -1901,6 +1933,9 @@ for (let i = 0; i < numFrames; i++) {
1901
1933
  offset = playbackInstance.writeSample(buffer, sample, offset)
1902
1934
  }
1903
1935
  }
1936
+
1937
+ playbackInstance.enqueue(buffer)
1938
+ playbackInstance.play()
1904
1939
  ```
1905
1940
 
1906
1941
  ### Sample formats
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.6.9",
2
+ "version": "0.7.1",
3
3
  "name": "@kmamal/sdl",
4
4
  "description": "SDL bindings for Node.js",
5
5
  "keywords": [
@@ -49,14 +49,14 @@
49
49
  "install-deps-mac": "./scripts/install-deps-mac.sh"
50
50
  },
51
51
  "dependencies": {
52
- "tar": "^6.1.11"
52
+ "tar": "^6.1.13"
53
53
  },
54
54
  "sdl": {
55
55
  "owner": "kmamal",
56
56
  "repo": "build-sdl",
57
- "version": "2.24.1"
57
+ "version": "2.26.4"
58
58
  },
59
59
  "devDependencies": {
60
- "@types/node": "^18.11.10"
60
+ "@types/node": "^18.15.11"
61
61
  }
62
62
  }
@@ -108,7 +108,6 @@ class AudioInstance extends EventsViaPoll {
108
108
  if (this._closed) { throw Object.assign(new Error("instance is closed"), { id: this._id }) }
109
109
 
110
110
  Bindings.audio_clearQueue(this._id)
111
- require('./prevent-exit').resetTimeout() // Avoid circular dependency
112
111
  }
113
112
 
114
113
  get closed () { return this._closed }
@@ -1,5 +1,6 @@
1
1
  const Bindings = require('../bindings')
2
2
  const { AudioInstance } = require('./audio-instance')
3
+ const { resetTimeout } = require('./prevent-exit')
3
4
 
4
5
  class AudioPlaybackInstance extends AudioInstance {
5
6
  enqueue (buffer, numBytes = buffer.length) {
@@ -11,6 +12,11 @@ class AudioPlaybackInstance extends AudioInstance {
11
12
 
12
13
  Bindings.audio_enqueue(this._id, buffer, numBytes)
13
14
  }
15
+
16
+ clearQueue () {
17
+ super.clearQueue()
18
+ resetTimeout()
19
+ }
14
20
  }
15
21
 
16
22
  module.exports = { AudioPlaybackInstance }
@@ -1,5 +1,4 @@
1
1
  const Globals = require('../globals')
2
- const { AudioPlaybackInstance } = require('./audio-playback-instance')
3
2
 
4
3
  let timeout
5
4
 
@@ -16,11 +15,12 @@ process.on('beforeExit', (code) => {
16
15
  let duration = 0
17
16
 
18
17
  for (const instance of Globals.audioInstances.values()) {
19
- if (!(instance instanceof AudioPlaybackInstance)) { continue }
20
- const { queued, playing, buffered } = instance
18
+ if (instance.device.type === 'recording') { continue }
19
+
20
+ const { queued, playing } = instance
21
21
  if (!queued || !playing) { continue }
22
22
 
23
- const { channels, frequency, bytesPerSample } = instance
23
+ const { channels, frequency, buffered, bytesPerSample } = instance
24
24
  const bytesPerSecond = channels * frequency * bytesPerSample
25
25
  duration = Math.max(duration, (queued + buffered) / bytesPerSecond)
26
26
  }
@@ -1,7 +1,6 @@
1
1
  const Bindings = require('../bindings')
2
2
  const Globals = require('../globals')
3
3
  const Enums = require('../enums')
4
- const { maybeTriggerQuit } = require('./quit')
5
4
  const { mapping } = require('../keyboard/key-mapping')
6
5
  const { joystick: joystickModule } = require('../joystick')
7
6
  const { controller: controllerModule } = require('../controller')
@@ -78,12 +77,6 @@ const handleEvents = () => {
78
77
  event.type = Enums.eventTypeNames[type]
79
78
 
80
79
  switch (family) {
81
- case Enums.eventFamily.app: {
82
- if (type === Enums.eventType.quit) {
83
- maybeTriggerQuit()
84
- }
85
- } break
86
-
87
80
  case Enums.eventFamily.window: {
88
81
  const { windowId } = event
89
82
  delete event.windowId
@@ -158,8 +151,6 @@ const handleEvents = () => {
158
151
  }
159
152
 
160
153
  window.emit(event.type, event)
161
-
162
- if (type === Enums.eventType.close) { window.destroy() }
163
154
  } break
164
155
 
165
156
  case Enums.eventFamily.keyboard: {
@@ -5,7 +5,6 @@ const Bindings = require('./bindings')
5
5
 
6
6
  const info = Bindings.initialize()
7
7
 
8
- const { sdl } = require('./sdl')
9
8
  const { video } = require('./video')
10
9
  const { keyboard } = require('./keyboard')
11
10
  const { mouse } = require('./mouse')
@@ -14,17 +13,16 @@ const { controller } = require('./controller')
14
13
  const { audio } = require('./audio')
15
14
  const { clipboard } = require('./clipboard')
16
15
 
17
- sdl.info = info
18
- sdl.video = video
19
- sdl.keyboard = keyboard
20
- sdl.mouse = mouse
21
- sdl.joystick = joystick
22
- sdl.controller = controller
23
- sdl.audio = audio
24
- sdl.clipboard = clipboard
25
-
26
16
  require('./events')
27
- require('./audio/prevent-exit')
28
17
  require('./cleanup')
29
18
 
30
- module.exports = sdl
19
+ module.exports = {
20
+ info,
21
+ video,
22
+ keyboard,
23
+ mouse,
24
+ joystick,
25
+ controller,
26
+ audio,
27
+ clipboard,
28
+ }
@@ -2,7 +2,6 @@ const Bindings = require('../bindings')
2
2
  const Globals = require('../globals')
3
3
  const Enums = require('../enums')
4
4
  const { EventsViaPoll } = require('../events/events-via-poll')
5
- const { maybeTriggerQuit } = require('../events/quit')
6
5
 
7
6
  const validEvents = [
8
7
  'show',
@@ -45,9 +44,14 @@ class Window extends EventsViaPoll {
45
44
  fullscreen = false,
46
45
  resizable = false,
47
46
  borderless = false,
47
+ alwaysOnTop = false,
48
48
  accelerated = true,
49
49
  vsync = true,
50
50
  opengl = false,
51
+ skipTaskbar = false,
52
+ popupMenu = false,
53
+ tooltip = false,
54
+ utility = false,
51
55
  } = options
52
56
 
53
57
  if (typeof title !== 'string') { throw Object.assign(new Error("title must be a string"), { title }) }
@@ -66,9 +70,14 @@ class Window extends EventsViaPoll {
66
70
  if (typeof fullscreen !== 'boolean') { throw Object.assign(new Error("fullscreen must be a boolean"), { fullscreen }) }
67
71
  if (typeof resizable !== 'boolean') { throw Object.assign(new Error("resizable must be a boolean"), { resizable }) }
68
72
  if (typeof borderless !== 'boolean') { throw Object.assign(new Error("borderless must be a boolean"), { borderless }) }
73
+ if (typeof alwaysOnTop !== 'boolean') { throw Object.assign(new Error("alwaysOnTop must be a boolean"), { alwaysOnTop }) }
69
74
  if (typeof accelerated !== 'boolean') { throw Object.assign(new Error("accelerated must be a boolean"), { accelerated }) }
70
75
  if (typeof vsync !== 'boolean') { throw Object.assign(new Error("vsync must be a boolean"), { vsync }) }
71
76
  if (typeof opengl !== 'boolean') { throw Object.assign(new Error("opengl must be a boolean"), { opengl }) }
77
+ if (typeof skipTaskbar !== 'boolean') { throw Object.assign(new Error("skipTaskbar must be a boolean"), { skipTaskbar }) }
78
+ if (typeof popupMenu !== 'boolean') { throw Object.assign(new Error("popupMenu must be a boolean"), { popupMenu }) }
79
+ if (typeof tooltip !== 'boolean') { throw Object.assign(new Error("tooltip must be a boolean"), { tooltip }) }
80
+ if (typeof utility !== 'boolean') { throw Object.assign(new Error("utility must be a boolean"), { utility }) }
72
81
  if (display && (Number.isFinite(x) || Number.isFinite(y))) { throw Object.assign(new Error("display and x/y are mutually exclusive"), { display, x, y }) }
73
82
  if (resizable && borderless) { throw Object.assign(new Error("resizable and borderless are mutually exclusive"), { resizable, borderless }) }
74
83
 
@@ -91,9 +100,14 @@ class Window extends EventsViaPoll {
91
100
  fullscreen,
92
101
  resizable,
93
102
  borderless,
103
+ alwaysOnTop,
94
104
  accelerated,
95
105
  vsync,
96
106
  opengl,
107
+ skipTaskbar,
108
+ popupMenu,
109
+ tooltip,
110
+ utility,
97
111
  )
98
112
 
99
113
  this._id = result.id
@@ -104,9 +118,14 @@ class Window extends EventsViaPoll {
104
118
  this._fullscreen = result.fullscreen
105
119
  this._resizable = result.resizable
106
120
  this._borderless = result.borderless
121
+ this._alwaysOnTop = result.alwaysOnTop
107
122
  this._accelerated = result.accelerated
108
123
  this._vsync = result.vsync
109
124
  this._native = result.native ?? null
125
+ this._skipTaskbar = result.skipTaskbar
126
+ this._popupMenu = result.popupMenu
127
+ this._tooltip = result.tooltip
128
+ this._utility = result.utility
110
129
 
111
130
  this._title = title
112
131
  this._visible = visible
@@ -122,6 +141,14 @@ class Window extends EventsViaPoll {
122
141
 
123
142
  // This also keeps Node.js alive while windows are open
124
143
  this.on('close', () => {
144
+ if (Globals.windows.hovered === this) { Globals.windows.hovered = null }
145
+ if (Globals.windows.focused === this) { Globals.windows.focused = null }
146
+
147
+ Bindings.window_destroy(this._id)
148
+ this._destroyed = true
149
+
150
+ Globals.windows.all.delete(this._id)
151
+
125
152
  process.nextTick(() => { this.removeAllListeners() })
126
153
  })
127
154
 
@@ -130,6 +157,7 @@ class Window extends EventsViaPoll {
130
157
  this.emit('resize', {
131
158
  width: this._width,
132
159
  height: this._height,
160
+ type: 'resize',
133
161
  })
134
162
  })
135
163
  }
@@ -213,6 +241,8 @@ class Window extends EventsViaPoll {
213
241
  this._borderless = Bindings.window_setBorderless(this._id, borderless)
214
242
  }
215
243
 
244
+ get alwaysOnTop () { return this._alwaysOnTop }
245
+
216
246
  get accelerated () { return this._accelerated }
217
247
  setAccelerated (accelerated) {
218
248
  if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
@@ -277,6 +307,11 @@ class Window extends EventsViaPoll {
277
307
 
278
308
  get hovered () { return this._hovered }
279
309
 
310
+ get skipTaskbar () { return this._skipTaskbar }
311
+ get popupMenu () { return this._popupMenu }
312
+ get tooltip () { return this._tooltip }
313
+ get utility () { return this._utility }
314
+
280
315
  render (width, height, stride, format, buffer) {
281
316
  if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
282
317
 
@@ -321,15 +356,7 @@ class Window extends EventsViaPoll {
321
356
  destroy () {
322
357
  if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
323
358
 
324
- if (Globals.windows.hovered === this) { Globals.windows.hovered = null }
325
- if (Globals.windows.focused === this) { Globals.windows.focused = null }
326
-
327
- Bindings.window_destroy(this._id)
328
- this._destroyed = true
329
-
330
- Globals.windows.all.delete(this._id)
331
-
332
- maybeTriggerQuit()
359
+ this.emit('close', { type: 'close' })
333
360
  }
334
361
  }
335
362
 
@@ -303,7 +303,7 @@ window_create(napi_env env, napi_callback_info info)
303
303
  int * height = nullptr;
304
304
  void * native_pointer = nullptr;
305
305
 
306
- napi_value argv[13];
306
+ napi_value argv[18];
307
307
  size_t argc = sizeof(argv) / sizeof(napi_value);
308
308
  CALL_NAPI(napi_get_cb_info, info, &argc, argv, nullptr, nullptr);
309
309
 
@@ -341,21 +341,30 @@ window_create(napi_env env, napi_callback_info info)
341
341
  CALL_NAPI(napi_get_value_int32, argv[5], y);
342
342
  }
343
343
 
344
- bool visible, fullscreen, resizable, borderless, accelerated, vsync, opengl;
344
+ bool visible, fullscreen, resizable, borderless, alwaysOnTop,
345
+ accelerated, vsync, opengl,
346
+ skipTaskbar, popupMenu, tooltip, utility;
345
347
  CALL_NAPI(napi_get_value_bool, argv[6], &visible);
346
348
  CALL_NAPI(napi_get_value_bool, argv[7], &fullscreen);
347
349
  CALL_NAPI(napi_get_value_bool, argv[8], &resizable);
348
350
  CALL_NAPI(napi_get_value_bool, argv[9], &borderless);
349
- CALL_NAPI(napi_get_value_bool, argv[10], &accelerated);
350
- CALL_NAPI(napi_get_value_bool, argv[11], &vsync);
351
- CALL_NAPI(napi_get_value_bool, argv[12], &opengl);
351
+ CALL_NAPI(napi_get_value_bool, argv[10], &alwaysOnTop);
352
+ CALL_NAPI(napi_get_value_bool, argv[11], &accelerated);
353
+ CALL_NAPI(napi_get_value_bool, argv[12], &vsync);
354
+ CALL_NAPI(napi_get_value_bool, argv[13], &opengl);
355
+ CALL_NAPI(napi_get_value_bool, argv[14], &skipTaskbar);
356
+ CALL_NAPI(napi_get_value_bool, argv[15], &popupMenu);
357
+ CALL_NAPI(napi_get_value_bool, argv[16], &tooltip);
358
+ CALL_NAPI(napi_get_value_bool, argv[17], &utility);
352
359
 
353
360
  int window_id;
354
361
  int native_pointer_size;
355
362
  CALL_SDL_HELPER(window_create,
356
363
  title, display,
357
364
  &x, &y, &width, &height,
358
- visible, &fullscreen, &resizable, &borderless, &accelerated, &vsync, opengl,
365
+ visible, &fullscreen, &resizable, &borderless, &alwaysOnTop,
366
+ &accelerated, &vsync, opengl,
367
+ &skipTaskbar, &popupMenu, &tooltip, &utility,
359
368
  &window_id, &native_pointer, &native_pointer_size
360
369
  );
361
370
 
@@ -397,6 +406,11 @@ window_create(napi_env env, napi_callback_info info)
397
406
  CALL_NAPI(napi_create_string_latin1, "borderless", 10, &key);
398
407
  CALL_NAPI(napi_set_property, result, key, value);
399
408
 
409
+ CALL_NAPI(napi_create_int32, alwaysOnTop, &value);
410
+ CALL_NAPI(napi_coerce_to_bool, value, &value);
411
+ CALL_NAPI(napi_create_string_latin1, "alwaysOnTop", 11, &key);
412
+ CALL_NAPI(napi_set_property, result, key, value);
413
+
400
414
  CALL_NAPI(napi_create_int32, accelerated, &value);
401
415
  CALL_NAPI(napi_coerce_to_bool, value, &value);
402
416
  CALL_NAPI(napi_create_string_latin1, "accelerated", 11, &key);
@@ -407,6 +421,26 @@ window_create(napi_env env, napi_callback_info info)
407
421
  CALL_NAPI(napi_create_string_latin1, "vsync", 5, &key);
408
422
  CALL_NAPI(napi_set_property, result, key, value);
409
423
 
424
+ CALL_NAPI(napi_create_int32, skipTaskbar, &value);
425
+ CALL_NAPI(napi_coerce_to_bool, value, &value);
426
+ CALL_NAPI(napi_create_string_latin1, "skipTaskbar", 11, &key);
427
+ CALL_NAPI(napi_set_property, result, key, value);
428
+
429
+ CALL_NAPI(napi_create_int32, popupMenu, &value);
430
+ CALL_NAPI(napi_coerce_to_bool, value, &value);
431
+ CALL_NAPI(napi_create_string_latin1, "popupMenu", 9, &key);
432
+ CALL_NAPI(napi_set_property, result, key, value);
433
+
434
+ CALL_NAPI(napi_create_int32, tooltip, &value);
435
+ CALL_NAPI(napi_coerce_to_bool, value, &value);
436
+ CALL_NAPI(napi_create_string_latin1, "tooltip", 7, &key);
437
+ CALL_NAPI(napi_set_property, result, key, value);
438
+
439
+ CALL_NAPI(napi_create_int32, utility, &value);
440
+ CALL_NAPI(napi_coerce_to_bool, value, &value);
441
+ CALL_NAPI(napi_create_string_latin1, "utility", 7, &key);
442
+ CALL_NAPI(napi_set_property, result, key, value);
443
+
410
444
  if (native_pointer) {
411
445
  CALL_NAPI(napi_create_external_buffer,
412
446
  native_pointer_size, native_pointer, freePointer, native_pointer,
@@ -120,7 +120,6 @@ ErrorMessage::
120
120
 
121
121
 
122
122
  enum class EventFamily {
123
- APP,
124
123
  WINDOW,
125
124
  KEYBOARD,
126
125
  MOUSE,
@@ -138,7 +137,6 @@ enum_getEventFamilies (Variant & families)
138
137
  {
139
138
  MAKE_MAP(families);
140
139
 
141
- SET_NUM(families, "app", (int) EventFamily::APP);
142
140
  SET_NUM(families, "window", (int) EventFamily::WINDOW);
143
141
  SET_NUM(families, "keyboard", (int) EventFamily::KEYBOARD);
144
142
  SET_NUM(families, "mouse", (int) EventFamily::MOUSE);
@@ -911,12 +909,6 @@ packageEvent (const SDL_Event & event, Variant & object)
911
909
 
912
910
  Variant value;
913
911
  switch (event.type) {
914
- case SDL_QUIT: {
915
- SET_NUM(object, "family", (int) EventFamily::APP);
916
- SET_NUM(object, "type", (int) EventType::QUIT);
917
- break;
918
- }
919
-
920
912
  case SDL_WINDOWEVENT: {
921
913
  SET_NUM(object, "family", (int) EventFamily::WINDOW);
922
914
  SET_NUM(object, "windowId", event.window.windowID);
@@ -1384,9 +1376,14 @@ window_create (
1384
1376
  bool * fullscreen,
1385
1377
  bool * resizable,
1386
1378
  bool * borderless,
1379
+ bool * alwaysOnTop,
1387
1380
  bool * accelerated,
1388
1381
  bool * vsync,
1389
1382
  bool opengl,
1383
+ bool * skipTaskbar,
1384
+ bool * popupMenu,
1385
+ bool * tooltip,
1386
+ bool * utility,
1390
1387
  int * window_id, void ** native_pointer, int * native_pointer_size
1391
1388
  ) {
1392
1389
  SDL_Window * window;
@@ -1412,7 +1409,12 @@ window_create (
1412
1409
  | (*fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)
1413
1410
  | (*resizable ? SDL_WINDOW_RESIZABLE : 0)
1414
1411
  | (*borderless ? SDL_WINDOW_BORDERLESS : 0)
1415
- | (opengl ? SDL_WINDOW_OPENGL : 0);
1412
+ | (*alwaysOnTop ? SDL_WINDOW_ALWAYS_ON_TOP : 0)
1413
+ | (opengl ? SDL_WINDOW_OPENGL : 0)
1414
+ | (*skipTaskbar ? SDL_WINDOW_SKIP_TASKBAR : 0)
1415
+ | (*popupMenu ? SDL_WINDOW_POPUP_MENU : 0)
1416
+ | (*tooltip ? SDL_WINDOW_TOOLTIP : 0)
1417
+ | (*utility ? SDL_WINDOW_UTILITY : 0);
1416
1418
 
1417
1419
  window = SDL_CreateWindow(title, **x, **y, **width, **height, desired_flags);
1418
1420
  if (window == nullptr) {
@@ -1425,6 +1427,11 @@ window_create (
1425
1427
  *fullscreen = actual_flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP);
1426
1428
  *resizable = actual_flags & SDL_WINDOW_RESIZABLE;
1427
1429
  *borderless = actual_flags & SDL_WINDOW_BORDERLESS;
1430
+ *alwaysOnTop = actual_flags & SDL_WINDOW_ALWAYS_ON_TOP;
1431
+ *skipTaskbar = actual_flags & SDL_WINDOW_SKIP_TASKBAR;
1432
+ *popupMenu = actual_flags & SDL_WINDOW_POPUP_MENU;
1433
+ *tooltip = actual_flags & SDL_WINDOW_TOOLTIP;
1434
+ *utility = actual_flags & SDL_WINDOW_UTILITY;
1428
1435
 
1429
1436
  *window_id = SDL_GetWindowID(window);
1430
1437
  if (*window_id == 0) {
@@ -60,9 +60,14 @@ ErrorMessage * window_create (
60
60
  bool * fullscreen,
61
61
  bool * resizable,
62
62
  bool * borderless,
63
+ bool * alwaysOnTop,
63
64
  bool * accelerated,
64
65
  bool * vsync,
65
66
  bool opengl,
67
+ bool * skipTaskbar,
68
+ bool * popupMenu,
69
+ bool * tooltip,
70
+ bool * utility,
66
71
  int * window_id, void ** native_pointer, int * native_pointer_size
67
72
  );
68
73
  ErrorMessage * window_setTitle (int window_id, const char * title);
@@ -5,17 +5,6 @@ export namespace Events {
5
5
 
6
6
  type PreventCallback = () => void
7
7
 
8
- namespace App {
9
-
10
- interface BeforeQuit extends BaseEvent {
11
- readonly type: 'beforeQuit'
12
- readonly prevent: PreventCallback
13
- }
14
-
15
- interface Quit extends BaseEvent { readonly type: 'quit' }
16
-
17
- }
18
-
19
8
  namespace Window {
20
9
 
21
10
  interface WindowEvent extends BaseEvent {}
@@ -339,6 +328,8 @@ export namespace Sdl {
339
328
  readonly borderless: boolean
340
329
  setBorderless (borderless: boolean): void
341
330
 
331
+ readonly alwaysOnTop: boolean
332
+
342
333
  readonly accelerated: boolean
343
334
  setAccelerated (accelerated: boolean): void
344
335
 
@@ -360,6 +351,11 @@ export namespace Sdl {
360
351
 
361
352
  readonly hovered: boolean
362
353
 
354
+ readonly skipTaskbar: boolean
355
+ readonly popupMenu: boolean
356
+ readonly tooltip: boolean
357
+ readonly utility: boolean
358
+
363
359
  render (width: number, height: number, stride: number, format: Format, buffer: Buffer): void
364
360
 
365
361
  setIcon (width: number, height: number, stride: number, format: Format, buffer: Buffer): void
@@ -386,9 +382,14 @@ export namespace Sdl {
386
382
  fullscreen?: boolean
387
383
  resizable?: boolean
388
384
  borderless?: boolean
385
+ alwaysOnTop?: boolean
389
386
  accelerated?: boolean
390
387
  vsync?: boolean
391
388
  opengl?: boolean
389
+ skipTaskbar?: boolean
390
+ popupMenu?: boolean
391
+ tooltip?: boolean
392
+ utility?: boolean
392
393
  }): Window
393
394
  }
394
395
  }
@@ -983,9 +984,6 @@ export namespace Sdl {
983
984
  }
984
985
 
985
986
  interface Module {
986
- on (event: 'beforeQuit', listener: (event: Events.App.BeforeQuit) => void): this
987
- on (event: 'quit', listener: (event: Events.App.Quit) => void): this
988
-
989
987
  readonly info: Info
990
988
  readonly video: Video.Module
991
989
  readonly keyboard: Keyboard.Module
@@ -1,23 +0,0 @@
1
- const Globals = require('../globals')
2
- const { sdl } = require('../sdl')
3
-
4
-
5
- const maybeTriggerQuit = () => {
6
- if (Globals.windows.all.size > 0) { return }
7
-
8
- let shouldPrevent = false
9
- const prevent = () => { shouldPrevent = true }
10
-
11
- const type1 = 'beforeQuit'
12
- const event1 = { type: type1, prevent }
13
- sdl.emit(type1, event1)
14
-
15
- if (shouldPrevent) { return }
16
-
17
- const type2 = 'quit'
18
- const event2 = { type: type2 }
19
- sdl.emit(type2, event2)
20
- process.exit()
21
- }
22
-
23
- module.exports = { maybeTriggerQuit }
@@ -1,5 +0,0 @@
1
- const { EventsViaPoll } = require('./events/events-via-poll')
2
-
3
- const sdl = new EventsViaPoll([ 'beforeQuit', 'quit' ])
4
-
5
- module.exports = { sdl }