Skip to content

Commit 7ebfaef

Browse files
authored
fix: replace all click actions to use actual mouse click rather than accessibility (#45)
1 parent f8c8463 commit 7ebfaef

5 files changed

Lines changed: 117 additions & 181 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ This is an intentional design choice to keep the project lean, maintainable, and
6363
- Consider zIndex for hints on different layers? There might be multiple layers when we are considering `Menubar`, `Dock` and `Notification bar`
6464
- Better UI representation for action menu (maybe auto edge detection like tooltip in browser, that will place itself around the element based on the space available around it)
6565
- Still a bit slow when activating in windows that have huge lists, such as Mail.app without `unread` filter
66-
- Maybe ditch Accessibility based actions and fully focus on pure mouse click simulation? Noticed that accessibility actions are not very reliable :(
6766
- Find a way to auto deduplicate hints that are targeting the same point
6867
- Scroll areas are hardcoded from 1-9, do we ever need more than that and make it dynamic upon query? We can still use <Tab> to cycle next tho
6968
- Homerow supports `continuous clicks`, is that something important?

cmd/govim/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ func (a *App) handleHintKey(key string) {
593593
} else {
594594
// Direct click mode - click immediately
595595
a.logger.Info("Clicking element", zap.String("label", a.hintInput))
596-
if err := hint.Element.Element.Click(); err != nil {
596+
if err := hint.Element.Element.LeftClick(); err != nil {
597597
a.logger.Error("Failed to click element", zap.Error(err))
598598
}
599599
a.exitMode()
@@ -714,7 +714,7 @@ func (a *App) handleActionKey(key string) {
714714
switch key {
715715
case "l": // Left click
716716
a.logger.Info("Performing left click", zap.String("label", hint.Label))
717-
err = hint.Element.Element.Click()
717+
err = hint.Element.Element.LeftClick()
718718
case "r": // Right click
719719
a.logger.Info("Performing right click", zap.String("label", hint.Label))
720720
err = hint.Element.Element.RightClick()

internal/accessibility/element.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,23 +267,18 @@ func (e *Element) GetChildrenCount() int {
267267
return int(C.getChildrenCount(e.ref))
268268
}
269269

270-
// Click performs a click action on the element
271-
func (e *Element) Click() error {
270+
// LeftClick performs a click action on the element
271+
func (e *Element) LeftClick() error {
272272
if e.ref == nil {
273273
return fmt.Errorf("element is nil")
274274
}
275275

276-
result := C.performClick(e.ref)
276+
result := C.performLeftClick(e.ref)
277277
if result == 1 {
278278
return nil
279279
}
280280

281-
// Fallback to a real mouse click at the element's center
282-
if C.clickElementWithMouse(e.ref) == 1 {
283-
return nil
284-
}
285-
286-
return fmt.Errorf("click action failed")
281+
return fmt.Errorf("left-click action failed")
287282
}
288283

289284
// RightClick performs a right-click action on the element

internal/bridge/accessibility.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,35 @@ typedef struct {
1818

1919
// Function declarations
2020
int checkAccessibilityPermissions();
21+
2122
void* getSystemWideElement();
2223
void* getFocusedApplication();
2324
void* getApplicationByPID(int pid);
2425
void* getApplicationByBundleId(const char* bundle_id);
2526
void* getMenuBar(void* app);
27+
2628
ElementInfo* getElementInfo(void* element);
2729
void freeElementInfo(ElementInfo* info);
30+
2831
void* getElementAtPosition(CGPoint position);
32+
2933
int getChildrenCount(void* element);
3034
void** getChildren(void* element, int* count);
3135
void** getVisibleChildren(void* element, int* count, int checkOcclusion);
32-
int performClick(void* element);
36+
37+
int getElementCenter(void* element, CGPoint* outPoint);
38+
39+
void moveMouse(CGPoint position);
40+
41+
// Click functions - perform click actions on accessibility elements and restore cursor position
42+
int performLeftClick(void* element);
3343
int performRightClick(void* element);
3444
int performDoubleClick(void* element);
3545
int performMiddleClick(void* element);
46+
3647
int hasClickAction(void* element);
3748
int setFocus(void* element);
49+
3850
char* getElementAttribute(void* element, const char* attribute);
3951
void freeString(char* str);
4052
void releaseElement(void* element);
@@ -51,7 +63,4 @@ int isScrollable(void* element);
5163
CGRect getScrollBounds(void* element);
5264
int scrollElement(void* element, int deltaX, int deltaY);
5365

54-
// Mouse click fallback
55-
int clickElementWithMouse(void* element);
56-
5766
#endif // ACCESSIBILITY_H

0 commit comments

Comments
 (0)