Merge branch 'fix-linux-win-resize'
This commit is contained in:
commit
4f5832827e
|
@ -25,7 +25,7 @@
|
||||||
// Show the current FPS
|
// Show the current FPS
|
||||||
void cInterfaceGLX::UpdateFPSDisplay(const char *text)
|
void cInterfaceGLX::UpdateFPSDisplay(const char *text)
|
||||||
{
|
{
|
||||||
XStoreName(GLWin.dpy, GLWin.win, text);
|
XStoreName(GLWin.evdpy, GLWin.win, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cInterfaceGLX::SwapInterval(int Interval)
|
void cInterfaceGLX::SwapInterval(int Interval)
|
||||||
|
@ -136,7 +136,7 @@ bool cInterfaceGLX::MakeCurrent()
|
||||||
#if defined(HAVE_WX) && (HAVE_WX)
|
#if defined(HAVE_WX) && (HAVE_WX)
|
||||||
Host_GetRenderWindowSize(GLWin.x, GLWin.y,
|
Host_GetRenderWindowSize(GLWin.x, GLWin.y,
|
||||||
(int&)GLWin.width, (int&)GLWin.height);
|
(int&)GLWin.width, (int&)GLWin.height);
|
||||||
XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y,
|
XMoveResizeWindow(GLWin.evdpy, GLWin.win, GLWin.x, GLWin.y,
|
||||||
GLWin.width, GLWin.height);
|
GLWin.width, GLWin.height);
|
||||||
#endif
|
#endif
|
||||||
return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx);
|
return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx);
|
||||||
|
|
|
@ -115,7 +115,10 @@ out:
|
||||||
#if HAVE_X11
|
#if HAVE_X11
|
||||||
if (selected_platform != EGL_PLATFORM_X11) {
|
if (selected_platform != EGL_PLATFORM_X11) {
|
||||||
if (GLWin.dpy)
|
if (GLWin.dpy)
|
||||||
|
{
|
||||||
XCloseDisplay(GLWin.dpy);
|
XCloseDisplay(GLWin.dpy);
|
||||||
|
XCloseDisplay(GLWin.evdpy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (selected_platform == EGL_PLATFORM_NONE)
|
if (selected_platform == EGL_PLATFORM_NONE)
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
#if USE_EGL
|
#if USE_EGL
|
||||||
bool cXInterface::ServerConnect(void)
|
bool cXInterface::ServerConnect(void)
|
||||||
{
|
{
|
||||||
GLWin.evdpy = XOpenDisplay(NULL);
|
GLWin.dpy = XOpenDisplay(NULL);
|
||||||
|
|
||||||
if (!GLWin.evdpy)
|
if (!GLWin.dpy)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -39,7 +39,7 @@ bool cXInterface::Initialize(void *config)
|
||||||
int num_visuals;
|
int num_visuals;
|
||||||
EGLint vid;
|
EGLint vid;
|
||||||
|
|
||||||
if (!GLWin.evdpy) {
|
if (!GLWin.dpy) {
|
||||||
printf("Error: couldn't open X display\n");
|
printf("Error: couldn't open X display\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ bool cXInterface::Initialize(void *config)
|
||||||
|
|
||||||
/* The X window visual must match the EGL config */
|
/* The X window visual must match the EGL config */
|
||||||
visTemplate.visualid = vid;
|
visTemplate.visualid = vid;
|
||||||
GLWin.vi = XGetVisualInfo(GLWin.evdpy, VisualIDMask, &visTemplate, &num_visuals);
|
GLWin.vi = XGetVisualInfo(GLWin.dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||||
if (!GLWin.vi) {
|
if (!GLWin.vi) {
|
||||||
printf("Error: couldn't get X visual\n");
|
printf("Error: couldn't get X visual\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -64,12 +64,12 @@ bool cXInterface::Initialize(void *config)
|
||||||
GLWin.width = _twidth;
|
GLWin.width = _twidth;
|
||||||
GLWin.height = _theight;
|
GLWin.height = _theight;
|
||||||
|
|
||||||
GLWin.dpy = XOpenDisplay(NULL);
|
GLWin.evdpy = XOpenDisplay(NULL);
|
||||||
GLWin.parent = GLWin.win;
|
GLWin.parent = GLWin.win;
|
||||||
GLWin.screen = DefaultScreen(GLWin.evdpy);
|
GLWin.screen = DefaultScreen(GLWin.dpy);
|
||||||
|
|
||||||
if (GLWin.parent == 0)
|
if (GLWin.parent == 0)
|
||||||
GLWin.parent = RootWindow(GLWin.evdpy, GLWin.screen);
|
GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen);
|
||||||
|
|
||||||
/* Set initial projection/viewing transformation.
|
/* Set initial projection/viewing transformation.
|
||||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||||
|
@ -82,7 +82,7 @@ bool cXInterface::Initialize(void *config)
|
||||||
|
|
||||||
void *cXInterface::EGLGetDisplay(void)
|
void *cXInterface::EGLGetDisplay(void)
|
||||||
{
|
{
|
||||||
return eglGetDisplay(GLWin.evdpy);
|
return eglGetDisplay(GLWin.dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cXInterface::CreateWindow(void)
|
void *cXInterface::CreateWindow(void)
|
||||||
|
@ -90,22 +90,22 @@ void *cXInterface::CreateWindow(void)
|
||||||
Atom wmProtocols[1];
|
Atom wmProtocols[1];
|
||||||
|
|
||||||
// Setup window attributes
|
// Setup window attributes
|
||||||
GLWin.attr.colormap = XCreateColormap(GLWin.dpy,
|
GLWin.attr.colormap = XCreateColormap(GLWin.evdpy,
|
||||||
GLWin.parent, GLWin.vi->visual, AllocNone);
|
GLWin.parent, GLWin.vi->visual, AllocNone);
|
||||||
GLWin.attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask;
|
GLWin.attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask;
|
||||||
GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen);
|
GLWin.attr.background_pixel = BlackPixel(GLWin.evdpy, GLWin.screen);
|
||||||
GLWin.attr.border_pixel = 0;
|
GLWin.attr.border_pixel = 0;
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
GLWin.win = XCreateWindow(GLWin.dpy, GLWin.parent,
|
GLWin.win = XCreateWindow(GLWin.evdpy, GLWin.parent,
|
||||||
GLWin.x, GLWin.y, GLWin.width, GLWin.height, 0,
|
GLWin.x, GLWin.y, GLWin.width, GLWin.height, 0,
|
||||||
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
|
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
|
||||||
CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr);
|
CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr);
|
||||||
wmProtocols[0] = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True);
|
wmProtocols[0] = XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", True);
|
||||||
XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 1);
|
XSetWMProtocols(GLWin.evdpy, GLWin.win, wmProtocols, 1);
|
||||||
XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL);
|
XSetStandardProperties(GLWin.evdpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL);
|
||||||
XMapRaised(GLWin.dpy, GLWin.win);
|
XMapRaised(GLWin.evdpy, GLWin.win);
|
||||||
XSync(GLWin.dpy, True);
|
XSync(GLWin.evdpy, True);
|
||||||
|
|
||||||
GLWin.xEventThread = std::thread(&cXInterface::XEventThread, this);
|
GLWin.xEventThread = std::thread(&cXInterface::XEventThread, this);
|
||||||
// Control window size and picture scaling
|
// Control window size and picture scaling
|
||||||
|
@ -116,16 +116,16 @@ void *cXInterface::CreateWindow(void)
|
||||||
|
|
||||||
void cXInterface::DestroyWindow(void)
|
void cXInterface::DestroyWindow(void)
|
||||||
{
|
{
|
||||||
XDestroyWindow(GLWin.dpy, GLWin.win);
|
XDestroyWindow(GLWin.evdpy, GLWin.win);
|
||||||
GLWin.win = 0;
|
GLWin.win = 0;
|
||||||
if (GLWin.xEventThread.joinable())
|
if (GLWin.xEventThread.joinable())
|
||||||
GLWin.xEventThread.join();
|
GLWin.xEventThread.join();
|
||||||
XFreeColormap(GLWin.dpy, GLWin.attr.colormap);
|
XFreeColormap(GLWin.evdpy, GLWin.attr.colormap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cXInterface::UpdateFPSDisplay(const char *text)
|
void cXInterface::UpdateFPSDisplay(const char *text)
|
||||||
{
|
{
|
||||||
XStoreName(GLWin.dpy, GLWin.win, text);
|
XStoreName(GLWin.evdpy, GLWin.win, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cXInterface::XEventThread()
|
void cXInterface::XEventThread()
|
||||||
|
@ -157,7 +157,7 @@ void cX11Window::CreateXWindow(void)
|
||||||
|
|
||||||
void cX11Window::DestroyXWindow(void)
|
void cX11Window::DestroyXWindow(void)
|
||||||
{
|
{
|
||||||
XUnmapWindow(GLWin.dpy, GLWin.win);
|
XUnmapWindow(GLWin.evdpy, GLWin.win);
|
||||||
GLWin.win = 0;
|
GLWin.win = 0;
|
||||||
if (GLWin.xEventThread.joinable())
|
if (GLWin.xEventThread.joinable())
|
||||||
GLWin.xEventThread.join();
|
GLWin.xEventThread.join();
|
||||||
|
@ -175,9 +175,9 @@ void cX11Window::XEventThread()
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
KeySym key;
|
KeySym key;
|
||||||
for (int num_events = XPending(GLWin.dpy); num_events > 0; num_events--)
|
for (int num_events = XPending(GLWin.evdpy); num_events > 0; num_events--)
|
||||||
{
|
{
|
||||||
XNextEvent(GLWin.dpy, &event);
|
XNextEvent(GLWin.evdpy, &event);
|
||||||
switch(event.type) {
|
switch(event.type) {
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
key = XLookupKeysym((XKeyEvent*)&event, 0);
|
key = XLookupKeysym((XKeyEvent*)&event, 0);
|
||||||
|
@ -305,17 +305,17 @@ void cX11Window::XEventThread()
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
Window winDummy;
|
Window winDummy;
|
||||||
unsigned int borderDummy, depthDummy;
|
unsigned int borderDummy, depthDummy;
|
||||||
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
|
XGetGeometry(GLWin.evdpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
|
||||||
&GLWin.width, &GLWin.height, &borderDummy, &depthDummy);
|
&GLWin.width, &GLWin.height, &borderDummy, &depthDummy);
|
||||||
GLInterface->SetBackBufferDimensions(GLWin.width, GLWin.height);
|
GLInterface->SetBackBufferDimensions(GLWin.width, GLWin.height);
|
||||||
break;
|
break;
|
||||||
case ClientMessage:
|
case ClientMessage:
|
||||||
if ((unsigned long) event.xclient.data.l[0] ==
|
if ((unsigned long) event.xclient.data.l[0] ==
|
||||||
XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False))
|
XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", False))
|
||||||
Host_Message(WM_USER_STOP);
|
Host_Message(WM_USER_STOP);
|
||||||
if ((unsigned long) event.xclient.data.l[0] ==
|
if ((unsigned long) event.xclient.data.l[0] ==
|
||||||
XInternAtom(GLWin.dpy, "RESIZE", False))
|
XInternAtom(GLWin.evdpy, "RESIZE", False))
|
||||||
XMoveResizeWindow(GLWin.dpy, GLWin.win,
|
XMoveResizeWindow(GLWin.evdpy, GLWin.win,
|
||||||
event.xclient.data.l[1], event.xclient.data.l[2],
|
event.xclient.data.l[1], event.xclient.data.l[2],
|
||||||
event.xclient.data.l[3], event.xclient.data.l[4]);
|
event.xclient.data.l[3], event.xclient.data.l[4]);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue