Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3cede0

Browse files
committed
Limit maximum tev window size (due to opening images) by total monitor work area
1 parent e9eff71 commit c3cede0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

include/tev/ImageViewer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ class ImageViewer : public nanogui::Screen {
271271
nanogui::Button* mClipToLdrButton;
272272

273273
int mDidFitToImage = 0;
274+
275+
nanogui::Vector2i mMaxSize = {8192, 8192};
274276
};
275277

276278
}

src/ImageViewer.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,27 @@ ImageViewer::ImageViewer(
5353
// At this point we no longer need the standalone console (if it exists).
5454
toggleConsole();
5555

56+
// Get monitor configuration to figure out how large the tev window may
57+
// maximally become.
58+
{
59+
int monitorCount;
60+
auto** monitors = glfwGetMonitors(&monitorCount);
61+
if (monitors && monitorCount > 0) {
62+
nanogui::Vector2i
63+
monitorMin{numeric_limits<int>::max(), numeric_limits<int>::max()},
64+
monitorMax{numeric_limits<int>::min(), numeric_limits<int>::min()};
65+
66+
for (int i = 0; i < monitorCount; ++i) {
67+
nanogui::Vector2i pos, size;
68+
glfwGetMonitorWorkarea(monitors[i], &pos.x(), &pos.y(), &size.x(), &size.y());
69+
monitorMin = min(monitorMin, pos);
70+
monitorMax = max(monitorMax, pos + size);
71+
}
72+
73+
mMaxSize = min(mMaxSize, max(monitorMax - monitorMin, nanogui::Vector2i{1024, 800}));
74+
}
75+
}
76+
5677
m_background = Color{0.23f, 1.0f};
5778

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

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

0 commit comments

Comments
 (0)