dsh-gufa-code 1.2.2 → 1.2.3

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.
@@ -12,6 +12,13 @@
12
12
  #import <AppKit/AppKit.h>
13
13
  #import <WebKit/WebKit.h>
14
14
  #import <CoreGraphics/CoreGraphics.h>
15
+ #import <Carbon/Carbon.h>
16
+
17
+ static const EventHotKeyID GufaToggleHotKey = {'gufa', 1};
18
+
19
+ @class GufaAppDelegate;
20
+
21
+ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
15
22
 
16
23
  @interface GufaDragStrip : NSView
17
24
  @property (nonatomic, weak) id doubleClickTarget;
@@ -29,7 +36,7 @@
29
36
  NSFontAttributeName: [NSFont systemFontOfSize:10 weight:NSFontWeightMedium],
30
37
  NSForegroundColorAttributeName: [NSColor colorWithCalibratedWhite:1.0 alpha:0.6],
31
38
  };
32
- NSString *label = @"古法编程 · 悬浮层(拖动移动 · 双击穿透 · 右键菜单)";
39
+ NSString *label = @"古法编程 · 悬浮层(拖动移动 · 双击穿透 · 右键菜单 · ⌥⌘G 切穿透)";
33
40
  NSSize size = [label sizeWithAttributes:attrs];
34
41
  NSPoint origin = NSMakePoint(floor((self.bounds.size.width - size.width) / 2.0), floor((self.bounds.size.height - size.height) / 2.0));
35
42
  [label drawAtPoint:origin withAttributes:attrs];
@@ -77,12 +84,14 @@
77
84
  @property (nonatomic, strong) NSString *frameKey;
78
85
  @property (nonatomic, strong) GufaNavigationDelegate *navigation;
79
86
  @property (nonatomic, strong) NSDictionary *options;
87
+ @property (nonatomic, assign) EventHotKeyRef hotKeyRef;
80
88
  @property (nonatomic, assign) BOOL following;
81
89
  @property (nonatomic, assign) int followWindowNumber;
82
90
  @property (nonatomic, assign) pid_t followOwnerPID;
83
91
  @property (nonatomic, strong) NSTimer *followTimer;
84
92
  @property (nonatomic, strong) NSMutableArray<NSDictionary *> *windowCandidates;
85
93
  - (void)loadWebContent;
94
+ - (void)registerToggleHotKey;
86
95
  - (void)toggleClickThrough:(id)sender;
87
96
  - (void)resetFrame:(id)sender;
88
97
  - (void)quitApp:(id)sender;
@@ -110,6 +119,7 @@
110
119
  [self parseOptions];
111
120
  [self buildWindow];
112
121
  [self buildStatusItem];
122
+ [self registerToggleHotKey];
113
123
  [self loadWebContent];
114
124
  }
115
125
 
@@ -197,7 +207,7 @@
197
207
  [menu addItemWithTitle:@"跟随 App 窗口…(需屏幕录制权限)" action:@selector(chooseFollowWindow:) keyEquivalent:@""].target = self;
198
208
  [menu addItemWithTitle:@"停止跟随" action:@selector(stopFollow:) keyEquivalent:@""].target = self;
199
209
  [menu addItem:[NSMenuItem separatorItem]];
200
- [menu addItemWithTitle:@"切换点击穿透(穿透后鼠标可操作下层 App)" action:@selector(toggleClickThrough:) keyEquivalent:@""].target = self;
210
+ [menu addItemWithTitle:@"切换点击穿透(⌥⌘G)" action:@selector(toggleClickThrough:) keyEquivalent:@""].target = self;
201
211
  [menu addItemWithTitle:@"重置窗口位置和大小" action:@selector(resetFrame:) keyEquivalent:@""].target = self;
202
212
  [menu addItem:[NSMenuItem separatorItem]];
203
213
  [menu addItemWithTitle:@"关闭悬浮层" action:@selector(quitApp:) keyEquivalent:@""].target = self;
@@ -379,6 +389,13 @@
379
389
  [self saveFrame];
380
390
  }
381
391
 
392
+ /* 全局快捷键 ⌥⌘G:穿透后窗口收不到鼠标事件,靠它切回来(Carbon 热键不需要辅助功能权限) */
393
+ - (void)registerToggleHotKey {
394
+ EventTypeSpec spec = {kEventClassKeyboard, kEventHotKeyPressed};
395
+ InstallApplicationEventHandler(NewEventHandlerUPP(GufaHotKeyHandler), 1, &spec, (__bridge void *)self, NULL);
396
+ RegisterEventHotKey(kVK_ANSI_G, cmdKey | optionKey, GufaToggleHotKey, GetApplicationEventTarget(), 0, &_hotKeyRef);
397
+ }
398
+
382
399
  - (void)toggleClickThrough:(id)sender {
383
400
  self.clickThrough = !self.clickThrough;
384
401
  self.window.ignoresMouseEvents = self.clickThrough;
@@ -406,6 +423,14 @@
406
423
 
407
424
  @end
408
425
 
426
+ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) {
427
+ (void)nextHandler;
428
+ (void)event;
429
+ GufaAppDelegate *self = (__bridge GufaAppDelegate *)userData;
430
+ [self toggleClickThrough:nil];
431
+ return noErr;
432
+ }
433
+
409
434
  int main(int argc, const char *argv[]) {
410
435
  @autoreleasepool {
411
436
  [NSApplication sharedApplication];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -5,7 +5,7 @@ cd "$(dirname "$0")/.."
5
5
  mkdir -p desktop/float/bin
6
6
  ARCH="$(uname -m)"
7
7
  OUT="desktop/float/bin/gufa-float-macos-${ARCH}"
8
- clang -fobjc-arc -O2 -framework AppKit -framework WebKit -o "$OUT" desktop/float/GufaFloat.m
8
+ clang -fobjc-arc -O2 -framework AppKit -framework WebKit -framework Carbon -o "$OUT" desktop/float/GufaFloat.m
9
9
  chmod +x "$OUT"
10
10
  codesign --force --sign - "$OUT" >/dev/null 2>&1 || true
11
11
  echo "built: $OUT"