From 80527eabeac54fa6913fbaf6026d47a0c254b8f5 Mon Sep 17 00:00:00 2001 From: Samuel Onoja Date: Thu, 1 Oct 2026 13:39:58 +0100 Subject: [PATCH] Fix area screenshots on automatically positioned outputs --- compositor/src/backends/direct.rs | 15 ++++++--------- packaging/ferese-screenshot | 9 +++++++-- scripts/tests/test_screenshot.py | 11 +++++++++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/compositor/src/backends/direct.rs b/compositor/src/backends/direct.rs index e334103..20207ef 100644 --- a/compositor/src/backends/direct.rs +++ b/compositor/src/backends/direct.rs @@ -1469,15 +1469,6 @@ fn create_output( output.add_mode(mode); } output.set_preferred(output_mode); - output.change_current_state( - Some(output_mode), - Some(output_transform(settings.transform)), - Some(Scale::Fractional(settings.scale)), - Some({ - let [x, y] = settings.position.unwrap_or([0, 0]); - (x, y).into() - }), - ); let position = settings.position.unwrap_or_else(|| { let x = state .space @@ -1488,6 +1479,12 @@ fn create_output( .unwrap_or(0); [x, 0] }); + output.change_current_state( + Some(output_mode), + Some(output_transform(settings.transform)), + Some(Scale::Fractional(settings.scale)), + Some((position[0], position[1]).into()), + ); state.space.map_output(&output, (position[0], position[1])); state.register_output(&output, identity); (output, global) diff --git a/packaging/ferese-screenshot b/packaging/ferese-screenshot index 9043707..332adba 100755 --- a/packaging/ferese-screenshot +++ b/packaging/ferese-screenshot @@ -60,9 +60,14 @@ directory=${pictures:-$HOME/Pictures}/Screenshots mkdir -p -- "$directory" || fail 'Could not create the screenshot directory.' file=$(mktemp "$directory/Screenshot-$(date +%Y-%m-%d_%H-%M-%S)-XXXXXX.png") || fail 'Could not create the screenshot file.' input='' -trap '[[ -z $input ]] || rm -f -- "$input"; [[ -s $file ]] || rm -f -- "$file"' EXIT +capture_error='' +trap '[[ -z $input ]] || rm -f -- "$input"; [[ -z $capture_error ]] || rm -f -- "$capture_error"; [[ -s $file ]] || rm -f -- "$file"' EXIT input=$(mktemp "$XDG_RUNTIME_DIR/ferese-screenshot-XXXXXX.png") || fail 'Could not create the temporary capture.' -feresectl screenshot "${capture_args[@]}" >"$input" || fail 'Could not capture the screen. Ferese must be running, unlocked, and reachable over its socket.' +capture_error=$(mktemp "$XDG_RUNTIME_DIR/ferese-screenshot-error-XXXXXX") || fail 'Could not create the capture log.' +if ! feresectl screenshot "${capture_args[@]}" >"$input" 2>"$capture_error"; then + detail=$(<"$capture_error") + fail "Could not capture the screen. ${detail:-The compositor returned no error details.}" +fi # Size the editor to the image that was actually captured, so a small area # selection does not open a huge window and a multi-monitor --all capture is not # sized from whichever output happened to be focused. Satty treats this as a diff --git a/scripts/tests/test_screenshot.py b/scripts/tests/test_screenshot.py index dddee97..e13bc08 100644 --- a/scripts/tests/test_screenshot.py +++ b/scripts/tests/test_screenshot.py @@ -165,6 +165,17 @@ class ScreenshotTest(unittest.TestCase): first.terminate() first.communicate(timeout=3) + def test_capture_failure_reports_the_compositor_error(self): + detail = 'invalid_request: The requested region does not intersect any enabled output' + self.bins.joinpath('feresectl').write_text( + '#!/bin/bash\nprintf "%s\\n" "' + detail + '" >&2\nexit 1\n') + result = self.run_script('--all') + self.assertNotEqual(result.returncode, 0) + self.assertIn(detail.encode(), result.stderr) + self.assertNotIn(b'must be running', result.stderr) + self.assertFalse((self.root / 'editors').exists()) + self.assertEqual(list(self.root.glob('ferese-screenshot-*')), []) + def test_area_selection_is_passed_through(self): self.bins.joinpath('slurp').write_text( '#!/bin/bash\nprintf "10,-20 300x200"\n')