Commit Graph
4114 Commits
Author SHA1 Message Date
trurl 2aa0b0bf53 Create an integration test for the WMFontPanel widget. 2026-03-26 23:48:29 -04:00
trurl d4c8f986a6 Bump to public insta-image crate. 2026-03-26 23:47:15 -04:00
trurl ec1761f4f3 Utilities for X11 image capture and acceptance testing.
These are put in their own crate so that we can link tests against libwings freely.

Once libwings is entirely rewritten in Rust, we should be able to move these tests back into the wings-rs crate.
2026-03-26 16:59:23 -04:00
trurl 32cf67b012 Fix panic when a handler triggers handler scheduling. 2026-03-07 21:19:00 -05:00
trurl ee28e9d0a2 Drop debugging print that was committed by accident. 2026-03-02 12:22:22 -05:00
trurl e882fd1f13 Make WMCreateCommandButton into a proper function instead of a macro. 2026-03-02 12:18:21 -05:00
trurl eaabf7e20c Fix panic when notification dispatch triggers notification dispatch.
The global `NotificationCenter` is kept behind a mutex, which was locked when notifications were dispatched.

As a result, if notification dispatch triggered dispatch of other notifications, we would fail to unlock the mutex and panic.

This change copies dispatch instructions out from inside the mutex, releases the mutex, and then actually does the dispatch.
2026-03-02 12:12:25 -05:00
trurl 7c7b9aa97c Rewrite WINGs handlers.c in Rust. 2026-02-15 23:15:22 -05:00
trurl 223a64286f Remove WINGs input handlers.
Input handlers date back to early versions of WINGs. They provide
a way to listen for state changes on file descriptors (including
networking sockets) as part of the WINGs event loop.

This functionality is not actually used in the Window Maker source
tree. It may have been more useful in the past, when WINGs provided
a networking socket API. The status quo appears to be that this is
largely dead code. Pumping the X11 event queue is special-cased in
the input handling code, so it can stay in for now.
2026-02-12 12:53:14 -05:00
trurl ce97a3b39f Drop select(2)-based input FD polling.
This is an intermediate step in the process of dropping input FD
polling entirely (except for pumping the X11 event queue).

There is code to use poll(2) instead of select(2) to wait for events
on file descriptors (which includes waiting for events from the X11
event queue). It appears not to have been used in quite some time,
or perhaps never, as it contains a typo (`poll fd` instead of `pollfd`
on its first line).

To reduce code bloat and make source code easier to navigate, it
makes sense to prefer only one of these codepaths.

After correcting this typo, waiting for X11 events appears to work, so
the poll(2)-based code seems to be good enough. Keeping the poll-based
code is vaguely preferable because poll(2) has a slightly better
interface than select(2), and poll(2) has been a standard Unix API
for 30 years.

Since this code is slated to be replaced, the decision to use the
poll(2)-based code here is probably not very important. But future
programmers may want to use this as a branching-off point for switching
to epoll(7) or some other, less-select(2)-like interface.
2026-02-12 12:53:14 -05:00
trurl 5075c877fa Remove WMDeleteTimerWithClientData.
This function requires tracking an explict client data pointer, which it would be preferable not to have in the Rust rewrite.

