From 2c9f63f0b8e85a4b743241f7aacb3b84960d5713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 8 Jan 2004 03:24:08 +0000 Subject: [PATCH] MouseSettings::RetrieveSettings() promised that the window will filter invalid coordinates and center the window on screen. Now, that really happens, and the MouseSettings class will also have a default value for the position that triggers this behaviour as well. Thanks to voidref for reporting this. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5983 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/prefs/mouse/MouseSettings.cpp | 2 ++ src/prefs/mouse/MouseWindow.cpp | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/prefs/mouse/MouseSettings.cpp b/src/prefs/mouse/MouseSettings.cpp index e24af7d5a4..1a16c0baa4 100644 --- a/src/prefs/mouse/MouseSettings.cpp +++ b/src/prefs/mouse/MouseSettings.cpp @@ -38,6 +38,8 @@ static const int32 kDefaultAccelerationFactor = 65536; MouseSettings::MouseSettings() + : + fWindowPosition(-1, -1) { RetrieveSettings(); diff --git a/src/prefs/mouse/MouseWindow.cpp b/src/prefs/mouse/MouseWindow.cpp index 50d26b19f7..22015e3195 100644 --- a/src/prefs/mouse/MouseWindow.cpp +++ b/src/prefs/mouse/MouseWindow.cpp @@ -62,8 +62,22 @@ MouseWindow::MouseWindow(BRect rect) // we are using the pulse rate to scan pressed mouse // buttons and draw the selected imagery - ResizeTo(fSettingsView->Frame().right + kBorderSpace, button->Frame().bottom + kBorderSpace - 1); - MoveTo(fSettings.WindowPosition()); + ResizeTo(fSettingsView->Frame().right + kBorderSpace, + button->Frame().bottom + kBorderSpace - 1); + + // check if the window is on screen + + rect = BScreen().Frame(); + rect.right -= 20; + rect.bottom -= 20; + + BPoint position = fSettings.WindowPosition(); + if (!rect.Contains(position)) { + // center window on screen as it doesn't fit on the saved position + position.x = (rect.Width() - Bounds().Width()) / 2; + position.y = (rect.Height() - Bounds().Height()) / 2; + } + MoveTo(position); }