dsh-gufa-code 1.3.4 → 1.3.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/README.md CHANGED
@@ -69,9 +69,10 @@ dsh plugin add dsh-gufa-code
69
69
 
70
70
  ### 摸鱼模式 / 桌面悬浮层(实验功能,macOS arm64)
71
71
 
72
- - **进入摸鱼**:IDE 标题栏点「显示器」图标 → 弹出 **App 窗口列表**(图标 + App 名 + 窗口标题 + 窗口尺寸,和投屏列表类似)→ 选中一个窗口,古法编程会:
72
+ - **进入摸鱼**:IDE 标题栏点「显示器」图标 → 弹出 **运行中 App 列表**(图标 + App 名,和投屏列表类似)→ 选中一个 App,古法编程会:
73
73
  - 把该 App 切到前台(主窗口自动被盖住,等于「隐藏主窗口」);
74
- - 以**无边框、半透明(0.55)、永远置顶**的独立悬浮窗出现,并**自动吸附**到该窗口:位置、大小完全一致,窗口移动/缩放时实时跟随。
74
+ - 以**无边框、半透明(0.55)、永远置顶**的独立悬浮窗出现,并**自动吸附**到该 App 当前窗口:位置、大小一致,窗口移动/缩放时实时跟随。
75
+ - 读取窗口位置/大小走 macOS **「辅助功能」**权限(不是屏幕录制):系统设置 → 隐私与安全性 → 辅助功能 → 勾选 **DeepSeek Harness**;改完重启一次 DSH 生效。
75
76
  - **悬浮层交互**:
76
77
  - 顶部 22px 拖动条移动窗口(右键 = 摸鱼菜单),窗口大小/位置会记住;
77
78
  - 全局快捷键 **⌃⌥⌘G**:切换点击穿透(穿透后鼠标直接操作下面的 App,再按一次切回来);
