Commit Graph

3988 Commits

Author SHA1 Message Date
Levi Neely 9fcfccd6db 9pfuse: fix truncate for modern kernels
Modern Linux kernels send additional flags (FATTR_CTIME, etc.) along
with FATTR_SIZE when truncating files. The exact equality check
(in->valid == FATTR_SIZE) failed, causing shell redirections like
'echo foo > file' to return ENOSYS on existing files.

Change to a bitmask check: (in->valid & FATTR_SIZE)
2026-03-20 17:33:17 +01:00
Ethan Burns 5848a455a7 wayland: abort compose when the keyboard leaves.
This indicates window focus change. Without this, focus change caused by alt-key combinations (ctrl+alt+arrow on many Linux configurations will switch virtual desktops) may incorrectly be interpreted as a key-compose.
2025-11-25 17:01:34 -05:00
Ethan Burns 03bad79eed Disable debug by default. 2025-11-25 17:01:34 -05:00
Ethan Burns 62d06bcdc0 Offer mime type UTF8_STRING for snarf.
For whatever reason when offering only text/plain, the snarf can't paste into Firefox. Offering also UTF8_STRING seems to fix it.
2025-11-25 17:01:34 -05:00
Ethan Burns 60d772e65f Don't call gfx_abortcompose with a lock held.
There has been some funny locking/stalling behavior that seems to be related to using alt+click as a simulated middle-click. It may have started after this gfx_abortcompose call was added. According to devdraw.h, the gfx_ routines should not be called with a lock held. Now I'm not sure this fixes the weird behavior I've seen, but can't hurt to still fix this buggy call.
2025-11-25 17:01:34 -05:00
Ethan Burns e6e18b13c2 Fix cursor background transparency.
It was not transparent, but drawn over a white square.
2025-11-25 17:01:34 -05:00
Ethan Burns 53a4e7c22f Remove scroll repeat.
This is OK with the touch pad, but it's actually not great with a real mouse scroll wheel, because the scrolling becomes inconsistent and hard to predict exactly how much the screen will scroll. Better to just remove it.
2025-11-25 17:01:34 -05:00
Ethan Burns 8a727c1e21 Cancel compose when clicking the mouse on an alt+click.
The alt key begins a compose. When using alt+click, compose was not previously cancelled and the next two typed characters would often end up composed.
2025-11-25 17:01:34 -05:00
Levi Neely 2079b5e9c7 short comment explaining the wayland.c include 2025-11-25 17:01:34 -05:00
Levi Neely e80cf9355d fix build when WSYSTYPE=wayland in local cfg 2025-11-25 17:01:34 -05:00
David Arroyo 27615c4efa move declarations to first use 2025-11-25 17:01:34 -05:00
David Arroyo fc69dfb001 Receive key repeat info from compositor
Upgrade to version 4 of the wl_seat interface which adds the
wl_keyboard::repeat_info event allowing the compositor to configure
key repeat delay and rate.
2025-11-25 17:01:34 -05:00
David Arroyo a5385a32b0 Only register repeat callbacks when repeat active
This change splits scroll repeat and key repeat into separate
callbacks, and only registers them when a key is pressed or
scrolling is active, respectively. The key repeat logic is
changed to support key repetitions higher than the frame rate.

The new logic will also accomodate key repeat parameters set by
the compositor, although the comment about us not receiving that
configuration event is still valid.
2025-11-25 17:01:34 -05:00
David Arroyo 338dd8ab45 Fix unexpected devdraw crashes on sway
I found sway 1.10 and wlroots 0.18.2 will occasionally generate
wl_keyboard::keymap events with an empty keymap. I do not have
a reliable reproduction for this, but it seems to occur when
switching back and forth between workspaces with the keyboard.

This also fixes the issue where devdraw can go into a busy loop if
the compositor goes away and wl_display_dispatch() returns -1.
2025-11-25 17:01:34 -05:00
David Arroyo 66598ad2c5 Fix race condition on attach and mouse track on warp
I tried running the wayland devdraw implementation on Sway 1.10,
wlroots 0.18 and encountered the error:

	xdg_surface#13: error 3: xdg_surface has never been configured

According to https://wayland.app/protocols/xdg-shell#xdg_surface ,
a client must commit a surface without a buffer, *wait* for the first
configure request from the compositor, ack it, and *only then* can
it proceed to attach a buffer to the surface and tell wayland to display it.

This was caused by the following sequence of events:

1. devdraw starts, enters gfx_main
2. `gfx_main` calls `gfx_started`, which spawns the `serveproc` thread
3. `gfx_main` enters `wl_display_dispatch`, flushing any buffered requests to
   the compositor, and enters `wl_display_poll()` to wait for incoming messages
