Parent window

This patch allow to create window as a child to another window. It helps
to create poput windows that are always on to of another.
This commit is contained in:
Kamil 2013-11-11 12:02:32 +01:00
parent d82095d7ea
commit ef463151b1
4 changed files with 18 additions and 11 deletions

View File

@ -1230,6 +1230,9 @@ GLFWAPI void glfwWindowHint(int target, int hint);
* windowed mode.
* @param[in] share The window whose context to share resources with, or `NULL`
* to not share resources.
* @param[in] make this window parent to new one, new window will be always on top another. Pass `NULL`
* to not make new window a child one.
* @return The handle of the created window, or `NULL` if an error occurred.
*
* @remarks **Windows:** Window creation will fail if the Microsoft GDI
@ -1258,7 +1261,7 @@ GLFWAPI void glfwWindowHint(int target, int hint);
*
* @ingroup window
*/
GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share, GLFWwindow* parent);
/*! @brief Destroys the specified window and its context.
*

View File

@ -453,7 +453,8 @@ void _glfwPlatformSetTime(double time);
*/
int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWfbconfig* fbconfig);
const _GLFWfbconfig* fbconfig,
_GLFWwindow* parent);
/*! @ingroup platform
*/

View File

@ -789,7 +789,8 @@ static ATOM registerWindowClass(void)
//
static int createWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWfbconfig* fbconfig)
const _GLFWfbconfig* fbconfig,
_GLFWwindow* parent )
{
int xpos, ypos, fullWidth, fullHeight;
WCHAR* wideTitle;
@ -842,7 +843,7 @@ static int createWindow(_GLFWwindow* window,
window->win32.dwStyle,
xpos, ypos,
fullWidth, fullHeight,
NULL, // No parent window
parent ? parent->win32.handle : NULL, // No parent window
NULL, // No window menu
GetModuleHandle(NULL),
window); // Pass object to WM_CREATE
@ -881,7 +882,8 @@ static void destroyWindow(_GLFWwindow* window)
int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWfbconfig* fbconfig)
const _GLFWfbconfig* fbconfig,
_GLFWwindow* parent)
{
int status;
@ -892,7 +894,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
return GL_FALSE;
}
if (!createWindow(window, wndconfig, fbconfig))
if (!createWindow(window, wndconfig, fbconfig, parent ))
return GL_FALSE;
status = _glfwAnalyzeContext(window, wndconfig, fbconfig);
@ -927,7 +929,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
destroyWindow(window);
// ...and then create them again, this time with better APIs
if (!createWindow(window, wndconfig, fbconfig))
if (!createWindow(window, wndconfig, fbconfig, parent))
return GL_FALSE;
}

View File

@ -143,12 +143,13 @@ void _glfwInputWindowCloseRequest(_GLFWwindow* window)
GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
const char* title,
GLFWmonitor* monitor,
GLFWwindow* share)
GLFWwindow* share,
GLFWwindow* parent )
{
_GLFWfbconfig fbconfig;
_GLFWwndconfig wndconfig;
_GLFWwindow* window;
_GLFWwindow* previous;
_GLFWwindow* window = NULL;
_GLFWwindow* previous = NULL;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
@ -222,7 +223,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
previous = (_GLFWwindow*) glfwGetCurrentContext();
// Open the actual window and create its context
if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig))
if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig, (_GLFWwindow*)parent ))
{
glfwDestroyWindow((GLFWwindow*) window);
glfwMakeContextCurrent((GLFWwindow*) previous);