@atom-js-org/runtime 0.5.3-alpha.3 → 0.5.3-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atom-js-org/runtime",
3
- "version": "0.5.3-alpha.3",
3
+ "version": "0.5.3-alpha.4",
4
4
  "description": "Electron-like desktop runtime powered by the operating system WebView.",
5
5
  "main": "src/index.cjs",
6
6
  "types": "index.d.ts",
@@ -18,10 +18,10 @@ class WindowsNativeDragApi {
18
18
  const user32 = koffi.load('user32.dll');
19
19
  const pointType = koffi.struct('ATOMJS_WIN32_POINT', { x: 'long', y: 'long' });
20
20
  this.releaseCapture = user32.func('__stdcall', 'ReleaseCapture', 'bool', []);
21
- this.sendMessageW = user32.func(
21
+ this.postMessageW = user32.func(
22
22
  '__stdcall',
23
- 'SendMessageW',
24
- 'intptr_t',
23
+ 'PostMessageW',
24
+ 'bool',
25
25
  ['void *', 'uint32_t', 'uintptr_t', 'intptr_t']
26
26
  );
27
27
  this.getAsyncKeyState = user32.func('__stdcall', 'GetAsyncKeyState', 'int16_t', ['int']);
@@ -46,15 +46,15 @@ class WindowsNativeDragApi {
46
46
  const handle = nativeWindowHandle(nativeWindow);
47
47
  if (handle === 0n || !this.isLeftButtonDown()) return false;
48
48
 
49
- // Hand control to DefWindowProc instead of moving the window from JavaScript.
50
- // This enters Windows' normal move loop, including snapping, monitor/DPI
51
- // transitions and maximized-window restore behavior.
49
+ // Queue the standard non-client title-bar press and return immediately.
50
+ // PostMessageW is important here: SendMessageW blocks Node while Windows runs
51
+ // its modal move loop, which causes frozen rendering and erratic input. Tao's
52
+ // own Window::drag_window() follows the same asynchronous Win32 path.
52
53
  const cursor = {};
53
54
  const cursorPosition = this.getCursorPos(cursor) ? packScreenPoint(cursor.x, cursor.y) : 0n;
54
55
 
55
56
  this.releaseCapture();
56
- this.sendMessageW(handle, WM_NCLBUTTONDOWN, HTCAPTION, cursorPosition);
57
- return true;
57
+ return Boolean(this.postMessageW(handle, WM_NCLBUTTONDOWN, HTCAPTION, cursorPosition));
58
58
  }
59
59
  }
60
60
 
@@ -124,7 +124,8 @@ class WindowsNativeHost {
124
124
  width: positive(config.width, 800),
125
125
  height: positive(config.height, 600)
126
126
  },
127
- lastDragClick: null
127
+ lastDragClick: null,
128
+ nativeDragPending: false
128
129
  };
129
130
  this.windows.set(Number(config.windowId), record);
130
131
  this._attachEvents(Number(config.windowId), record);
@@ -146,6 +147,10 @@ class WindowsNativeHost {
146
147
  record.nativeWindow.on('focus', () => emit({ type: 'focus' }));
147
148
  record.nativeWindow.on('blur', () => emit({ type: 'blur' }));
148
149
  record.nativeWindow.on('move', (event) => {
150
+ if (record.nativeDragPending) {
151
+ record.nativeDragPending = false;
152
+ record.lastDragClick = null;
153
+ }
149
154
  const scale = safeScaleFactor(record.nativeWindow);
150
155
  emit({
151
156
  type: 'bounds-changed',
@@ -167,6 +172,9 @@ class WindowsNativeHost {
167
172
  if (!point || !isDraggablePoint(record, point)) return;
168
173
  this._startNativeWindowDrag(record, point);
169
174
  });
175
+ record.nativeWindow.on('mouse-up', (event) => {
176
+ if (Number(event.button) === 0) record.nativeDragPending = false;
177
+ });
170
178
  record.webview.on('page-load-started', (event) => emit({ type: 'did-start-loading', url: event.url || '' }));
171
179
  record.webview.on('page-load-finished', (event) => emit({ type: 'did-finish-load', url: event.url || '' }));
172
180
  record.webview.on('title-changed', (event) => emit({ type: 'page-title-updated', title: event.title || '' }));
@@ -182,17 +190,12 @@ class WindowsNativeHost {
182
190
  return true;
183
191
  }
184
192
 
185
- const before = readPhysicalWindowPosition(record.nativeWindow);
186
193
  const started = nativeDrag.startWindowDrag(record.nativeWindow);
187
194
  if (!started) return false;
188
195
 
189
- // SendMessageW returns when the native move loop ends. A real movement must
190
- // not become the first half of a later title-bar double click.
191
- const after = readPhysicalWindowPosition(record.nativeWindow);
192
- if (!samePhysicalPosition(before, after)) {
193
- record.lastDragClick = null;
194
- emitFinalWindowBounds(record);
195
- }
196
+ // The Win32 move loop is queued asynchronously. Native move events keep the
197
+ // BrowserWindow bounds synchronized while Windows owns the pointer.
198
+ record.nativeDragPending = true;
196
199
  return true;
197
200
  }
198
201
 
@@ -352,42 +355,6 @@ function isSystemDoubleClick(record, point, settings) {
352
355
  Math.abs(Number(previous.y) - Number(point.y)) <= halfHeight;
353
356
  }
354
357
 
355
- function readPhysicalWindowPosition(win) {
356
- try {
357
- const position = win.getPosition(false);
358
- const x = Number(position && position.x);
359
- const y = Number(position && position.y);
360
- return Number.isFinite(x) && Number.isFinite(y) ? { x, y } : null;
361
- } catch {
362
- return null;
363
- }
364
- }
365
-
366
-
367
- function emitFinalWindowBounds(record) {
368
- try {
369
- const win = record.nativeWindow;
370
- const scale = safeScaleFactor(win);
371
- const position = win.getPosition(false);
372
- const size = win.getInnerSize(true);
373
- record.atomWindow._handleHostEvent({
374
- type: 'bounds-changed',
375
- reason: 'move',
376
- windowId: record.windowId,
377
- bounds: {
378
- x: Number(position.x) / scale,
379
- y: Number(position.y) / scale,
380
- width: Number(size.width),
381
- height: Number(size.height)
382
- }
383
- });
384
- } catch {}
385
- }
386
-
387
- function samePhysicalPosition(a, b) {
388
- if (!a || !b) return true;
389
- return Math.abs(a.x - b.x) <= 1 && Math.abs(a.y - b.y) <= 1;
390
- }
391
358
 
392
359
  function resolveWritableWebViewDataDirectory() {
393
360
  const identity = sanitizePathSegment(
@@ -443,7 +410,5 @@ module.exports = {
443
410
  isDraggablePoint,
444
411
  normalizeDragRegions,
445
412
  resolveWritableWebViewDataDirectory,
446
- isSystemDoubleClick,
447
- emitFinalWindowBounds,
448
- samePhysicalPosition
413
+ isSystemDoubleClick
449
414
  };