prevent windows from being located at fractional offsets, fixes BAlerts (again)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14879 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2005-11-13 00:17:04 +00:00
parent 758b1d0e05
commit d51a034e21
1 changed files with 22 additions and 1 deletions

View File

@ -48,6 +48,16 @@
#endif
// TODO: move to some place public (used in View.cpp as well)
static inline float
roundf(float v)
{
if (v >= 0.0)
return floorf(v + 0.5);
else
return ceilf(v - 0.5);
}
class BWindow::Shortcut {
public:
Shortcut(uint32 key, uint32 modifiers, BMenuItem* item);
@ -1839,6 +1849,9 @@ BWindow::MoveTo(BPoint point)
{
Lock();
point.x = roundf(point.x);
point.y = roundf(point.y);
if (fFrame.left != point.x || fFrame.top != point.y) {
float xOffset = point.x - fFrame.left;
float yOffset = point.y - fFrame.top;
@ -1861,6 +1874,10 @@ void
BWindow::ResizeBy(float dx, float dy)
{
Lock();
dx = roundf(dx);
dy = roundf(dy);
// stay in minimum & maximum frame limits
if (fFrame.Width() + dx < fMinWidth)
dx = fMinWidth - fFrame.Width();
@ -2004,7 +2021,6 @@ BWindow::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier,
// #pragma mark - Private Methods
void
BWindow::_InitData(BRect frame, const char* title, window_look look,
window_feel feel, uint32 flags, uint32 workspace, int32 bitmapToken)
@ -2016,6 +2032,11 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
return;
}
frame.left = roundf(frame.left);
frame.top = roundf(frame.top);
frame.right = roundf(frame.right);
frame.bottom = roundf(frame.bottom);
fFrame = frame;
if (title == NULL)