From Blasius Czink, "when creating windows with decorations (titlebar) the mouse position

should be adjusted."
This commit is contained in:
Robert Osfield 2007-05-15 19:32:55 +00:00
parent e8cf7b22ad
commit 9cfff7fa19
2 changed files with 13 additions and 0 deletions

View File

@ -129,6 +129,8 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow
AGLContext _context;
AGLPixelFormat _pixelFormat;
int _windowTitleHeight;
private:
bool _closeRequested;
};

View File

@ -538,6 +538,7 @@ void GraphicsWindowCarbon::setWindowDecoration(bool flag)
void GraphicsWindowCarbon::init()
{
_windowTitleHeight = 0;
_closeRequested = false;
_context = NULL;
_window = NULL;
@ -594,8 +595,14 @@ bool GraphicsWindowCarbon::realizeImplementation()
if (err) {
osg::notify(osg::WARN) << "GraphicsWindowCarbon::realizeImplementation() failed creating a window: " << err << std::endl;
return false;
} else {
osg::notify(osg::INFO) << "GraphicsWindowCarbon::realizeImplementation() - window created with bounds(" << bounds.top << ", " << bounds.left << ", " << bounds.bottom << ", " << bounds.right << ")" << std::endl;
}
Rect titleRect;
GetWindowBounds(_window, kWindowTitleBarRgn, &titleRect);
_windowTitleHeight = abs(titleRect.top);
// register window event handler to receive resize-events
EventTypeSpec windEventList[] = {
{ kEventClassWindow, kEventWindowBoundsChanged},
@ -744,6 +751,10 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
Point wheresMyMouse;
GetEventParameter (theEvent, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(wheresMyMouse), NULL, &wheresMyMouse);
wheresMyMouse.v -= _windowTitleHeight;
if (_useWindowDecoration && (wheresMyMouse.v < 0))
return false;
Point wheresMyMouseGlobal;
GetEventParameter (theEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(wheresMyMouse), NULL, &wheresMyMouseGlobal);