Removing this function entails tracking timer handlers explicitly, but this is not an undue burden.
2026-02-12 12:53:14 -05:00
trurl fa67563c2b Break out Sendable into its own utility module. 2025-12-20 13:09:32 -05:00
trurl cd711ba52b Restore function prototype for W_ClearNotificationCenter.
This was mistakenly removed when writing wutil-rs/src/notification.rs.
2025-12-20 12:38:29 -05:00
trurl d46810291b Remove unused import. 2025-12-20 12:38:29 -05:00
trurl 7c875284dc Add build-generated files to .gitignore. 2025-12-20 12:35:10 -05:00
trurl 52db12fbf2 Merge pull request 'Merge refactor/wings-rs into refactor/riir' (#13) from refactor/wings-rs into refactor/riir
Reviewed-on: #13
2025-12-15 13:03:10 -05:00
trurl b2481cf657 Name arguments directly instead of aping the Google C++ style guide. 2025-12-15 13:00:00 -05:00
trurl c371e26d05 Add new Rust source files to Makefile.am.
Forgot to do this earlier.
2025-12-15 13:00:00 -05:00
trurl 98421afc38 Rewrite all functions from WINGs wfont.c in Rust.
This starts to establish the structure for an in-place rewrite of WINGs. An
actual redesign of WINGs may follow, but for now there are no plans to alter the
structure of WINGs substantially.
2025-12-15 13:00:00 -05:00
trurl 9e49ed98a2 Make WINGs configuration visible from Rust. 2025-12-15 13:00:00 -05:00
trurl a466f17c35 Fix build order issues by moving wings-rs/ into WINGs/.
Having wings-rs depend on WINGs/WINGs/WINGsP.h was not working very well if all
of WINGs/ had to be built before wings-rs/. Moving wings-rs/ into WINGs/
addresses this.
2025-12-15 13:00:00 -05:00
trurl d33c05ef08 Ignore target dir for nested Cargo subdirs, too. 2025-12-15 13:00:00 -05:00
trurl 79873413db Tweak build so that WINGsP.rs gets generated at the right time. 2025-12-15 13:00:00 -05:00
trurl 57ac6b8178 Put the font and y (ascent) fields of W_Font behind accessors. 2025-12-15 13:00:00 -05:00
trurl d30fe6182d Mark wings-rs as a staticlib. 2025-12-15 13:00:00 -05:00
trurl e20009a880 Use bindgen to generate Rust bindings for WINGs types.
We will use these to port W_Font, W_Screen, etc., to Rust.

Bindings are regenerated whenever the relevant C source files change and then
patched to make sure they will build. This is a bit hacky but will serve our
purposes: the struct definitions should be migrated to Rust sooner rather than
later, so the hackishness should be transient.
2025-12-15 13:00:00 -05:00
trurl ee71db6693 Remove unused functions WMSetWidgetDefaultFont, WMSetWidgetDefaultBoldFont. 2025-12-15 13:00:00 -05:00
trurl 01c7eb7275 Remove unused function WMCopyFontWithStyle. 2025-12-15 13:00:00 -05:00
trurl fa99c12fd7 Remove unused function WMIsAntialiasingEnabled. 2025-12-15 13:00:00 -05:00
trurl d7e815010b Merge pull request 'Merge refactor/wutil-rs into refactor/riir' (#12) from trurl/wmaker:refactor/wutil-rs into refactor/riir
Reviewed-on: #12
2025-12-15 12:50:52 -05:00
trurl a31fa582bd Merge branch 'refactor/riir' into refactor/wutil-rs 2025-12-15 12:49:49 -05:00
trurl d3dac752cc Indent with tabs, as is standard for this file. 2025-12-08 13:31:05 -05:00
trurl 0893be1cea Use BTreeMap instead of HashMap for notification subscriptions.
This allows us to initialize the global NotificationCenter singleton in a const
context, which eliminates the need for OnceLock.
2025-12-08 13:24:44 -05:00
trurl d8057575ce Use a helper method for adding notification listeners. 2025-12-08 13:14:12 -05:00
trurl d8912c58e6 Fix typo in comment. 2025-12-08 13:06:58 -05:00
trurl b7f765e3f6 Rewrite WINGs/notification.c in Rust. 2025-12-08 13:06:04 -05:00
trurl d88d626fbe Remove direct creation and posting of notifications from WINGs.
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.
2025-12-08 13:05:20 -05:00
trurl 5847e9d68f Ditch the notification function WMRemoveNotificationObserverWithName.
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).
2025-12-08 13:05:20 -05:00
trurl adb967ab15 Drop dead notification queue code.
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.)
2025-12-08 13:05:20 -05:00
trurl 0c4d78a53d Drop unused macro (dead code) that invokes WMCreateNotification. 2025-12-08 13:05:20 -05:00
trurl dcd45f0677 Make some unused public WMNotification APIs private.
`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.
2025-12-08 13:05:20 -05:00
trurl 0097d1819e Move functions on Bag which were only called by FFI code inline. 2025-12-08 13:00:14 -05:00
trurl 8270124869 Nix dead code that was left commented out. 2025-12-08 13:00:14 -05:00
trurl 89183f3bcb Rewrite WMBag in Rust.
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*).
2025-12-08 13:00:14 -05:00
trurl 46e540b1b1 Prune the WMBag API in preparation for rewriting it in Rust. 2025-12-08 13:00:14 -05:00
trurl 9802b684ae Rewrite WINGs/tree.c in Rust.
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.
2025-12-08 12:48:37 -05:00
trurl 0a04a4c12e Remove depthFirst parameter from WMTreeWalk.
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.
2025-12-08 12:47:39 -05:00
trurl e1a263cc5b Prune unused WMTree API functions.
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!
2025-12-08 12:47:39 -05:00
trurl c298b5f96f Avoid an unnecessary allocation in wtrimspace. 2025-12-08 12:40:33 -05:00
trurl dfd77b11a9 Don't scan ahead unnecessarily in wstrndup. 2025-12-08 12:40:33 -05:00