@@ -2533,20 +2533,10 @@ int main(int argc, char *argv[]) {
2533
2533
2534
2534
free (image_raw_format );
2535
2535
2536
+ xcb_pixmap_t bg_pixmap ; // Initialized only `if (blur)`
2536
2537
if (blur ) {
2537
- xcb_pixmap_t bg_pixmap = capture_bg_pixmap (conn , screen , last_resolution );
2538
- cairo_surface_t * xcb_img = cairo_xcb_surface_create (conn , bg_pixmap , get_root_visual_type (screen ), last_resolution [0 ], last_resolution [1 ]);
2539
-
2540
- blur_bg_img = cairo_image_surface_create (CAIRO_FORMAT_ARGB32 , last_resolution [0 ], last_resolution [1 ]);
2541
- cairo_t * ctx = cairo_create (blur_bg_img );
2542
-
2543
- cairo_set_source_surface (ctx , xcb_img , 0 , 0 );
2544
- cairo_paint (ctx );
2545
- blur_image_surface (blur_bg_img , blur_sigma );
2546
-
2547
- cairo_destroy (ctx );
2548
- cairo_surface_destroy (xcb_img );
2549
- xcb_free_pixmap (conn , bg_pixmap );
2538
+ // Make the screenshot before opening the window, blur it later
2539
+ bg_pixmap = capture_bg_pixmap (conn , screen , last_resolution );
2550
2540
}
2551
2541
2552
2542
xcb_window_t stolen_focus = find_focused_window (conn , screen -> root );
@@ -2581,6 +2571,23 @@ int main(int argc, char *argv[]) {
2581
2571
}
2582
2572
}
2583
2573
2574
+ if (blur ) {
2575
+ // Blurring the earlier taken screenshot (`bg_pixmap`)
2576
+
2577
+ cairo_surface_t * xcb_img = cairo_xcb_surface_create (conn , bg_pixmap , get_root_visual_type (screen ), last_resolution [0 ], last_resolution [1 ]);
2578
+
2579
+ blur_bg_img = cairo_image_surface_create (CAIRO_FORMAT_ARGB32 , last_resolution [0 ], last_resolution [1 ]);
2580
+ cairo_t * ctx = cairo_create (blur_bg_img );
2581
+
2582
+ cairo_set_source_surface (ctx , xcb_img , 0 , 0 );
2583
+ cairo_paint (ctx );
2584
+ blur_image_surface (blur_bg_img , blur_sigma );
2585
+
2586
+ cairo_destroy (ctx );
2587
+ cairo_surface_destroy (xcb_img );
2588
+ xcb_free_pixmap (conn , bg_pixmap );
2589
+ }
2590
+
2584
2591
pid_t pid = fork ();
2585
2592
/* The pid == -1 case is intentionally ignored here:
2586
2593
* While the child process is useful for preventing other windows from
0 commit comments