Skip to content

fix: keep focus on the surface that received press, so it receives release - #2181

Open
hojjatabdollahi wants to merge 1 commit into
Smithay:masterfrom
hojjatabdollahi:hojjat/click-grab
Open

hojjatabdollahi wants to merge 1 commit into
Smithay:masterfrom
hojjatabdollahi:hojjat/click-grab

Conversation

@hojjatabdollahi

@hojjatabdollahi hojjatabdollahi commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

If you drag a slider in an applet in cosmic-comp and while dragging exit the bounds of the applet, then release the mouse button. The release event doesn't get delivered to the applet.

Before:

before.mp4

After:

after.mp4

Checklist

@YaLTeR

YaLTeR commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

I guess the problem here is that we can't use a ClickGrab because Smithay doesn't have a grab stack/tree system?

Comment on lines +566 to +568
if *new_target == target {
location = *new_location;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up disabling this new part in the default ClickGrab in niri btw because it results in more accidental interactions when scrolling is involved. With popups it's not such a big deal since you'd need quite specific conditions in niri to trigger scrolling with a click inside a popup (usually, a non-autoclosing popup). So I'm not sure it's worth going through the trouble to make this overridable. I guess it's one more thing that would resolve itself once Smithay has a grab stack/tree system since it'd just use the normal ClickGrab.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I mirrored ClickGrab::motion, but I'm happy to drop these three lines, since they're not doing much here.

But I agree a grab stack would've been able to push the ClickGrab on top of the popup grab and release would pop it. Until then this should be OK.

@Drakulix

Copy link
Copy Markdown
Member

I guess the problem here is that we can't use a ClickGrab because Smithay doesn't have a grab stack/tree system?

Yeah, I would flag this as another symptom of our inadequate grab system.

I am not sure I like this change because in general there might be cases, where the pointer leaving is all the application in question does need to know. We shouldn't inject events to return things to a neutral position. This doesn't necessarily inject events, but it does redirect them when the ClickGrab already should handle it.

@hojjatabdollahi

Copy link
Copy Markdown
Contributor Author

when the ClickGrab already should handle it

ClickGrab doesn't handle this AFAICT. We don't have a grab stack, so only one grab is active. ClickGrab is installed by DefaultGrab. But when PopupPointerGrab is active it receives the press.

This gives PopupPointerGrab the same focus behaviour ClickGrab::motion has while buttons are held, and nothing more. It doesn't create or reorder any events. The client just gets the release on the surface it pressed on, as it would anywhere outside a popup. The leave is sent later on the first motion after the release, which is also what happens with the normal ClickGrab too.

@Drakulix

Copy link
Copy Markdown
Member

when the ClickGrab already should handle it

ClickGrab doesn't handle this AFAICT. We don't have a grab stack, so only one grab is active. ClickGrab is installed by DefaultGrab. But when PopupPointerGrab is active it receives the press.

Yeah, so we duplicate logic, when we really should support nesting instead. :/

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants