@@ -68,8 +68,31 @@ static void GLFWKeyCallback(GLFWwindow* window,
68
68
}
69
69
70
70
void GLFWwindowSizeCallback (GLFWwindow* window, int width, int height) {
71
+ int left, top;
72
+ glfwGetWindowPos (window, &left, &top);
71
73
FlutterWindowMetricsEvent event = {};
72
74
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;
73
96
event.width = width * g_pixelRatio;
74
97
event.height = height * g_pixelRatio;
75
98
event.pixel_ratio = g_pixelRatio;
@@ -150,6 +173,7 @@ int main(int argc, const char* argv[]) {
150
173
151
174
glfwSetKeyCallback (window, GLFWKeyCallback);
152
175
glfwSetWindowSizeCallback (window, GLFWwindowSizeCallback);
176
+ glfwSetWindowPosCallback (window, GLFWwindowPosCallback);
153
177
glfwSetMouseButtonCallback (window, GLFWmouseButtonCallback);
154
178
155
179
while (!glfwWindowShouldClose (window)) {
0 commit comments