Add glfwDragWindow

This is the initial implementation of glfwDragWindow, with support for
X11. The function glfwDragWindow requires only the target window to be
dragged. To make the function easier and more portable, the position of
the window and of the cursor are grabbed internally, so the end-user do
not need to pass them manually.

The example 'simple.c' was updated to include this functionality when
clicking on the client area of the window.
This commit is contained in:
Felipe Ferreira da Silva
2017-04-05 22:14:09 -03:00
committed by Camilla Löwy
parent 5b7281bd41
commit a4c76fbeed
11 changed files with 80 additions and 0 deletions
+7
View File
@@ -68,6 +68,12 @@ static void error_callback(int error, const char* description)
fprintf(stderr, "Error: %s\n", description);
}
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS)
glfwDragWindow(window);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
@@ -96,6 +102,7 @@ int main(void)
}
glfwSetKeyCallback(window, key_callback);
glfwSetMouseButtonCallback(window, mouse_button_callback);
glfwMakeContextCurrent(window);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);