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