Commit 9f83642a authored by hybrid's avatar hybrid

Avoid window destruction if using external window. Patch by tp4me.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2461 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c46a6b24
......@@ -69,7 +69,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
Close(false), WindowHasFocus(false), WindowMinimized(false),
UseXVidMode(false), UseXRandR(false), UseGLXWindow(false),
AutorepeatSupport(0)
ExternalWindow(false), AutorepeatSupport(0)
{
#ifdef _DEBUG
setDebugName("CIrrDeviceLinux");
......@@ -161,9 +161,13 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
if (SoftwareImage)
XDestroyImage(SoftwareImage);
if (!ExternalWindow)
{
XDestroyWindow(display,window);
XCloseDisplay(display);
}
}
if (visual)
XFree(visual);
......@@ -540,6 +544,8 @@ bool CIrrDeviceLinux::createWindow()
ButtonPressMask | KeyPressMask |
ButtonReleaseMask | KeyReleaseMask;
if (!CreationParams.WindowId)
{
// create Window, either for Fullscreen or windowed mode
if (CreationParams.Fullscreen)
{
......@@ -565,24 +571,13 @@ bool CIrrDeviceLinux::createWindow()
attributes.event_mask |= ExposureMask;
attributes.event_mask |= FocusChangeMask;
if(!CreationParams.WindowId)
{
window = XCreateWindow(display,
RootWindow(display, visual->screen),
0, 0, Width, Height, 0, visual->depth,
InputOutput, visual->visual,
CWBorderPixel | CWColormap | CWEventMask,
&attributes);
}
else
{
window = XCreateWindow(display,
(Window)CreationParams.WindowId,
0, 0, Width, Height, 0, visual->depth,
InputOutput, visual->visual,
CWBorderPixel | CWColormap | CWEventMask,
&attributes);
}
CreationParams.WindowId = (void*)window;
Atom wmDelete;
......@@ -590,6 +585,19 @@ bool CIrrDeviceLinux::createWindow()
XSetWMProtocols(display, window, &wmDelete, 1);
XMapRaised(display, window);
}
}
else
{
// attach external window
window = (Window)CreationParams.WindowId;
XWindowAttributes wa;
XGetWindowAttributes(display, window, &wa);
CreationParams.WindowSize.Width = wa.width;
CreationParams.WindowSize.Height = wa.height;
CreationParams.Fullscreen = false;
ExternalWindow = true;
}
WindowMinimized=false;
// Currently broken in X, see Bug ID 2795321
// XkbSetDetectableAutoRepeat(display, True, &AutorepeatSupport);
......
......@@ -340,6 +340,7 @@ namespace irr
bool UseXVidMode;
bool UseXRandR;
bool UseGLXWindow;
bool ExternalWindow;
int AutorepeatSupport;
struct SKeyMap
......
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