Simplify output workspace lifecycle
cf30b410dd7207d52019e1c25475f0bb6dbc3bbf
1 parent
fa8cd671
swm.c
+10 -15
| 315 | 315 | int layout_x; /* Last configured layout position. */ |
|
| 316 | 316 | int layout_y; |
|
| 317 | 317 | struct wl_list layers[4]; /* Layer surfaces on this display. */ |
|
| 318 | 318 | workspace_t *ws; /* Workspace shown on this display. */ |
|
| 319 | 319 | workspace_t *previous_workspace; /* Workspace shown before the current one. */ |
|
| 320 | - | workspace_t *disabled_workspace; /* Workspace hidden while the output is disabled. */ |
|
| 321 | 320 | int gamma_lut_changed; |
|
| 322 | 321 | int asleep; |
|
| 323 | 322 | }; |
|
| 324 | 323 | ||
| 325 | 324 | /* Each workspace keeps separate settings for vertical and horizontal layouts. */ |
| 2159 | 2158 | break; |
|
| 2160 | 2159 | } |
|
| 2161 | 2160 | } |
|
| 2162 | 2161 | } |
|
| 2163 | 2162 | if (m->ws) { |
|
| 2164 | - | m->disabled_workspace = m->ws; |
|
| 2165 | 2163 | m->ws->mon = nullptr; |
|
| 2164 | + | m->previous_workspace = m->ws; |
|
| 2166 | 2165 | } |
|
| 2167 | - | m->ws = m->previous_workspace = nullptr; |
|
| 2166 | + | m->ws = nullptr; |
|
| 2168 | 2167 | ||
| 2169 | 2168 | for (ws = workspaces; ws < END(workspaces); ws++) { |
|
| 2170 | 2169 | if (ws->mon == m) |
|
| 2171 | 2170 | ws->mon = nullptr; |
|
| 2172 | 2171 | } |
| 2575 | 2574 | wlr_output_state_set_scale(&state, r->scale); |
|
| 2576 | 2575 | wlr_output_state_set_transform(&state, r->rr); |
|
| 2577 | 2576 | break; |
|
| 2578 | 2577 | } |
|
| 2579 | 2578 | } |
|
| 2580 | - | /* Show the lowest-numbered hidden workspace on this output; client |
|
| 2581 | - | * monitor pointers are synced in update_monitors() once the output has its |
|
| 2582 | - | * final geometry. */ |
|
| 2583 | - | m->ws = m->previous_workspace = free_workspace(); |
|
| 2584 | - | ||
| 2585 | - | if (m->ws) |
|
| 2586 | - | m->ws->mon = m; |
|
| 2587 | 2579 | ||
| 2588 | 2580 | /* The mode is a tuple of (width, height, refresh rate), and each |
|
| 2589 | 2581 | * monitor supports only a specific set of modes. We just pick the |
|
| 2590 | 2582 | * monitor's preferred mode; a more sophisticated compositor would let |
|
| 2591 | 2583 | * the user configure it. */ |
| 2593 | 2585 | ||
| 2594 | 2586 | wlr_output_state_set_enabled(&state, 1); |
|
| 2595 | 2587 | ||
| 2596 | 2588 | if (!wlr_output_commit_state(wlr_output, &state)) { |
|
| 2597 | 2589 | wlr_output_state_finish(&state); |
|
| 2598 | - | ||
| 2599 | - | if (m->ws) |
|
| 2600 | - | m->ws->mon = nullptr; |
|
| 2601 | 2590 | wlr_output->data = nullptr; |
|
| 2602 | 2591 | pool_release(&monitor_pool, m); |
|
| 2603 | 2592 | fprintf(stderr, "swm: failed to enable output %s\n", wlr_output->name); |
|
| 2604 | 2593 | return; |
|
| 2605 | 2594 | } |
|
| 2606 | 2595 | wlr_output_state_finish(&state); |
|
| 2596 | + | /* Show the lowest-numbered hidden workspace on this output; client |
|
| 2597 | + | * monitor pointers are synced in update_monitors() once the output has its |
|
| 2598 | + | * final geometry. */ |
|
| 2599 | + | m->ws = m->previous_workspace = free_workspace(); |
|
| 2600 | + | ||
| 2601 | + | if (m->ws) |
|
| 2602 | + | m->ws->mon = m; |
|
| 2607 | 2603 | ||
| 2608 | 2604 | /* Listen for display events after its initial state has committed. */ |
|
| 2609 | 2605 | LISTEN(&wlr_output->events.frame, &m->frame, render_monitor); |
|
| 2610 | 2606 | LISTEN(&wlr_output->events.destroy, &m->destroy, cleanup_monitor); |
|
| 2611 | 2607 | LISTEN(&wlr_output->events.request_state, &m->request_state, request_monitor_state); |
| 6406 | 6402 | struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data; |
|
| 6407 | 6403 | wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y); |
|
| 6408 | 6404 | wlr_session_lock_surface_v1_configure(m->lock_surface, m->m.width, m->m.height); |
|
| 6409 | 6405 | } |
|
| 6410 | 6406 | if (!m->ws) { |
|
| 6411 | - | workspace_t *ws = m->disabled_workspace; |
|
| 6407 | + | workspace_t *ws = m->previous_workspace; |
|
| 6412 | 6408 | ||
| 6413 | 6409 | if (!ws || ws->mon) |
|
| 6414 | 6410 | ws = free_workspace(); |
|
| 6415 | - | m->disabled_workspace = nullptr; |
|
| 6416 | 6411 | m->ws = m->previous_workspace = ws; |
|
| 6417 | 6412 | ||
| 6418 | 6413 | if (ws) |
|
| 6419 | 6414 | ws->mon = m; |
|
| 6420 | 6415 | } |