From 1b4205b277fa63ae107e5ac923067f73b79581d1 Mon Sep 17 00:00:00 2001 From: rti Date: Sun, 31 Oct 2010 20:53:14 +0100 Subject: [PATCH] Fixed: #1013 Viewport size when embedding NeL Cocoa view in Qt --- .../3d/driver/opengl/driver_opengl_window.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 10b632245..b45813d41 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -913,6 +913,22 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re else { _win = wnd; + + /* The NSView* extracted from a QWidget using winId() has bounds set to + * (QWidget::x(), QWidget::y(), QWidget::width(), QWidget::height()). + * This causes cocoa to draw at an offset of x(), y() leaving an unhandled + * border in the NSView. The code below fixes this by translating the + * coordinate system of the NSView back to 0,0. + * In my opinion this is an error in Qt since QWidget::x/y() are relative to + * parent and [NSView bounds.origin] is relative to it's own coordinate + * system. This are incompatible notations. Qt should handle the conversion. + * Fixes: #1013 Viewport size when embedding NeL Cocoa view in Qt + * (http://dev.ryzom.com/issues/1013) + */ + NSView* view = (NSView*)wnd; + if(view.frame.origin.x != 0 || view.frame.origin.y != 0) { + [view setBoundsOrigin:view.frame.origin]; + } } // setup opengl settings