internal: windowinfo pass in client

So it can be used for clients other than the active one
Also fix text below screencopyview
This commit is contained in:
2 * r + 2 * t 2025-06-27 21:46:24 +10:00
parent b264ae9888
commit bed6f7c5d5
5 changed files with 43 additions and 32 deletions

View file

@ -86,6 +86,7 @@ Item {
sourceComponent: WindowInfo { sourceComponent: WindowInfo {
screen: root.screen screen: root.screen
client: Hyprland.activeToplevel
} }
} }

View file

@ -8,6 +8,7 @@ import QtQuick.Layouts
ColumnLayout { ColumnLayout {
id: root id: root
required property var client
property bool moveToWsExpanded property bool moveToWsExpanded
anchors.fill: parent anchors.fill: parent
@ -78,7 +79,7 @@ ColumnLayout {
Button { Button {
required property int index required property int index
readonly property int wsId: Math.floor((Hyprland.activeWsId - 1) / 10) * 10 + index + 1 readonly property int wsId: Math.floor((Hyprland.activeWsId - 1) / 10) * 10 + index + 1
readonly property bool isCurrent: Hyprland.activeToplevel?.workspace.id === wsId readonly property bool isCurrent: root.client?.workspace.id === wsId
color: isCurrent ? Colours.palette.m3surfaceContainerHighest : Colours.palette.m3tertiaryContainer color: isCurrent ? Colours.palette.m3surfaceContainerHighest : Colours.palette.m3tertiaryContainer
onColor: isCurrent ? Colours.palette.m3onSurface : Colours.palette.m3onTertiaryContainer onColor: isCurrent ? Colours.palette.m3onSurface : Colours.palette.m3onTertiaryContainer
@ -86,7 +87,7 @@ ColumnLayout {
disabled: isCurrent disabled: isCurrent
function onClicked(): void { function onClicked(): void {
Hyprland.dispatch(`movetoworkspace ${wsId},address:0x${Hyprland.activeToplevel?.address}`); Hyprland.dispatch(`movetoworkspace ${wsId},address:0x${root.client?.address}`);
} }
} }
} }
@ -107,20 +108,20 @@ ColumnLayout {
Layout.rightMargin: Appearance.padding.large Layout.rightMargin: Appearance.padding.large
Layout.bottomMargin: Appearance.padding.large Layout.bottomMargin: Appearance.padding.large
spacing: Hyprland.activeToplevel?.lastIpcObject.floating ? Appearance.spacing.normal : Appearance.spacing.small spacing: root.client?.lastIpcObject.floating ? Appearance.spacing.normal : Appearance.spacing.small
Button { Button {
color: Colours.palette.m3secondaryContainer color: Colours.palette.m3secondaryContainer
onColor: Colours.palette.m3onSecondaryContainer onColor: Colours.palette.m3onSecondaryContainer
text: Hyprland.activeToplevel?.lastIpcObject.floating ? qsTr("Tile") : qsTr("Float") text: root.client?.lastIpcObject.floating ? qsTr("Tile") : qsTr("Float")
function onClicked(): void { function onClicked(): void {
Hyprland.dispatch(`togglefloating address:0x${Hyprland.activeToplevel?.address}`); Hyprland.dispatch(`togglefloating address:0x${root.client?.address}`);
} }
} }
Loader { Loader {
active: Hyprland.activeToplevel?.lastIpcObject.floating active: root.client?.lastIpcObject.floating
asynchronous: true asynchronous: true
Layout.fillWidth: active Layout.fillWidth: active
Layout.leftMargin: active ? 0 : -parent.spacing Layout.leftMargin: active ? 0 : -parent.spacing
@ -129,10 +130,10 @@ ColumnLayout {
sourceComponent: Button { sourceComponent: Button {
color: Colours.palette.m3secondaryContainer color: Colours.palette.m3secondaryContainer
onColor: Colours.palette.m3onSecondaryContainer onColor: Colours.palette.m3onSecondaryContainer
text: Hyprland.activeToplevel?.lastIpcObject.pinned ? qsTr("Unpin") : qsTr("Pin") text: root.client?.lastIpcObject.pinned ? qsTr("Unpin") : qsTr("Pin")
function onClicked(): void { function onClicked(): void {
Hyprland.dispatch(`pin address:0x${Hyprland.activeToplevel?.address}`); Hyprland.dispatch(`pin address:0x${root.client?.address}`);
} }
} }
} }
@ -143,7 +144,7 @@ ColumnLayout {
text: qsTr("Kill") text: qsTr("Kill")
function onClicked(): void { function onClicked(): void {
Hyprland.dispatch(`movetoworkspace ${wsId},address:0x${Hyprland.activeToplevel?.address}`); Hyprland.dispatch(`movetoworkspace ${wsId},address:0x${root.client?.address}`);
} }
} }
} }

View file

@ -1,20 +1,22 @@
import "root:/widgets" import "root:/widgets"
import "root:/services" import "root:/services"
import "root:/config" import "root:/config"
import Quickshell import Quickshell.Hyprland
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
ColumnLayout { ColumnLayout {
id: root id: root
required property HyprlandToplevel client
anchors.fill: parent anchors.fill: parent
spacing: Appearance.spacing.small spacing: Appearance.spacing.small
Label { Label {
Layout.topMargin: Appearance.padding.large * 2 Layout.topMargin: Appearance.padding.large * 2
text: Hyprland.activeToplevel?.title ?? qsTr("No active client") text: root.client?.title ?? qsTr("No active client")
wrapMode: Text.WrapAtWordBoundaryOrAnywhere wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font.pointSize: Appearance.font.size.large font.pointSize: Appearance.font.size.large
@ -22,7 +24,7 @@ ColumnLayout {
} }
Label { Label {
text: Hyprland.activeToplevel?.lastIpcObject.class ?? qsTr("No active client") text: root.client?.lastIpcObject.class ?? qsTr("No active client")
color: Colours.palette.m3tertiary color: Colours.palette.m3tertiary
font.pointSize: Appearance.font.size.larger font.pointSize: Appearance.font.size.larger
@ -41,31 +43,31 @@ ColumnLayout {
Detail { Detail {
icon: "location_on" icon: "location_on"
text: qsTr("Address: %1").arg(`0x${Hyprland.activeToplevel?.address}` ?? "unknown") text: qsTr("Address: %1").arg(`0x${root.client?.address}` ?? "unknown")
color: Colours.palette.m3primary color: Colours.palette.m3primary
} }
Detail { Detail {
icon: "location_searching" icon: "location_searching"
text: qsTr("Position: %1, %2").arg(Hyprland.activeToplevel?.lastIpcObject.at[0] ?? -1).arg(Hyprland.activeToplevel?.lastIpcObject.at[1] ?? -1) text: qsTr("Position: %1, %2").arg(root.client?.lastIpcObject.at[0] ?? -1).arg(root.client?.lastIpcObject.at[1] ?? -1)
} }
Detail { Detail {
icon: "resize" icon: "resize"
text: qsTr("Size: %1 x %2").arg(Hyprland.activeToplevel?.lastIpcObject.size[0] ?? -1).arg(Hyprland.activeToplevel?.lastIpcObject.size[1] ?? -1) text: qsTr("Size: %1 x %2").arg(root.client?.lastIpcObject.size[0] ?? -1).arg(root.client?.lastIpcObject.size[1] ?? -1)
color: Colours.palette.m3tertiary color: Colours.palette.m3tertiary
} }
Detail { Detail {
icon: "workspaces" icon: "workspaces"
text: qsTr("Workspace: %1 (%2)").arg(Hyprland.activeToplevel?.workspace.name ?? -1).arg(Hyprland.activeToplevel?.workspace.id ?? -1) text: qsTr("Workspace: %1 (%2)").arg(root.client?.workspace.name ?? -1).arg(root.client?.workspace.id ?? -1)
color: Colours.palette.m3secondary color: Colours.palette.m3secondary
} }
Detail { Detail {
icon: "desktop_windows" icon: "desktop_windows"
text: { text: {
const mon = Hyprland.activeToplevel?.monitor; const mon = root.client?.monitor;
if (mon) if (mon)
return qsTr("Monitor: %1 (%2) at %3, %4").arg(mon.name).arg(mon.id).arg(mon.x).arg(mon.y); return qsTr("Monitor: %1 (%2) at %3, %4").arg(mon.name).arg(mon.id).arg(mon.x).arg(mon.y);
return qsTr("Monitor: unknown"); return qsTr("Monitor: unknown");
@ -74,42 +76,42 @@ ColumnLayout {
Detail { Detail {
icon: "page_header" icon: "page_header"
text: qsTr("Initial title: %1").arg(Hyprland.activeToplevel?.lastIpcObject.initialTitle ?? "unknown") text: qsTr("Initial title: %1").arg(root.client?.lastIpcObject.initialTitle ?? "unknown")
color: Colours.palette.m3tertiary color: Colours.palette.m3tertiary
} }
Detail { Detail {
icon: "category" icon: "category"
text: qsTr("Initial class: %1").arg(Hyprland.activeToplevel?.lastIpcObject.initialClass ?? "unknown") text: qsTr("Initial class: %1").arg(root.client?.lastIpcObject.initialClass ?? "unknown")
} }
Detail { Detail {
icon: "account_tree" icon: "account_tree"
text: qsTr("Process id: %1").arg(Hyprland.activeToplevel?.lastIpcObject.pid ?? -1) text: qsTr("Process id: %1").arg(root.client?.lastIpcObject.pid ?? -1)
color: Colours.palette.m3primary color: Colours.palette.m3primary
} }
Detail { Detail {
icon: "picture_in_picture_center" icon: "picture_in_picture_center"
text: qsTr("Floating: %1").arg(Hyprland.activeToplevel?.lastIpcObject.floating ? "yes" : "no") text: qsTr("Floating: %1").arg(root.client?.lastIpcObject.floating ? "yes" : "no")
color: Colours.palette.m3secondary color: Colours.palette.m3secondary
} }
Detail { Detail {
icon: "gradient" icon: "gradient"
text: qsTr("Xwayland: %1").arg(Hyprland.activeToplevel?.lastIpcObject.xwayland ? "yes" : "no") text: qsTr("Xwayland: %1").arg(root.client?.lastIpcObject.xwayland ? "yes" : "no")
} }
Detail { Detail {
icon: "keep" icon: "keep"
text: qsTr("Pinned: %1").arg(Hyprland.activeToplevel?.lastIpcObject.pinned ? "yes" : "no") text: qsTr("Pinned: %1").arg(root.client?.lastIpcObject.pinned ? "yes" : "no")
color: Colours.palette.m3secondary color: Colours.palette.m3secondary
} }
Detail { Detail {
icon: "fullscreen" icon: "fullscreen"
text: { text: {
const fs = Hyprland.activeToplevel?.lastIpcObject.fullscreen; const fs = root.client?.lastIpcObject.fullscreen;
if (fs) if (fs)
return qsTr("Fullscreen state: %1").arg(fs == 0 ? "off" : fs == 1 ? "maximised" : "on"); return qsTr("Fullscreen state: %1").arg(fs == 0 ? "off" : fs == 1 ? "maximised" : "on");
return qsTr("Fullscreen state: unknown"); return qsTr("Fullscreen state: unknown");

View file

@ -4,9 +4,8 @@ import "root:/widgets"
import "root:/services" import "root:/services"
import "root:/config" import "root:/config"
import Quickshell import Quickshell
import Quickshell.Io
import Quickshell.Wayland import Quickshell.Wayland
import Quickshell.Widgets import Quickshell.Hyprland
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
@ -14,6 +13,7 @@ Item {
id: root id: root
required property ShellScreen screen required property ShellScreen screen
required property HyprlandToplevel client
Layout.preferredWidth: preview.implicitWidth + Appearance.padding.large * 2 Layout.preferredWidth: preview.implicitWidth + Appearance.padding.large * 2
Layout.fillHeight: true Layout.fillHeight: true
@ -34,7 +34,7 @@ Item {
Loader { Loader {
anchors.centerIn: parent anchors.centerIn: parent
active: !Hyprland.activeToplevel active: !root.client
asynchronous: true asynchronous: true
sourceComponent: ColumnLayout { sourceComponent: ColumnLayout {
@ -69,10 +69,10 @@ Item {
anchors.centerIn: parent anchors.centerIn: parent
captureSource: Hyprland.activeToplevel?.wayland ?? null captureSource: root.client?.wayland ?? null
live: true live: true
constraintSize.width: parent.height * Math.min(root.screen.width / root.screen.height, Hyprland.activeToplevel?.lastIpcObject.size[0] / Hyprland.activeToplevel?.lastIpcObject.size[1]) constraintSize.width: parent.height * Math.min(root.screen.width / root.screen.height, root.client?.lastIpcObject.size[0] / root.client?.lastIpcObject.size[1])
constraintSize.height: parent.height constraintSize.height: parent.height
} }
} }
@ -86,12 +86,12 @@ Item {
animate: true animate: true
text: { text: {
const client = Hyprland.activeToplevel; const client = root.client;
if (!client) if (!client)
return qsTr("No active client"); return qsTr("No active client");
const mon = client.monitor; const mon = client.monitor;
return qsTr("%1 on monitor %2 at %3, %4").arg(client.title).arg(mon.name).arg(client.x).arg(client.y); return qsTr("%1 on monitor %2 at %3, %4").arg(client.title).arg(mon.name).arg(client.lastIpcObject.at[0]).arg(client.lastIpcObject.at[1]);
} }
} }
} }

View file

@ -2,6 +2,7 @@ import "root:/widgets"
import "root:/services" import "root:/services"
import "root:/config" import "root:/config"
import Quickshell import Quickshell
import Quickshell.Hyprland
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
@ -9,6 +10,7 @@ Item {
id: root id: root
required property ShellScreen screen required property ShellScreen screen
required property HyprlandToplevel client
implicitWidth: child.implicitWidth implicitWidth: child.implicitWidth
implicitHeight: screen.height * Config.winfo.sizes.heightMult implicitHeight: screen.height * Config.winfo.sizes.heightMult
@ -23,6 +25,7 @@ Item {
Preview { Preview {
screen: root.screen screen: root.screen
client: root.client
} }
ColumnLayout { ColumnLayout {
@ -38,7 +41,9 @@ Item {
color: Colours.palette.m3surfaceContainer color: Colours.palette.m3surfaceContainer
radius: Appearance.rounding.normal radius: Appearance.rounding.normal
Details {} Details {
client: root.client
}
} }
StyledRect { StyledRect {
@ -50,6 +55,8 @@ Item {
Buttons { Buttons {
id: buttons id: buttons
client: root.client
} }
} }
} }