Add glfwSetWindowAttrib

This function allows updating the GLFW_DECORATED, GLFW_RESIZABLE,
GLFW_FLOATING and GLFW_AUTO_ICONIFY attributes for existing windows.

Fixes #537.
This commit is contained in:
Camilla Löwy
2016-09-30 01:52:22 +02:00
parent d92bb41e25
commit 9e56099edd
12 changed files with 354 additions and 54 deletions

View File

@@ -45,7 +45,6 @@ static void usage(void)
printf(" -a create windows for all monitors\n");
printf(" -f create full screen window(s)\n");
printf(" -h show this help\n");
printf(" -n no automatic iconification of full screen windows\n");
}
static void error_callback(int error, const char* description)
@@ -76,6 +75,18 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GLFW_TRUE);
break;
case GLFW_KEY_A:
glfwSetWindowAttrib(window, GLFW_AUTO_ICONIFY, !glfwGetWindowAttrib(window, GLFW_AUTO_ICONIFY));
break;
case GLFW_KEY_B:
glfwSetWindowAttrib(window, GLFW_RESIZABLE, !glfwGetWindowAttrib(window, GLFW_RESIZABLE));
break;
case GLFW_KEY_D:
glfwSetWindowAttrib(window, GLFW_DECORATED, !glfwGetWindowAttrib(window, GLFW_DECORATED));
break;
case GLFW_KEY_F:
glfwSetWindowAttrib(window, GLFW_FLOATING, !glfwGetWindowAttrib(window, GLFW_FLOATING));
break;
case GLFW_KEY_F11:
case GLFW_KEY_ENTER:
{
@@ -143,24 +154,11 @@ static void window_maximize_callback(GLFWwindow* window, int maximized)
static void window_refresh_callback(GLFWwindow* window)
{
int width, height;
printf("%0.2f Window refresh\n", glfwGetTime());
glfwGetFramebufferSize(window, &width, &height);
glfwMakeContextCurrent(window);
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, width, height);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glScissor(0, 0, 640, 480);
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
}
@@ -203,7 +201,7 @@ static GLFWwindow* create_window(GLFWmonitor* monitor)
int main(int argc, char** argv)
{
int ch, i, window_count;
int auto_iconify = GLFW_TRUE, fullscreen = GLFW_FALSE, all_monitors = GLFW_FALSE;
int fullscreen = GLFW_FALSE, all_monitors = GLFW_FALSE;
GLFWwindow** windows;
while ((ch = getopt(argc, argv, "afhn")) != -1)
@@ -222,10 +220,6 @@ int main(int argc, char** argv)
fullscreen = GLFW_TRUE;
break;
case 'n':
auto_iconify = GLFW_FALSE;
break;
default:
usage();
exit(EXIT_FAILURE);
@@ -237,8 +231,6 @@ int main(int argc, char** argv)
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_AUTO_ICONIFY, auto_iconify);
if (fullscreen && all_monitors)
{
int monitor_count;