4. `serveproc` calls `rpc_attach`, sets up the surface, and buffers a commit.

The race is between #3 and #4. If #3 happens first, the buffered commit
just sits there until `rpc_flush` is called, which calls `wl_display_flush()`,
but at that point a buffer is attached too quickly for the configure to happen.

This commit fixes the race by adding a `configured` field to the WaylandClient
and using it to guard `rpc_flush`.

In addition, I found that mouse warping, at least in sway, would move
the cursor but future mouse presses would register at the old location
until I moved the mouse. So I added a call to gfx_mousetrack to the end
of `rpc_setmouse`.
2025-11-25 17:01:34 -05:00
ylh 1a0c0a9fdd devdraw/wayland.c: prevent divide-by-zero in scroll repeat 2025-11-25 17:01:34 -05:00
Ethan Burns 2b1cd9bc03 Link the snarf buffer to the compositor's copy/paste buffer on Wayland. 2025-11-25 17:01:34 -05:00
Ethan Burns 263ec8a56a Add wayland support to devdraw. 2025-11-25 17:01:34 -05:00
G. Branden Robinson f39a2407b6 troff: fix SIGFPE when using modulus operator
I uncovered this problem while writing unit tests for GNU troff's
delimited expression handling.  Plan 9 troff's numeric expression
evaluator handles division by zero but not modulus by zero.

Fixes:
$ echo '.if %0%0% .tm true' | 9 troff
Floating point exception (core dumped)
$ echo '.if 1%0 .tm true' | 9 troff
Floating point exception (core dumped)

After this patch:
$ echo '.if %0%0% .tm true' | 9 troff
x T utf
x res 720 1 1
x init
troff: modulus by zero.; stdin:1
troff: modulus by zero.; stdin:1
x trailer
V0
x stop
$ echo '.if 1%0 .tm true' | 9 troff
x T utf
x res 720 1 1
x init
troff: modulus by zero.; stdin:1
x trailer
V0
x stop
2025-11-09 14:25:48 -05:00
Scott Schwartz 37cd522b0a cmd/devdraw: handle X11 selections better
x11-screen.c accepts selection targets with the MIME type
"text/plain;charset-UTF8", but it should do so case insensitively. The
current code draws an error when working with xfce4-terminal 1.0.4,
which sends lower case.  To reproduce, run acme, snarf some text, then
paste in the terminal.  acme will report:
acme: cannot handle selection request for 'text/plain;charset=utf-8' (590)
2025-11-04 07:10:14 -05:00
G. Branden Robinson 46fbe4cd00 tmac/tmac.an*: work around formatter bug
...when rendering some man pages, such as those of ncurses.

I did not manage (nor seriously attempt) to identify the root cause of
this bug.  ncurses's use of `SH` and `SS` man(7) macros is
unremarkable.[1]  I cannot account for why the less(1) man page renders
fine and ncurses pages like insstr(3) do not.  But render badly they do,
emitting *roff logic as formatted output.

```
$ 9 nroff -man $(man -w insstr) | grep -F .ss | cat -v
     "'''if^GNAME^GSYNOPSIS^G .ss 18 NAME
     "'''if^GSYNOPSIS^GSYNOPSIS^G .ss 18 SYNOPSIS
     "'''if^GDESCRIPTION^GSYNOPSIS^G .ss 18 DESCRIPTION
     "'''if^GRETURN^GSYNOPSIS^G .ss 18 RETURN VALUE
     "'''if^GNOTES^GSYNOPSIS^G .ss 18 NOTES
     "'''if^GEXTENSIONS^GSYNOPSIS^G .ss 18 EXTENSIONS
     "'''if^GPORTABILITY^GSYNOPSIS^G .ss 18 PORTABILITY
     "'''if^GHISTORY^GSYNOPSIS^G .ss 18 HISTORY
     "'''if^GSEE^GSYNOPSIS^G .ss 18 SEE ALSO
```

With this patch:

```
$ 9 nroff -man $(man -w insstr) | grep -F .ss | cat -v | grep . || echo NO OUTPUT
NO OUTPUT
```

I do observe that the problem seems to correspond to the only use in the
package of the old-fashioned `'''` commenting convention _within a macro
definition_.  I have a notion of how GNU troff works, but little about
AT&T troff.  That said, if I were to try to get to the bottom of this
problem, I'd look into if and how the no-break command character is
handled differently in copy mode.  I see nothing in CSTR #54 to suggest
that the command characters have different meanings in copy mode and its
complement.[2]

