Merge refactor/wutil-rs into refactor/riir #11

Closed
trurl wants to merge 0 commits from refactor/wutil-rs into refactor/riir
Owner

Rewrite/refactor efforts have gotten split between branches off of refactor/wutil-rs and refactor/wings-rs, with refactor/riir tagging along when I remember to merge changes back into that. refactor/riir can continue to be the trunk, but we should merge refactor/wutil-rs and refactor/wings-rs into it and ditch them as upstream branches that PRs can target.

Rewrite/refactor efforts have gotten split between branches off of `refactor/wutil-rs` and `refactor/wings-rs`, with `refactor/riir` tagging along when I remember to merge changes back into that. `refactor/riir` can continue to be the trunk, but we should merge `refactor/wutil-rs` and `refactor/wings-rs` into it and ditch them as upstream branches that PRs can target.
trurl added 24 commits 2025-12-15 12:45:12 -05:00
These functions were added to glibc 2.38, so we don't even need to check for
libbsd. There isn't a strong need to worry about supporting older systems
because use of these functions should go away as we rewrite string.c in
Rust. And, apparently, they are not held in high regard historically. That's at
least 2 reasons to be rid of them.
This is slated for replacement, but it will help to be better documented first.
These functions should be gotten rid of as we transition to Rust, but replacing
them with minimally tested Rust code should suffice as a first step.
Without this, `make` won't automatically rebuild wutil-rs when string.rs
changes.
This is a first step towards migrating WINGs/tree.c to Rust.

Happy finding: no parent pointer are actually needed, so we don't have to use a
shared structure for node pointers!
WMTreeWalk is only called once, with depthFirst set to true, so we might as well
just hard-code that behavior.

Also, this parameter appears to have been misnamed (since the search is always DFS)
and should properly be named to indicate that it controls if this is a pre- or
post-order traversal.
This is a bit of a red herring, since WMTree is only used in wmmenugen, which I
don't think I've ever directly used. See notes at the top of tree.rs for more
musings on whether this should be in wutil-rs at all.
We should eventually get rid of this entirely, in favor of something along the
lines of a sorted Vec that is fully typed (so the payload isn't just a void*).
`WMRetainNotification`, `WMGetDefaultNotificationQueue`,
`WMDequeueNotificationMatching`, `WMEnqueueNotification`, and
`WMEnqueueCoalesceNotification`, are only used in WINGs/notification.c. To
reduce the API surface area that needs to be migrated to Rust, they are being
made private.
This appears to have been used by now-defunct support for network
connections (WMConnection). No live code instantiates a notification queue or
pushes/dequeues notifications from a notification queue. (The global
NotificationCenter in WINGs/notification.c is still in use, so it is not going
anywhere in this commit.)
This reduces the notification API in a way that is helpful for rewriting in
Rust. This function is only used in one place, and the object that is being
deregistered is free'd immediately after WMRemoveNotificationObserverWithName is
called, so it should be safe just to use WMRemoveNotificationObserver (since I
hope it's an error to keep a notification to a free'd object registered).
We can reduce the WMNotification API surface area further by getting rid of
WMCreateNotification and WMPostNotification. WMNotification remains a
first-class object, but it is no longer possible for client code to create a
notification object directly. Notifications must now be posted through
WMPostNotificationName, which handles notification creation and destruction on
its own.

This will simplify the notification lifecycle and make the Rust rewrite
simpler. (Notifications no longer need to be reference-counted, heap-allocated
objects that might be saved somewhere after they are dispatched.)

WTextField code which reused the WMNotification struct has been modified to take
parameters of the correct type directly, instead of through a WMNotification's
void* data field.
This allows us to initialize the global NotificationCenter singleton in a const
context, which eliminates the need for OnceLock.
Author
Owner

Hm, let's actually do this via PRs from https://git.sdf.org/trurl/wmaker.

Hm, let's actually do this via PRs from https://git.sdf.org/trurl/wmaker.
trurl closed this pull request 2025-12-15 12:49:23 -05:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitrine/wmaker#11