GLFW: size, position & monitorsGLFW 3.3

glfwGetMonitorWorkarea

Reads the part of a monitor that windows may use: the screen minus the taskbar, dock or menu bar.

Signature

void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);

How it works

The work area is the rectangle a maximized window fills. Center windows inside it, not inside the full screen, or the window ends up partly under the taskbar.

All four values are in screen coordinates on the virtual desktop. xpos and ypos are not always 0: a taskbar on the left or top shifts them, and so does a second monitor.

Parameters

monitorGLFWmonitor*

The monitor, e.g. glfwGetPrimaryMonitor().

xposint*

Left edge of the work area, or NULL.

yposint*

Top edge of the work area, or NULL.

widthint*

Width of the work area, or NULL.

heightint*

Height of the work area, or NULL.

Errors

When the call is invalid it does nothing and sets an error, which glGetError returns:

GLFW_NOT_INITIALIZED
Called before glfwInit or after glfwTerminate.
GLFW_PLATFORM_ERROR
The operating system or window system reported a failure; the description says which.

Example

example.cpp
1int ax, ay, aw, ah;
2glfwGetMonitorWorkarea(glfwGetPrimaryMonitor(), &ax, &ay, &aw, &ah);
3// center of the usable area
4int cx = ax + aw / 2, cy = ay + ah / 2;
Official GLFW documentation