# Undecorated desktop docking with GLFW\_LEFT\_SUPER

**URL:** <https://discourse.glfw.org/t/undecorated-desktop-docking-with-glfw-left-super/1600>\
**Category:** support\
**Created:** [July 6, 2020, 8:29pm UTC](https://discourse.glfw.org/t/undecorated-desktop-docking-with-glfw-left-super/1600 "2020-07-06T20:29:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathiasgam](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mathiasgam/32/385_2.png) [@mathiasgam](https://discourse.glfw.org/u/mathiasgam)\
**Post date:** [July 6, 2020, 8:29pm UTC](https://discourse.glfw.org/t/undecorated-desktop-docking-with-glfw-left-super/1600/1 "2020-07-06T20:29:10Z")

</div>

Hi all

When using a decorated window in Windows 10, the winkey (GLFW\_LEFT\_SUPER) would usually dock your window to the desktop. eg. winkey+left will dock your window to the left and prompt the user to select what window to put on the right.

Is there a way to replicate this behaviour with an undecorated window with glfw? I can’t seem to find anything in the documentation.

I guess the docking itself can be done be checking the position and size of the window related to the monitor, but I don’t have any clue on how the prompt the user for a window of an external program.

- Mathias

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 7, 2020, 9:07am UTC](https://discourse.glfw.org/t/undecorated-desktop-docking-with-glfw-left-super/1600/2 "2020-07-07T09:07:13Z")

</div>

Windows Snap is an OS feature, and it requires a window with a `WS_SIZEBOX` style, which is the same as `WS_THICKFRAME` - i.e. you get a thick border with resize controls.

The prompt for which Window to dock is also an OS feature, and it can be turned off in the Multi-tasking control panel by disabling _When I snap a window, show what I can snap next to it_.

Since these are OS features, GLFW doesn’t handle them itself.

You could emulate snap movement by using [glfwSetWindowSize()](https://www.glfw.org/docs/latest/group__window.html#ga371911f12c74c504dd8d47d832d095cb) when the user presses the `GLFW_LEFT_SUPER` and an arrow, however GLFW does not have functions for finding and setting other processes window positions.

EDIT: You’ll also need to use [glfwGetMonitorWorkarea](https://www.glfw.org/docs/latest/group__monitor.html#ga7387a3bdb64bfe8ebf2b9e54f5b6c9d0) to get the size of the work area to know what size to use for your window, and [glfwSetWindowPos](https://www.glfw.org/docs/latest/group__window.html#ga1abb6d690e8c88e0c8cd1751356dbca8) to set the position.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 7, 2020, 11:17am UTC](https://discourse.glfw.org/t/undecorated-desktop-docking-with-glfw-left-super/1600/3 "2020-07-07T11:17:19Z")

</div>

I have found a potentially interesting workaround using the [glfw Native Access API](https://www.glfw.org/docs/3.3/group__native.html).

Essentially we capture the `GLFW_KEY_LEFT_SUPER` and set the style to have a resize, then unset it when the key is released. This enables the Windows OS snap features to work.

```auto
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3native.h>

void KeyCallback( GLFWwindow* window, int key, int scancode, int action, int mods )
	{
        if( GLFW_KEY_LEFT_SUPER == key )
        {
            // switch to decorated
            HWND hwnd = glfwGetWin32Window(g_pSys->window);
            if( action == GLFW_PRESS )
            {
                LONG style = GetWindowLongA( hwnd, GWL_STYLE );
                style = style | WS_SIZEBOX;
                SetWindowLongA( hwnd, GWL_STYLE, style );
            }
            if( action == GLFW_RELEASE )
            {
                LONG style = GetWindowLongA( hwnd, GWL_STYLE );
                style = style & (~WS_SIZEBOX);
                SetWindowLongA( hwnd, GWL_STYLE, style );
            }
        }
}

```

This can also be done with `glfwSetWindowAttrib(g_pSys->window, GLFW_DECORATED, GLFW_TRUE );` but the result isn’t as good as the client area is resized to be smaller than the full monitor height. You could potentially trap the resize and reset the size to what the user probably intended with some extra work.

---

<div class="post-metadata">

**Author:** ![mathiasgam](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mathiasgam/32/385_2.png) [@mathiasgam](https://discourse.glfw.org/u/mathiasgam)\
**Post date:** [July 7, 2020, 12:58pm UTC](https://discourse.glfw.org/t/undecorated-desktop-docking-with-glfw-left-super/1600/4 "2020-07-07T12:58:18Z")

</div>

Thanks, this seams to work. is there a way to avoid the temporary border created from the sizebox?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 7, 2020, 1:56pm UTC](https://discourse.glfw.org/t/undecorated-desktop-docking-with-glfw-left-super/1600/5 "2020-07-07T13:56:54Z")

</div>

Apparently you can do this by processing the[WM\_NCCALCSIZE message](https://docs.microsoft.com/en-us/windows/win32/dwm/customframe#removing-the-standard-frame), but you’d need to modify GLFW or set a new windows proc to do this (and call the GLFW one).
