-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geany doesn't get focus #3531
Comments
Since it works from the file manager this looks most likely to be your desktop setup. Set the keyboard shortcut to run exactly the same command as the file manager runs on double click. The dialog with Geany logo and the filename is not something Geany creates AFAIK, its more likely to be your desktop. |
It is not a mystery, and has nothing to do with Geany. I have the identical issue, and have been researching and studying the topic for months. I am also using Kubuntu 22.04.2, and its GTK/Gnome relative, Linux Mint Cinnamon 21.2. The initial focus acquiring behavior was taken over by the window one is working in. In this context, the desktop is counted as a window. This also applies to opening Firefox where the home page is DuckDuckGo. Running Geany, or any other software, from a .sh file, is the only quick solution I can think of. This would set the focus after Geany is open. I hope this helps, but I feel that this is not a good long term solution. On the other hand, this may be resolved from within Geany. |
Correct, X11 tools don't necessarily work on Wayland systems which is where the world is going.
This part cannot, see #3538 (comment) |
Same here, Ubuntu 22.04 & 23.04. |
First a comment, with Linux Mint Cinnamon, default settings, open-in-geany in the file manager (Nemo) always brings Geany to the front with the notebook page containing the selected file having focus, both when Geany is first started, and when the selected file is added to an open instance. Everybody who is complaining, the problem is not with Geany, it is with your window manager and/or the settings you use that tell the window manager not to grant Geany's focus request. Perhaps enquire on your window manager support what settings need to be changed, or if you need to use a different window manager. |
Any other apps, working perfect. They get focus. Everything exept Ver.38 of Geany. |
As I said, it works for me, and I presume for other main contributors to Geany since none have commented. Since it can't be reproduced "somebody" who has the problem needs to provide a reproducing environment and debug what if anything other apps do different to Geany if they work. Note that Geany is a portable GTK application available on Gnome, KDE, Xfce, Windows, Macos so it does not use any desktop specific APIs that other less portable apps might use. But if "somebody" wants to contribute and support a desktop portability library for such specific functions it would likely be accepted. |
I forgot to mention that my comments are exclusively about the X11 windowing system. Also, that apps can monitor movement and easily set focus to themselves. Of the two apps mentioned, I know observed that LibreOffice has a history of increasing sophistication. |
To be clear, Gedit is a Gnome application, it is "integrated with that desktop" to quote the linked page, not a plain GTK application like Geany. As @ineuw says Libreoffice has the resources to maintain integration with individual desktops, so for example Debian has a libreoffice-gnome integration package and I am aware of an evolution integration package and I am sure it has specific integration with Windows and Macos. |
From the OP, specific to the use case of Geany and Nautilus under Gnome... this is mutter's focus-stealing prevention at work. I found this still-open issue here as I was searching for a feature request with Geany to implement support for the XDG Activation protocol. A nice explanation and discussion of how it all works was recently posted on Gnome Discourse. That reminded me... ...For a long time now, and specifically to solve the use-case noted in the OP, I've been employing a very simple extension to work around this issue, and to immediately focus Geany when opening files from Nautilus file manager. One key point missing from the OP is that if Geany is not running, the first time a file is opened from Nautilus, a Geany window will open and gain focus. I.E..
Should a new issue be filed specifically to request the XDG Activation protocol be supported in Geany? |
Thanks for the research, that looks like the cause of the Gnome problem and why it works just fine on other compositors that don't try to enforce their idea of how things should work.
It should not need anything in Geany. GTK is what is communicating with the Wayland compositor (or X11 or Windows or Macos) but Geany does not know which backend is being used by GTK, and also there is no way of passing a token to GTK when requesting focus. GTK knows which backend it is using and if it should get the token and supply it to the compositor on Wayland or not on other platforms. Probably GTK hasn't caught up with the activation yet, and the Wayland activation protocol is still "Warning! The protocol described in this file is currently in the testing phase.". And if/when it is added it will be to GTK4, GTK3 which is used by Geany will probably never get the capability. So its probably not worth adding a Geany issue that will likely bitrot, but maybe you could raise it with GTK. PS I'm not sure it will work anyway, how does Nautilus know which process will want to focus, its the first Geany that subsequent files open in new tabs, not the no GUI process that Nautilus runs that sends the request to the first Geany. So how does Nautilus know what window to get the token for? |
Thank you for the rationale you explained here. As an example... I don't use chrome/chromium (also a GTK3 app) as my browser, but it was big news this year when they started supporting XDG Activation, allowing links from other apps to bring the browser window to the front, closing a long-standing issue. I was under the impression apps (at least on Wayland) needed to be modified to support this behavior. I'll poke around with the GTK folks to see if I can glean anything further in regard to this behavior with Geany under Gnome/Wayland (no X11 or Xwayland here). EDIT: Oh, yes... GDK3 support for the protocol landed in v3.24 a few years ago. EDIT2: Guess I should have also mentioned that other GTK3 apps like Firefox and LibreOffice have long supported these activation tokens and properly focus their windows when activated from external app sources. EDIT3: Being a Wayland protocol, it's also not specifically tied to Gnome/GTK, and is supported in environments with other Wayland compositors such as Sway and Kwin. |
I thought chromium used skia not gtk and did everything itself.
Well the merge has no documentation so it would be reasonable to assume it all happens inside GTK and no changes are required of the apps?
Ok.
Don't think they are gtk either, didn't look at firefox but libreoffice has backends based on qt, skia, quartz, win, but not gtk. |
Hmm, okay. Perhaps I lack some fundamental understanding here. If so I apologize for the noise. Going back to the original Wayland protocol merge itself, we see it's pretty toolkit-agnostic at this point:
And currently has been, or is being requested to be, implemented by apps across these various frameworks Electron recently was a biggee for many folks, similar to this year's Chromium support. As for chromium, FF, Libreoffice apps, I think you're correct but referring to their rendering engines, whereas they all use GTK to present their windows/decorations and widgets? Firefox has been GTK3 for 7 years now. Libreoffice (GTK3): Off-topic here... but I'm sure you can find relatable... they all have their respective user's clamoring for a GTK4 port haha! Both LibreOffice and Chromium have experiment support for GTK4: Firefox not so much: Anyhow, I'll investigate further my assertion that some change needs to be made to the Geany client to support the activation mechanism. Thanks for taking time with meaningful responses here. |
IRO libreoffice, I think you are right, GTK is the default UI library and is built in to the code so it doesn't have a gtk directory in https://github.com/LibreOffice/core/tree/master/vcl where all the alternative UI libraries are, and that confused me. Something similar might be the case for the other apps you listed too. One thing to be clear about, listing large well supported projects like Libreoffice, Firefox, or Chromium is pretty irrelevant to Geany which is a volunteer project and is unlikely to add backend specific code (Wayland in this case), we have in the past expunged an amount of X11 specific stuff, and we expect GTK or other portable libraries to handle backend specifics, not us. We simply don't have the resources to do Wayland specific token handling that big projects might do. As I said before, I can't see where GTK makes Wayland activate tokens available to applications so they can handle it, and in my opinion it should not require the application to do anything. Although I havn't examined it closely, possibly the activation token is one of the things handled by the The reasoning behind preventing "evil_app" for example from popping its own version of the password dialog over the top of the real one to read the password is good. But IMO the implementation is wrong, the password dialog should be able to be identified as secure and prevent any interaction with any other windows so it is guaranteed the password will go to that. Sure its complicated for the secure password feature, but that way it does not impinge on every other application. As for GTK4 ....... [deep breath] ...... (bearing in mind I am not a GTK expert but I am quoting one ;-) ... GTK4 is missing a number of features that Geany (and likely other complex apps) use. IIUC we would have to make our own widgets to maintain those features, but in C (not C++) that is a lot more work than the port from GTK2 to GTK3. And the Scintilla editing widget which is the main window is not planning to include GTK4 support "soon" due to how much difference there is. So Geany has put GTK4 on the nearest backburner and turned the gas down to off. |
@tekstryder Does #4071 fix your problem? |
Sorry for the delay. Indeed, #4071 allows me to disable the Gnome extension and use Mutter's default focus-stealing prevention without issue now. This is awesome. Thanks so much! |
Ubuntu22.04 desktop with LUKS, GNOME 42.9
FileManager: Nautilus (alias Files) 42.6
I set Geany as the default application to open text files
from the FileManager GUI if i click on a .txt file then Geany doesn't get focus,
instead an alert/dialog is displayed which disappears after a few seconds,
this alert/dialog contains the geany logo and the file name,
to be able to assign focus to Geany I have to switch between running programs with ALT+TAB
I checked what happens with other editors
with Gedit and Libreoffice it doesn't occur, it only occurs with Geany
more specifically, it does not occur if you double-click on the file, then all works
however, it occurs if you open the context menu with the keyboard menu key > open file >
with Dconf Editor searched the Nautilus configurations
also searched in geany configurations ~/.config/geany/geany.conf
still didn't solve
The text was updated successfully, but these errors were encountered: