diff --git a/src/preferences/screen/ScreenMode.cpp b/src/preferences/screen/ScreenMode.cpp index 8b5d4e37a5..c4a37bbabd 100644 --- a/src/preferences/screen/ScreenMode.cpp +++ b/src/preferences/screen/ScreenMode.cpp @@ -331,13 +331,33 @@ ScreenMode::GetMonitorInfo(monitor_info& info, float* _diagonalInches) return status; if (_diagonalInches != NULL) { - *_diagonalInches = sqrt(info.width * info.width - + info.height * info.height) / 2.54; + *_diagonalInches = round(sqrt(info.width * info.width + + info.height * info.height) / 0.254) / 10.0; } - if (!strcmp(info.vendor, "LEN")) - strcpy(info.vendor, "Lenovo"); + // TODO: If the names aren't sound, we could see if we find/create a + // database for the entries with user presentable names; they are fine + // for the models I could test with so far. + + uint32 id = (info.vendor[0] << 24) | (info.vendor[1] << 16) + | (info.vendor[2] << 8) | (info.vendor[3]); + // TODO: replace more vendor strings with something readable + switch (id) { + case 'BNQ\0': + strcpy(info.vendor, "BenQ"); + break; + case 'LEN\0': + strcpy(info.vendor, "Lenovo"); + break; + case 'SAM\0': + strcpy(info.vendor, "Samsung"); + break; + case 'VSC\0': + strcpy(info.vendor, "ViewSonic"); + break; + } + return B_OK; } diff --git a/src/preferences/screen/ScreenWindow.cpp b/src/preferences/screen/ScreenWindow.cpp index 43994248e0..ca47aa8e26 100644 --- a/src/preferences/screen/ScreenWindow.cpp +++ b/src/preferences/screen/ScreenWindow.cpp @@ -201,6 +201,9 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings) layout->SetInsets(10, 10, 10, 10); screenBox->SetLayout(layout); + fMonitorInfo = new BStringView("monitor info", ""); + screenBox->AddChild(fMonitorInfo); + fMonitorView = new MonitorView(BRect(0.0, 0.0, 80.0, 80.0), "monitor", screen.Frame().IntegerWidth() + 1, screen.Frame().IntegerHeight() + 1); screenBox->AddChild(fMonitorView); @@ -464,6 +467,7 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings) controlsBox->TopBorderOffset() - 1)); _UpdateControls(); + _UpdateMonitor(); } @@ -720,6 +724,7 @@ ScreenWindow::_UpdateActiveMode() fScreenMode.Get(fActive); fSelected = fActive; + _UpdateMonitor(); _UpdateControls(); } @@ -1068,6 +1073,30 @@ ScreenWindow::_UpdateOriginal() } +void +ScreenWindow::_UpdateMonitor() +{ + monitor_info info; + float diagonalInches; + status_t status = fScreenMode.GetMonitorInfo(info, &diagonalInches); + + if (status != B_OK) { + if (!fMonitorInfo->IsHidden()) + fMonitorInfo->Hide(); + return; + } + + char text[256]; + snprintf(text, sizeof(text), "%s %s %g\"", info.vendor, info.name, + diagonalInches); + + fMonitorInfo->SetText(text); + + if (fMonitorInfo->IsHidden()) + fMonitorInfo->Show(); +} + + void ScreenWindow::_Apply() { diff --git a/src/preferences/screen/ScreenWindow.h b/src/preferences/screen/ScreenWindow.h index ad35d67dff..14d7036d5a 100644 --- a/src/preferences/screen/ScreenWindow.h +++ b/src/preferences/screen/ScreenWindow.h @@ -20,6 +20,7 @@ class BBox; class BPopUpMenu; class BMenuField; +class BStringView; class BTextControl; class RefreshWindow; @@ -52,6 +53,7 @@ class ScreenWindow : public BWindow { void _UpdateMonitorView(); void _UpdateControls(); void _UpdateOriginal(); + void _UpdateMonitor(); void _Apply(); @@ -62,6 +64,7 @@ class ScreenWindow : public BWindow { bool fIsVesa; bool fBootWorkspaceApplied; + BStringView* fMonitorInfo; MonitorView* fMonitorView; BMenuItem* fAllWorkspacesItem;