WindowServer: Return ShareableBitmap() on fail

WindowServer returns {} on non-existing screen index,
however shot program hangs instead of retriving an empty
ShareableBitmap. With this change, the function returns an empty
ShareableBitmap and shot exits gracefully.
This commit is contained in:
Aziz Berkay Yesilyurt 2021-11-03 21:51:25 +01:00 committed by Andreas Kling
parent 7f8794f902
commit bfb36fec89

View file

@ -968,7 +968,7 @@ Messages::WindowServer::GetScreenBitmapResponse ClientConnection::get_screen_bit
auto* screen = Screen::find_by_index(screen_index.value());
if (!screen) {
dbgln("get_screen_bitmap: Screen {} does not exist!", screen_index.value());
return { {} };
return { Gfx::ShareableBitmap() };
}
if (rect.has_value()) {
auto bitmap = Compositor::the().front_bitmap_for_screenshot({}, *screen).cropped(rect.value());
@ -994,7 +994,7 @@ Messages::WindowServer::GetScreenBitmapResponse ClientConnection::get_screen_bit
});
return bitmap->to_shareable_bitmap();
}
return { {} };
return { Gfx::ShareableBitmap() };
}
Messages::WindowServer::GetScreenBitmapAroundCursorResponse ClientConnection::get_screen_bitmap_around_cursor(Gfx::IntSize const& size)