@@ -189,11 +189,17 @@ static void new_output_notify(wl_listener* listener, void* data) {
189
189
* would let the user configure it. */
190
190
if (wl_list_empty (&new_output->modes ) == 0 ) {
191
191
wlr_output_mode* mode = wlr_output_preferred_mode (new_output);
192
- wlr_output_set_mode (new_output, mode);
193
- wlr_output_enable (new_output, true );
194
- if (!wlr_output_commit (new_output)) {
192
+ wlr_output_state state = {};
193
+ wlr_output_state_init (&state);
194
+ wlr_output_state_set_mode (&state, mode);
195
+ wlr_output_state_set_enabled (&state, true );
196
+ if (!wlr_output_commit_state (new_output, &state)) {
197
+ wlr_log (WLR_ERROR, " Failed to commit mode to new output %s" , new_output->name );
198
+ wlr_output_state_finish (&state);
195
199
return ;
196
200
}
201
+
202
+ wlr_output_state_finish (&state);
197
203
}
198
204
199
205
/* Allocates and configures our state for this output */
@@ -224,37 +230,41 @@ static void output_power_manager_set_mode_notify([[maybe_unused]] wl_listener* l
224
230
225
231
const auto & event = *static_cast <wlr_output_power_v1_set_mode_event*>(data);
226
232
227
- if (event.mode == ZWLR_OUTPUT_POWER_V1_MODE_ON) {
228
- wlr_output_enable (event.output , true );
229
- if (!wlr_output_test (event.output )) {
230
- wlr_output_rollback (event.output );
231
- }
232
- wlr_output_commit (event.output );
233
- } else {
234
- wlr_output_enable (event.output , false );
235
- wlr_output_commit (event.output );
233
+ wlr_output_state state = {};
234
+ wlr_output_state_init (&state);
235
+ wlr_output_state_set_enabled (&state, event.mode == ZWLR_OUTPUT_POWER_V1_MODE_ON);
236
+ if (!wlr_output_commit_state (event.output , &state)) {
237
+ wlr_log (WLR_ERROR, " Failed to set enabled state %d for output %s" , state.enabled , event.output ->name );
236
238
}
239
+ wlr_output_state_finish (&state);
237
240
}
238
241
239
- /* This event is raised when wlr_xdg_shell receives a new xdg surface from a
240
- * client, either a toplevel (application window) or popup. */
241
- static void new_xdg_surface_notify (wl_listener* listener, void * data) {
242
- wlr_log (WLR_DEBUG, " wlr_xdg_shell.events.new_surface(listener=%p, data=%p)" , (void *) listener, data);
242
+ static void new_xdg_toplevel_notify (wl_listener* listener, void * data) {
243
+ wlr_log (WLR_DEBUG, " wlr_xdg_shell.events.new_toplevel(listener=%p, data=%p)" , (void *) listener, data);
243
244
244
245
if (data == nullptr ) {
245
- wlr_log (WLR_ERROR, " No data passed to wlr_xdg_shell.events.new_surface " );
246
+ wlr_log (WLR_ERROR, " No data passed to wlr_xdg_shell.events.new_toplevel " );
246
247
return ;
247
248
}
248
249
249
- Server& server = magpie_container_of (listener, server, xdg_shell_new_xdg_surface );
250
- const auto & xdg_surface = *static_cast <wlr_xdg_surface *>(data);
250
+ Server& server = magpie_container_of (listener, server, xdg_shell_new_xdg_toplevel );
251
+ auto & xdg_toplevel = *static_cast <wlr_xdg_toplevel *>(data);
251
252
252
- if (xdg_surface.role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
253
- server.views .emplace_back (std::make_shared<XdgView>(server, *xdg_surface.toplevel ));
254
- } else if (xdg_surface.role == WLR_XDG_SURFACE_ROLE_POPUP) {
255
- auto * surface = static_cast <Surface*>(xdg_surface.popup ->parent ->data );
256
- surface->popups .emplace (std::make_shared<Popup>(*surface, *xdg_surface.popup ));
253
+ server.views .emplace_back (std::make_shared<XdgView>(server, xdg_toplevel));
254
+ }
255
+
256
+ static void new_xdg_popup_notify (wl_listener*, void * data) {
257
+ if (data == nullptr ) {
258
+ wlr_log (WLR_ERROR, " No data passed to wlr_xdg_shell.events.new_popup" );
259
+ return ;
257
260
}
261
+
262
+ auto & xdg_popup = *static_cast <wlr_xdg_popup*>(data);
263
+
264
+ auto * parent = wlr_xdg_surface_try_from_wlr_surface (xdg_popup.parent );
265
+
266
+ auto & parent_surface = *static_cast <Surface*>(parent->data );
267
+ parent_surface.popups .emplace (std::make_shared<Popup>(parent_surface, xdg_popup));
258
268
}
259
269
260
270
static void new_layer_surface_notify (wl_listener* listener, void * data) {
@@ -344,8 +354,11 @@ static void drm_lease_request_notify(wl_listener* listener, void* data) {
344
354
continue ;
345
355
}
346
356
347
- wlr_output_enable (&output->wlr , false );
348
- wlr_output_commit (&output->wlr );
357
+ wlr_output_state state = {};
358
+ wlr_output_state_init (&state);
359
+ wlr_output_state_set_enabled (&state, false );
360
+ wlr_output_commit_state (&output->wlr , &state);
361
+ wlr_output_state_finish (&state);
349
362
wlr_output_layout_remove (server.output_layout , &output->wlr );
350
363
output->is_leased = true ;
351
364
}
@@ -396,25 +409,29 @@ void output_manager_apply_notify(wl_listener* listener, void* data) {
396
409
const bool adding = enabled && !output.wlr .enabled ;
397
410
const bool removing = !enabled && output.wlr .enabled ;
398
411
399
- wlr_output_enable (&output.wlr , enabled);
412
+ wlr_output_state state = {};
413
+ wlr_output_state_init (&state);
414
+ wlr_output_state_set_enabled (&state, enabled);
415
+
400
416
if (enabled) {
401
417
if (head->state .mode != nullptr ) {
402
- wlr_output_set_mode (&output. wlr , head->state .mode );
418
+ wlr_output_state_set_mode (&state , head->state .mode );
403
419
} else {
404
420
const int32_t width = head->state .custom_mode .width ;
405
421
const int32_t height = head->state .custom_mode .height ;
406
422
const int32_t refresh = head->state .custom_mode .refresh ;
407
- wlr_output_set_custom_mode (&output. wlr , width, height, refresh);
423
+ wlr_output_state_set_custom_mode (&state , width, height, refresh);
408
424
}
409
425
410
- wlr_output_set_scale (&output. wlr , head->state .scale );
411
- wlr_output_set_transform (&output. wlr , head->state .transform );
426
+ wlr_output_state_set_scale (&state , head->state .scale );
427
+ wlr_output_state_set_transform (&state , head->state .transform );
412
428
}
413
429
414
- if (!wlr_output_commit (&output.wlr )) {
430
+ if (!wlr_output_commit_state (&output.wlr , &state )) {
415
431
wlr_log (WLR_ERROR, " Output config commit failed" );
416
432
continue ;
417
433
}
434
+ wlr_output_state_finish (&state);
418
435
419
436
if (adding) {
420
437
wlr_output_layout_add_auto (server.output_layout , &output.wlr );
@@ -485,7 +502,7 @@ Server::Server() : listeners(*this) {
485
502
* backend based on the current environment, such as opening an X11 window
486
503
* if an X11 server is running. */
487
504
session = nullptr ;
488
- backend = wlr_backend_autocreate (display, &session);
505
+ backend = wlr_backend_autocreate (wl_display_get_event_loop ( display) , &session);
489
506
if (backend == nullptr ) {
490
507
early_exit (display, " Failed to create a wlr_backend for the Wayland display" );
491
508
}
@@ -528,7 +545,7 @@ Server::Server() : listeners(*this) {
528
545
529
546
/* Creates an output layout, which a wlroots utility for working with an
530
547
* arrangement of screens in a physical layout. */
531
- output_layout = wlr_output_layout_create ();
548
+ output_layout = wlr_output_layout_create (display );
532
549
listeners.output_layout_change .notify = output_layout_change_notify;
533
550
wl_signal_add (&output_layout->events .change , &listeners.output_layout_change );
534
551
@@ -569,13 +586,14 @@ Server::Server() : listeners(*this) {
569
586
570
587
auto * presentation = wlr_presentation_create (display, backend);
571
588
if (presentation == nullptr ) {
572
- early_exit (display, " Failed to create a wlr_presentation for the wlr_scene " );
589
+ early_exit (display, " Failed to create a wlr_presentation for the Wayland display " );
573
590
}
574
- wlr_scene_set_presentation (scene, presentation);
575
591
576
592
xdg_shell = wlr_xdg_shell_create (display, 5 );
577
- listeners.xdg_shell_new_xdg_surface .notify = new_xdg_surface_notify;
578
- wl_signal_add (&xdg_shell->events .new_surface , &listeners.xdg_shell_new_xdg_surface );
593
+ listeners.xdg_shell_new_xdg_toplevel .notify = new_xdg_toplevel_notify;
594
+ wl_signal_add (&xdg_shell->events .new_toplevel , &listeners.xdg_shell_new_xdg_toplevel );
595
+ listeners.xdg_shell_new_xdg_popup .notify = new_xdg_popup_notify;
596
+ wl_signal_add (&xdg_shell->events .new_popup , &listeners.xdg_shell_new_xdg_popup );
579
597
580
598
layer_shell = wlr_layer_shell_v1_create (display, 4 );
581
599
listeners.layer_shell_new_layer_surface .notify = new_layer_surface_notify;
0 commit comments