From 881325a06eabaed95c4cf6450b2895f8284accba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 14 Sep 2015 20:36:11 +0200 Subject: [PATCH] Keymap: improve initial window size, and position. * By making it scale with the font size, and by using BWindow::MoveOnScreen(). --- src/preferences/keymap/KeymapWindow.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/preferences/keymap/KeymapWindow.cpp b/src/preferences/keymap/KeymapWindow.cpp index 0c90022649..65da77def3 100644 --- a/src/preferences/keymap/KeymapWindow.cpp +++ b/src/preferences/keymap/KeymapWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2004-2014 Haiku, Inc. All rights reserved. + * Copyright 2004-2015 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -153,6 +153,7 @@ KeymapWindow::KeymapWindow() ResizeTo(windowFrame.Width(), windowFrame.Height()); MoveTo(windowFrame.LeftTop()); + MoveOnScreen(); // TODO: this might be a bug in the interface kit, but scrolling to // selection does not correctly work unless the window is shown. @@ -1057,6 +1058,9 @@ KeymapWindow::_LoadSettings(BRect& windowFrame, BString& keyboardLayout) windowFrame.right = 899; windowFrame.bottom = 349; } + float scaling = be_plain_font->Size() / 12.0f; + windowFrame.right *= scaling; + windowFrame.bottom *= scaling; keyboardLayout = ""; @@ -1074,23 +1078,6 @@ KeymapWindow::_LoadSettings(BRect& windowFrame, BString& keyboardLayout) } } - if (!screen.Frame().Contains(windowFrame)) { - // Make sure the window is not larger than the screen - if (windowFrame.Width() > screen.Frame().Width()) - windowFrame.right = windowFrame.left + screen.Frame().Width(); - if (windowFrame.Height() > screen.Frame().Height()) - windowFrame.bottom = windowFrame.top + screen.Frame().Height(); - - // Make sure the window is on screen (and center if it isn't) - if (windowFrame.left < screen.Frame().left - || windowFrame.right > screen.Frame().right - || windowFrame.top < screen.Frame().top - || windowFrame.bottom > screen.Frame().bottom) { - windowFrame.OffsetTo(BAlert::AlertPosition(windowFrame.Width(), - windowFrame.Height())); - } - } - return status; }