quickshell: click a notification to jump to its app

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-08-01 20:29:19 +01:00
parent bcd685f3e3
commit f436389ad7

View file

@ -2988,6 +2988,19 @@ in
if (a.startsWith("/")) return "file://" + a; if (a.startsWith("/")) return "file://" + a;
return ""; return "";
} }
// Clicking a notification jumps to the sending app: invoke its
// default action (apps use it to open the right chat/tab) and
// focus the window ourselves misc:focus_on_activate is off,
// so the app's own activation request would be ignored.
function activateNotif(notif) {
if (!notif) return;
for (const a of notif.actions)
if (a.identifier === "default") { a.invoke(); break; }
const entry = (notif.desktopEntry || "").replace(/\.desktop$/, "");
const m = [entry, notif.appName].filter(s => s !== "").join("|");
if (m !== "") Hyprland.dispatch("focuswindow class:(?i)^(" + m + ")$");
}
function toggleDropdown(dd, setupFn) { function toggleDropdown(dd, setupFn) {
if (dd.visible && !dd.closing) { if (dd.visible && !dd.closing) {
dd.animateClose(); dd.animateClose();
@ -5816,6 +5829,18 @@ in
width: parent.width width: parent.width
height: Math.max(notifPreview.visible ? 48 : 0, ncBody.height) height: Math.max(notifPreview.visible ? 48 : 0, ncBody.height)
// First child, so the dismiss button and
// action chips still get their clicks.
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
bar.activateNotif(notifItem.modelData);
notifItem.modelData.dismiss();
bar.closeAllDropdowns();
}
}
// Image preview (album art, screenshot thumb) // Image preview (album art, screenshot thumb)
ClippingRectangle { ClippingRectangle {
id: notifPreview id: notifPreview
@ -6096,6 +6121,18 @@ in
property string previewSource: bar.notifPreviewSource(toastItem.currentNotif) property string previewSource: bar.notifPreviewSource(toastItem.currentNotif)
// First child, so the dismiss button and action
// chips still get their clicks.
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
bar.activateNotif(toastItem.currentNotif);
toastItem.currentNotif.dismiss();
toastItem.dismiss();
}
}
// Image preview (screenshot thumb, album art) // Image preview (screenshot thumb, album art)
ClippingRectangle { ClippingRectangle {
id: toastPreview id: toastPreview