qs: normalize screenshot rect
This commit is contained in:
parent
34d752c42f
commit
1720cb6c9b
2 changed files with 191 additions and 8 deletions
|
@ -42,7 +42,7 @@ Scope {
|
|||
command: [
|
||||
"magick",
|
||||
root.path,
|
||||
"-crop", `${selection.w}x${selection.h}+${selection.x}+${selection.y}`,
|
||||
"-crop", `${selection.normal.width}x${selection.normal.height}+${selection.normal.x}+${selection.normal.y}`,
|
||||
"-quality", "70",
|
||||
"-page", "0x0+0+0", // removes page size and shot position
|
||||
root.path,
|
||||
|
@ -74,6 +74,16 @@ Scope {
|
|||
readonly property real y: Math.min(y1, y2)
|
||||
readonly property real w: Math.max(x1, x2) - x
|
||||
readonly property real h: Math.max(y1, y2) - y
|
||||
readonly property rect normal: Qt.rect(x - topleft.x, y - topleft.y, w, h)
|
||||
}
|
||||
|
||||
readonly property point topleft: Quickshell.screens.reduce((point, screen) => {
|
||||
return Qt.point(Math.min(point.x, screen.x), Math.min(point.y, screen.y))
|
||||
}, Qt.point(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY))
|
||||
|
||||
function normalizedScreenRect(screen: ShellScreen): rect {
|
||||
const p = topleft;
|
||||
return Qt.rect(screen.x - p.x, screen.y - p.y, screen.width, screen.height)
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
|
@ -93,6 +103,7 @@ Scope {
|
|||
}
|
||||
|
||||
PanelWindow {
|
||||
id: panel
|
||||
required property var modelData;
|
||||
screen: modelData
|
||||
visible: root.visible
|
||||
|
@ -115,15 +126,15 @@ Scope {
|
|||
enabled: !selectionComplete
|
||||
|
||||
onPressed: {
|
||||
selection.x1 = mouseX + screen.x;
|
||||
selection.x1 = mouseX + panel.screen.x;
|
||||
selection.x2 = selection.x1;
|
||||
selection.y1 = mouseY + screen.y;
|
||||
selection.y1 = mouseY + panel.screen.y;
|
||||
selection.y2 = selection.y1;
|
||||
}
|
||||
|
||||
onPositionChanged: {
|
||||
selection.x2 = mouseX + screen.x;
|
||||
selection.y2 = mouseY + screen.y;
|
||||
selection.x2 = mouseX + panel.screen.x;
|
||||
selection.y2 = mouseY + panel.screen.y;
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
|
@ -139,14 +150,14 @@ Scope {
|
|||
parent: area
|
||||
anchors.fill: parent
|
||||
source: root.visible ? root.path : ""
|
||||
sourceClipRect: Qt.rect(screen.x, screen.y, screen.width, screen.height)
|
||||
sourceClipRect: root.normalizedScreenRect(panel.screen)
|
||||
}
|
||||
|
||||
CutoutRect {
|
||||
id: cutoutRect
|
||||
anchors.fill: parent
|
||||
innerX: selection.x - screen.x
|
||||
innerY: selection.y - screen.y
|
||||
innerX: selection.x - panel.screen.x
|
||||
innerY: selection.y - panel.screen.y
|
||||
innerW: selection.w
|
||||
innerH: selection.h
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue