Author: pulkomandy Date: 2011-08-06 23:13:28 +0200 (Sat, 06 Aug 2011) New Revision: 42588 Changeset: https://dev.haiku-os.org/changeset/42588 Modified: haiku/trunk/src/kits/interface/Window.cpp haiku/trunk/src/servers/notification/NotificationWindow.cpp haiku/trunk/src/servers/notification/NotificationWindow.h Log: * Fix DecoratorFrame() for kLeftTitledWindowLook windows * Use it in notification window for better positionning. Thanks augiedoggie for reporting the problem ! Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2011-08-06 10:41:45 UTC (rev 42587) +++ haiku/trunk/src/kits/interface/Window.cpp 2011-08-06 21:13:28 UTC (rev 42588) @@ -2078,14 +2078,34 @@ BWindow::DecoratorFrame() const { BRect decoratorFrame(Frame()); - float borderWidth; - float tabHeight; - _GetDecoratorSize(&borderWidth, &tabHeight); - // TODO: Broken for tab on left window side windows... - decoratorFrame.top -= tabHeight; - decoratorFrame.left -= borderWidth; - decoratorFrame.right += borderWidth; - decoratorFrame.bottom += borderWidth; + BRect tabRect(0, 0, 0, 0); + + float borderWidth = 5.0; + + BMessage settings; + if (GetDecoratorSettings(&settings) == B_OK) { + settings.FindRect("tab frame", &tabRect); + settings.FindFloat("border width", &borderWidth); + } else { + // probably no-border window look + if (fLook == B_NO_BORDER_WINDOW_LOOK) { + borderWidth = 0.0; + } + // else use fall-back values from above + } + + if (fLook & kLeftTitledWindowLook) { + decoratorFrame.top -= borderWidth; + decoratorFrame.left -= tabRect.Width(); + decoratorFrame.right += borderWidth; + decoratorFrame.bottom += borderWidth; + } else { + decoratorFrame.top -= tabRect.Height(); + decoratorFrame.left -= borderWidth; + decoratorFrame.right += borderWidth; + decoratorFrame.bottom += borderWidth; + } + return decoratorFrame; } Modified: haiku/trunk/src/servers/notification/NotificationWindow.cpp =================================================================== --- haiku/trunk/src/servers/notification/NotificationWindow.cpp 2011-08-06 10:41:45 UTC (rev 42587) +++ haiku/trunk/src/servers/notification/NotificationWindow.cpp 2011-08-06 21:13:28 UTC (rev 42588) @@ -62,8 +62,7 @@ fBorder = new BorderView(Bounds(), "Notification"); AddChild(fBorder); - - SetPosition(); + Show(); Hide(); @@ -371,8 +370,13 @@ void NotificationWindow::SetPosition() { - float width = Bounds().Width(); - float height = Bounds().Height(); + BRect bounds = DecoratorFrame(); + float width = bounds.Width(); + float height = bounds.Height(); + + float leftOffset = Frame().left - DecoratorFrame().left; + float topOffset = DecoratorFrame().top - Frame().top; + float x = 0, y = 0, sx, sy; float pad = 0; BDeskbar deskbar; @@ -381,10 +385,8 @@ switch (deskbar.Location()) { case B_DESKBAR_TOP: // Put it just under, top right corner - sx = frame.right; - sy = frame.bottom + pad; - y = sy; - x = sx - width - pad; + y = frame.bottom + pad + topOffset; + x = frame.right - width; break; case B_DESKBAR_BOTTOM: // Put it just above, lower left corner @@ -396,14 +398,14 @@ case B_DESKBAR_LEFT_TOP: // Put it just to the right of the deskbar sx = frame.right + pad; - sy = frame.top - height; - x = sx; + //sy = frame.top - height; + x = sx + leftOffset; y = frame.top + pad; break; case B_DESKBAR_RIGHT_TOP: // Put it just to the left of the deskbar sx = frame.left - width - pad; - sy = frame.top - height; + //sy = frame.top - height; x = sx; y = frame.top + pad; break; @@ -411,7 +413,7 @@ // Put it to the right of the deskbar. sx = frame.right + pad; sy = frame.bottom; - x = sx; + x = sx + leftOffset; y = sy - height - pad; break; case B_DESKBAR_RIGHT_BOTTOM: @@ -516,6 +518,13 @@ } +void NotificationWindow::Show() +{ + BWindow::Show(); + SetPosition(); +} + + void NotificationWindow::_LoadGeneralSettings(bool startMonitor) { Modified: haiku/trunk/src/servers/notification/NotificationWindow.h =================================================================== --- haiku/trunk/src/servers/notification/NotificationWindow.h 2011-08-06 10:41:45 UTC (rev 42587) +++ haiku/trunk/src/servers/notification/NotificationWindow.h 2011-08-06 21:13:28 UTC (rev 42588) @@ -51,6 +51,8 @@ virtual void WorkspaceActivated(int32, bool); virtual BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, int32, const char*); + + void Show(); icon_size IconSize(); int32 Timeout();