@@ -109,6 +109,7 @@ static void destroy_surface(struct swaylock_surface *surface) {
109
109
destroy_buffer (& surface -> buffers [1 ]);
110
110
destroy_buffer (& surface -> indicator_buffers [0 ]);
111
111
destroy_buffer (& surface -> indicator_buffers [1 ]);
112
+ wp_viewport_destroy (surface -> viewport );
112
113
wl_output_destroy (surface -> output );
113
114
free (surface );
114
115
}
@@ -173,6 +174,11 @@ static void create_surface(struct swaylock_surface *surface) {
173
174
wl_region_destroy (region );
174
175
}
175
176
177
+ if (state -> viewporter ) {
178
+ surface -> viewport = wp_viewporter_get_viewport (
179
+ state -> viewporter , surface -> surface );
180
+ }
181
+
176
182
if (!state -> ext_session_lock_v1 ) {
177
183
wl_surface_commit (surface -> surface );
178
184
}
@@ -373,6 +379,13 @@ static void handle_global(void *data, struct wl_registry *registry,
373
379
} else if (strcmp (interface , ext_session_lock_manager_v1_interface .name ) == 0 ) {
374
380
state -> ext_session_lock_manager_v1 = wl_registry_bind (registry , name ,
375
381
& ext_session_lock_manager_v1_interface , 1 );
382
+ } else if (strcmp (interface , wp_viewporter_interface .name ) == 0 ) {
383
+ state -> viewporter = wl_registry_bind (registry , name ,
384
+ & wp_viewporter_interface , 1 );
385
+ } else if (strcmp (interface ,
386
+ wp_single_pixel_buffer_manager_v1_interface .name ) == 0 ) {
387
+ state -> single_pixel_buffer_manager = wl_registry_bind (registry , name ,
388
+ & wp_single_pixel_buffer_manager_v1_interface , 1 );
376
389
}
377
390
}
378
391
@@ -1265,6 +1278,20 @@ int main(int argc, char **argv) {
1265
1278
return 1 ;
1266
1279
}
1267
1280
1281
+ if (state .single_pixel_buffer_manager && state .viewporter ) {
1282
+ uint8_t r8 = (state .args .colors .background >> 24 ) & 0xFF ;
1283
+ uint8_t g8 = (state .args .colors .background >> 16 ) & 0xFF ;
1284
+ uint8_t b8 = (state .args .colors .background >> 8 ) & 0xFF ;
1285
+ uint8_t a8 = (state .args .colors .background >> 0 ) & 0xFF ;
1286
+ uint32_t f = 0xFFFFFFFF / 0xFF ; // division result is an integer
1287
+ uint32_t r32 = r8 * f ;
1288
+ uint32_t g32 = g8 * f ;
1289
+ uint32_t b32 = b8 * f ;
1290
+ uint32_t a32 = a8 * f ;
1291
+ state .background_buffer = wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer (
1292
+ state .single_pixel_buffer_manager , r32 , g32 , b32 , a32 );
1293
+ }
1294
+
1268
1295
struct swaylock_surface * surface ;
1269
1296
wl_list_for_each (surface , & state .surfaces , link ) {
1270
1297
create_surface (surface );
@@ -1298,6 +1325,7 @@ int main(int argc, char **argv) {
1298
1325
wl_display_flush (state .display );
1299
1326
}
1300
1327
1328
+ wl_buffer_destroy (state .background_buffer );
1301
1329
free (state .args .font );
1302
1330
return 0 ;
1303
1331
}
0 commit comments