Add GLFW_FOCUS_ON_SHOW window hint and attribute

This adds a window hint and attribute for controlling whether
glfwShowWindow gives the specified window input focus in addition to
making it visible.

Fixes #1189.
Closes #1275.
This commit is contained in:
Doug Binks
2018-05-29 14:51:36 +01:00
committed by Camilla Löwy
parent bf6551a3ca
commit 0be4f3f75a
7 changed files with 65 additions and 7 deletions

View File

@@ -56,9 +56,10 @@ static const struct
static void usage(void)
{
printf("Usage: windows [-h] [-b]\n");
printf("Usage: windows [-h] [-b] [-f] \n");
printf("Options:\n");
printf(" -b create decorated windows\n");
printf(" -f set focus on show off for all but first window\n");
printf(" -h show this help\n");
}
@@ -92,16 +93,20 @@ int main(int argc, char** argv)
{
int i, ch;
int decorated = GLFW_FALSE;
int focusOnShow = GLFW_TRUE;
int running = GLFW_TRUE;
GLFWwindow* windows[4];
while ((ch = getopt(argc, argv, "bh")) != -1)
while ((ch = getopt(argc, argv, "bfh")) != -1)
{
switch (ch)
{
case 'b':
decorated = GLFW_TRUE;
break;
case 'f':
focusOnShow = GLFW_FALSE;
break;
case 'h':
usage();
exit(EXIT_SUCCESS);
@@ -122,6 +127,8 @@ int main(int argc, char** argv)
for (i = 0; i < 4; i++)
{
int left, top, right, bottom;
if (i)
glfwWindowHint(GLFW_FOCUS_ON_SHOW, focusOnShow);
windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL);
if (!windows[i])