diff --git a/src/preferences/screen/ScreenSettings.cpp b/src/preferences/screen/ScreenSettings.cpp index c7629de3fd..c70ad6d8da 100644 --- a/src/preferences/screen/ScreenSettings.cpp +++ b/src/preferences/screen/ScreenSettings.cpp @@ -1,40 +1,51 @@ +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Rafael Romo + * Stefano Ceccherini (burton666@libero.it) + * Axel Dörfler, axeld@pinc-software.de + */ + + #include #include #include "ScreenSettings.h" -const char ScreenSettings::fScreenSettingsFile[] = "Screen_data"; + +static const char* kSettingsFileName = "Screen_data"; + ScreenSettings::ScreenSettings() { BScreen screen(B_MAIN_SCREEN_ID); - - if (!screen.IsValid()) - ; //Debugger() ? - - fWindowFrame.Set( 0, 0, 356, 202 ); - BRect screenFrame = screen.Frame(); - + + fWindowFrame.Set(0, 0, 356, 202); + BPath path; - if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) - { - path.Append(fScreenSettingsFile); + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { + path.Append(kSettingsFileName); BFile file(path.Path(), B_READ_ONLY); - if (file.InitCheck() == B_OK) - { + if (file.InitCheck() == B_OK) { BPoint point; file.Read(&point, sizeof(BPoint)); fWindowFrame.OffsetTo(point); - - if (screen.Frame().right >= fWindowFrame.right - && screen.Frame().bottom >= fWindowFrame.bottom) + + // make sure the window is visible on screen + if (screenFrame.right >= fWindowFrame.left + 40 + && screenFrame.bottom >= fWindowFrame.top + 40 + && screenFrame.left <= fWindowFrame.right - 40 + && screenFrame.top <= fWindowFrame.bottom - 40) return; } } - fWindowFrame.OffsetTo((screenFrame.Width() - fWindowFrame.Width()) / 2, - (screenFrame.Height() - fWindowFrame.Height()) /2 ); + + fWindowFrame.OffsetTo(screenFrame.left + (screenFrame.Width() - fWindowFrame.Width()) / 2, + screenFrame.top + (screenFrame.Height() - fWindowFrame.Height()) /2); } @@ -44,7 +55,7 @@ ScreenSettings::~ScreenSettings() if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK) return; - path.Append(fScreenSettingsFile); + path.Append(kSettingsFileName); BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); if (file.InitCheck() == B_OK) { diff --git a/src/preferences/screen/ScreenSettings.h b/src/preferences/screen/ScreenSettings.h index 9416f65dc7..a4236f4cfa 100644 --- a/src/preferences/screen/ScreenSettings.h +++ b/src/preferences/screen/ScreenSettings.h @@ -1,20 +1,29 @@ -#ifndef __SCREENSETTINGS_H -#define __SCREENSETTINGS_H +/* + * Copyright 2001-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Rafael Romo + * Stefano Ceccherini (burton666@libero.it) + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef SCREEN_SETTINGS_H +#define SCREEN_SETTINGS_H -#include -class ScreenSettings -{ -public: - ScreenSettings(); - virtual ~ScreenSettings(); +#include - BRect WindowFrame() const { return fWindowFrame; }; - void SetWindowFrame(BRect); -private: - static const char fScreenSettingsFile[]; - BRect fWindowFrame; +class ScreenSettings { + public: + ScreenSettings(); + virtual ~ScreenSettings(); + + BRect WindowFrame() const { return fWindowFrame; }; + void SetWindowFrame(BRect); + + private: + BRect fWindowFrame; }; -#endif +#endif // SCREEN_SETTINGS_H