Skip to content

Conversation

@vtyrtov
Copy link
Contributor

@vtyrtov vtyrtov commented Nov 19, 2025

Fixes #19775

Problem:
When the mouse cursor is over a thumbnail in the filmstrip (especially over overlay elements like stars or edges), keyboard shortcuts for rating, color labels, etc. were being applied to the currently open image in darkroom instead of the image under the cursor.

Root cause:
Keyboard events trigger spurious GDK_LEAVE_NOTIFY events with GDK_NOTIFY_ANCESTOR detail in GTK. The thumbnail's leave event handlers (_event_box_enter_leave, _event_btn_enter_leave, _event_star_leave, _event_main_leave) were resetting mouse_over_id to NO_IMGID when receiving these events, causing dt_act_on_get_images() to fall back to using active_images instead of the hovered image.

Solution:
Remove the mouse_over_id resets from thumbnail-level leave handlers. The proper place to reset mouse_over_id is in thumbtable's leave handler (_event_leave_notify in thumbtable.c), which correctly distinguishes between leaving the thumbnail for another thumbnail (GDK_NOTIFY_INFERIOR) and actually leaving the thumbtable area.

Changes:

  • Removed mouse_over_id resets from _event_box_enter_leave, _event_btn_enter_leave, and _event_star_leave
  • Removed _event_main_leave function and its signal connection entirely as it served no purpose after removing the mouse_over_id reset

@horazont
Copy link
Contributor

From a quick test, it looks like that fixes it.

@vtyrtov vtyrtov marked this pull request as ready for review November 20, 2025 03:45
@TurboGit TurboGit added this to the 5.4 milestone Nov 20, 2025
@TurboGit TurboGit added bugfix pull request fixing a bug priority: high core features are broken and not usable at all, software crashes scope: DAM managing files, collections, archiving, metadata, etc. labels Nov 20, 2025
@TurboGit
Copy link
Member

@dterrahe : I'd like you review on this if possible. TIA.

@TurboGit
Copy link
Member

This fixes the issue on my side too.

@dterrahe
Copy link
Member

I can't properly test this week, sorry. The thing to look out for is what happens when you move directly from hovering over a "gadget" within the thumbnail to outside the thumbnail. For example when the gadget (a star or something) is bordering the thumbnail or if the mouse move is so quick that there's no intermediate position where it is outside the gadget but still inside the thumbnail. In that case, does the thumbnail leave get called? Does everything reset correctly?

In gtk4 the enter/leave stuff is rejigged so that (I think) the outermost object always gets notified when you leave, but in gtk3 I remember we had issues around this.

@vtyrtov
Copy link
Contributor Author

vtyrtov commented Nov 20, 2025

If you move the cursor from the "stars" from left to right in the reject of another image, the ID does not change. Working with it.

I haven't found any other errors yet.

@vtyrtov vtyrtov marked this pull request as draft November 20, 2025 14:10
@horazont
Copy link
Contributor

Another option would be to get rid of the 1px of space between the thumbs (or make that space part of the thumb widget somehow), wouldn't it?

@vtyrtov
Copy link
Contributor Author

vtyrtov commented Nov 20, 2025

Another option would be to get rid of the 1px of space between the thumbs (or make that space part of the thumb widget somehow), wouldn't it?

There's a different problem - the overlays don't cover the thumbnail entirely. But there is no gap between the thumbnail (this is indicated by the correct operation of the tooltip). They'll make a commit soon, which I haven't identified any problems on yet (I'm testing at the moment)

Fixes darktable-org#19775

Problem:
When the mouse cursor is over a thumbnail in the filmstrip (especially
over overlay elements like stars or reject button), keyboard shortcuts
for rating, color labels, etc. were being applied to the currently open
image in darkroom instead of the image under the cursor.

Additionally, fast transitions between overlay elements of different
thumbnails didn't update mouse_over_id correctly.

Root cause:
Keyboard events trigger spurious GDK_LEAVE_NOTIFY events with
GDK_NOTIFY_ANCESTOR detail in GTK. The thumbnail's leave event handlers
were resetting mouse_over_id to NO_IMGID when receiving these events,
causing dt_act_on_get_images() to fall back to using active_images
instead of the hovered image.

before updating mouse_over_id, which prevented updates during fast
transitions between overlay elements of different thumbnails.

Solution:
1. Remove mouse_over_id resets from thumbnail-level leave handlers.
   The proper place to reset mouse_over_id is in thumbtable's leave
   handler (_event_leave_notify in thumbtable.c), which correctly
   distinguishes between leaving the thumbnail for another thumbnail
   (GDK_NOTIFY_INFERIOR) and actually leaving the thumbtable area.

   ensure mouse_over_id is updated on every enter event, enabling
   proper tracking during fast mouse movements between thumbnails.

3. Add mouse_over_id update to _event_btn_enter_leave for overlay
   buttons (reject, color labels, etc.) to handle transitions to
   these elements.

4. Add proper darktable.control->element reset in leave handler for
   reject button to ensure hover state is cleared correctly.

Changes:
  _event_image_enter_leave, and _event_star_enter
- Added mouse_over_id update to _event_btn_enter_leave enter handler
- Added darktable.control->element reset to _event_btn_enter_leave
  leave handler for reject button
- Removed _event_main_leave function and its signal connection entirely
  as it served no purpose after removing the mouse_over_id reset
@vtyrtov vtyrtov force-pushed the fix/film-strip-dead-space branch from 98ebe19 to 0c8724f Compare November 20, 2025 15:37
@vtyrtov
Copy link
Contributor Author

vtyrtov commented Nov 20, 2025

Updated the fix to handle additional edge cases:

  1. Removed !thumb->mouse_over conditions from all enter event handlers (_event_box_enter_leave, _event_image_enter_leave, _event_star_enter). This ensures mouse_over_id is updated on every enter event, fixing issues with fast transitions between overlay elements of different thumbnails.

  2. Added mouse_over_id update to _event_btn_enter_leave enter handler. This handles transitions to overlay buttons (reject, color labels, etc.) that weren't being tracked before.

  3. Added proper cleanup in _event_btn_enter_leave leave handler to reset darktable.control->element when leaving the reject button, ensuring hover state is cleared correctly.

These changes address the feedback about fast mouse movements between overlay elements while maintaining the original fix for keyboard shortcuts.

@vtyrtov vtyrtov marked this pull request as ready for review November 20, 2025 16:59
@TurboGit
Copy link
Member

I'm a bit uneasy for this in 5.4. The issue it fixes is not that bad and I fear some possible regression with this as it touches a delicate part.

@vtyrtov
Copy link
Contributor Author

vtyrtov commented Nov 21, 2025

Yes, there's a vicious circle - fixing one problem brings back another. If the move to gtk4 is just around the corner, then let it stay as it is?

@TurboGit
Copy link
Member

Yes, either that or merge this early in 5.6 cycle to at least get good field testing. You're call on this, if you prefer closing this let me know.

@vtyrtov
Copy link
Contributor Author

vtyrtov commented Nov 21, 2025

merge this early in 5.6 cycle to at least get good field testing

Let's do this

@TurboGit TurboGit modified the milestones: 5.4, 5.6 Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix pull request fixing a bug priority: high core features are broken and not usable at all, software crashes scope: DAM managing files, collections, archiving, metadata, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

One pixel of dead space between film strip images can cause accidental misapplication of actions (such as rating)

4 participants