fix: quickshell bar spacing
This commit is contained in:
1 parent
fb7781e4a7
commit
b1afff322f
9 files changed
+169
-134
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
fps_limit=0
|
||||||
|
frame_timing=1
|
||||||
|
gpu_stats=1
|
||||||
|
cpu_stats=1
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
lutris
|
lutris
|
||||||
claude-code
|
claude-code
|
||||||
imagemagick
|
imagemagick
|
||||||
|
mangohud
|
||||||
];
|
];
|
||||||
|
|
||||||
home.file = {
|
home.file = {
|
||||||
|
|||||||
@@ -111,11 +111,11 @@ keep_dead_proc_usage = false
|
|||||||
|
|
||||||
#* Sets the CPU stat shown in upper half of the CPU graph, "total" is always available.
|
#* Sets the CPU stat shown in upper half of the CPU graph, "total" is always available.
|
||||||
#* Select from a list of detected attributes from the options menu.
|
#* Select from a list of detected attributes from the options menu.
|
||||||
cpu_graph_upper = "total"
|
cpu_graph_upper = "Auto"
|
||||||
|
|
||||||
#* Sets the CPU stat shown in lower half of the CPU graph, "total" is always available.
|
#* Sets the CPU stat shown in lower half of the CPU graph, "total" is always available.
|
||||||
#* Select from a list of detected attributes from the options menu.
|
#* Select from a list of detected attributes from the options menu.
|
||||||
cpu_graph_lower = "total"
|
cpu_graph_lower = "Auto"
|
||||||
|
|
||||||
#* If gpu info should be shown in the cpu box. Available values = "Auto", "On" and "Off".
|
#* If gpu info should be shown in the cpu box. Available values = "Auto", "On" and "Off".
|
||||||
show_gpu_info = "Auto"
|
show_gpu_info = "Auto"
|
||||||
|
|||||||
@@ -228,6 +228,12 @@ hl.bind("XF86AudioStop", hl.dsp.exec_cmd("playerctl stop"), { locked = true })
|
|||||||
hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true })
|
hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true })
|
||||||
hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true })
|
hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true })
|
||||||
|
|
||||||
|
-- Screenshots
|
||||||
|
hl.bind("Print", hl.dsp.exec_cmd("hyprshot -m output"))
|
||||||
|
hl.bind("SHIFT + Print", hl.dsp.exec_cmd("hyprshot -m window"))
|
||||||
|
hl.bind("CTRL + Print", hl.dsp.exec_cmd("hyprshot -m region"))
|
||||||
|
hl.bind(mainMod .. " + Print", hl.dsp.exec_cmd("hyprshot -m region --raw | swappy -f -"))
|
||||||
|
|
||||||
-- Move focus with mainMod + arrow keys
|
-- Move focus with mainMod + arrow keys
|
||||||
hl.bind(mainMod .. " + left", hl.dsp.focus({ direction = "left" }))
|
hl.bind(mainMod .. " + left", hl.dsp.focus({ direction = "left" }))
|
||||||
hl.bind(mainMod .. " + right", hl.dsp.focus({ direction = "right" }))
|
hl.bind(mainMod .. " + right", hl.dsp.focus({ direction = "right" }))
|
||||||
@@ -285,3 +291,11 @@ for _, title in ipairs(quickshell_popups) do
|
|||||||
rounding = 20,
|
rounding = 20,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- The bar's surface grows/shrinks to fit its hover tooltip (see Bar.qml);
|
||||||
|
-- Hyprland's default layer animation makes that resize visibly slide/fade,
|
||||||
|
-- which reads as broken rather than intentional. Disable it for the bar.
|
||||||
|
hl.layer_rule({
|
||||||
|
match = { namespace = "^(quickshell-bar)$" },
|
||||||
|
no_anim = true,
|
||||||
|
})
|
||||||
@@ -11,10 +11,6 @@ PanelWindow {
|
|||||||
|
|
||||||
// Reference to global state
|
// Reference to global state
|
||||||
property QtObject rootState
|
property QtObject rootState
|
||||||
// Shared overlay window that renders tray icon hover tooltips (see
|
|
||||||
// TrayTooltip.qml) so this bar's own surface can stay exactly as tall
|
|
||||||
// as the pill itself.
|
|
||||||
property QtObject trayTooltip
|
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: true
|
top: true
|
||||||
@@ -22,9 +18,6 @@ PanelWindow {
|
|||||||
right: true
|
right: true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Matches hyprland.lua's general.gaps_out (20) so the gap above the bar
|
|
||||||
// (this margin) and the gap below it (added by Hyprland once the
|
|
||||||
// exclusiveZone ends) read as the same size.
|
|
||||||
readonly property int hyprGapsOut: 20
|
readonly property int hyprGapsOut: 20
|
||||||
|
|
||||||
margins {
|
margins {
|
||||||
@@ -33,22 +26,74 @@ PanelWindow {
|
|||||||
right: hyprGapsOut
|
right: hyprGapsOut
|
||||||
}
|
}
|
||||||
|
|
||||||
// No separate bottom buffer here — Hyprland's gaps_out already adds its
|
// Fixed pill-row height. The tray tooltip (below) needs extra surface
|
||||||
// own gap between the reserved zone and the tiled window below.
|
// space beneath this to render into, but that space is reserved
|
||||||
exclusiveZone: implicitHeight + margins.top
|
// up front at a constant size rather than grown/shrunk at runtime -
|
||||||
|
// resizing a wlr-layer-shell surface on every hover forces a full
|
||||||
|
// reconfigure that visibly flashes/redraws the whole bar. Instead the
|
||||||
|
// surface is always tall enough, and only the tooltip's own visibility
|
||||||
|
// toggles.
|
||||||
|
readonly property int barContentHeight: 40
|
||||||
|
readonly property int tooltipReserve: 40
|
||||||
|
|
||||||
implicitHeight: 40
|
// Just the pill row's own height - not barContentHeight + margins.top.
|
||||||
|
// The wlr-layer-shell protocol already adds this surface's margins on
|
||||||
|
// top of exclusiveZone when reserving screen space, so including
|
||||||
|
// margins.top here again double-counts it (verified via `hyprctl
|
||||||
|
// monitors`: reported reserved space was margins.top + exclusiveZone,
|
||||||
|
// not just exclusiveZone). That double-count was also why the gap below
|
||||||
|
// the bar measured out to margins.top + 22px instead of a fixed 22px
|
||||||
|
// (Hyprland's own gaps_out + border) - no value of margins.top could
|
||||||
|
// ever make the two gaps equal while the formula double-counted it.
|
||||||
|
exclusiveZone: barContentHeight
|
||||||
|
|
||||||
|
implicitHeight: barContentHeight + tooltipReserve
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
WlrLayershell.layer: WlrLayer.Top
|
WlrLayershell.layer: WlrLayer.Top
|
||||||
WlrLayershell.namespace: "quickshell-bar"
|
WlrLayershell.namespace: "quickshell-bar"
|
||||||
|
|
||||||
|
// Only the pill row accepts input - the reserved tooltip space below it
|
||||||
|
// stays click-through so it doesn't block the desktop/windows under it
|
||||||
|
// when no tooltip is showing.
|
||||||
|
mask: Region {
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
width: barWindow.width
|
||||||
|
height: barWindow.barContentHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
property string tooltipText: ""
|
||||||
|
property real tooltipAnchorX: 0
|
||||||
|
property real tooltipAnchorY: 0
|
||||||
|
|
||||||
|
function showTooltip(x, y, text) {
|
||||||
|
tooltipAnchorX = x;
|
||||||
|
tooltipAnchorY = y;
|
||||||
|
tooltipText = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideTooltip() {
|
||||||
|
tooltipText = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
Tooltip {
|
||||||
|
id: tooltipItem
|
||||||
|
text: barWindow.tooltipText
|
||||||
|
visible: barWindow.tooltipText.length > 0
|
||||||
|
x: Math.max(
|
||||||
|
Theme.geometry.spacing,
|
||||||
|
Math.min(barWindow.tooltipAnchorX - width / 2, barWindow.width - width - Theme.geometry.spacing)
|
||||||
|
)
|
||||||
|
y: barWindow.tooltipAnchorY
|
||||||
|
}
|
||||||
|
|
||||||
// Left Pill (Workspaces) - tinted with the primary accent.
|
// Left Pill (Workspaces) - tinted with the primary accent.
|
||||||
Pill {
|
Pill {
|
||||||
id: leftPill
|
id: leftPill
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: parent.top
|
||||||
height: parent.height
|
height: barWindow.barContentHeight
|
||||||
tint: Theme.colors.primary
|
tint: Theme.colors.primary
|
||||||
glow: true
|
glow: true
|
||||||
|
|
||||||
@@ -89,8 +134,8 @@ PanelWindow {
|
|||||||
Pill {
|
Pill {
|
||||||
id: centerPill
|
id: centerPill
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: parent.top
|
||||||
height: parent.height
|
height: barWindow.barContentHeight
|
||||||
tint: Theme.colors.secondary
|
tint: Theme.colors.secondary
|
||||||
glow: true
|
glow: true
|
||||||
|
|
||||||
@@ -114,8 +159,8 @@ PanelWindow {
|
|||||||
Pill {
|
Pill {
|
||||||
id: rightPill
|
id: rightPill
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: parent.top
|
||||||
height: parent.height
|
height: barWindow.barContentHeight
|
||||||
tint: Theme.colors.tertiary
|
tint: Theme.colors.tertiary
|
||||||
|
|
||||||
StatIndicator {
|
StatIndicator {
|
||||||
@@ -123,29 +168,32 @@ PanelWindow {
|
|||||||
text: sysStats.cpuPercent + "%"
|
text: sysStats.cpuPercent + "%"
|
||||||
tint: Theme.colors.tertiary
|
tint: Theme.colors.tertiary
|
||||||
tooltip: "CPU usage: " + sysStats.cpuPercent + "%"
|
tooltip: "CPU usage: " + sysStats.cpuPercent + "%"
|
||||||
tooltipWindow: barWindow.trayTooltip
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StatIndicator {
|
Repeater {
|
||||||
visible: sysStats.cpuTemp.length > 0
|
model: dieTempsModel
|
||||||
glyph: "" // nf-fa-thermometer_half
|
|
||||||
text: sysStats.cpuTemp + "°"
|
StatIndicator {
|
||||||
tint: {
|
required property string label
|
||||||
let t = Number(sysStats.cpuTemp);
|
required property string temp
|
||||||
if (t >= 80) return Theme.colors.alert;
|
|
||||||
if (t >= 65) return Theme.colors.warning;
|
glyph: "" // nf-fa-thermometer_half
|
||||||
return Theme.colors.textMuted;
|
text: temp + "°"
|
||||||
|
tint: {
|
||||||
|
let t = Number(temp);
|
||||||
|
if (t >= 80) return Theme.colors.alert;
|
||||||
|
if (t >= 65) return Theme.colors.warning;
|
||||||
|
return Theme.colors.textMuted;
|
||||||
|
}
|
||||||
|
tooltip: (dieTempsModel.count > 1 ? label + " " : "CPU ") + "temp: " + temp + "°C"
|
||||||
}
|
}
|
||||||
tooltip: "CPU temp: " + sysStats.cpuTemp + "°C"
|
|
||||||
tooltipWindow: barWindow.trayTooltip
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StatIndicator {
|
StatIndicator {
|
||||||
glyph: "" // nf-fa-server
|
glyph: "" // nf-fa-server
|
||||||
text: sysStats.ramPercent + "%"
|
text: sysStats.ramUsedGB + "G"
|
||||||
tint: Theme.colors.secondary
|
tint: Theme.colors.secondary
|
||||||
tooltip: "RAM usage: " + sysStats.ramPercent + "%"
|
tooltip: "RAM usage: " + sysStats.ramUsedGB + " GiB (" + sysStats.ramPercent + "%)"
|
||||||
tooltipWindow: barWindow.trayTooltip
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrayIcon {
|
TrayIcon {
|
||||||
@@ -154,7 +202,6 @@ PanelWindow {
|
|||||||
tint: Theme.colors.primary
|
tint: Theme.colors.primary
|
||||||
tooltip: "WiFi: " + wifiPoll.ssid
|
tooltip: "WiFi: " + wifiPoll.ssid
|
||||||
visible: wifiPoll.connected
|
visible: wifiPoll.connected
|
||||||
tooltipWindow: barWindow.trayTooltip
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrayIcon {
|
TrayIcon {
|
||||||
@@ -163,7 +210,6 @@ PanelWindow {
|
|||||||
tint: Theme.colors.secondary
|
tint: Theme.colors.secondary
|
||||||
tooltip: "Bluetooth: " + bluetoothPoll.connectedDevices
|
tooltip: "Bluetooth: " + bluetoothPoll.connectedDevices
|
||||||
visible: bluetoothPoll.connectedDevices.length > 0
|
visible: bluetoothPoll.connectedDevices.length > 0
|
||||||
tooltipWindow: barWindow.trayTooltip
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrayIcon {
|
TrayIcon {
|
||||||
@@ -188,18 +234,17 @@ PanelWindow {
|
|||||||
+ (battery.state === UPowerDeviceState.Charging ? " (charging)" : "")
|
+ (battery.state === UPowerDeviceState.Charging ? " (charging)" : "")
|
||||||
: "No battery"
|
: "No battery"
|
||||||
visible: battery.isPresent
|
visible: battery.isPresent
|
||||||
tooltipWindow: barWindow.trayTooltip
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property QtObject battery: UPower.displayDevice
|
property QtObject battery: UPower.displayDevice
|
||||||
|
|
||||||
// --- System stats (CPU%, CPU temp, RAM%) read straight from /proc and /sys ---
|
// --- System stats (CPU%, per-die CPU temps, RAM%) read straight from /proc and /sys ---
|
||||||
QtObject {
|
QtObject {
|
||||||
id: sysStats
|
id: sysStats
|
||||||
property string cpuPercent: "0"
|
property string cpuPercent: "0"
|
||||||
property string cpuTemp: ""
|
|
||||||
property string ramPercent: "0"
|
property string ramPercent: "0"
|
||||||
|
property string ramUsedGB: "0"
|
||||||
|
|
||||||
// Previous /proc/stat totals, for computing CPU% as a delta between polls.
|
// Previous /proc/stat totals, for computing CPU% as a delta between polls.
|
||||||
property real prevTotal: -1
|
property real prevTotal: -1
|
||||||
@@ -241,21 +286,44 @@ PanelWindow {
|
|||||||
sysStats.ramPercent = mem.MemTotal > 0
|
sysStats.ramPercent = mem.MemTotal > 0
|
||||||
? Math.round(100 * (mem.MemTotal - mem.MemAvailable) / mem.MemTotal).toString()
|
? Math.round(100 * (mem.MemTotal - mem.MemAvailable) / mem.MemTotal).toString()
|
||||||
: "0";
|
: "0";
|
||||||
|
// MemTotal/MemAvailable are in KiB.
|
||||||
|
sysStats.ramUsedGB = mem.MemTotal > 0
|
||||||
|
? ((mem.MemTotal - mem.MemAvailable) / 1024 / 1024).toFixed(1)
|
||||||
|
: "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discover the CPU temp sensor's hwmon path once (the hwmonN numbering
|
// One entry per CPU die: { label: "Tccd1", temp: "45" }. On chips with
|
||||||
// isn't stable across boots), then poll that fixed path via FileView.
|
// a single die (no Tccd sensors, e.g. most Intel coretemp setups) this
|
||||||
FileView { id: cpuTempFile; watchChanges: false }
|
// falls back to a single "CPU" entry from Tctl/Package temp. Updated
|
||||||
|
// in place (set/append/remove) rather than replaced wholesale, so the
|
||||||
|
// Repeater bound to it doesn't destroy/recreate delegates - and lose
|
||||||
|
// their hover state - on every poll.
|
||||||
|
ListModel { id: dieTempsModel }
|
||||||
|
|
||||||
|
// Find the CPU sensor chip's hwmon dir and emit one "label millideg" line
|
||||||
|
// per die (Tccd1, Tccd2, ...), falling back to a single Tctl/Package
|
||||||
|
// reading on chips with no per-die sensors. Re-run in full every poll
|
||||||
|
// rather than caching the hwmon path, since hwmonN numbering isn't
|
||||||
|
// stable across boots and this walk is cheap.
|
||||||
Process {
|
Process {
|
||||||
id: hwmonDiscovery
|
id: dieTempProcess
|
||||||
command: ["bash", "-c", "for h in /sys/class/hwmon/hwmon*; do n=$(cat \"$h/name\" 2>/dev/null); if [ \"$n\" = k10temp ] || [ \"$n\" = coretemp ] || [ \"$n\" = zenpower ]; then echo \"$h/temp1_input\"; break; fi; done"]
|
command: ["bash", "-c", "h=\"\"; for d in /sys/class/hwmon/hwmon*; do n=$(cat \"$d/name\" 2>/dev/null); if [ \"$n\" = k10temp ] || [ \"$n\" = zenpower ] || [ \"$n\" = coretemp ]; then h=\"$d\"; break; fi; done; [ -z \"$h\" ] && exit 0; found=0; for lbl in \"$h\"/temp*_label; do [ -e \"$lbl\" ] || continue; name=$(cat \"$lbl\"); case \"$name\" in Tccd*) idx=\"${lbl%_label}\"; val=$(cat \"${idx}_input\" 2>/dev/null); if [ -n \"$val\" ]; then echo \"$name $val\"; found=1; fi ;; esac; done; if [ \"$found\" = 0 ]; then val=$(cat \"$h/temp1_input\" 2>/dev/null); [ -n \"$val\" ] && echo \"CPU $val\"; fi"]
|
||||||
running: true
|
running: false
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
let path = this.text.trim();
|
let temps = [];
|
||||||
if (path.length > 0) cpuTempFile.path = path;
|
for (const line of this.text.trim().split("\n")) {
|
||||||
|
let parts = line.trim().split(/\s+/);
|
||||||
|
if (parts.length < 2) continue;
|
||||||
|
let millideg = Number(parts[1]);
|
||||||
|
if (millideg > 0) temps.push({ label: parts[0], temp: Math.round(millideg / 1000).toString() });
|
||||||
|
}
|
||||||
|
for (let i = 0; i < temps.length; i++) {
|
||||||
|
if (i < dieTempsModel.count) dieTempsModel.set(i, temps[i]);
|
||||||
|
else dieTempsModel.append(temps[i]);
|
||||||
|
}
|
||||||
|
while (dieTempsModel.count > temps.length) dieTempsModel.remove(dieTempsModel.count - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,12 +333,7 @@ PanelWindow {
|
|||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
triggeredOnStart: true
|
triggeredOnStart: true
|
||||||
onTriggered: {
|
onTriggered: dieTempProcess.exec(dieTempProcess.command)
|
||||||
if (cpuTempFile.path.length === 0) return;
|
|
||||||
cpuTempFile.reload();
|
|
||||||
let millideg = Number(cpuTempFile.text().trim());
|
|
||||||
if (millideg > 0) sysStats.cpuTemp = Math.round(millideg / 1000).toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- WiFi status (polled via nmcli; requires NetworkManager) ---
|
// --- WiFi status (polled via nmcli; requires NetworkManager) ---
|
||||||
@@ -346,7 +409,6 @@ PanelWindow {
|
|||||||
property alias text: statText.text
|
property alias text: statText.text
|
||||||
property color tint: Theme.colors.text
|
property color tint: Theme.colors.text
|
||||||
property string tooltip: ""
|
property string tooltip: ""
|
||||||
property QtObject tooltipWindow
|
|
||||||
|
|
||||||
width: statRow.width
|
width: statRow.width
|
||||||
height: 24
|
height: 24
|
||||||
@@ -381,20 +443,16 @@ PanelWindow {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (statIndicator.tooltipWindow && statIndicator.tooltip.length > 0) {
|
if (statIndicator.tooltip.length > 0) {
|
||||||
let pos = statIndicator.mapToGlobal(statIndicator.width / 2, statIndicator.height + Theme.geometry.spacing / 2);
|
let pos = statIndicator.mapToItem(null, statIndicator.width / 2, statIndicator.height + 12);
|
||||||
statIndicator.tooltipWindow.showAt(pos.x, pos.y, statIndicator.tooltip);
|
barWindow.showTooltip(pos.x, pos.y, statIndicator.tooltip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: barWindow.hideTooltip()
|
||||||
if (statIndicator.tooltipWindow) statIndicator.tooltipWindow.hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inline component for a hoverable tray icon. The tooltip itself is
|
// Inline component for a hoverable tray icon. `tint` is this icon's
|
||||||
// rendered by the shared TrayTooltip overlay window (see tooltipWindow)
|
|
||||||
// so it isn't clipped by this bar's small surface. `tint` is this icon's
|
|
||||||
// own identity color (wifi vs bluetooth vs battery-by-level, etc.).
|
// own identity color (wifi vs bluetooth vs battery-by-level, etc.).
|
||||||
component TrayIcon: Item {
|
component TrayIcon: Item {
|
||||||
id: trayIcon
|
id: trayIcon
|
||||||
@@ -402,7 +460,6 @@ PanelWindow {
|
|||||||
property string tooltip: ""
|
property string tooltip: ""
|
||||||
property bool active: false
|
property bool active: false
|
||||||
property color tint: Theme.colors.primary
|
property color tint: Theme.colors.primary
|
||||||
property QtObject tooltipWindow
|
|
||||||
|
|
||||||
width: 24
|
width: 24
|
||||||
height: 24
|
height: 24
|
||||||
@@ -432,16 +489,14 @@ PanelWindow {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (trayIcon.tooltipWindow && trayIcon.tooltip.length > 0) {
|
if (trayIcon.tooltip.length > 0) {
|
||||||
// Anchor on the icon's horizontal center; the tooltip
|
// Anchor on the icon's horizontal center; the tooltip
|
||||||
// window centers its bubble under this point itself.
|
// item centers its bubble under this point itself.
|
||||||
let pos = trayIcon.mapToGlobal(trayIcon.width / 2, trayIcon.height + Theme.geometry.spacing / 2);
|
let pos = trayIcon.mapToItem(null, trayIcon.width / 2, trayIcon.height + 12);
|
||||||
trayIcon.tooltipWindow.showAt(pos.x, pos.y, trayIcon.tooltip);
|
barWindow.showTooltip(pos.x, pos.y, trayIcon.tooltip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: barWindow.hideTooltip()
|
||||||
if (trayIcon.tooltipWindow) trayIcon.tooltipWindow.hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Wayland
|
|
||||||
import "../Shared"
|
|
||||||
|
|
||||||
// Full-screen, click-through overlay used to render tray icon tooltips.
|
|
||||||
// Kept as its own window so the Bar's own surface can stay exactly as tall
|
|
||||||
// as the pill itself (no shadow/margin bloat from an oversized surface).
|
|
||||||
PanelWindow {
|
|
||||||
id: tooltipWindow
|
|
||||||
|
|
||||||
property string shownText: ""
|
|
||||||
property real anchorX: 0
|
|
||||||
property real anchorY: 0
|
|
||||||
|
|
||||||
function showAt(x, y, text) {
|
|
||||||
anchorX = x;
|
|
||||||
anchorY = y;
|
|
||||||
shownText = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hide() {
|
|
||||||
shownText = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
anchors {
|
|
||||||
top: true
|
|
||||||
left: true
|
|
||||||
right: true
|
|
||||||
bottom: true
|
|
||||||
}
|
|
||||||
|
|
||||||
exclusiveZone: 0
|
|
||||||
color: "transparent"
|
|
||||||
visible: shownText.length > 0
|
|
||||||
|
|
||||||
WlrLayershell.layer: WlrLayer.Overlay
|
|
||||||
WlrLayershell.namespace: "quickshell-tray-tooltip"
|
|
||||||
|
|
||||||
// Never accept input; this window only ever draws a small label.
|
|
||||||
mask: Region {}
|
|
||||||
|
|
||||||
Tooltip {
|
|
||||||
// anchorX is the icon's horizontal center; center this bubble on it,
|
|
||||||
// clamped so it never runs past the screen edges.
|
|
||||||
x: Math.max(
|
|
||||||
Theme.geometry.spacing,
|
|
||||||
Math.min(tooltipWindow.anchorX - width / 2, tooltipWindow.width - width - Theme.geometry.spacing)
|
|
||||||
)
|
|
||||||
y: tooltipWindow.anchorY
|
|
||||||
text: tooltipWindow.shownText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,6 +21,19 @@ Rectangle {
|
|||||||
|
|
||||||
function focusInput() { input.forceActiveFocus(); }
|
function focusInput() { input.forceActiveFocus(); }
|
||||||
|
|
||||||
|
// The layer-shell surface only gets real keyboard focus from the
|
||||||
|
// compositor asynchronously after it's first mapped, so a single
|
||||||
|
// forceActiveFocus() call right on visible-toggle can silently lose
|
||||||
|
// input the first time a panel is shown in a session. There's no
|
||||||
|
// reliable signal for "the compositor granted focus now" on a
|
||||||
|
// wlr-layer-shell surface, so just retry until it actually sticks.
|
||||||
|
Timer {
|
||||||
|
interval: 30
|
||||||
|
repeat: true
|
||||||
|
running: field.visible && !input.activeFocus
|
||||||
|
onTriggered: input.forceActiveFocus()
|
||||||
|
}
|
||||||
|
|
||||||
height: 50
|
height: 50
|
||||||
color: Theme.colors.surface
|
color: Theme.colors.surface
|
||||||
radius: Theme.geometry.radiusSmall
|
radius: Theme.geometry.radiusSmall
|
||||||
|
|||||||
@@ -168,11 +168,17 @@ PanelWindow {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
Connections {
|
// The layer-shell surface only gets real keyboard focus from the
|
||||||
target: pickerWindow
|
// compositor asynchronously after it's first mapped, so a single
|
||||||
function onVisibleChanged() {
|
// forceActiveFocus() call right on visible-toggle can silently lose
|
||||||
if (pickerWindow.visible) keyHandler.forceActiveFocus();
|
// input the first time this panel is shown in a session. There's no
|
||||||
}
|
// reliable signal for "the compositor granted focus now" on a
|
||||||
|
// wlr-layer-shell surface, so just retry until it actually sticks.
|
||||||
|
Timer {
|
||||||
|
interval: 30
|
||||||
|
repeat: true
|
||||||
|
running: pickerWindow.visible && !keyHandler.activeFocus
|
||||||
|
onTriggered: keyHandler.forceActiveFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onEscapePressed: (event) => {
|
Keys.onEscapePressed: (event) => {
|
||||||
|
|||||||
@@ -86,10 +86,6 @@ ShellRoot {
|
|||||||
running: false
|
running: false
|
||||||
}
|
}
|
||||||
|
|
||||||
TrayTooltip {
|
|
||||||
id: trayTooltip
|
|
||||||
}
|
|
||||||
|
|
||||||
Variants {
|
Variants {
|
||||||
model: Quickshell.screens
|
model: Quickshell.screens
|
||||||
|
|
||||||
@@ -97,7 +93,6 @@ ShellRoot {
|
|||||||
required property var modelData
|
required property var modelData
|
||||||
screen: modelData
|
screen: modelData
|
||||||
rootState: root
|
rootState: root
|
||||||
trayTooltip: trayTooltip
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user