mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Moved X11 screen and root from window to library struct (for now).
This commit is contained in:
parent
48f5a7e763
commit
93046aecd0
@ -203,8 +203,6 @@ typedef struct _GLFWwindowX11
|
|||||||
// Platform specific window resources
|
// Platform specific window resources
|
||||||
Colormap colormap; // Window colormap
|
Colormap colormap; // Window colormap
|
||||||
Window window; // Window
|
Window window; // Window
|
||||||
Window root; // Root window for screen
|
|
||||||
int screen; // Screen ID
|
|
||||||
Atom wmDeleteWindow; // WM_DELETE_WINDOW atom
|
Atom wmDeleteWindow; // WM_DELETE_WINDOW atom
|
||||||
Atom wmPing; // _NET_WM_PING atom
|
Atom wmPing; // _NET_WM_PING atom
|
||||||
Atom wmState; // _NET_WM_STATE atom
|
Atom wmState; // _NET_WM_STATE atom
|
||||||
@ -230,6 +228,8 @@ typedef struct _GLFWwindowX11
|
|||||||
typedef struct _GLFWlibraryX11
|
typedef struct _GLFWlibraryX11
|
||||||
{
|
{
|
||||||
Display* display;
|
Display* display;
|
||||||
|
int screen;
|
||||||
|
Window root;
|
||||||
|
|
||||||
// Server-side GLX version
|
// Server-side GLX version
|
||||||
int glxMajor, glxMinor;
|
int glxMajor, glxMinor;
|
||||||
|
@ -67,7 +67,7 @@ int _glfwPlatformExtensionSupported(const char* extension)
|
|||||||
// Get list of GLX extensions
|
// Get list of GLX extensions
|
||||||
// Yuck
|
// Yuck
|
||||||
extensions = (const GLubyte*) glXQueryExtensionsString(_glfwLibrary.X11.display,
|
extensions = (const GLubyte*) glXQueryExtensionsString(_glfwLibrary.X11.display,
|
||||||
_glfwLibrary.window->X11.screen);
|
_glfwLibrary.X11.screen);
|
||||||
if (extensions != NULL)
|
if (extensions != NULL)
|
||||||
{
|
{
|
||||||
if (_glfwStringInExtensionString(extension, extensions))
|
if (_glfwStringInExtensionString(extension, extensions))
|
||||||
|
@ -90,6 +90,12 @@ static GLboolean initDisplay(void)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As the API currently doesn't understand multiple display devices, we hardcode
|
||||||
|
// this choice and hope for the best
|
||||||
|
_glfwLibrary.X11.screen = DefaultScreen(_glfwLibrary.X11.display);
|
||||||
|
_glfwLibrary.X11.root = RootWindow(_glfwLibrary.X11.display,
|
||||||
|
_glfwLibrary.X11.screen);
|
||||||
|
|
||||||
// Check for XF86VidMode extension
|
// Check for XF86VidMode extension
|
||||||
#ifdef _GLFW_HAS_XF86VIDMODE
|
#ifdef _GLFW_HAS_XF86VIDMODE
|
||||||
_glfwLibrary.X11.XF86VidMode.available =
|
_glfwLibrary.X11.XF86VidMode.available =
|
||||||
@ -139,7 +145,6 @@ static GLboolean initDisplay(void)
|
|||||||
|
|
||||||
static void terminateDisplay(void)
|
static void terminateDisplay(void)
|
||||||
{
|
{
|
||||||
// Open display
|
|
||||||
if (_glfwLibrary.X11.display)
|
if (_glfwLibrary.X11.display)
|
||||||
{
|
{
|
||||||
XCloseDisplay(_glfwLibrary.X11.display);
|
XCloseDisplay(_glfwLibrary.X11.display);
|
||||||
|
@ -144,7 +144,7 @@ static GLboolean checkForEWMH(_GLFWwindow* window)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
|
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
|
||||||
if (getWindowProperty(window->X11.root,
|
if (getWindowProperty(_glfwLibrary.X11.root,
|
||||||
supportingWmCheck,
|
supportingWmCheck,
|
||||||
XA_WINDOW,
|
XA_WINDOW,
|
||||||
(unsigned char**) &windowFromRoot) != 1)
|
(unsigned char**) &windowFromRoot) != 1)
|
||||||
@ -182,7 +182,7 @@ static GLboolean checkForEWMH(_GLFWwindow* window)
|
|||||||
unsigned long atomCount;
|
unsigned long atomCount;
|
||||||
|
|
||||||
// Now we need to check the _NET_SUPPORTED property of the root window
|
// Now we need to check the _NET_SUPPORTED property of the root window
|
||||||
atomCount = getWindowProperty(window->X11.root,
|
atomCount = getWindowProperty(_glfwLibrary.X11.root,
|
||||||
wmSupported,
|
wmSupported,
|
||||||
XA_ATOM,
|
XA_ATOM,
|
||||||
(unsigned char**) &supportedAtoms);
|
(unsigned char**) &supportedAtoms);
|
||||||
@ -429,7 +429,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
|||||||
if (window->GLX.has_GLX_SGIX_fbconfig)
|
if (window->GLX.has_GLX_SGIX_fbconfig)
|
||||||
{
|
{
|
||||||
fbconfigs = window->GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
fbconfigs = window->GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
||||||
window->X11.screen,
|
_glfwLibrary.X11.screen,
|
||||||
NULL,
|
NULL,
|
||||||
&count);
|
&count);
|
||||||
if (!count)
|
if (!count)
|
||||||
@ -441,7 +441,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fbconfigs = glXGetFBConfigs(_glfwLibrary.X11.display, window->X11.screen, &count);
|
fbconfigs = glXGetFBConfigs(_glfwLibrary.X11.display, _glfwLibrary.X11.screen, &count);
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "No GLXFBConfigs returned\n");
|
fprintf(stderr, "No GLXFBConfigs returned\n");
|
||||||
@ -534,14 +534,14 @@ static int createContext(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, G
|
|||||||
if (window->GLX.has_GLX_SGIX_fbconfig)
|
if (window->GLX.has_GLX_SGIX_fbconfig)
|
||||||
{
|
{
|
||||||
fbconfig = window->GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
fbconfig = window->GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
||||||
window->X11.screen,
|
_glfwLibrary.X11.screen,
|
||||||
attribs,
|
attribs,
|
||||||
&dummy);
|
&dummy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fbconfig = glXChooseFBConfig(_glfwLibrary.X11.display,
|
fbconfig = glXChooseFBConfig(_glfwLibrary.X11.display,
|
||||||
window->X11.screen,
|
_glfwLibrary.X11.screen,
|
||||||
attribs,
|
attribs,
|
||||||
&dummy);
|
&dummy);
|
||||||
}
|
}
|
||||||
@ -732,7 +732,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
// Create one based on the visual used by the current context
|
// Create one based on the visual used by the current context
|
||||||
|
|
||||||
window->X11.colormap = XCreateColormap(_glfwLibrary.X11.display,
|
window->X11.colormap = XCreateColormap(_glfwLibrary.X11.display,
|
||||||
window->X11.root,
|
_glfwLibrary.X11.root,
|
||||||
window->GLX.visual->visual,
|
window->GLX.visual->visual,
|
||||||
AllocNone);
|
AllocNone);
|
||||||
|
|
||||||
@ -751,13 +751,13 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
// The /only/ reason we are setting the background pixel here is
|
// The /only/ reason we are setting the background pixel here is
|
||||||
// that otherwise our window wont get any decorations on systems
|
// that otherwise our window wont get any decorations on systems
|
||||||
// using Compiz on Intel hardware
|
// using Compiz on Intel hardware
|
||||||
wa.background_pixel = BlackPixel(_glfwLibrary.X11.display, window->X11.screen);
|
wa.background_pixel = BlackPixel(_glfwLibrary.X11.display, _glfwLibrary.X11.screen);
|
||||||
wamask |= CWBackPixel;
|
wamask |= CWBackPixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->X11.window = XCreateWindow(
|
window->X11.window = XCreateWindow(
|
||||||
_glfwLibrary.X11.display,
|
_glfwLibrary.X11.display,
|
||||||
window->X11.root,
|
_glfwLibrary.X11.root,
|
||||||
0, 0, // Upper left corner of this window on root
|
0, 0, // Upper left corner of this window on root
|
||||||
window->width, window->height,
|
window->width, window->height,
|
||||||
0, // Border width
|
0, // Border width
|
||||||
@ -898,7 +898,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
|
|||||||
_glfwLibrary.X11.saver.changed = GL_TRUE;
|
_glfwLibrary.X11.saver.changed = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwSetVideoMode(window->X11.screen,
|
_glfwSetVideoMode(_glfwLibrary.X11.screen,
|
||||||
&window->width, &window->height,
|
&window->width, &window->height,
|
||||||
&window->refreshRate);
|
&window->refreshRate);
|
||||||
|
|
||||||
@ -923,7 +923,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
|
|||||||
event.xclient.data.l[1] = 0; // We don't really know the timestamp
|
event.xclient.data.l[1] = 0; // We don't really know the timestamp
|
||||||
|
|
||||||
XSendEvent(_glfwLibrary.X11.display,
|
XSendEvent(_glfwLibrary.X11.display,
|
||||||
window->X11.root,
|
_glfwLibrary.X11.root,
|
||||||
False,
|
False,
|
||||||
SubstructureNotifyMask | SubstructureRedirectMask,
|
SubstructureNotifyMask | SubstructureRedirectMask,
|
||||||
&event);
|
&event);
|
||||||
@ -946,7 +946,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
|
|||||||
event.xclient.data.l[3] = 1; // Sender is a normal application
|
event.xclient.data.l[3] = 1; // Sender is a normal application
|
||||||
|
|
||||||
XSendEvent(_glfwLibrary.X11.display,
|
XSendEvent(_glfwLibrary.X11.display,
|
||||||
window->X11.root,
|
_glfwLibrary.X11.root,
|
||||||
False,
|
False,
|
||||||
SubstructureNotifyMask | SubstructureRedirectMask,
|
SubstructureNotifyMask | SubstructureRedirectMask,
|
||||||
&event);
|
&event);
|
||||||
@ -981,7 +981,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
|
|||||||
|
|
||||||
static void leaveFullscreenMode(_GLFWwindow* window)
|
static void leaveFullscreenMode(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
_glfwRestoreVideoMode(window->X11.screen);
|
_glfwRestoreVideoMode(_glfwLibrary.X11.screen);
|
||||||
|
|
||||||
// Did we change the screen saver setting?
|
// Did we change the screen saver setting?
|
||||||
if (_glfwLibrary.X11.saver.changed)
|
if (_glfwLibrary.X11.saver.changed)
|
||||||
@ -1016,7 +1016,7 @@ static void leaveFullscreenMode(_GLFWwindow* window)
|
|||||||
event.xclient.data.l[3] = 1; // Sender is a normal application
|
event.xclient.data.l[3] = 1; // Sender is a normal application
|
||||||
|
|
||||||
XSendEvent(_glfwLibrary.X11.display,
|
XSendEvent(_glfwLibrary.X11.display,
|
||||||
window->X11.root,
|
_glfwLibrary.X11.root,
|
||||||
False,
|
False,
|
||||||
SubstructureNotifyMask | SubstructureRedirectMask,
|
SubstructureNotifyMask | SubstructureRedirectMask,
|
||||||
&event);
|
&event);
|
||||||
@ -1216,7 +1216,7 @@ static GLboolean processSingleEvent(void)
|
|||||||
// The window manager is pinging us to make sure we are still
|
// The window manager is pinging us to make sure we are still
|
||||||
// responding to events
|
// responding to events
|
||||||
|
|
||||||
event.xclient.window = window->X11.root;
|
event.xclient.window = _glfwLibrary.X11.root;
|
||||||
XSendEvent(_glfwLibrary.X11.display,
|
XSendEvent(_glfwLibrary.X11.display,
|
||||||
event.xclient.window,
|
event.xclient.window,
|
||||||
False,
|
False,
|
||||||
@ -1324,13 +1324,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
window->refreshRate = wndconfig->refreshRate;
|
window->refreshRate = wndconfig->refreshRate;
|
||||||
window->windowNoResize = wndconfig->windowNoResize;
|
window->windowNoResize = wndconfig->windowNoResize;
|
||||||
|
|
||||||
// As the 2.x API doesn't understand multiple display devices, we hardcode
|
|
||||||
// this choice and hope for the best
|
|
||||||
window->X11.screen = DefaultScreen(_glfwLibrary.X11.display);
|
|
||||||
window->X11.root = RootWindow(_glfwLibrary.X11.display, window->X11.screen);
|
|
||||||
|
|
||||||
// Create the invisible cursor for hidden cursor mode
|
// Create the invisible cursor for hidden cursor mode
|
||||||
window->X11.cursor = createNULLCursor(_glfwLibrary.X11.display, window->X11.root);
|
window->X11.cursor = createNULLCursor(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
||||||
|
|
||||||
initGLXExtensions(window);
|
initGLXExtensions(window);
|
||||||
|
|
||||||
@ -1489,7 +1484,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
if (window->mode == GLFW_FULLSCREEN)
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
{
|
{
|
||||||
// Get the closest matching video mode for the specified window size
|
// Get the closest matching video mode for the specified window size
|
||||||
mode = _glfwGetClosestVideoMode(window->X11.screen, &width, &height, &rate);
|
mode = _glfwGetClosestVideoMode(_glfwLibrary.X11.screen, &width, &height, &rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->windowNoResize)
|
if (window->windowNoResize)
|
||||||
@ -1516,7 +1511,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
if (window->mode == GLFW_FULLSCREEN)
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
{
|
{
|
||||||
// Change video mode, keeping current refresh rate
|
// Change video mode, keeping current refresh rate
|
||||||
_glfwSetVideoModeMODE(window->X11.screen, mode, window->refreshRate);
|
_glfwSetVideoModeMODE(_glfwLibrary.X11.screen, mode, window->refreshRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set window size (if not already changed)
|
// Set window size (if not already changed)
|
||||||
@ -1548,7 +1543,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XIconifyWindow(_glfwLibrary.X11.display, window->X11.window, window->X11.screen);
|
XIconifyWindow(_glfwLibrary.X11.display, window->X11.window, _glfwLibrary.X11.screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1615,14 +1610,14 @@ void _glfwPlatformRefreshWindowParams(void)
|
|||||||
if (window->GLX.has_GLX_SGIX_fbconfig)
|
if (window->GLX.has_GLX_SGIX_fbconfig)
|
||||||
{
|
{
|
||||||
fbconfig = window->GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
fbconfig = window->GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
||||||
window->X11.screen,
|
_glfwLibrary.X11.screen,
|
||||||
attribs,
|
attribs,
|
||||||
&dummy);
|
&dummy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fbconfig = glXChooseFBConfig(_glfwLibrary.X11.display,
|
fbconfig = glXChooseFBConfig(_glfwLibrary.X11.display,
|
||||||
window->X11.screen,
|
_glfwLibrary.X11.screen,
|
||||||
attribs,
|
attribs,
|
||||||
&dummy);
|
&dummy);
|
||||||
}
|
}
|
||||||
@ -1669,7 +1664,7 @@ void _glfwPlatformRefreshWindowParams(void)
|
|||||||
#if defined(_GLFW_HAS_XRANDR)
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
if (_glfwLibrary.X11.XRandR.available)
|
if (_glfwLibrary.X11.XRandR.available)
|
||||||
{
|
{
|
||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, window->X11.root);
|
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
||||||
window->refreshRate = XRRConfigCurrentRate(sc);
|
window->refreshRate = XRRConfigCurrentRate(sc);
|
||||||
XRRFreeScreenConfigInfo(sc);
|
XRRFreeScreenConfigInfo(sc);
|
||||||
}
|
}
|
||||||
@ -1677,7 +1672,7 @@ void _glfwPlatformRefreshWindowParams(void)
|
|||||||
if (_glfwLibrary.X11.XF86VidMode.available)
|
if (_glfwLibrary.X11.XF86VidMode.available)
|
||||||
{
|
{
|
||||||
// Use the XF86VidMode extension to get current video mode
|
// Use the XF86VidMode extension to get current video mode
|
||||||
XF86VidModeGetModeLine(_glfwLibrary.X11.display, window->X11.screen,
|
XF86VidModeGetModeLine(_glfwLibrary.X11.display, _glfwLibrary.X11.screen,
|
||||||
&dotclock, &modeline);
|
&dotclock, &modeline);
|
||||||
pixels_per_second = 1000.0f * (float) dotclock;
|
pixels_per_second = 1000.0f * (float) dotclock;
|
||||||
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;
|
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;
|
||||||
|
Loading…
Reference in New Issue
Block a user