mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
Userland: Keep ImageViewer window size the same while zooming in
ImageViewer window kept growing while zooming in, which causes out of memory error and crashes the application. Now, only the image content is rescaled and the window size is preserved. We also open the display window as the same size as the image, which may cause a similar issue for very large image files. This is prevented by limiting the maximum window size to be the screen size.
This commit is contained in:
parent
c0e20252da
commit
0da1353c80
1 changed files with 5 additions and 3 deletions
|
@ -92,9 +92,11 @@ int main(int argc, char** argv)
|
|||
if (window->is_maximized())
|
||||
return;
|
||||
|
||||
auto w = max(window->width(), rect.width() + 4);
|
||||
auto h = max(window->height(), rect.height() + widget.toolbar_height() + 6);
|
||||
window->resize(w, h);
|
||||
if (scale == 100) {
|
||||
auto w = min(GUI::Desktop::the().rect().width(), rect.width() + 4);
|
||||
auto h = min(GUI::Desktop::the().rect().height(), rect.height() + widget.toolbar_height() + 6);
|
||||
window->resize(w, h);
|
||||
}
|
||||
};
|
||||
widget.on_drop = [&](auto& event) {
|
||||
window->move_to_front();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue