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) ...@@ -69,7 +69,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
Width(param.WindowSize.Width), Height(param.WindowSize.Height), Width(param.WindowSize.Width), Height(param.WindowSize.Height),
Close(false), WindowHasFocus(false), WindowMinimized(false), Close(false), WindowHasFocus(false), WindowMinimized(false),
UseXVidMode(false), UseXRandR(false), UseGLXWindow(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false),
AutorepeatSupport(0) ExternalWindow(false), AutorepeatSupport(0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CIrrDeviceLinux"); setDebugName("CIrrDeviceLinux");
...@@ -161,9 +161,13 @@ CIrrDeviceLinux::~CIrrDeviceLinux() ...@@ -161,9 +161,13 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
if (SoftwareImage) if (SoftwareImage)
XDestroyImage(SoftwareImage); XDestroyImage(SoftwareImage);
if (!ExternalWindow)
{
XDestroyWindow(display,window); XDestroyWindow(display,window);
XCloseDisplay(display); XCloseDisplay(display);
} }
}
if (visual) if (visual)
XFree(visual); XFree(visual);
...@@ -540,6 +544,8 @@ bool CIrrDeviceLinux::createWindow() ...@@ -540,6 +544,8 @@ bool CIrrDeviceLinux::createWindow()
ButtonPressMask | KeyPressMask | ButtonPressMask | KeyPressMask |
ButtonReleaseMask | KeyReleaseMask; ButtonReleaseMask | KeyReleaseMask;
if (!CreationParams.WindowId)
{
// create Window, either for Fullscreen or windowed mode // create Window, either for Fullscreen or windowed mode
if (CreationParams.Fullscreen) if (CreationParams.Fullscreen)
{ {
...@@ -565,24 +571,13 @@ bool CIrrDeviceLinux::createWindow() ...@@ -565,24 +571,13 @@ bool CIrrDeviceLinux::createWindow()
attributes.event_mask |= ExposureMask; attributes.event_mask |= ExposureMask;
attributes.event_mask |= FocusChangeMask; attributes.event_mask |= FocusChangeMask;
if(!CreationParams.WindowId)
{
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,
(Window)CreationParams.WindowId,
0, 0, Width, Height, 0, visual->depth,
InputOutput, visual->visual,
CWBorderPixel | CWColormap | CWEventMask,
&attributes);
}
CreationParams.WindowId = (void*)window; CreationParams.WindowId = (void*)window;
Atom wmDelete; Atom wmDelete;
...@@ -590,6 +585,19 @@ bool CIrrDeviceLinux::createWindow() ...@@ -590,6 +585,19 @@ bool CIrrDeviceLinux::createWindow()
XSetWMProtocols(display, window, &wmDelete, 1); XSetWMProtocols(display, window, &wmDelete, 1);
XMapRaised(display, window); 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; WindowMinimized=false;
// Currently broken in X, see Bug ID 2795321 // Currently broken in X, see Bug ID 2795321
// XkbSetDetectableAutoRepeat(display, True, &AutorepeatSupport); // XkbSetDetectableAutoRepeat(display, True, &AutorepeatSupport);
......
...@@ -340,6 +340,7 @@ namespace irr ...@@ -340,6 +340,7 @@ namespace irr
bool UseXVidMode; bool UseXVidMode;
bool UseXRandR; bool UseXRandR;
bool UseGLXWindow; bool UseGLXWindow;
bool ExternalWindow;
int AutorepeatSupport; int AutorepeatSupport;
struct SKeyMap 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