Skip to content
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

Rofi closes, on mouse release, when selecting mode from button if mouse is outside of window after resize #1896

Closed
2 tasks done
Girv98 opened this issue Sep 7, 2023 · 6 comments
Labels
Milestone

Comments

@Girv98
Copy link

Girv98 commented Sep 7, 2023

Rofi version (rofi -v)

1.7.5

Configuration

https://gist.github.com/Girv98/54f27f464667d0a0b2dc704505f33252

Theme

https://gist.github.com/Girv98/4e32b6e3ff849a8628417785b31eec31

Timing report

No response

Launch command

rofi -show-icons -modi drun,emoji,run,calc,window -show drun

Step to reproduce

  1. Launch rofi with config/theme provided
  2. Click on button to change to calculator (which is a shorter window than the app menu)
  3. Relaunch, then click and hold on the same button
  4. Repeat same action, now drag mouse back inside the window before releasing

Expected behavior

Rofi should not close on mouse release.

Actual behavior

  • (Step 2) - Window closes on mouse release
  • (Step 3) - Window stays open until mouse is released
  • (Step 4) - Window remains open

Additional information

I believe this closed issue is describing the same behaviour. I should be able to provide a screen recording of the issue if needed.

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
@Girv98 Girv98 added the bug label Sep 7, 2023
@Girv98 Girv98 changed the title Rofi closes, on mouse release, when selecting modi from button if mouse is outside of window after resize Rofi closes, on mouse release, when selecting mode from button if mouse is outside of window after resize Sep 7, 2023
@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Sep 7, 2023

It looks like X11 is reporting the release is not going to the rofi window, therefor it decides to close as it thinks it is a click outside the window.
Button press event outside of rofi window I don't seem to register (only release :?)

@sardemff7 can we link/relate the release of a click to a press event? So if the press originates within rofi, we ignore the release? I don't think this is information we get?

(no config file version to reproduce issue:
rofi -show drun -no-config -sidebar-mode -theme-str 'listview { fixed-height: false; }'
)

@DaveDavenport
Copy link
Collaborator

Possible one liner 'fix':
(sorry for extra debug spam)

diff --git a/source/xcb.c b/source/xcb.c
index 62dddfbf..2822fbbd 100644
--- a/source/xcb.c
+++ b/source/xcb.c
@@ -1264,7 +1264,8 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
   case XCB_MOTION_NOTIFY: {
     xcb_motion_notify_event_t *xme = (xcb_motion_notify_event_t *)event;
     gboolean button_mask = xme->state & XCB_EVENT_MASK_BUTTON_1_MOTION;
-    if (button_mask && config.click_to_exit == TRUE) {
+    if (button_mask) {
+      printf("seen\r\n");
       xcb->mouse_seen = TRUE;
     }
     rofi_view_handle_mouse_motion(state, xme->event_x, xme->event_y,
@@ -1285,6 +1286,8 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
     } else if (x11_button_to_nk_bindings_scroll(bpe->detail, &axis, &steps)) {
       nk_bindings_seat_handle_scroll(xcb->bindings_seat, NULL, axis, steps);
     }
+    printf("seen\r\n");
+    xcb->mouse_seen = TRUE;
     break;
   }
   case XCB_SELECTION_CLEAR: {
@@ -1347,6 +1350,7 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
       if (!xcb->mouse_seen) {
         rofi_view_temp_click_to_exit(state, bre->event);
       }
+      printf("unseen\r\n");
       xcb->mouse_seen = FALSE;
     }
     break;

This will go wrong if users start pressing/releasing multiple buttons.

@DaveDavenport
Copy link
Collaborator

diff --git a/include/xcb-internal.h b/include/xcb-internal.h
index 8b012a79..1e44cd5b 100644
--- a/include/xcb-internal.h
+++ b/include/xcb-internal.h
@@ -64,7 +64,7 @@ struct _xcb_stuff {
   } xkb;
   xcb_timestamp_t last_timestamp;
   NkBindingsSeat *bindings_seat;
-  gboolean mouse_seen;
+  uint32_t mouse_seen;
   xcb_window_t focus_revert;
   char *clipboard;
 };
diff --git a/source/xcb.c b/source/xcb.c
index 62dddfbf..375cfcfc 100644
--- a/source/xcb.c
+++ b/source/xcb.c
@@ -1264,9 +1264,6 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
   case XCB_MOTION_NOTIFY: {
     xcb_motion_notify_event_t *xme = (xcb_motion_notify_event_t *)event;
     gboolean button_mask = xme->state & XCB_EVENT_MASK_BUTTON_1_MOTION;
-    if (button_mask && config.click_to_exit == TRUE) {
-      xcb->mouse_seen = TRUE;
-    }
     rofi_view_handle_mouse_motion(state, xme->event_x, xme->event_y,
                                   !button_mask && config.hover_select);
     break;
@@ -1285,6 +1282,7 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
     } else if (x11_button_to_nk_bindings_scroll(bpe->detail, &axis, &steps)) {
       nk_bindings_seat_handle_scroll(xcb->bindings_seat, NULL, axis, steps);
     }
+    xcb->mouse_seen++;
     break;
   }
   case XCB_SELECTION_CLEAR: {
@@ -1347,7 +1345,7 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
       if (!xcb->mouse_seen) {
         rofi_view_temp_click_to_exit(state, bre->event);
       }
-      xcb->mouse_seen = FALSE;
+      xcb->mouse_seen--;
     }
     break;
   }

@DaveDavenport
Copy link
Collaborator

Can you test the (latest) patch and confirm this works?

@Girv98
Copy link
Author

Girv98 commented Sep 14, 2023

Can confirm! Works as expected

@DaveDavenport DaveDavenport added this to the 1.7.6 milestone Sep 24, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants