Added GLFW_FOCUSED window hint.

Fixes #101.
This commit is contained in:
Camilla Berglund
2014-06-20 13:39:06 +02:00
parent 4ae6eae58d
commit e9c7314d50
9 changed files with 56 additions and 2 deletions
+6
View File
@@ -1155,6 +1155,12 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
_glfwInputWindowVisibility(window, GL_TRUE);
}
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
{
[window->ns.object orderFront:nil];
_glfwInputWindowVisibility(window, GL_TRUE);
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
[window->ns.object orderOut:nil];
+6
View File
@@ -152,6 +152,7 @@ struct _GLFWwndconfig
GLboolean resizable;
GLboolean visible;
GLboolean decorated;
GLboolean focused;
GLboolean autoIconify;
GLboolean floating;
_GLFWmonitor* monitor;
@@ -326,6 +327,7 @@ struct _GLFWlibrary
int resizable;
int visible;
int decorated;
int focused;
int autoIconify;
int floating;
int samples;
@@ -562,6 +564,10 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window);
*/
void _glfwPlatformShowWindow(_GLFWwindow* window);
/*! @ingroup platform
*/
void _glfwPlatformUnhideWindow(_GLFWwindow* window);
/*! @copydoc glfwHideWindow
* @ingroup platform
*/
+5
View File
@@ -1183,6 +1183,11 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
SetFocus(window->win32.handle);
}
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_SHOW);
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_HIDE);
+15 -2
View File
@@ -163,6 +163,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
wndconfig.resizable = _glfw.hints.resizable ? GL_TRUE : GL_FALSE;
wndconfig.visible = _glfw.hints.visible ? GL_TRUE : GL_FALSE;
wndconfig.decorated = _glfw.hints.decorated ? GL_TRUE : GL_FALSE;
wndconfig.focused = _glfw.hints.focused ? GL_TRUE : GL_FALSE;
wndconfig.autoIconify = _glfw.hints.autoIconify ? GL_TRUE : GL_FALSE;
wndconfig.floating = _glfw.hints.floating ? GL_TRUE : GL_FALSE;
wndconfig.monitor = (_GLFWmonitor*) monitor;
@@ -190,6 +191,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
{
wndconfig.resizable = GL_TRUE;
wndconfig.visible = GL_TRUE;
wndconfig.focused = GL_TRUE;
// Set up desired video mode
window->videoMode.width = width;
@@ -200,6 +202,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->videoMode.refreshRate = _glfw.hints.refreshRate;
}
// Transfer window hints that are persistent settings and not
// just initial states
window->monitor = wndconfig.monitor;
window->resizable = wndconfig.resizable;
window->decorated = wndconfig.decorated;
@@ -257,7 +261,12 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
else
{
if (wndconfig.visible)
_glfwPlatformShowWindow(window);
{
if (wndconfig.focused)
_glfwPlatformShowWindow(window);
else
_glfwPlatformUnhideWindow(window);
}
}
return (GLFWwindow*) window;
@@ -274,10 +283,11 @@ void glfwDefaultWindowHints(void)
_glfw.hints.major = 1;
_glfw.hints.minor = 0;
// The default is a visible, resizable window with decorations
// The default is a focused, visible, resizable window with decorations
_glfw.hints.resizable = GL_TRUE;
_glfw.hints.visible = GL_TRUE;
_glfw.hints.decorated = GL_TRUE;
_glfw.hints.focused = GL_TRUE;
_glfw.hints.autoIconify = GL_TRUE;
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
@@ -345,6 +355,9 @@ GLFWAPI void glfwWindowHint(int target, int hint)
case GLFW_DECORATED:
_glfw.hints.decorated = hint;
break;
case GLFW_FOCUSED:
_glfw.hints.focused = hint;
break;
case GLFW_AUTO_ICONIFY:
_glfw.hints.autoIconify = hint;
break;
+6
View File
@@ -325,6 +325,12 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
wl_shell_surface_set_toplevel(window->wl.shell_surface);
}
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
{
// TODO
fprintf(stderr, "_glfwPlatformUnhideWindow not implemented yet\n");
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
wl_surface_attach(window->wl.surface, NULL, 0, 0);
+6
View File
@@ -1577,6 +1577,12 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
XFlush(_glfw.x11.display);
}
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
{
XMapWindow(_glfw.x11.display, window->x11.handle);
XFlush(_glfw.x11.display);
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
XUnmapWindow(_glfw.x11.display, window->x11.handle);