Window appears and immediately hides again when using `copyq toggle` and `copyq show`
Describe the bug
copyq toggle and copyq show don't work as expected. The program window appears and immediately hides again.
To Reproduce
When I use the copyq toggle or copyq show commands, the program window appears and immediately hides again.
Expected behaviour
copyq toggle and copyq show should toggle or show the program window.
Version, OS and Environment
CopyQ Clipboard Manager 10.0.0~noble
Qt: 5.15.13
KNotifications: 5.115.0
Compiler: GCC
Arch: x86_64-little_endian-lp64
OS: Linux Mint 22.1 (Cinnamon)
This may happen if the window does not get focus—for example, due to a focus-prevention behavior in window managers—and "Close When Unfocused" option is enabled. Can you try disabling the option?
Yeah, that seems to have been the issue, thanks. It's really weird that this feature is on by default.
And another strange thing: now toggle doesn't work to hide the window (it always shows it, basically working just like show). When the window is open and I use toggle, it doesn't hide.
Hmm, okay, so the show command is kind of working right now, but the window still pops up behind other applications, which isn't very helpful. It would be much better if the window appeared on the foreground when it opens. How can I achieve that? I tried the "always on top" setting, but it's really inconvenient because it makes it hard to easily switch to other windows. What I need is for the CopyQ window to actually be on the foreground when the command is executed, but without using the "always on top" feature. Any ideas?
I think this is a problem with some focus-prevention in the desktop environment. No idea what else this could be.
I'm not sure what prevents copyq window from getting focus properly in Cinnamon.
I have found only this option and it's enabled:
I tried another approach. Here's a script I put together:
#!/bin/bash
# Get window IDs *before* toggle (if any)
WID_BEFORE=$(xdotool search --onlyvisible --class copyq | head -n 1)
# Toggle the window
copyq toggle
# Wait for window state to settle
sleep 0.2
# Get window ID *after* toggle (if any)
WID_AFTER=$(xdotool search --onlyvisible --class Copyq | head -n 1)
# If the window exists now, AND it didn't exist before (or is different), activate it.
# This handles the case where toggle just showed the window.
if [[ -n "$WID_AFTER" && "$WID_AFTER" != "$WID_BEFORE" ]]; then
xdotool windowactivate "$WID_AFTER"
fi
It works perfectly, but I feel like it's a bit of a hack, and there must be a better approach. I'd appreciate any ideas.