retext
retext copied to clipboard
Allow focus on window when file opened
In most applications where opening a file creates a new tab in an existing window (e.g. Chrome, Firefox) the window is brought to focus. Using retext 8.0.0 with Linux Mint 21 Cinnamon, when Retext is already open in a window that does not have focus, opening a Markdown file results in its being opened in a new tab in the Retext window, and the Retext icon in the desktop panel is highlighted, but the window is not brought to focus.
I would request that there be an item in the preferences dialog allowing the user to specify the Retext window should be brought to focus whenever a file is opened.
We do have this line, which is supposed to raise the window to the top of the window manager's stack. https://github.com/retext-project/retext/blob/0987c28226714633a470b8b8a7ee89de9c7f6bc9/ReText/main.py#L121
However, for some reason this does not happen. Maybe the window manager protects you from the aggressive windows and only highlights them, instead of actually raising.
I tried other Qt's methods such as activateWindow() and setWindowState() but none of them or their combinations has the needed effect with my window manger (Metacity). I also read about some hacks such as marking the window as top-level (and unmarking again), or showing and hiding a message box, but such methods look too ugly for me.
Advices how to better implement it are welcome.