From bd514095bbcae303fd10d708eed1fb64d9e0b97c Mon Sep 17 00:00:00 2001 From: Oishika Pradhan Date: Sun, 24 Mar 2019 20:13:28 +0530 Subject: [PATCH] Keymap: better default window size. Use a larger default window size so the keymap is readable. However, size it down on low resolution displays. Fixes #14892 Change-Id: Id35c46fa14bef570f78d8f065d95f6e6d8f0c6d7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1312 Reviewed-by: Adrien Destugues --- src/preferences/keymap/KeymapWindow.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/preferences/keymap/KeymapWindow.cpp b/src/preferences/keymap/KeymapWindow.cpp index 16cef4b6f7..b8d0256e75 100644 --- a/src/preferences/keymap/KeymapWindow.cpp +++ b/src/preferences/keymap/KeymapWindow.cpp @@ -73,6 +73,8 @@ static const char* kDeadKeyTriggerNone = ""; static const char* kCurrentKeymapName = "(Current)"; static const char* kDefaultKeymapName = "US-International"; +static const float kDefaultHeight = 440; +static const float kDefaultWidth = 1000; static int compare_key_list_items(const void* a, const void* b) @@ -82,12 +84,24 @@ compare_key_list_items(const void* a, const void* b) return BLocale::Default()->StringCompare(item1->Text(), item2->Text()); } - KeymapWindow::KeymapWindow() : - BWindow(BRect(80, 50, 650, 300), B_TRANSLATE_SYSTEM_NAME("Keymap"), - B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) + BWindow(BRect(80, 50, kDefaultWidth, kDefaultHeight), + B_TRANSLATE_SYSTEM_NAME("Keymap"), B_TITLED_WINDOW, + B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) { + // If the window doesn't fit the screen, make it smaller but keep the + // aspect ratio + BScreen screen(this); + display_mode mode; + status_t status = screen.GetMode(&mode); + if(status == B_OK && (mode.virtual_width <= kDefaultWidth + || mode.virtual_height <= kDefaultHeight)) { + float width = mode.virtual_width - 64; + ResizeTo(mode.virtual_width - 64, + width * kDefaultHeight / kDefaultWidth); + } + fKeyboardLayoutView = new KeyboardLayoutView("layout"); fKeyboardLayoutView->SetKeymap(&fCurrentMap); fKeyboardLayoutView->SetExplicitMinSize(BSize(B_SIZE_UNSET, 192));