package/client.js CHANGED
@@ -10266,9 +10266,11 @@ G.GufaApp = function GufaApp(props) {
10266
10266
  setFloatPicker({ status: 'loading', windows: [], error: '' })
10267
10267
  try {
10268
10268
  const value = await G.api('float.windows')
10269
- if (value?.ok === true && Array.isArray(value.windows)) {
10270
- setFloatPicker({ status: 'ready', windows: value.windows, error: '' })
10271
- } else if (value?.ok === false && value?.permission === 'screen-recording') {
10269
+ if (value?.ok === true && value?.accessibility !== true) {
10270
+ setFloatPicker({ status: 'permission', windows: [], error: '' })
10271
+ } else if (value?.ok === true && Array.isArray(value.apps)) {
10272
+ setFloatPicker({ status: 'ready', windows: value.apps, error: '' })
10273
+ } else if (value?.ok === false) {
10272
10274
  setFloatPicker({ status: 'permission', windows: [], error: '' })
10273
10275
  } else {
10274
10276
  setFloatPicker({ status: 'error', windows: [], error: '没有读到可吸附的窗口' })
@@ -10284,7 +10286,11 @@ G.GufaApp = function GufaApp(props) {
10284
10286
  setFloatBusy(true)
10285
10287
  try {
10286
10288
  const value = await G.api('float.start', {
10287
- follow: { windowNumber: Number(target.windowNumber) || 0, pid: Number(target.pid) || 0 },
10289
+ follow: {
10290
+ pid: Number(target.pid) || 0,
10291
+ bundleId: typeof target.bundleId === 'string' ? target.bundleId : '',
10292
+ title: '',
10293
+ },
10288
10294
  })
10289
10295
  setFloatRunning(value?.running === true)
10290
10296
  setFloatPicker(null)
@@ -11579,8 +11585,8 @@ G.GufaApp = function GufaApp(props) {
11579
11585
  ? h(
11580
11586
  'div',
11581
11587
  { className: 'gufa-float-permission' },
11582
- h('div', { className: 'gufa-float-permission-title' }, '需要「屏幕录制」权限'),
11583
- h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App 的窗口尺寸(只读尺寸,不录屏)。系统只认悬浮层 App 自己的授权:请在「系统设置 → 隐私与安全性 → 屏幕录制」里点左下角「+」,添加「古法编程悬浮层.app」并打开开关(DeepSeek Harness 的开关也保持打开)。加好后点「重试」。'),
11588
+ h('div', { className: 'gufa-float-permission-title' }, '需要「辅助功能」权限'),
11589
+ h('div', { className: 'gufa-hint' }, '摸鱼模式需要「辅助功能」权限才能读取/跟随其他 App 的窗口位置和大小(只读窗口信息,不录屏)。请在「系统设置 → 隐私与安全性 → 辅助功能」里打开 **DeepSeek Harness** 的开关(改完可能需要重启一次 DSH),然后点「重试」。'),
11584
11590
  h(
11585
11591
  'div',
11586
11592
  { className: 'gufa-row', style: { gap: 8, marginTop: 12, flexWrap: 'wrap' } },
@@ -11613,10 +11619,10 @@ G.GufaApp = function GufaApp(props) {
11613
11619
  h(
11614
11620
  'span',
11615
11621
  { className: 'gufa-float-meta' },
11616
- h('span', { className: 'gufa-float-owner' }, win.owner !== '' ? win.owner : '未知 App'),
11617
- h('span', { className: 'gufa-float-title' }, win.title !== '' ? win.title : '(无标题窗口)'),
11622
+ h('span', { className: 'gufa-float-owner' }, win.name !== undefined && win.name !== '' ? win.name : '未知 App'),
11623
+ h('span', { className: 'gufa-float-title' }, win.bundleId !== undefined ? win.bundleId : ''),
11618
11624
  ),
11619
- h('span', { className: 'gufa-float-size' }, `${Math.round(win.width)}×${Math.round(win.height)}`),
11625
+ win.frontmost === true ? h('span', { className: 'gufa-float-size' }, '当前') : null,
11620
11626
  ),
11621
11627
  ),
11622
11628
  ),
@@ -12,14 +12,25 @@
12
12
  #import <AppKit/AppKit.h>
13
13
  #import <WebKit/WebKit.h>
14
14
  #import <CoreGraphics/CoreGraphics.h>
15
+ #import <ApplicationServices/ApplicationServices.h>
15
16
  #import <Carbon/Carbon.h>
16
17
  #import <signal.h>
17
18
 
18
19
  static const EventHotKeyID GufaToggleHotKey = {'gufa', 1};
19
20
 
21
+ /* 前置声明(实现位于文件后半部分) */
22
+ static NSString *GufaOutputPath = nil;
23
+ static void GufaEmitJSON(NSDictionary *out);
24
+ static BOOL GufaTrustedForAX(void);
25
+ static NSArray<NSDictionary *> *GufaAXWindows(void);
26
+ static AXUIElementRef GufaCopyAXWindow(pid_t pid, NSString *title);
27
+ static BOOL GufaRectFromAX(AXUIElementRef element, NSRect *out);
28
+ static void GufaActivateBundle(NSString *bundleId);
29
+ static NSArray<NSDictionary *> *GufaAXApps(void);
30
+ static AXUIElementRef GufaCopyAppWindow(pid_t pid);
31
+
20
32
  /* SIGTERM 时先把主窗口(DeepSeek Harness)唤回前台,再退出,实现「退出摸鱼」 */
21
33
  static void GufaInstallTermHandler(void);
22
- static BOOL GufaRowsHaveForeignWindows(NSArray<NSDictionary *> *rows);
23
34
 
24
35
  @class GufaAppDelegate;
25
36
 
@@ -85,8 +96,9 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
85
96
  @property (nonatomic, strong) NSDictionary *options;
86
97
  @property (nonatomic, assign) EventHotKeyRef hotKeyRef;
87
98
  @property (nonatomic, assign) BOOL following;
88
- @property (nonatomic, assign) int followWindowNumber;
89
- @property (nonatomic, assign) pid_t followOwnerPID;
99
+ @property (nonatomic, assign) pid_t followPid;
100
+ @property (nonatomic, copy) NSString *followTitle;
101
+ @property (nonatomic, assign) AXUIElementRef followWindowRef;
90
102
  @property (nonatomic, strong) NSTimer *followTimer;
91
103
  @property (nonatomic, strong) NSMutableArray<NSDictionary *> *windowCandidates;
92
104
  - (void)loadWebContent;
@@ -128,29 +140,38 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
128
140
  [self loadWebContent];
129
141
  }
130
142
 
131
- /** 吸附目标 App:把它切到前台,主窗口就自然被盖住了(等价于「隐藏主窗口」的观感)。 */
143
+ /** 吸附目标 App:把它切到前台(主窗口自然被盖住 + 切到它所在的 Space)。 */
132
144
  - (void)activateTargetApp {
133
145
  NSDictionary *follow = self.options[@"follow"];
134
- NSNumber *pid = [follow isKindOfClass:[NSDictionary class]] ? follow[@"pid"] : nil;
146
+ if (![follow isKindOfClass:[NSDictionary class]]) return;
147
+ NSString *bundleId = [follow[@"bundleId"] isKindOfClass:[NSString class]] ? follow[@"bundleId"] : @"";
148
+ if (bundleId.length > 0) {
149
+ GufaActivateBundle(bundleId);
150
+ return;
151
+ }
152
+ NSNumber *pid = follow[@"pid"];
135
153
  if (![pid isKindOfClass:[NSNumber class]]) return;
136
154
  NSRunningApplication *app = [NSRunningApplication runningApplicationWithProcessIdentifier:(pid_t)pid.intValue];
137
- if (app == nil) return;
138
- [app activateWithOptions:NSApplicationActivateAllWindows];
155
+ if (app != nil) GufaActivateBundle(app.bundleIdentifier);
139
156
  }
140
157
 
141
- /** 启动就进入「吸附跟随」模式(摸鱼列表选好窗口后直接启动)。 */
158
+ /** 启动就进入「吸附跟随」模式(摸鱼列表选好 App 后直接启动)。 */
142
159
  - (void)beginningFollowFromOptions {
143
160
  NSDictionary *follow = self.options[@"follow"];
144
161
  if (![follow isKindOfClass:[NSDictionary class]]) return;
145
- NSNumber *number = follow[@"windowNumber"];
146
162
  NSNumber *pid = follow[@"pid"];
147
- if (![number isKindOfClass:[NSNumber class]] || ![pid isKindOfClass:[NSNumber class]]) return;
148
- self.followWindowNumber = number.intValue;
149
- self.followOwnerPID = (pid_t)pid.intValue;
150
- self.following = YES;
151
- [self startFollowTimer];
152
- [self applyFollowFrame];
153
- self.statusItem.button.title = @"古法·摸鱼";
163
+ if (![pid isKindOfClass:[NSNumber class]]) return;
164
+ self.followPid = (pid_t)pid.intValue;
165
+ self.followTitle = [follow[@"title"] isKindOfClass:[NSString class]] ? follow[@"title"] : @"";
166
+ /* App 刚被激活,窗口可能还没切到当前 Space;稍等再抓窗口 */
167
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
168
+ self.followWindowRef = GufaCopyAppWindow(self.followPid);
169
+ if (self.followWindowRef == NULL) return;
170
+ self.following = YES;
171
+ [self startFollowTimer];
172
+ [self applyFollowFrame];
173
+ self.statusItem.button.title = @"古法·摸鱼";
174
+ });
154
175
  }
155
176
 
156
177
  - (void)parseOptions {
@@ -232,7 +253,7 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
232
253
  self.statusItem.button.title = @"古法";
233
254
  self.statusItem.button.toolTip = @"古法编程悬浮层";
234
255
  NSMenu *menu = [[NSMenu alloc] init];
235
- [menu addItemWithTitle:@"跟随 App 窗口…(需屏幕录制权限)" action:@selector(chooseFollowWindow:) keyEquivalent:@""].target = self;
256
+ [menu addItemWithTitle:@"跟随 App 窗口…(需辅助功能权限)" action:@selector(chooseFollowWindow:) keyEquivalent:@""].target = self;
236
257
  [menu addItemWithTitle:@"停止跟随" action:@selector(stopFollow:) keyEquivalent:@""].target = self;
237
258
  [menu addItem:[NSMenuItem separatorItem]];
238
259
  [menu addItemWithTitle:@"切换点击穿透(⌃⌥⌘G)" action:@selector(toggleClickThrough:) keyEquivalent:@""].target = self;
@@ -275,87 +296,53 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
275
296
  [[NSUserDefaults standardUserDefaults] setObject:NSStringFromRect(self.window.frame) forKey:self.frameKey];
276
297
  }
277
298
 
278
- /* ── P1:跟随选中的 App 窗口 ───────────────────────────────────── */
279
-
280
- /** 枚举屏幕上的普通窗口(需要屏幕录制权限才能看到别的 App)。 */
281
- - (NSArray<NSDictionary *> *)visibleWindows {
282
- NSMutableArray<NSDictionary *> *rows = [NSMutableArray array];
283
- CFArrayRef list = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
284
- if (list == NULL) return rows;
285
- NSInteger count = CFArrayGetCount(list);
286
- pid_t selfPid = NSProcessInfo.processInfo.processIdentifier;
287
- for (NSInteger i = 0; i < count && rows.count < 60; i++) {
288
- NSDictionary *info = (__bridge NSDictionary *)CFArrayGetValueAtIndex(list, i);
289
- NSNumber *layer = info[(id)kCGWindowLayer];
290
- if (![layer isKindOfClass:[NSNumber class]] || layer.intValue != 0) continue;
291
- NSNumber *pid = info[(id)kCGWindowOwnerPID];
292
- if (![pid isKindOfClass:[NSNumber class]] || pid.intValue == selfPid) continue;
293
- NSNumber *number = info[(id)kCGWindowNumber];
294
- NSDictionary *bounds = info[(id)kCGWindowBounds];
295
- if (number == nil || bounds == nil) continue;
296
- CGRect rect = CGRectZero;
297
- if (!CGRectMakeWithDictionaryRepresentation((__bridge CFDictionaryRef)bounds, &rect)) continue;
298
- if (rect.size.width < 220 || rect.size.height < 160) continue;
299
- NSString *owner = info[(id)kCGWindowOwnerName];
300
- NSString *title = info[(id)kCGWindowName];
301
- NSString *label = [NSString stringWithFormat:@"%@%@ · %.0f×%.0f",
302
- owner != nil ? owner : @"?",
303
- (title.length > 0 ? [NSString stringWithFormat:@" — %@", title] : @""),
304
- rect.size.width, rect.size.height];
305
- [rows addObject:@{
306
- @"number": number,
307
- @"pid": pid,
308
- @"owner": owner != nil ? owner : @"?",
309
- @"title": title != nil ? title : @"",
310
- @"label": label,
311
- @"rect": NSStringFromRect(NSRectFromCGRect(rect)),
312
- }];
313
- }
314
- CFRelease(list);
315
- return rows;
316
- }
299
+ /* ── 跟随选中的 App 窗口(Accessibility API) ─────────────────────── */
317
300
 
318
301
  - (void)showPermissionGuide {
319
302
  NSAlert *alert = [[NSAlert alloc] init];
320
- alert.messageText = @"需要「屏幕录制」权限";
321
- alert.informativeText = @"要跟随其他 App 的窗口大小,系统需要授予本悬浮层「屏幕录制」权限:\n\n系统设置 → 隐私与安全性 → 屏幕录制 → 勾选「古法编程悬浮层 / gufa-float」;授权后点「重试」。\n\n(只读取窗口尺寸,不录屏、不采集画面。)";
303
+ alert.messageText = @"需要「辅助功能」权限";
304
+ alert.informativeText = @"摸鱼列表要读取其他 App 窗口的位置和大小,需要「辅助功能」权限:\n\n系统设置 → 隐私与安全性 → 辅助功能 → 打开 DeepSeek Harness(以及「古法编程悬浮层」)的开关;改完后点「重试」。\n\n(只读取窗口尺寸/位置,不录屏、不采集画面。)";
322
305
  [alert addButtonWithTitle:@"打开系统设置"];
323
306
  [alert addButtonWithTitle:@"取消"];
324
- NSModalResponse response = [alert runModal];
325
- if (response == NSAlertFirstButtonReturn) {
326
- [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"]];
307
+ if ([alert runModal] == NSAlertFirstButtonReturn) {
308
+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"]];
327
309
  }
328
310
  }
329
311
 
330
312
  - (void)chooseFollowWindow:(id)sender {
331
- NSArray<NSDictionary *> *rows = [self visibleWindows];
332
- if (rows.count == 0 || !GufaRowsHaveForeignWindows(rows)) {
333
- CGRequestScreenCaptureAccess();
313
+ if (!GufaTrustedForAX()) {
314
+ [self showPermissionGuide];
315
+ return;
316
+ }
317
+ NSArray<NSDictionary *> *rows = GufaAXApps();
318
+ if (rows.count == 0) {
334
319
  [self showPermissionGuide];
335
320
  return;
336
321
  }
337
- self.windowCandidates = [rows mutableCopy];
338
-
339
322
  NSAlert *alert = [[NSAlert alloc] init];
340
- alert.messageText = @"选择要跟随的 App 窗口";
341
- alert.informativeText = @"悬浮层会保持与该窗口相同的位置和大小;窗口移动/缩放时自动跟随。";
323
+ alert.messageText = @"选择要吸附的 App";
324
+ alert.informativeText = @"悬浮层会切到该 App 的窗口并保持相同位置/大小,窗口移动时自动跟随。";
342
325
  NSPopUpButton *popup = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 420, 26) pullsDown:NO];
343
- for (NSDictionary *row in self.windowCandidates) {
344
- [popup addItemWithTitle:row[@"label"]];
345
- }
326
+ for (NSDictionary *row in rows) [popup addItemWithTitle:row[@"name"] ?: @"?"];
346
327
  alert.accessoryView = popup;
347
- [alert addButtonWithTitle:@"开始跟随"];
328
+ [alert addButtonWithTitle:@"开始摸鱼"];
348
329
  [alert addButtonWithTitle:@"取消"];
349
330
  if ([alert runModal] != NSAlertFirstButtonReturn) return;
350
331
  NSInteger index = popup.indexOfSelectedItem;
351
- if (index < 0 || index >= (NSInteger)self.windowCandidates.count) return;
352
- NSDictionary *row = self.windowCandidates[(NSUInteger)index];
353
- self.followWindowNumber = [row[@"number"] intValue];
354
- self.followOwnerPID = (pid_t)[row[@"pid"] intValue];
355
- self.following = YES;
356
- [self startFollowTimer];
357
- [self applyFollowFrame];
358
- self.statusItem.button.title = @"古法·跟随";
332
+ if (index < 0 || index >= (NSInteger)rows.count) return;
333
+ NSDictionary *row = rows[(NSUInteger)index];
334
+ self.followPid = (pid_t)[row[@"pid"] intValue];
335
+ self.followTitle = @"";
336
+ if (self.followWindowRef != NULL) { CFRelease(self.followWindowRef); self.followWindowRef = NULL; }
337
+ GufaActivateBundle(row[@"bundleId"]);
338
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
339
+ self.followWindowRef = GufaCopyAppWindow(self.followPid);
340
+ if (self.followWindowRef == NULL) return;
341
+ self.following = YES;
342
+ [self startFollowTimer];
343
+ [self applyFollowFrame];
344
+ self.statusItem.button.title = @"古法·摸鱼";
345
+ });
359
346
  }
360
347
 
361
348
  - (void)stopFollow:(id)sender {
@@ -379,29 +366,25 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
379
366
  self.followTimer = nil;
380
367
  }
381
368
  self.following = NO;
369
+ if (self.followWindowRef != NULL) {
370
+ CFRelease(self.followWindowRef);
371
+ self.followWindowRef = NULL;
372
+ }
382
373
  }
383
374
 
384
- /** 找到被跟随窗口当前 bounds,把悬浮窗贴上去(主屏坐标换算;多屏后续再完善)。 */
375
+ /** 读取被跟随窗口当前 bounds,把悬浮窗贴上去(主屏坐标换算;多屏后续再完善)。 */
385
376
  - (void)applyFollowFrame {
386
- if (!self.following || self.followWindowNumber == 0) return;
387
- CFArrayRef list = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
388
- if (list == NULL) return;
389
- CGRect target = CGRectZero;
390
- BOOL found = NO;
391
- NSInteger count = CFArrayGetCount(list);
392
- for (NSInteger i = 0; i < count; i++) {
393
- NSDictionary *info = (__bridge NSDictionary *)CFArrayGetValueAtIndex(list, i);
394
- NSNumber *number = info[(id)kCGWindowNumber];
395
- if (![number isKindOfClass:[NSNumber class]] || number.intValue != self.followWindowNumber) continue;
396
- NSNumber *pid = info[(id)kCGWindowOwnerPID];
397
- if (![pid isKindOfClass:[NSNumber class]] || pid.intValue != self.followOwnerPID) continue;
398
- NSDictionary *bounds = info[(id)kCGWindowBounds];
399
- if (bounds != nil && CGRectMakeWithDictionaryRepresentation((__bridge CFDictionaryRef)bounds, &target)) found = YES;
400
- break;
377
+ if (!self.following) return;
378
+ if (self.followWindowRef == NULL) {
379
+ self.followWindowRef = GufaCopyAXWindow(self.followPid, self.followTitle);
380
+ if (self.followWindowRef == NULL) {
381
+ [self stopFollowTimer];
382
+ self.statusItem.button.title = @"古法";
383
+ return;
384
+ }
401
385
  }
402
- CFRelease(list);
403
- if (!found) {
404
- /* 目标窗口关闭:停止跟随,保持当前位置 */
386
+ NSRect target = NSZeroRect;
387
+ if (!GufaRectFromAX(self.followWindowRef, &target)) {
405
388
  [self stopFollowTimer];
406
389
  self.statusItem.button.title = @"古法";
407
390
  return;
@@ -409,7 +392,6 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
409
392
  CGFloat screenHeight = NSScreen.mainScreen.frame.size.height;
410
393
  NSRect frame = NSMakeRect(target.origin.x, screenHeight - target.origin.y - target.size.height, target.size.width, target.size.height);
411
394
  [self.window setFrame:frame display:YES animate:NO];
412
- [self saveFrame];
413
395
  }
414
396
 
415
397
  /* 全局快捷键 ⌃⌥⌘G(四键,避免冲突):穿透后窗口收不到鼠标事件,靠它切回来(Carbon 热键不需要辅助功能权限) */
@@ -445,10 +427,7 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
445
427
  }
446
428
 
447
429
  - (void)restoreMainWindow {
448
- NSArray<NSRunningApplication *> *apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.deepseek.dsh"];
449
- for (NSRunningApplication *app in apps) {
450
- [app activateWithOptions:NSApplicationActivateAllWindows];
451
- }
430
+ GufaActivateBundle(@"com.deepseek.dsh");
452
431
  }
453
432
 
454
433
  - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender { return YES; }
@@ -460,10 +439,7 @@ static void GufaInstallTermHandler(void) {
460
439
  signal(SIGTERM, SIG_IGN);
461
440
  dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, dispatch_get_main_queue());
462
441
  dispatch_source_set_event_handler(source, ^{
463
- NSArray<NSRunningApplication *> *apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.deepseek.dsh"];
464
- for (NSRunningApplication *app in apps) {
465
- [app activateWithOptions:NSApplicationActivateAllWindows];
466
- }
442
+ GufaActivateBundle(@"com.deepseek.dsh");
467
443
  [NSApp terminate:nil];
468
444
  });
469
445
  dispatch_resume(source);
@@ -477,60 +453,170 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
477
453
  return noErr;
478
454
  }
479
455
 
480
- /* ── 窗口列表模式:gufa-float --list-windows ─────────────────────── */
456
+ /* ── 窗口枚举:用 Accessibility(辅助功能)API ─────────────────────
457
+ * 不用 CGWindowList(它需要「屏幕录制」,ad-hoc 签名的 helper 拿不到授权);
458
+ * 辅助功能权限按 responsible app(DeepSeek Harness)继承,用户只需在
459
+ * 「隐私与安全性 → 辅助功能」里勾选 DeepSeek Harness 即可。
460
+ */
481
461
 
482
- static NSArray<NSDictionary *> *GufaEnumerateWindows(void) {
462
+ static BOOL GufaStringFromAX(AXUIElementRef element, CFStringRef attribute, NSString **out) {
463
+ CFTypeRef value = NULL;
464
+ if (AXUIElementCopyAttributeValue(element, attribute, &value) != kAXErrorSuccess || value == NULL) return NO;
465
+ if (CFGetTypeID(value) != CFStringGetTypeID()) { CFRelease(value); return NO; }
466
+ if (out != NULL) *out = (__bridge_transfer NSString *)value;
467
+ else CFRelease(value);
468
+ return YES;
469
+ }
470
+
471
+ static BOOL GufaRectFromAX(AXUIElementRef element, NSRect *out) {
472
+ CFTypeRef posRef = NULL;
473
+ CFTypeRef sizeRef = NULL;
474
+ CGPoint pos = CGPointZero;
475
+ CGSize size = CGSizeZero;
476
+ BOOL ok = NO;
477
+ if (AXUIElementCopyAttributeValue(element, (CFStringRef)CFSTR("AXPosition"), &posRef) == kAXErrorSuccess && posRef != NULL) {
478
+ AXValueGetValue((AXValueRef)posRef, kAXValueCGPointType, &pos);
479
+ CFRelease(posRef);
480
+ }
481
+ if (AXUIElementCopyAttributeValue(element, (CFStringRef)CFSTR("AXSize"), &sizeRef) == kAXErrorSuccess && sizeRef != NULL) {
482
+ AXValueGetValue((AXValueRef)sizeRef, kAXValueCGSizeType, &size);
483
+ CFRelease(sizeRef);
484
+ ok = YES;
485
+ }
486
+ if (out != NULL) *out = NSMakeRect(pos.x, pos.y, size.width, size.height);
487
+ return ok;
488
+ }
489
+
490
+ /** 枚举所有可见窗口,返回 [{pid, owner, title, rect, icon}]。 */
491
+ static NSArray<NSDictionary *> *GufaAXWindows(void) {
483
492
  NSMutableArray<NSDictionary *> *rows = [NSMutableArray array];
484
- CFArrayRef list = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
485
- if (list == NULL) return rows;
486
- NSInteger count = CFArrayGetCount(list);
487
- pid_t selfPid = NSProcessInfo.processInfo.processIdentifier;
488
493
  NSMutableDictionary<NSNumber *, NSData *> *iconCache = [NSMutableDictionary dictionary];
489
- for (NSInteger i = 0; i < count && rows.count < 60; i++) {
490
- NSDictionary *info = (__bridge NSDictionary *)CFArrayGetValueAtIndex(list, i);
491
- NSNumber *layer = info[(id)kCGWindowLayer];
492
- if (![layer isKindOfClass:[NSNumber class]] || layer.intValue != 0) continue;
493
- NSNumber *pid = info[(id)kCGWindowOwnerPID];
494
- if (![pid isKindOfClass:[NSNumber class]] || pid.intValue == selfPid) continue;
495
- NSNumber *number = info[(id)kCGWindowNumber];
496
- NSDictionary *bounds = info[(id)kCGWindowBounds];
497
- if (number == nil || bounds == nil) continue;
498
- CGRect rect = CGRectZero;
499
- if (!CGRectMakeWithDictionaryRepresentation((__bridge CFDictionaryRef)bounds, &rect)) continue;
500
- if (rect.size.width < 200 || rect.size.height < 140) continue;
501
- NSString *owner = info[(id)kCGWindowOwnerName];
502
- NSString *title = info[(id)kCGWindowName];
503
- NSData *iconData = iconCache[pid];
504
- if (iconData == nil) {
505
- iconData = NSData.data;
506
- NSRunningApplication *app = [NSRunningApplication runningApplicationWithProcessIdentifier:(pid_t)pid.intValue];
507
- NSImage *icon = app.icon;
508
- if (icon != nil) {
509
- NSImage *resized = [[NSImage alloc] initWithSize:NSMakeSize(32, 32)];
510
- [resized lockFocus];
511
- [icon drawInRect:NSMakeRect(0, 0, 32, 32) fromRect:NSZeroRect operation:NSCompositingOperationCopy fraction:1.0 respectFlipped:YES hints:nil];
512
- [resized unlockFocus];
513
- NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithData:resized.TIFFRepresentation];
514
- NSData *png = [rep representationUsingType:NSBitmapImageFileTypePNG properties:@{}];
515
- if (png != nil) iconData = png;
494
+ for (NSRunningApplication *app in [NSWorkspace sharedWorkspace].runningApplications) {
495
+ if (app.activationPolicy != NSApplicationActivationPolicyRegular) continue;
496
+ AXUIElementRef appElement = AXUIElementCreateApplication(app.processIdentifier);
497
+ if (appElement == NULL) continue;
498
+ CFTypeRef winsRef = NULL;
499
+ if (AXUIElementCopyAttributeValue(appElement, (CFStringRef)CFSTR("AXWindows"), &winsRef) == kAXErrorSuccess && winsRef != NULL) {
500
+ NSArray *wins = (__bridge_transfer NSArray *)winsRef;
501
+ for (id win in wins) {
502
+ AXUIElementRef window = (__bridge AXUIElementRef)win;
503
+ NSRect rect = NSZeroRect;
504
+ if (!GufaRectFromAX(window, &rect)) continue;
505
+ if (rect.size.width < 200 || rect.size.height < 140) continue;
506
+ NSString *title = @"";
507
+ GufaStringFromAX(window, (CFStringRef)CFSTR("AXTitle"), &title);
508
+ NSNumber *pidKey = @(app.processIdentifier);
509
+ NSData *iconData = iconCache[pidKey];
510
+ if (iconData == nil) {
511
+ iconData = NSData.data;
512
+ NSImage *icon = app.icon;
513
+ if (icon != nil) {
514
+ NSImage *resized = [[NSImage alloc] initWithSize:NSMakeSize(32, 32)];
515
+ [resized lockFocus];
516
+ [icon drawInRect:NSMakeRect(0, 0, 32, 32) fromRect:NSZeroRect operation:NSCompositingOperationCopy fraction:1.0 respectFlipped:YES hints:nil];
517
+ [resized unlockFocus];
518
+ NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithData:resized.TIFFRepresentation];
519
+ NSData *png = [rep representationUsingType:NSBitmapImageFileTypePNG properties:@{}];
520
+ if (png != nil) iconData = png;
521
+ }
522
+ iconCache[pidKey] = iconData;
523
+ }
524
+ [rows addObject:@{
525
+ @"pid": pidKey,
526
+ @"owner": app.localizedName ?: @"",
527
+ @"title": title,
528
+ @"x": @(rect.origin.x),
529
+ @"y": @(rect.origin.y),
530
+ @"width": @(rect.size.width),
531
+ @"height": @(rect.size.height),
532
+ @"icon": [iconData base64EncodedStringWithOptions:0] ?: @"",
533
+ }];
516
534
  }
517
- iconCache[pid] = iconData;
535
+ }
536
+ CFRelease(appElement);
537
+ }
538
+ return rows;
539
+ }
540
+
541
+ /** 枚举运行中的普通 App(不依赖任何权限),按「最前 → 后台」排序。 */
542
+ static NSArray<NSDictionary *> *GufaAXApps(void) {
543
+ NSMutableArray<NSDictionary *> *rows = [NSMutableArray array];
544
+ NSRunningApplication *front = [NSWorkspace sharedWorkspace].frontmostApplication;
545
+ CGFloat iconScale = 32.0;
546
+ for (NSRunningApplication *app in [NSWorkspace sharedWorkspace].runningApplications) {
547
+ if (app.activationPolicy != NSApplicationActivationPolicyRegular) continue;
548
+ if (app.bundleIdentifier.length == 0) continue;
549
+ NSData *iconData = NSData.data;
550
+ NSImage *icon = app.icon;
551
+ if (icon != nil) {
552
+ NSImage *resized = [[NSImage alloc] initWithSize:NSMakeSize(iconScale, iconScale)];
553
+ [resized lockFocus];
554
+ [icon drawInRect:NSMakeRect(0, 0, iconScale, iconScale) fromRect:NSZeroRect operation:NSCompositingOperationCopy fraction:1.0 respectFlipped:YES hints:nil];
555
+ [resized unlockFocus];
556
+ NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithData:resized.TIFFRepresentation];
557
+ NSData *png = [rep representationUsingType:NSBitmapImageFileTypePNG properties:@{}];
558
+ if (png != nil) iconData = png;
518
559
  }
519
560
  [rows addObject:@{
520
- @"windowNumber": number,
521
- @"pid": pid,
522
- @"owner": owner != nil ? owner : @"",
523
- @"title": title != nil ? title : @"",
524
- @"width": @(rect.size.width),
525
- @"height": @(rect.size.height),
561
+ @"pid": @(app.processIdentifier),
562
+ @"bundleId": app.bundleIdentifier,
563
+ @"name": app.localizedName ?: @"",
564
+ @"frontmost": @(front != nil && front.processIdentifier == app.processIdentifier),
526
565
  @"icon": [iconData base64EncodedStringWithOptions:0] ?: @"",
527
566
  }];
528
567
  }
529
- CFRelease(list);
568
+ [rows sortUsingComparator:^NSComparisonResult(NSDictionary *a, NSDictionary *b) {
569
+ BOOL fa = [a[@"frontmost"] boolValue];
570
+ BOOL fb = [b[@"frontmost"] boolValue];
571
+ if (fa != fb) return fa ? NSOrderedAscending : NSOrderedDescending;
572
+ return [a[@"name"] localizedCompare:b[@"name"]];
573
+ }];
530
574
  return rows;
531
575
  }
532
576
 
533
- static NSString *GufaOutputPath = nil;
577
+ /** 找某个 App 的窗口:优先 focused/main,其次最大的窗口。 */
578
+ static AXUIElementRef GufaCopyAppWindow(pid_t pid) {
579
+ AXUIElementRef appElement = AXUIElementCreateApplication(pid);
580
+ if (appElement == NULL) return NULL;
581
+ CFTypeRef windowRef = NULL;
582
+ AXUIElementRef found = NULL;
583
+ if (AXUIElementCopyAttributeValue(appElement, (CFStringRef)CFSTR("AXFocusedWindow"), &windowRef) == kAXErrorSuccess && windowRef != NULL) {
584
+ found = (AXUIElementRef)CFRetain(windowRef);
585
+ CFRelease(windowRef);
586
+ }
587
+ if (found == NULL && AXUIElementCopyAttributeValue(appElement, (CFStringRef)CFSTR("AXMainWindow"), &windowRef) == kAXErrorSuccess && windowRef != NULL) {
588
+ found = (AXUIElementRef)CFRetain(windowRef);
589
+ CFRelease(windowRef);
590
+ }
591
+ if (found == NULL) {
592
+ CFTypeRef winsRef = NULL;
593
+ if (AXUIElementCopyAttributeValue(appElement, (CFStringRef)CFSTR("AXWindows"), &winsRef) == kAXErrorSuccess && winsRef != NULL) {
594
+ NSArray *wins = (__bridge NSArray *)winsRef;
595
+ CGFloat bestArea = 0;
596
+ for (id win in wins) {
597
+ AXUIElementRef window = (__bridge AXUIElementRef)win;
598
+ NSRect rect = NSZeroRect;
599
+ if (!GufaRectFromAX(window, &rect)) continue;
600
+ CGFloat area = rect.size.width * rect.size.height;
601
+ if (area > bestArea && rect.size.width >= 200 && rect.size.height >= 140) {
602
+ if (found != NULL) CFRelease(found);
603
+ found = (AXUIElementRef)CFRetain(window);
604
+ bestArea = area;
605
+ }
606
+ }
607
+ CFRelease(winsRef);
608
+ }
609
+ }
610
+ CFRelease(appElement);
611
+ return found;
612
+ }
613
+
614
+ static BOOL GufaTrustedForAX(void) {
615
+ if (AXIsProcessTrusted()) return YES;
616
+ NSDictionary *options = @{(__bridge NSString *)kAXTrustedCheckOptionPrompt: @YES};
617
+ AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef)options);
618
+ return NO;
619
+ }
534
620
 
535
621
  static void GufaEmitJSON(NSDictionary *out) {
536
622
  NSData *json = [NSJSONSerialization dataWithJSONObject:out options:0 error:NULL];
@@ -543,33 +629,59 @@ static void GufaEmitJSON(NSDictionary *out) {
543
629
  fputc('\n', stdout);
544
630
  }
545
631
 
546
- static void GufaPrintPermissionResult(void) {
547
- GufaEmitJSON(@{@"ok": @NO, @"permission": @"screen-recording"});
632
+ static int GufaListWindowsMode(void) {
633
+ NSArray<NSDictionary *> *rows = GufaAXApps();
634
+ GufaEmitJSON(@{@"ok": @YES, @"apps": rows, @"accessibility": @(GufaTrustedForAX())});
635
+ return 0;
548
636
  }
549
637
 
550
- /** 没权限时 CGWindowList 只返回「自己这个 App」的窗口;据此判断权限,而不是信 CGPreflight。 */
551
- static BOOL GufaRowsHaveForeignWindows(NSArray<NSDictionary *> *rows) {
552
- NSString *own = NSProcessInfo.processInfo.processName;
553
- for (NSDictionary *row in rows) {
554
- NSString *owner = row[@"owner"];
555
- if ([owner isKindOfClass:[NSString class]] && owner.length > 0
556
- && ![owner isEqualToString:@"DeepSeek Harness"] && ![owner isEqualToString:own]) {
557
- return YES;
558
- }
638
+ /** 激活目标 App(LaunchServices open -b,能切到它的 Space)。 */
639
+ static void GufaActivateBundle(NSString *bundleId) {
640
+ if (bundleId.length == 0) return;
641
+ NSTask *task = [[NSTask alloc] init];
642
+ task.executableURL = [NSURL fileURLWithPath:@"/usr/bin/open"];
643
+ task.arguments = @[@"-b", bundleId];
644
+ @try {
645
+ [task launchAndReturnError:NULL];
646
+ } @catch (NSException *exception) {
647
+ /* ignore */
559
648
  }
560
- return NO;
561
649
  }
562
650
 
563
- static int GufaListWindowsMode(void) {
564
- NSArray<NSDictionary *> *rows = GufaEnumerateWindows();
565
- if (rows.count == 0 || !GufaRowsHaveForeignWindows(rows)) {
566
- /* 触发一次系统授权提示(授权后重新点「重试」即可) */
567
- CGRequestScreenCaptureAccess();
568
- GufaPrintPermissionResult();
569
- return 2;
651
+ /** 按 pid + title 查找对应 AX window(follow 用)。 */
652
+ static AXUIElementRef GufaCopyAXWindow(pid_t pid, NSString *title) {
653
+ AXUIElementRef appElement = AXUIElementCreateApplication(pid);
654
+ if (appElement == NULL) return NULL;
655
+ CFTypeRef winsRef = NULL;
656
+ AXUIElementRef found = NULL;
657
+ if (AXUIElementCopyAttributeValue(appElement, (CFStringRef)CFSTR("AXWindows"), &winsRef) == kAXErrorSuccess && winsRef != NULL) {
658
+ NSArray *wins = (__bridge NSArray *)winsRef;
659
+ for (id win in wins) {
660
+ AXUIElementRef window = (__bridge AXUIElementRef)win;
661
+ NSRect rect = NSZeroRect;
662
+ if (!GufaRectFromAX(window, &rect)) continue;
663
+ NSString *candidateTitle = @"";
664
+ GufaStringFromAX(window, (CFStringRef)CFSTR("AXTitle"), &candidateTitle);
665
+ if (title.length > 0 && ![candidateTitle isEqualToString:title]) continue;
666
+ if (rect.size.width < 200 || rect.size.height < 140) continue;
667
+ found = (AXUIElementRef)CFRetain(window);
668
+ break;
669
+ }
670
+ if (found == NULL && title.length == 0) {
671
+ /* 没标题时退化为第一个够大的窗口 */
672
+ for (id win in wins) {
673
+ AXUIElementRef window = (__bridge AXUIElementRef)win;
674
+ NSRect rect = NSZeroRect;
675
+ if (!GufaRectFromAX(window, &rect)) continue;
676
+ if (rect.size.width < 200 || rect.size.height < 140) continue;
677
+ found = (AXUIElementRef)CFRetain(window);
678
+ break;
679
+ }
680
+ }
681
+ CFRelease(winsRef);
570
682
  }
571
- GufaEmitJSON(@{@"ok": @YES, @"windows": rows});
572
- return 0;
683
+ CFRelease(appElement);
684
+ return found;
573
685
  }
574
686
 
575
687
  int main(int argc, const char *argv[]) {
package/host/dev.js CHANGED
@@ -176,7 +176,7 @@ export function register(router, env) {
176
176
  router.method('float.openPrivacy', async () => {
177
177
  if (process.platform !== 'darwin') return { ok: false }
178
178
  try {
179
- spawn('open', ['x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture'], { detached: true, stdio: 'ignore' }).unref()
179
+ spawn('open', ['x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility'], { detached: true, stdio: 'ignore' }).unref()
180
180
  return { ok: true }
181
181
  } catch {
182
182
  return { ok: false }
@@ -187,9 +187,13 @@ export function register(router, env) {
187
187
  if (process.platform !== 'darwin') throw new ApiError('unsupported', '摸鱼模式目前只支持 macOS', 400)
188
188
  if (appBundlePath() === null) throw new ApiError('missing-helper', '悬浮层 App 未构建,请先运行 scripts/build-float-macos.sh', 500)
189
189
  const follow = body !== null && typeof body === 'object' && body.follow !== null && typeof body.follow === 'object'
190
- ? { windowNumber: Number(body.follow.windowNumber) || 0, pid: Number(body.follow.pid) || 0 }
190
+ ? {
191
+ pid: Number(body.follow.pid) || 0,
192
+ bundleId: typeof body.follow.bundleId === 'string' ? body.follow.bundleId : '',
193
+ title: typeof body.follow.title === 'string' ? body.follow.title : '',
194
+ }
191
195
  : null
192
- if (follow !== null && follow.windowNumber > 0) {
196
+ if (follow !== null && follow.pid > 0) {
193
197
  await killFloat()
194
198
  } else if (await floatRunningAsync()) {
195
199
  return { running: true, pid: (await listFloatPids())[0] ?? null }
@@ -201,7 +205,7 @@ export function register(router, env) {
201
205
  }
202
206
  const base = `${webServer.protocol}//127.0.0.1:${String(webServer.port)}`
203
207
  const authUrl = connection.authenticatedUrl(`${base}/`)
204
- const payload = JSON.stringify({ authUrl, appUrl: `${base}/`, follow: follow !== null && follow.windowNumber > 0 ? follow : undefined })
208
+ const payload = JSON.stringify({ authUrl, appUrl: `${base}/`, follow: follow !== null && follow.pid > 0 ? follow : undefined })
205
209
  await openApp([payload])
206
210
  await new Promise((resolve) => setTimeout(resolve, 300))
207
211
  const pids = await listFloatPids()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -852,9 +852,11 @@ G.GufaApp = function GufaApp(props) {
852
852
  setFloatPicker({ status: 'loading', windows: [], error: '' })
853
853
  try {
854
854
  const value = await G.api('float.windows')
855
- if (value?.ok === true && Array.isArray(value.windows)) {
856
- setFloatPicker({ status: 'ready', windows: value.windows, error: '' })
857
- } else if (value?.ok === false && value?.permission === 'screen-recording') {
855
+ if (value?.ok === true && value?.accessibility !== true) {
856
+ setFloatPicker({ status: 'permission', windows: [], error: '' })
857
+ } else if (value?.ok === true && Array.isArray(value.apps)) {
858
+ setFloatPicker({ status: 'ready', windows: value.apps, error: '' })
859
+ } else if (value?.ok === false) {
858
860
  setFloatPicker({ status: 'permission', windows: [], error: '' })
859
861
  } else {
860
862
  setFloatPicker({ status: 'error', windows: [], error: '没有读到可吸附的窗口' })
@@ -870,7 +872,11 @@ G.GufaApp = function GufaApp(props) {
870
872
  setFloatBusy(true)
871
873
  try {
872
874
  const value = await G.api('float.start', {
873
- follow: { windowNumber: Number(target.windowNumber) || 0, pid: Number(target.pid) || 0 },
875
+ follow: {
876
+ pid: Number(target.pid) || 0,
877
+ bundleId: typeof target.bundleId === 'string' ? target.bundleId : '',
878
+ title: '',
879
+ },
874
880
  })
875
881
  setFloatRunning(value?.running === true)
876
882
  setFloatPicker(null)
@@ -2165,8 +2171,8 @@ G.GufaApp = function GufaApp(props) {
2165
2171
  ? h(
2166
2172
  'div',
2167
2173
  { className: 'gufa-float-permission' },
2168
- h('div', { className: 'gufa-float-permission-title' }, '需要「屏幕录制」权限'),
2169
- h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App 的窗口尺寸(只读尺寸,不录屏)。系统只认悬浮层 App 自己的授权:请在「系统设置 → 隐私与安全性 → 屏幕录制」里点左下角「+」,添加「古法编程悬浮层.app」并打开开关(DeepSeek Harness 的开关也保持打开)。加好后点「重试」。'),
2174
+ h('div', { className: 'gufa-float-permission-title' }, '需要「辅助功能」权限'),
2175
+ h('div', { className: 'gufa-hint' }, '摸鱼模式需要「辅助功能」权限才能读取/跟随其他 App 的窗口位置和大小(只读窗口信息,不录屏)。请在「系统设置 → 隐私与安全性 → 辅助功能」里打开 **DeepSeek Harness** 的开关(改完可能需要重启一次 DSH),然后点「重试」。'),
2170
2176
  h(
2171
2177
  'div',
2172
2178
  { className: 'gufa-row', style: { gap: 8, marginTop: 12, flexWrap: 'wrap' } },
@@ -2199,10 +2205,10 @@ G.GufaApp = function GufaApp(props) {
2199
2205
  h(
2200
2206
  'span',
2201
2207
  { className: 'gufa-float-meta' },
2202
- h('span', { className: 'gufa-float-owner' }, win.owner !== '' ? win.owner : '未知 App'),
2203
- h('span', { className: 'gufa-float-title' }, win.title !== '' ? win.title : '(无标题窗口)'),
2208
+ h('span', { className: 'gufa-float-owner' }, win.name !== undefined && win.name !== '' ? win.name : '未知 App'),
2209
+ h('span', { className: 'gufa-float-title' }, win.bundleId !== undefined ? win.bundleId : ''),
2204
2210
  ),
2205
- h('span', { className: 'gufa-float-size' }, `${Math.round(win.width)}×${Math.round(win.height)}`),
2211
+ win.frontmost === true ? h('span', { className: 'gufa-float-size' }, '当前') : null,
2206
2212
  ),
2207
2213
  ),
2208
2214
  ),