keepassxreboot / keepassxc

KeePassXC is a cross-platform community-driven port of the Windows application “Keepass Password Safe”.
https://keepassxc.org/
Other
21.39k stars 1.48k forks source link

[macOS] sometimes fails to display the window front when clicking the dock icon #11384

Open qupig opened 1 month ago

qupig commented 1 month ago

Overview

Sometimes clicking on the Dock icon won't show the KeePassXC App window to front, no matter how many times I click on it. Unless I click the menu bar icon once at this time. (Normally clicking menu bar icon should display a menu, but no, this time the menu is not displayed, only the window is displayed)

Steps to Reproduce

  1. After the app is started normally, it is not minimized, the window is not switched/toggled/hidden through the menu, and the indicator light of the Dock icon is on. (In other words, no state manipulation is done to the App/Window)
  2. Directly run or click on the windows of other Apps (at this time the KeePassXC window is covered by other windows)
  3. After a while, when clicking the KeePassXC Dock icon again in an attempt to bring its window to front, no, it won't bring it to front, no matter how many times you click it.
  4. An easy way to bring it to the front at this point is to click once on the KeePassXC icon in the menu bar, and at this point the menu bar icon will not show the menu unless you click it a second time.
  5. Another complicated way is to right-click the KeePassXC Dock icon, click "Show all windows" in its context menu, and then click the KeePassXC window. This method sometimes fails by bringing the window to the front and then immediately auto-hiding, unless I repeat the entire operation again.

Expected Behavior

Under normal circumstances, clicking on the KeePassXC Dock icon should bring its main window to the front.

Actual Behavior

Its main window cannot be brought to the front, no matter how many times the Dock icon is clicked.

Context

KeePassXC - 2.7.9 Revision: 8f6dd13

Operating System: macOS

droidmonkey commented 1 month ago

I can't replicate this at all on macOS 16. Both the menu icon "toggle window" and clicking the app icon in the dock bring KeePassXC to the front. It could be perhaps those 40% of the time you have a modal dialog or something else active that is interfering.

I can replicate "Toggle Window" not working the first time. However that is technically "expected behavior" since Toggle Window hides KeePassXC to the tray icon. The first time you use it then KeePassXC will be removed from the Dock. The second time will show KeePassXC window. That menu item is not "Raise KeePassXC"

I can't see anything worthwhile within the log file you posted.

droidmonkey commented 1 month ago

Actually take it back, slightly, I was able to replicate a state where pressing the dock icon did not bring KeePassXC to the front. It looked like the tray icon was still "activated" during that situation. You can get into this state if you activate the tray menu then click on the menu bar. The tray menu disappears but the icon is still selected and KeePassXC cannot be brought to the front at this point. KeePassXC has to be in the background for this to occur.

qupig commented 1 month ago

I can replicate "Toggle Window" not working the first time. However that is technically "expected behavior" since Toggle Window hides KeePassXC to the tray icon. The first time you use it then KeePassXC will be removed from the Dock. The second time will show KeePassXC window. That menu item is not "Raise KeePassXC"

I'm not sure if this is what I'm experiencing because usually I don't click on it at all, I do know that it makes the Dock icon's light disappear and reappear.

I think it would be better to improve that menu "text" if possible, e.g. show it as "Hide to tray"/"Show to foreground" in different states. Or even just "Hide to tray" and put a tick in front to show the difference states.

You can get into this state if you activate the tray menu then click on the menu bar. The tray menu disappears but the icon is still selected and KeePassXC cannot be brought to the front at this point. KeePassXC has to be in the background for this to occur.

I can reproduce the situation what you are describing. But I'm pretty sure that's not what I'm experiencing because usually I don't click on the menu bar/tray icon at all after running KeePassXC, plus I'm pretty sure the tray icon is not in the "activated" state because if its background is lit I will definitely notice.

It could be perhaps those 40% of the time you have a modal dialog or something else active that is interfering.

Like I said on the first floor, I don't identify any specific correlation. But I can be sure 40% of the time there won't be a "modal dialog" there because I know what that is, and it will definitely affects my other operations. But I'm not sure about other factors.

droidmonkey commented 1 month ago

without eliciting any further details it is impossible to correct. If you can identify any other patterns that can cause this situation it will be very helpful.

qupig commented 1 month ago

I'll definitely add it if I find the patterns.

But unfortunately I can't provide any more information at the moment, I'll keep an eye out for that.

hardrockhodl commented 1 week ago

I actually solved this problem by writing about my findings.
I only had problems when running my MBP with external displays. It just hit me!
There is a setting in KeePassXC that toggles "Allow Screen Captures"

Im guessing all macbook owners, just like me is running Displaylink Manager.app to make external display work. And by some weird reason (or maybe logical) Displaylink needs to be running screensharing to work.

Solution:

(if runninging Displaylink Manager.app)

shottr_2024-11-14_151149

qupig commented 1 week ago

@hardrockhodl Thanks for sharing the info, I do use an external monitor, but I'm not using the Displaylink solution, so that's not what I'm experiencing.

The Displaylink solution is to break through the limit of the number of external monitors on the Mac hardware device itself. It uses a virtual-desktop and streaming solution, which is why it requires screen capture.

But I suggest you note that when you allow keepassxc window screen capture, you reduce its security. Now any apps that can capture the screen has the opportunity to obtain the information of your keepassxc window.

hardrockhodl commented 1 week ago

@qupig Yeah, that is concerning.
Maybe application whitelisting can be a solution?
I'm out of my ballpark here regarding how macOS apps are made, but maybe apple change the behavior of the WindowManager.app in Sequoia.

I'll run etrecheck to see if it can catch any logs about it.