Skip to content

Commit

Permalink
Limit maximum tev window size (due to opening images) by total monito…
Browse files Browse the repository at this point in the history
…r work area
  • Loading branch information
Tom94 committed Oct 2, 2024
1 parent e9eff71 commit c3cede0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/tev/ImageViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ class ImageViewer : public nanogui::Screen {
nanogui::Button* mClipToLdrButton;

int mDidFitToImage = 0;

nanogui::Vector2i mMaxSize = {8192, 8192};
};

}
23 changes: 22 additions & 1 deletion src/ImageViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ ImageViewer::ImageViewer(
// At this point we no longer need the standalone console (if it exists).
toggleConsole();

// Get monitor configuration to figure out how large the tev window may
// maximally become.
{
int monitorCount;
auto** monitors = glfwGetMonitors(&monitorCount);
if (monitors && monitorCount > 0) {
nanogui::Vector2i
monitorMin{numeric_limits<int>::max(), numeric_limits<int>::max()},
monitorMax{numeric_limits<int>::min(), numeric_limits<int>::min()};

for (int i = 0; i < monitorCount; ++i) {
nanogui::Vector2i pos, size;
glfwGetMonitorWorkarea(monitors[i], &pos.x(), &pos.y(), &size.x(), &size.y());
monitorMin = min(monitorMin, pos);
monitorMax = max(monitorMax, pos + size);
}

mMaxSize = min(mMaxSize, max(monitorMax - monitorMin, nanogui::Vector2i{1024, 800}));
}
}

m_background = Color{0.23f, 1.0f};

mVerticalScreenSplit = new Widget{this};
Expand Down Expand Up @@ -1730,7 +1751,7 @@ void ImageViewer::resizeToFit(nanogui::Vector2i targetSize) {

// For sanity, don't make us larger than 8192x8192 to ensure that we
// don't break any texture size limitations of the user's GPU.
targetSize = min(targetSize, nanogui::Vector2i{8192, 8192});
targetSize = min(targetSize, mMaxSize);
set_size(targetSize);
}

Expand Down

0 comments on commit c3cede0

Please sign in to comment.