ui: make gl_block use a counter
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 11 Mar 2021 07:45:33 +0000 (11:45 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 21 Dec 2021 06:50:21 +0000 (10:50 +0400)
Track multiple callers blocking requests.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
ui/console.c

index 87f897e46dc49dec47b6ee06a85cc42bdc8b23d5..39f7b66baf5475cddd0b7b2693b7d787910ef6e8 100644 (file)
@@ -79,7 +79,7 @@ struct QemuConsole {
     DisplaySurface *surface;
     int dcls;
     DisplayChangeListener *gl;
-    bool gl_block;
+    int gl_block;
     int window_id;
 
     /* Graphic console state.  */
@@ -237,10 +237,19 @@ void graphic_hw_gl_block(QemuConsole *con, bool block)
 {
     assert(con != NULL);
 
-    con->gl_block = block;
-    if (con->hw_ops->gl_block) {
-        con->hw_ops->gl_block(con->hw, block);
+    if (block) {
+        con->gl_block++;
+    } else {
+        con->gl_block--;
+    }
+    assert(con->gl_block >= 0);
+    if (!con->hw_ops->gl_block) {
+        return;
+    }
+    if ((block && con->gl_block != 1) || (!block && con->gl_block != 0)) {
+        return;
     }
+    con->hw_ops->gl_block(con->hw, block);
 }
 
 void graphic_hw_gl_flushed(QemuConsole *con)