davatorium/rofi

[BUG] Librewolf window is not focused after launching with drun

Opened this issue · 7 comments

Rofi version (rofi -v)

1.7.5

Configuration

https://gist.github.com/Kostrol/e9a7aa3808b6bce40f86f2a180d757a9

Theme

https://gist.github.com/Kostrol/038e20bb18b58153fa13cd3ac1167bd3

Timing report

No response

Launch command

rofi -show drun

Step to reproduce

  1. launch drun and select librewolf to open
  2. librewolf window opens but without focus

Expected behavior

browser opens and is immediately focused

Actual behavior

browser window opens but only previous window is in focus

Additional information

No response

Using wayland display server protocol

  • No, I don't use the wayland display server protocol

I've checked if the issue exists in the latest stable release

  • Yes, I have checked the problem exists in the latest stable version

What window manager do you use?

With f.e. i3 focus_follow_mouse could move the focus away from the newly launched application.

Using Mutter and X11, I have click to focus enabled and have a border hint so I can tell with the window.

Can you test this patch against git? see if it helps for drun mode?

diff --git a/source/modes/drun.c b/source/modes/drun.c
index c18d8f95..5ed1a45a 100644
--- a/source/modes/drun.c
+++ b/source/modes/drun.c
@@ -53,6 +53,8 @@
 #include "settings.h"
 #include "timings.h"
 #include "widgets/textbox.h"
+
+#include "xcb-internal.h"
 #include "xcb.h"
 
 #include "rofi-icon-fetcher.h"
@@ -1213,9 +1215,13 @@ static ModeMode drun_mode_result(Mode *sw, int mretv, char **input,
     switch (rmpd->entry_list[selected_line].type) {
     case DRUN_DESKTOP_ENTRY_TYPE_SERVICE:
     case DRUN_DESKTOP_ENTRY_TYPE_APPLICATION:
+      xcb->focus_revert = 0;
+      rofi_view_hide();
       exec_cmd_entry(&(rmpd->entry_list[selected_line]), NULL);
       break;
     case DRUN_DESKTOP_ENTRY_TYPE_LINK:
+      xcb->focus_revert = 0;
+      rofi_view_hide();
       launch_link_entry(&(rmpd->entry_list[selected_line]));
       break;
     default:
@@ -1225,6 +1231,9 @@ static ModeMode drun_mode_result(Mode *sw, int mretv, char **input,
              *input[0] != '\0') {
     RofiHelperExecuteContext context = {.name = NULL};
     gboolean run_in_term = ((mretv & MENU_CUSTOM_ACTION) == MENU_CUSTOM_ACTION);
+    xcb->focus_revert = 0;
+    rofi_view_hide();
+
     // FIXME: We assume startup notification in terminals, not in others
     if (!helper_execute_command(NULL, *input, run_in_term,
                                 run_in_term ? &context : NULL)) {

it could also be mutters focus stealing prevention.. do you get a 'window is ready' notification?

https://extensions.gnome.org/extension/2182/noannoyance/

Looking at the journal this is all I get :

rofi[3729661]: g_string_insert_len: assertion 'len == 0 || val != NULL' failed

systemd[2245]: Started `app-flatpak-io.gitlab.librewolf\x2dcommunity-3729706.scope.

It's strange because regular Firefox shifts focus the to window correctly when opening as well as all other applications I've tested, Librewolf seems to be the outlier that just wont.

Can you test this patch against git? see if it helps for drun mode?

diff --git a/source/modes/drun.c b/source/modes/drun.c

I'm sorry, I'm by no means a developer or familiar with patching and staging git. How would I go about doing and applying this?
I've cloned the next branch.

it could also be mutters focus stealing prevention.. do you get a 'window is ready' notification?

Yes that would have been a factor, I do already have a similar extension installed for just that reason however.

Is librewolf the only flatpak application that does it?

Rofi launches every application in an identical manner, so not sure why one would work, and another not.

Is librewolf the only flatpak application that does it?

Yes, it does seem that way.

Rofi launches every application in an identical manner, so not sure why one would work, and another not.

This what puzzles me as well.