My solution is to use idiomatic comment syntax inside macro definitions.

[1] d5dc8a4a7c/man/curs_insstr.3x (L47)

[2] unnamed in AT&T documentation but which I term "interpretation mode"
    in groff
2025-10-26 19:03:55 -04:00
Dan Cross 499efb270d nroff: bad symbold definition on command line.
`-DTDEVNAME=...` should be `-DNDEVNAME=...`.  We've been
defaulting for "37", probably forever.

Signed-off-by: Dan Cross <cross@gajendra.net>
2025-10-10 14:34:02 -04:00
G. Branden Robinson e5b5757e64 tmac/tmac.an*: support `lq`, `rq` strings
The `lq` and `rq` strings are not a groffism, but _almost_ universally
portable to man(7) renderers.

They originate in 4BSD (1980).[1]  They entered Unix System V with SVR4
(1988 or 1989).[2]  mandoc(1) has supported them since its inception.[3]

* tmac/tmac.an:
* tmac/tmac.antimes: Do it.  Use U+201C and U+201D if the output device
  is "utf", otherwise define them as `` and ''.  Don't define them as
  `"` because that breaks when interpolating the strings in macro
  arguments.[4]

[1] https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/lib/tmac/tmac.an.new
[2]
e68293af91/sysvr4/svr4/ucbcmd/troff/troff.d/tmac.d/an (L46)
[3] https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/mandoc/predefs.in?rev=1.1&content-type=text/x-cvsweb-markup
[4] https://www.gnu.org/software/groff/manual/groff.html.node/Calling-Macros.html

   "For the (neutral) double quote, you have recourse to an obscure
   syntactical feature of AT&T troff. ..."
2025-10-10 13:44:47 -04:00
Russ Cox 19263a1071 devdraw: work around XWayland pointer warping 2025-10-09 19:37:41 -04:00
Arusekk 00754b35a2 devdraw: fix dangling else
Because of a dangling else, after adding a name to an image with 'N',
it was immediately deleted, resulting in Enoname in response to 'n'.

This went mostly unnoticed, since plan9port itself does not use named
images, but it can break external applications like truedraw[1].

[1]: https://git.sr.ht/~arusekk/truedraw

Fixes: c66b52501b ("new draw server")
2025-10-09 09:29:12 -04:00
Anthony Sorace 80b7829854 man: remove -s from usage message 2025-09-23 17:52:58 -04:00
Jordan Niethe bafcdddd31 B: Print usage message to stderr
B's usage message redirects its stderr to stdout instead of vice versa.
Fix this.

Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
2025-09-06 05:33:17 -04:00
dependabot[bot] a20cff92cf ci: bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-12 07:06:27 -04:00
dependabot[bot] b83954eaf6 ci: bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-27 10:41:04 -04:00
Dmitri Vereshchagin 10564b1175 tmac/tmac.an: define .MR in a groff compatible way
groff 1.23.0 added .MR to its -man macro package.  The NEWS file states
that the inclusion of the macro "was prompted by its introduction to
Plan 9 from User Space's troff in August 2020."  From d32deab it seems
that the name for Plan 9 from User Space's implementation was suggested
by groff maintainer G. Brandon Robinson.

Not sure if the intention was to make these definitions compatible, but
it would be nice if they were.

