@@ -68,8 +68,31 @@ static void GLFWKeyCallback(GLFWwindow* window,
6868}
6969
7070void GLFWwindowSizeCallback (GLFWwindow* window, int width, int height) {
71+ int left, top;
72+ glfwGetWindowPos (window, &left, &top);
7173 FlutterWindowMetricsEvent event = {};
7274 event.struct_size = sizeof (event);
75+ event.window_id = 0 ;
76+ event.screen_id = 0 ;
77+ event.left = left * g_pixelRatio;
78+ event.top = top * g_pixelRatio;
79+ event.width = width * g_pixelRatio;
80+ event.height = height * g_pixelRatio;
81+ event.pixel_ratio = g_pixelRatio;
82+ FlutterEngineSendWindowMetricsEvent (
83+ reinterpret_cast <FlutterEngine>(glfwGetWindowUserPointer (window)),
84+ &event);
85+ }
86+
87+ void GLFWwindowPosCallback (GLFWwindow* window, int left, int top) {
88+ int width, height;
89+ glfwGetWindowSize (window, &width, &height);
90+ FlutterWindowMetricsEvent event = {};
91+ event.struct_size = sizeof (event);
92+ event.window_id = 0 ;
93+ event.screen_id = 0 ;
94+ event.left = left * g_pixelRatio;
95+ event.top = top * g_pixelRatio;
7396 event.width = width * g_pixelRatio;
7497 event.height = height * g_pixelRatio;
7598 event.pixel_ratio = g_pixelRatio;
@@ -150,6 +173,7 @@ int main(int argc, const char* argv[]) {
150173
151174 glfwSetKeyCallback (window, GLFWKeyCallback);
152175 glfwSetWindowSizeCallback (window, GLFWwindowSizeCallback);
176+ glfwSetWindowPosCallback (window, GLFWwindowPosCallback);
153177 glfwSetMouseButtonCallback (window, GLFWmouseButtonCallback);
154178
155179 while (!glfwWindowShouldClose (window)) {
0 commit comments