Commit ebf3a273 authored by hybrid's avatar hybrid

Support externally created windows under Linux. Patch submitted by cyberwan.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1231 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0672eea6
...@@ -42,6 +42,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType, ...@@ -42,6 +42,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType,
u32 bits, bool fullscreen, u32 bits, bool fullscreen,
bool sbuffer, bool vsync, bool antiAlias, bool sbuffer, bool vsync, bool antiAlias,
IEventReceiver* receiver, IEventReceiver* receiver,
Window externalWindow,
const char* version) const char* version)
: CIrrDeviceStub(version, receiver), : CIrrDeviceStub(version, receiver),
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
...@@ -79,7 +80,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType, ...@@ -79,7 +80,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(video::E_DRIVER_TYPE driverType,
if (driverType != video::EDT_NULL) if (driverType != video::EDT_NULL)
{ {
// create the window, only if we do not use the null device // create the window, only if we do not use the null device
if (!createWindow(windowSize, bits)) if (!createWindow(windowSize, bits, externalWindow))
return; return;
} }
...@@ -160,7 +161,7 @@ int IrrPrintXError(Display *display, XErrorEvent *event) ...@@ -160,7 +161,7 @@ int IrrPrintXError(Display *display, XErrorEvent *event)
bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize, bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
u32 bits) u32 bits, Window externalWindow)
{ {
Width = windowSize.Width; Width = windowSize.Width;
Height = windowSize.Height; Height = windowSize.Height;
...@@ -508,12 +509,24 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize, ...@@ -508,12 +509,24 @@ bool CIrrDeviceLinux::createWindow(const core::dimension2d<s32>& windowSize,
attributes.event_mask |= ExposureMask; attributes.event_mask |= ExposureMask;
attributes.event_mask |= FocusChangeMask; attributes.event_mask |= FocusChangeMask;
if(!externalWindow)
{
window = XCreateWindow(display, window = XCreateWindow(display,
RootWindow(display, visual->screen), RootWindow(display, visual->screen),
0, 0, Width, Height, 0, visual->depth, 0, 0, Width, Height, 0, visual->depth,
InputOutput, visual->visual, InputOutput, visual->visual,
CWBorderPixel | CWColormap | CWEventMask, CWBorderPixel | CWColormap | CWEventMask,
&attributes); &attributes);
}
else
{
window = XCreateWindow(display,
externalWindow,
0, 0, Width, Height, 0, visual->depth,
InputOutput, visual->visual,
CWBorderPixel | CWColormap | CWEventMask,
&attributes);
}
Atom wmDelete; Atom wmDelete;
wmDelete = XInternAtom(display, wmDeleteWindow, True); wmDelete = XInternAtom(display, wmDeleteWindow, True);
...@@ -1321,6 +1334,7 @@ IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationP ...@@ -1321,6 +1334,7 @@ IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationP
param.Vsync, param.Vsync,
param.AntiAlias, param.AntiAlias,
param.EventReceiver, param.EventReceiver,
(Window)param.WindowId,
param.SDK_version_do_not_use); param.SDK_version_do_not_use);
if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL) if (dev && !dev->getVideoDriver() && param.DriverType != video::EDT_NULL)
......
...@@ -50,7 +50,7 @@ namespace irr ...@@ -50,7 +50,7 @@ namespace irr
CIrrDeviceLinux(video::E_DRIVER_TYPE deviceType, CIrrDeviceLinux(video::E_DRIVER_TYPE deviceType,
const core::dimension2d<s32>& windowSize, u32 bits, const core::dimension2d<s32>& windowSize, u32 bits,
bool fullscreen, bool stencilbuffer, bool vsync, bool antiAlias, IEventReceiver* receiver, bool fullscreen, bool stencilbuffer, bool vsync, bool antiAlias, IEventReceiver* receiver,
const char* version); Window window, const char* version);
//! destructor //! destructor
virtual ~CIrrDeviceLinux(); virtual ~CIrrDeviceLinux();
...@@ -90,7 +90,8 @@ namespace irr ...@@ -90,7 +90,8 @@ namespace irr
void createDriver(const core::dimension2d<s32>& windowSize, void createDriver(const core::dimension2d<s32>& windowSize,
bool vsync); bool vsync);
bool createWindow(const core::dimension2d<s32>& windowSize, u32 bits); bool createWindow(const core::dimension2d<s32>& windowSize, u32 bits,
Window externalWindow);
void createKeyMap(); void createKeyMap();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment