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,8 +161,12 @@ CIrrDeviceLinux::~CIrrDeviceLinux() ...@@ -161,8 +161,12 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
if (SoftwareImage) if (SoftwareImage)
XDestroyImage(SoftwareImage); XDestroyImage(SoftwareImage);
XDestroyWindow(display,window);
XCloseDisplay(display); if (!ExternalWindow)
{
XDestroyWindow(display,window);
XCloseDisplay(display);
}
} }
if (visual) if (visual)
XFree(visual); XFree(visual);
...@@ -322,7 +326,7 @@ bool CIrrDeviceLinux::createWindow() ...@@ -322,7 +326,7 @@ bool CIrrDeviceLinux::createWindow()
GLX_DEPTH_SIZE, CreationParams.ZBufferBits, GLX_DEPTH_SIZE, CreationParams.ZBufferBits,
GLX_DOUBLEBUFFER, CreationParams.Doublebuffer?True:False, GLX_DOUBLEBUFFER, CreationParams.Doublebuffer?True:False,
GLX_STENCIL_SIZE, CreationParams.Stencilbuffer?1:0, GLX_STENCIL_SIZE, CreationParams.Stencilbuffer?1:0,
#ifdef GLX_ARB_multisample #ifdef GLX_ARB_multisample
GLX_SAMPLE_BUFFERS_ARB, 1, GLX_SAMPLE_BUFFERS_ARB, 1,
GLX_SAMPLES_ARB, CreationParams.AntiAlias, GLX_SAMPLES_ARB, CreationParams.AntiAlias,
#elif defined(GLX_SAMPLE_BUFFERS) #elif defined(GLX_SAMPLE_BUFFERS)
...@@ -539,57 +543,61 @@ bool CIrrDeviceLinux::createWindow() ...@@ -539,57 +543,61 @@ bool CIrrDeviceLinux::createWindow()
attributes.event_mask |= PointerMotionMask | attributes.event_mask |= PointerMotionMask |
ButtonPressMask | KeyPressMask | ButtonPressMask | KeyPressMask |
ButtonReleaseMask | KeyReleaseMask; ButtonReleaseMask | KeyReleaseMask;
// create Window, either for Fullscreen or windowed mode if (!CreationParams.WindowId)
if (CreationParams.Fullscreen)
{ {
attributes.override_redirect = True; // create Window, either for Fullscreen or windowed mode
if (CreationParams.Fullscreen)
window = XCreateWindow(display,
RootWindow(display, visual->screen),
0, 0, Width, Height, 0, visual->depth,
InputOutput, visual->visual,
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
&attributes);
CreationParams.WindowId = (void*)window;
XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0);
XMapRaised(display, window);
XGrabKeyboard(display, window, True, GrabModeAsync,
GrabModeAsync, CurrentTime);
XGrabPointer(display, window, True, ButtonPressMask,
GrabModeAsync, GrabModeAsync, window, None, CurrentTime);
}
else
{ // we want windowed mode
attributes.event_mask |= ExposureMask;
attributes.event_mask |= FocusChangeMask;
if(!CreationParams.WindowId)
{ {
attributes.override_redirect = True;
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 | CWOverrideRedirect,
&attributes); &attributes);
CreationParams.WindowId = (void*)window;
XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0);
XMapRaised(display, window);
XGrabKeyboard(display, window, True, GrabModeAsync,
GrabModeAsync, CurrentTime);
XGrabPointer(display, window, True, ButtonPressMask,
GrabModeAsync, GrabModeAsync, window, None, CurrentTime);
} }
else else
{ { // we want windowed mode
attributes.event_mask |= ExposureMask;
attributes.event_mask |= FocusChangeMask;
window = XCreateWindow(display, window = XCreateWindow(display,
(Window)CreationParams.WindowId, 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);
}
CreationParams.WindowId = (void*)window; CreationParams.WindowId = (void*)window;
Atom wmDelete; Atom wmDelete;
wmDelete = XInternAtom(display, wmDeleteWindow, True); wmDelete = XInternAtom(display, wmDeleteWindow, True);
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