diff --git a/.gitignore b/.gitignore index 96d5ba3f6..7082f1fef 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,4 @@ tests/title tests/triangle-vulkan tests/windows +/[Bb]uild*/ \ No newline at end of file diff --git a/examples/boing.c b/examples/boing.c index ca389086a..f0d83575e 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -54,6 +54,7 @@ void reshape( GLFWwindow* window, int w, int h ); void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods ); void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ); void cursor_position_callback( GLFWwindow* window, double x, double y ); +void window_maximize_callback( GLFWwindow* window, int maximized ); void DrawBoingBall( void ); void BounceBall( double dt ); void DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi ); @@ -297,6 +298,25 @@ void cursor_position_callback( GLFWwindow* window, double x, double y ) set_ball_pos(cursor_x, cursor_y); } +void window_maximize_callback( GLFWwindow* window, int maximize ) +{ + if (maximize) { + GLFWmonitor* monitor = glfwGetPrimaryMonitor(); + if (monitor == NULL) + return; + + const GLFWvidmode* mode = glfwGetVideoMode(monitor); + if (mode == NULL) + return; + + glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, + mode->height, mode->refreshRate); + } else { + glfwSetWindowMonitor(window, NULL, windowed_xpos, + windowed_ypos, windowed_width, windowed_height, 0); + } +} + /***************************************************************************** * Draw the Boing ball. * @@ -628,6 +648,8 @@ int main( void ) if( !glfwInit() ) exit( EXIT_FAILURE ); + glfwWindowHint(GLFW_AUTO_ICONIFY, GLFW_FALSE); + window = glfwCreateWindow( 400, 400, "Boing (classic Amiga demo)", NULL, NULL ); if (!window) { @@ -641,6 +663,7 @@ int main( void ) glfwSetKeyCallback(window, key_callback); glfwSetMouseButtonCallback(window, mouse_button_callback); glfwSetCursorPosCallback(window, cursor_position_callback); + glfwSetWindowMaximizeCallback(window, window_maximize_callback); glfwMakeContextCurrent(window); gladLoadGL(glfwGetProcAddress); diff --git a/src/win32_window.c b/src/win32_window.c index b8d0dc3d5..5d8f377ac 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1735,6 +1735,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE); style &= ~WS_OVERLAPPEDWINDOW; style |= getWindowStyle(window); + style |= WS_POPUPWINDOW; SetWindowLongW(window->win32.handle, GWL_STYLE, style); flags |= SWP_FRAMECHANGED; } @@ -1742,7 +1743,13 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, acquireMonitor(window); GetMonitorInfo(window->monitor->win32.handle, &mi); - SetWindowPos(window->win32.handle, HWND_TOPMOST, + + HWND z_mode = HWND_TOP; + if (window->floating) { + z_mode = HWND_TOPMOST; + } + + SetWindowPos(window->win32.handle, z_mode, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left,