Closed john2zy closed 10 months ago
This is a side-effect of the new mouse/event system. The new API I am using seems to not report any mouse events on non-focussed displays.
I realize that this suboptimal but going back to the rusty Carbon API would be even more suboptimal I think. Maybe I can improve on the current design by doing some more research.
Thank you! Maybe I can dig into this if I manage to find time.
v2.16.3 fixed this issue for me. Cheers.
https://github.com/FelixKratz/SketchyBar/assets/35300157/a8f4503c-33a4-4eb2-9cd3-2fef3d53c423
Hi, @FelixKratz,
I have upgraded to mac os sonoma today, and faced with slightly similar issue. In my case the clicking on the window numbers is not working even in the focused display.
Sketchybar: v 2.16.3 Yabai: 5.0.8
It is a change in Sonoma that causes mouse events to not work at all. I will soon prepare a patch for Sonoma, then the original issue will be solved as well.
All of these issues should be fixed in v.2.16.4
Hey @FelixKratz - I'm playing around with adding popup
windows to my bar today and have found that I can't get clicks to trigger. In fact, I'm realizing that none of my, recent working, click_script
are triggering. After reading this it hit me that I installed the latest Sanoma update (14.2.1) a couple of days ago. Could that be related?
I am on 14.2.1 as well and my click scripts seem to be working can you provide a minimal example which does not work for you?
Edit:
This minimal example works for me:
sketchybarrc
sketchybar --bar color=0xff000000
sketchybar --add item test left --set test label="Click Me" click_script='osascript -e "display dialog \"Works\""'
My minimal example was the example you shared for popups: https://github.com/FelixKratz/SketchyBar/discussions/12?sort=new#discussioncomment-1843975
However, thanks for sharing ☝️, that's much simpler and also not triggering clicks. I'm running sketchybar
in the foreground and seeing nothing in STDOUT/ERR.
❯ which sketchybar
/opt/homebrew/bin/sketchybar
❯ sketchybar -v
sketchybar-v2.19.6
What else... I'm using AeroSpace (not Yabai), I have SIP disabled. 🤔 If there's some other way I can debug I'm game. Also, I'm happy to open a new Issue.
We can try some other things to narrow down the problem some more:
sketchybar --query test
return?sketchybar --add slider slider left 100 --set slider slider.background.color=0xffffffff slider.highlight_color=0xffff0000 slider.background.height=15
sketchybar --add item test left --set test label="Click Me" script='osascript -e "display dialog \"Hallo\""' --subscribe test mouse.clicked
query test
❯ sketchybar --query test
{
"name": "test",
"type": "item",
"geometry": {
"drawing": "on",
"position": "left",
"associated_space_mask": 0,
"associated_display_mask": 0,
"ignore_association": "off",
"y_offset": 0,
"width": 0,
"padding_left": 0,
"padding_right": -1,
"background": {
"drawing": "off",
"color": "0x0",
"border_color": "0x0",
"border_width": 0,
"height": 0,
"corner_radius": 0,
"padding_left": 0,
"padding_right": 0,
"y_offset": 0,
"clip": 0.000000,
"image": {
"value": "(null)",
"drawing": "off",
"scale": 1.000000
},
"shadow": {
"drawing": "off",
"color": "0xff000000",
"angle": 30,
"distance": 5
}
}
},
"icon": {
"value": "",
"drawing": "on",
"highlight": "off",
"color": "0xffffffff",
"highlight_color": "0xff000000",
"padding_left": 0,
"padding_right": 0,
"y_offset": 0,
"font": "Hack Nerd Font:Bold:14.00",
"width": 0,
"align": "left",
"background": {
"drawing": "off",
"color": "0x0",
"border_color": "0x0",
"border_width": 0,
"height": 0,
"corner_radius": 0,
"padding_left": 0,
"padding_right": 0,
"y_offset": 0,
"clip": 0.000000,
"image": {
"value": "(null)",
"drawing": "off",
"scale": 1.000000
},
"shadow": {
"drawing": "off",
"color": "0xff000000",
"angle": 30,
"distance": 5
}
},
"shadow": {
"drawing": "off",
"color": "0xff000000",
"angle": 30,
"distance": 5
}
},
"label": {
"value": "Click Me",
"drawing": "on",
"highlight": "off",
"color": "0xffffffff",
"highlight_color": "0xff000000",
"padding_left": 0,
"padding_right": 0,
"y_offset": 0,
"font": "Hack Nerd Font:Bold:14.00",
"width": 0,
"align": "left",
"background": {
"drawing": "off",
"color": "0x0",
"border_color": "0x0",
"border_width": 0,
"height": 0,
"corner_radius": 0,
"padding_left": 0,
"padding_right": 0,
"y_offset": 0,
"clip": 0.000000,
"image": {
"value": "(null)",
"drawing": "off",
"scale": 1.000000
},
"shadow": {
"drawing": "off",
"color": "0xff000000",
"angle": 30,
"distance": 5
}
},
"shadow": {
"drawing": "off",
"color": "0xff000000",
"angle": 30,
"distance": 5
}
},
"scripting": {
"script": "(null)",
"click_script": "osascript -e \"display dialog \\"Works\\"\"",
"update_freq": 0,
"update_mask": 0,
"updates": "on"
},
"bounding_rects": {
"display-1": {
"origin": [ 20.000000, 0.000000 ],
"size": [ 68.000000, 25.000000 ]
},
"display-2": {
"origin": [ 1372.000000, -349.000000 ],
"size": [ 68.000000, 25.000000 ]
}
}
}
mouse.clicked
- nosketchybar
and macOS) - noOk, next steps for debugging are in code, are you able to build from source?
First interesting test would be:
put printf("Mouse Event\n");
above this line:
https://github.com/FelixKratz/SketchyBar/blob/6ff8ffabef129fa823c9b38924ab39c71ea428be/src/mouse.c#L20
and next step after that would be:
put printf("item: %llu\n", window);
here:
build the binary and see what it prints when you try to click the test item.
OK, thanks for sticking with my @FelixKratz. I do see "Mouse Event" but I do not see "item: " when adding these debug lines.
Can you try to find out in which line of this function the mouse handling errors out?
Maybe first do a sanity check that the event actually reaches this function with a print in the first line and then progressively work through all the return
paths (which there is only one) and check where the mouse handling errors out.
uint32_t wid = get_wid_from_cg_event(context);
contain?uint32_t adid = display_arrangement(display_active_display_id());
contain?BTW are you using arm or intel?
OK, I don't know what I did wrong last time but I am getting all the way through event_mouse_up
. 🤦♂️
wid: 362
adid: 0
after bar_manager_refresh
I'm on Arm.
edit - maybe I should look at bar_item_on_click
now?
Yes, have a look inside bar_item_on_click
. Does it survive the first check? I.e. is bar_item
not NULL
? If the click works the control flow should eventually reach the function fork_exec
Nope, it does not survive here: https://github.com/FelixKratz/SketchyBar/blob/6ff8ffabef129fa823c9b38924ab39c71ea428be/src/bar_item.c#L205
bar_item
appears to be 0
Oh I overlooked something above that is probably already the problem.... adid
should not be zero.
Can you check why this function returns zero? https://github.com/FelixKratz/SketchyBar/blob/6ff8ffabef129fa823c9b38924ab39c71ea428be/src/display.c#L101-L131
Is it because of an early return due to some error, or does the function go all the way to the bottom?
Was just grabbing all the values through adid
:
point: 4653974661560795136
wid: 514
type: 2
mouse_button_code: 0
modifier_keys: 0
adid: 0
Will checkout display_arrangement
now.
Looks like display_uuid(did)
is returning 0
. So not making it through that function. Digging further, CGDisplayCreateUUIDFromDisplayID(did)
is returning 0
.
Can you check the value of did
?
did
is 2
Ok, interesting, I just disconnected my external and the click worked as expected (eg. I saw the "Works" dialog). When I reconnect it does not work. 🤔
The function display_uuid
failing is bad, several other things will probably not work as well, such as
sketchybar --set test display=active
should only render the test item (from above) on the active display. Can you check if this is indeed not working by switching focus between displays?
On both displays:
❯ sketchybar --set test display=active
no value returned, though exit code is 👍. However the item itself seems to be destroyed when running the command (disappears from bar).
FWIW - I can reliably reproduce this. External connected I never see the dialog, external disconnected I always see the dialog.
I can also say that about a week ago, while converting my config to Lua, click_script
was working just fine with an external monitor connected. The difference being, since then, the macOS update.
Can you try the latest commit? https://github.com/FelixKratz/SketchyBar/commit/d2299c8379f31d30ecd110663e8f0f52b2226f87
Same behaviour, works w/o external, does not work w/ external. At a glance, adid
is still 0
with the external connected.
I think I know why. It has to do with the option: "Displays have separate spaces" in System Settings under Desktop & Dock. If you activate it it and reboot, clicks work. If it is deactivated I can reproduce the issue. Now I will be able to provide a fix.
The problem with "Displays have separate spaces" being off is that there seems to be no event emitted when the active display changes. It would probably be best to include a check on startup that prevents sketchybar from running if this option is not set appropriately.
OK, nice find! It's possible I changed this setting in that time span as well (sorry I forgot) when switching from Yabai to Aerospace related docs. I've had some odd issues with that setting enabled so I had switched it off.
I have included a check on startup. Just too many things are completely broken when the active display id is not reported properly. Maybe I find another way to get the id of the active display which works with "Displays have separate spaces" off, then the bar should again work with this option turned off.
After upgrading to v2.16.2, clicking on an icon that's not on the current focused display won't produce a mouse click event. For example, I'm now typing in the browser on display 1; if I click a sketchbar icon on display 2, the callback script won't be called. I've tested with a script that prints a message when clicked and confirmed no event was received.
I'm using sketchybar with yabai v5.0.7. Is it possible that yabai's space focus logic interferes with sketchybar?