Skip to content

Conversation

@bbedward
Copy link
Contributor

@bbedward bbedward commented Sep 29, 2025

Implement keyboard-shortcuts-inhibit-unstable-v1

There's probably a few use cases for this in quickshell, but the one i'm interested in is getting an interface for creating keybinds. Without it it gets eaten by the compositor.

Usage is as follows:

import Quickshell.Wayland

ShortcutsInhibitor {
    window: root // PanelWindow
    enabled: root.recording
}

@outfoxxed
Copy link
Member

This does not look helpful for creating keybinds and I can't think of much to use it for apart from making misguided lock screens that don't work properly.

Can you explain exactly what you want to do with it and why having your compositor run qs ipc does not solve it?

@bbedward
Copy link
Contributor Author

bbedward commented Sep 30, 2025

This does not look helpful for creating keybinds and I can't think of much to use it for apart from making misguided lock screens that don't work properly.

Can you explain exactly what you want to do with it and why having your compositor run qs ipc does not solve it?

Specifically, I want to integrate a settings screen for configuring niri keybinds into my shell. Which is now possible with niris config include branch.

It's not possible to have a keybind input field without it. (If I want to overwrite one that's already bound)

@bbedward
Copy link
Contributor Author

rec_1759233568.mp4

This is the type of input field I have in mind

Copy link
Member

@outfoxxed outfoxxed left a comment

Choose a reason for hiding this comment

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

I've gone over the protocol and the implementation, and most of it is missing here. To merge this we'll need to be able to tell if the compositor takes away the inhibitor or it disappears due to focus loss.

Additionally, only one inhibitor object can be created at a time per surface or a protocol error will be raised and quickshell will crash, so merge them.

@bbedward bbedward force-pushed the add-zwp-shortcut-inhibit branch from f484db0 to 21eb42f Compare November 6, 2025 14:47
@bbedward
Copy link
Contributor Author

bbedward commented Nov 6, 2025

I added an activeChanged signal and also accounted for creating multiple on the same surface

WARN quickshell.wayland.shortcuts_inhibit: An inhibitor already exists for surface, skipping creation. 0x7fe132c6bc40

@bbedward bbedward force-pushed the add-zwp-shortcut-inhibit branch from 21eb42f to a764cec Compare November 6, 2025 15:42
Copy link
Member

@outfoxxed outfoxxed left a comment

Choose a reason for hiding this comment

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

went through everything

this->onWindowVisibilityChanged();
}

emit this->windowChanged();
Copy link
Member

Choose a reason for hiding this comment

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

It looks like window and bBoundWindow should be pretty much unrelated. As window hasn't changed here, it shouldn't update. If the window is actually connected should be transparent to the window property.

Comment on lines 29 to 56
ShortcutsInhibitor*
ShortcutsInhibitManager::createShortcutsInhibitor(QtWaylandClient::QWaylandWindow* surface) {
auto* display = QtWaylandClient::QWaylandIntegration::instance()->display();
auto* inputDevice = display->lastInputDevice();
if (inputDevice == nullptr) inputDevice = display->defaultInputDevice();

if (inputDevice == nullptr) {
qCCritical(logShortcutsInhibit) << "Could not create shortcuts inhibitor: No seat.";
return nullptr;
}

auto* wlSurface = surface->surface();

if (this->inhibitors.contains(wlSurface)) {
auto* inhibitor = this->inhibitors.value(wlSurface);
this->refCounts[inhibitor]++;
qCDebug(logShortcutsInhibit) << "Reusing existing inhibitor" << inhibitor << "for surface"
<< wlSurface << "- refcount:" << this->refCounts[inhibitor];
return inhibitor;
}

auto* inhibitor =
new ShortcutsInhibitor(this->inhibit_shortcuts(wlSurface, inputDevice->object()), wlSurface);
this->inhibitors.insert(wlSurface, inhibitor);
this->refCounts.insert(inhibitor, 1);
qCDebug(logShortcutsInhibit) << "Created inhibitor" << inhibitor << "for surface" << wlSurface;
return inhibitor;
}
Copy link
Member

Choose a reason for hiding this comment

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

We should return an existing inhibitor if we have one that matches.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is if it already exists for the surface

@bbedward bbedward force-pushed the add-zwp-shortcut-inhibit branch from 27b5ae9 to a77f9b0 Compare November 14, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants