Fix area screenshots on automatically positioned outputs
This commit is contained in:
1 parent
bdc3ba435f
commit
80527eabea
3 files changed
+24
-11
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in new issue
Block a user