loader/dri3: setup present event with drawable type info
authorQiang Yu <yuq825@gmail.com>
Fri, 12 Nov 2021 02:49:07 +0000 (10:49 +0800)
committerMarge Bot <emma+marge@anholt.net>
Tue, 7 Dec 2021 03:26:13 +0000 (03:26 +0000)
If we already know the drawable type, setup event in a simpler way.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13750>

src/loader/loader_dri3_helper.c

index fb37616..b7e0449 100644 (file)
@@ -1685,13 +1685,29 @@ dri3_detect_drawable_is_window(struct loader_dri3_drawable *draw)
 static bool
 dri3_setup_present_event(struct loader_dri3_drawable *draw)
 {
+   /* No need to setup for pixmap drawable. */
+   if (draw->type == LOADER_DRI3_DRAWABLE_PIXMAP ||
+       draw->type == LOADER_DRI3_DRAWABLE_PBUFFER) {
+      draw->is_pixmap = true;
+      return true;
+   }
+
    draw->eid = xcb_generate_id(draw->conn);
 
-   if (!dri3_detect_drawable_is_window(draw))
-      return false;
+   if (draw->type == LOADER_DRI3_DRAWABLE_WINDOW) {
+      xcb_present_select_input(draw->conn, draw->eid, draw->drawable,
+                               XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY |
+                               XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY |
+                               XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY);
+   } else {
+      assert(draw->type == LOADER_DRI3_DRAWABLE_UNKNOWN);
 
-   if (draw->is_pixmap)
-      return true;
+      if (!dri3_detect_drawable_is_window(draw))
+         return false;
+
+      if (draw->is_pixmap)
+         return true;
+   }
 
    /* Create an XCB event queue to hold present events outside of the usual
     * application event queue