ext-workspace-v1: initial implementation#9064
ext-workspace-v1: initial implementation#9064WhyNotHugo wants to merge 2 commits intoswaywm:masterfrom
Conversation
fcc4046 to
ae319e5
Compare
|
v2: use one group per output, so that clients can move workspaces to another output by moving a workspace to another group. I haven't found a client which implements ext_workspace_handle_v1::assign, so that particular handler needs better testing. |
3959493 to
80b723d
Compare
|
v3: applied suggested refactor. Squashed commits; they no make much less sense separate. |
80b723d to
9b71f7d
Compare
|
All concerns addressed… but apparently I've regressed and now a ext_workspace_handle_v1::activate request activates the wrong workspace. Still trying to find out how I broke this. |
|
There seems to now be at least one other subtle bug. I'd mark this as draft, but the "Convert to Draft" button is broken and is a no-op. |
|
I debugged this further. When I say "create workspace", I mean If I start waybar (my ext-workspace client) early, then workspaces get id 1,2,3,4… If I create several workspaces, and then start waybar, workspaces get ids in inverted order: 4,3,2,1. So the first-created workspace (with sway name "1") get ids 4, the second one (with sway name "2") gets id 3, etc… But we don't control ids, wlroots assigns them, and it seems that it doesn't assign names until the first ext-workspace client connects? Here's the output of starting Here's the output of creating workspaces before starting waybar: Waybar shows me widgets for both sway IPC and ext-workspace, and the mismatch is also visually obvious. |
9b71f7d to
ac74ec7
Compare
|
My refactor accidentally removed the initial I restored this and waybar works fine: it only uses ids if no names are supplied. I'll report the wlroots issue properly, but it's no longer a problem for us. This is working and ready for review. CI failures are due to API changes in wlroots. |
|
I'm using We don't have any stable id for workspaces. Maybe we can use the memory positions of the object itself? |
That would be unique, but may be re-used by a completely unrelated workspace later on and is not persistent across sessions. We can leave the ID NULL instead. |
ac74ec7 to
75a4a96
Compare
Done |
Move workspace_move_to_output out of the command handler, so it can be re-used for ext_workspace_handle_v1::assign.
75a4a96 to
3532186
Compare
emersion
left a comment
There was a problem hiding this comment.
Looks good apart from these last comments!
| } | ||
| name = req->create_workspace.name; | ||
| } else { | ||
| name = workspace_next_name(output->wlr_output->name); |
There was a problem hiding this comment.
We need to free() this after the workspace has been created.
Easiest would be to unconditionally free name, and strdup(req->create_workspace.name).
There was a problem hiding this comment.
We need to strdup() in the first branch to avoid a double-free, right?
Done.
|
|
||
| // Must be called whenever an output is enabled. | ||
| void sway_ext_workspace_output_enable(struct sway_output *output) { | ||
| if (!server.workspace_manager_v1 || !output->wlr_output) { |
There was a problem hiding this comment.
Nit: I think the !server.workspace_manager_v1 check can be removed
There was a problem hiding this comment.
It can be NULL if wlr_ext_workspace_manager_v1_create fails. We simply ignore that failure at start-up (rather than bailing).
I ignored the error during initialisation because that's what similar calls do (e.g.: wlr_ext_foreign_toplevel_list_v1_create)
Maintain a 1:1 relationship between workspace groups and outputs, so that moving a workspace across groups effectively moves it across outputs. ext_workspace_handle_v1::id is never emitted; sway has no concept of ids or of stable vs temporary workspaces. Everything is ephemeral to the current session. ext_workspace_handle_v1::coordinates is never emitted; sway does not organise workspaces into any sort of grid. ext_workspace_handle_v1::assign is mostly untested, because no client current implements this. Perhaps it's best to not-advertise the feature for now? Deactivating a workspace is a no-op. This functionality doesn't really align with sway, although it could potentially be implemented to "switch to previous workspace on this output" as a follow-up. Removing a workspace is a no-op. Implements: swaywm#8812
3532186 to
b982d56
Compare
Only use a single, global group. Sway does not have any concept of workspace groups, and workspaces can move freely across outputs.
ext_workspace_handle_v1::id is never emitted; sway has no concept of ids or of stable vs temporary workspaces. Everything is ephemeral to the current session.
ext_workspace_handle_v1::coordinates is never emitted; sway does not organise workspaces into any sort of grid.
Deactivating a workspace is a no-op. This functionality doesn't really align with sway, although it could potentially be implemented to "switch to previous workspace on this output" as a follow-up.
Removing a workspace is a no-op.
Implements: #8812