Currently, Plan 9 from User Space's .MR expects its second argument to
be parenthesized.  groff's .MR does not.  This results in extra
parentheses appearing in manual references when viewing Plan 9 from User
Space's manual pages on a system using groff.
2025-07-27 09:58:50 -04:00
Kare Nuorteva 00446db7d8 ci: add Dependabot for GitHub Actions
Dependabot automatically maintains GitHub Actions workflows by sending
Pull Requests to project when action updates are released. Dependabot
labels the pull requests 'ci: bump actions/checkout from v3 to v4'.
Dependabot opens a maximum of five Pull Requests at a time and reviews
the need for PRs once a week.
2025-07-27 09:56:22 -04:00
lufia 8ff39da062 src/cmd/rc: import rc syntax `delim{cmd} for splitting commands from 9atom
Co-authored-by: <ori@eigenstate.org>
2025-07-27 09:55:45 -04:00
Kare Nuorteva cc89d24235 .gitignore: ignore macOS .DS_Store files 2025-07-27 09:52:08 -04:00
Dan Cross b2fc88d60a SunOS: silence some warnings
Give `-Wformat=0` on illumos/Solaris so that the build does not
complain about `execlp` not having a sentinel (it's nil).  Also
fix an integer size issue when casting to a void pointer.
2025-07-25 18:46:52 +00:00
Dan Cross 9d2e0d31f7 DragonFly: fix build
Fix the build for DragonFlyBSD.
2025-07-25 19:02:59 +00:00
Dan Cross 0bc66bfb3d libthread: remove check for LinuxThreads
libthread had code in `_pthreadinit` to test for LinuxThreads,
and error if it was in use.  This hasn't been relevant since
Linux 2.6, and I can't imagine there are many people trying to
build (recent) plan9port on systems that old.

Unfortunately, this code violated aliasing rules, and compilers
were complaining about it.  But, since it likely hasn't had much
relevance in 20ish years, we can probably just remove it.
2025-07-25 13:06:53 -04:00
Dan Cross 156e745be9 all: remove need for `-fcommon`
Use `extern` where appropriate so that we can remove `-fcommon`
on macOS and others.  On macOS, `-fcommon` generates a number of
linker warnings.

I've tested building on macOS, Linux, FreeBSD, NetBSD, OpenBSD
and illumos.  I am not in a position to test on AIX or other
more esoteric platforms, however.
2025-07-25 12:25:11 -04:00
Dan Cross 1e6e30e91e rio: proper prototypes in `fns.h`
Use proper function prototypes in `fns.h`, that include argument
type information.
2025-07-25 11:58:36 -04:00
Dan Cross 655f7c3184 all: clean up misleading indentation warnings
Misleading indentation warnings are actually useful, as they
will occasionally reveal actual bugs (cf the apple `goto fail`
security bug from a few years ago).  Newer versions of clang
(at least) are more aggressive about warnings in this regard,
which has exposed a few warnings that are annoying.  However,
they are easy to address.
2025-07-25 11:20:03 -04:00
Dan Cross 5a9ced10ee sort: rename kcmp to keycmp
Fixes: #648
Fixes: #655
2025-07-24 16:35:15 +00:00
Dan Cross 67dd74a964 INSTALL: set defaults for awk and egrep
Set defaults for `awk` and `egrep`, instead of
setting things multiple times when specializing on
OS, and using a default in a `case` statement.
This is cleaner and less error-prone.
2025-07-24 16:25:44 +00:00
Dan Cross 4089e29e89 warnings: fix warnings on newer compilers
Mostly turning the crank on fixing simple warnings: arrays, for
instance, can never be nil.  A couple of pointers should have been
initialized to `nil` before being tested.

Some logic in `troff` was simplified: basically, an `if` statement had
a condition that must have always been true if that section of code
were being executed at all.
2025-07-24 15:45:31 +00:00
Dan Cross 564d45b5a5 config: add $egrep
Introduce a new variable set in $PLAN9/config:
$egrep, which is conditionally set to either
`egrep` or `grep -E`, based on platform, and use
this when we want to invoke `egrep`.

This works around the endless warnings from GNU
grep stating that `egrep` is deprecated in favor
of `grep -E`, when run on e.g. Linux.
2025-07-23 19:44:54 +00:00
erentar 28690cd427 9c: change -std=c17 to -stc=c11 based on feedback in \#716 2025-07-22 12:12:39 +02:00
erentar f97483e519 u.h: define __USE_POSIX to make glibc happy
glibc will only expose sigjmp_buf if __USE_POSIX is defined.
2025-07-22 12:12:39 +02:00
erentar 53ed65a982 9c: Explicitly set c standard as newer changes in c23 break compilation 2025-07-22 12:12:39 +02:00
erentar 6df4828542 9c: "-Wdeprecated-pragma" is only present in clang and is absent from gcc 2025-07-22 12:12:39 +02:00
Russ Cox df9b195ebf libflate: fiz inflatezlibblock
This has obviously never been run.
2025-05-08 13:29:20 -04:00
Roger Peppe 9da5b44513 cmd/devdraw: avoid use of X button state field
This bug is an intermittent annoyance and does not seem likely to be
fixed soon. It means that every so often my acme becomes unusable
because it behaves as if a mouse button is permanently set.

Avoid that issue by keeping track of mouse button state directly.

While we're about it, fix another annoying issue: under Linux the
FocusOut event reset the kstate field but not the kbuttons field,
meaning that the buttons state could inappropriately persist. This
happened occasionally by accident, but was easy to reproduce: with the
mouse button held down, drag outside the window and click Alt-Tab to
switch away from the window. We see a KeyDown event followed by FocusOut
but no KeyUp event.

Change-Id: I3708316478c80c41806d7157ae9929c6cd84b662
2025-03-29 11:23:26 -04:00
Igor Burago 13582b1a89 .gitignore: add bin/mntgen 2025-02-17 20:15:27 -05:00