Commit Graph

82 Commits (master)

Author SHA1 Message Date
Sigrid 4ec97f73ee libdraw: enter/eenter: fix ^W removing the text on the right side of the tick 2021-02-04 10:57:37 +01:00
Sigrid e0bfd148e2 libdraw: enter/eenter: fix Kleft for non-ascii text 2021-02-04 10:45:52 +01:00
Ori Bernstein c207b78d07 libdraw: add bezierpts
This patch exposes the bezierpts function,
providing a way to get the points on a path,
similar how bezsplinepts gives them for b
splines.
2021-01-09 12:20:49 -08:00
cinap_lenrek eb3d055eb3 backout OCEXEC changes when potentially opening /srv files
Opening a /srv file sets the close-on-exec flag on the
shared channel breaking the exportfs openmount() hack.

The devsrv tries to prevent posting a channel with the
close-on-exec or remove-on-close flags. but nothing
currently prevents this poisoning on open.

Until this gets fixed in eigther exportfs or devsrv,
i'll back out the changes that could have potential side
effects like this.
2020-12-09 01:04:03 +01:00
cinap_lenrek f341ae8c77 libdraw: open file-descriptor with OCEXEC flag in readcolmap() 2020-12-07 16:30:27 +01:00
cinap_lenrek 4d22dbb0f5 libdraw: open internal file-descriptors with OCEXEC flag 2020-12-07 14:32:34 +01:00
cinap_lenrek e8b871ef5a libdraw: remove unused Error label in freescreen() 2020-12-07 14:32:12 +01:00
cinap_lenrek 1bce6d0981 libdraw: do not force flushimage() on freescreen()
This causes visual flashes of white in rio. If it is
really needed (it is rare) it should be done by the caller.
2020-12-02 00:56:21 +01:00
cinap_lenrek 7ff6ea0f70 libdraw: fix mount() error handling in newwindow() 2020-05-02 17:05:17 +02:00
cinap_lenrek 064ea89caa libdraw: avoid deadlock for mouse ioproc sending on resizec
a deadlock has been observed with samterm (thanks burnzez),
that shows the mouse ioproc being stuck in sending on the
resize channel, while the mouse consumer is stuck in a
readmouse() loop wanting a rectangle to be drawn by the
user:

recv(v=0x42df50)+0x28 /sys/src/libthread/channel.c:321
readmouse(mc=0x42df50)+0x54 /sys/src/libdraw/mouse.c:34
getrect(.ret=0x41bce0,but=0x4,mc=0x42df50)+0x62 /sys/src/libdraw/getrect.c:49
	r=0x41bc70
	rc=0x41bc70
getr(rp=0x41bce0)+0x24 /sys/src/cmd/samterm/main.c:244
	p=0x6b000004f6
	r=0x2
sweeptext(new=0x0,tag=0x2d)+0x12 /sys/src/cmd/samterm/menu.c:208
	r=0x2
	t=0x42df50
inmesg(type=0x2,count=0x2)+0x1ab /sys/src/cmd/samterm/mesg.c:136
	m=0x10000002d
	l=0x2d00001b00
	i=0x43829000000001
	t=0x438290
	lp=0x42e050
rcv()+0x7a /sys/src/cmd/samterm/mesg.c:77
threadmain(argv=0x7ffffeffef90)+0x173 /sys/src/cmd/samterm/main.c:63

so avoid blocking in the mouse ioproc by using nbsend()
instead of send() for writing to the resize channel.
2018-11-18 03:37:04 +01:00
cinap_lenrek b7aedbb366 libdraw: cannot happen 2018-11-08 16:56:34 +01:00
cinap_lenrek df7fcc6cac libdraw: fix gengetwindow()
- fix fd leak in winname read() <= 0 case
- avoid freeing d->image (was by freeimage((*scrp)->image))
- dont leak screen and window in fullscreen mode
2018-11-07 22:01:18 +01:00
cinap_lenrek 34c7af22c1 libdraw: accept unsigned msec timestamp in /dev/mouse 2018-07-23 19:25:28 +02:00
cinap_lenrek d4a6dc8910 libdraw: get rid of _drawdebug variable 2017-04-29 21:03:52 +02:00
cinap_lenrek 6d97f77c2d libdraw: avoid dropping queued button change mouse events in emouse() 2016-10-22 00:04:21 +02:00
cinap_lenrek 1787584ad8 libdraw: avoid BPSHORT()/BPLONG() expansion, cleanup loadchar(),cachechars()
assigning the expression value to a temporary variable in
BPSHORT() and BPLONG() saves arround 2K of text in rio on
arm and arround 1K on amd64.

loadchar(): use the passed in "h" as the char index instead
of recomputing it from c-f->cache. dont recompute wid.

cachechars(): do cache lookup and find oldest entry in a
single loop pass.
2016-04-13 00:34:48 +02:00
cinap_lenrek b47c096c8c libdraw: dont postnote to pid==0 in ekill() 2016-04-10 00:00:37 +02:00
cinap_lenrek 796e7b84bd libdraw: fix out of bounds memory access after subfont array reallocation (thanks ray)
/n/bugs/open/libdrawfont.c_buffer_overflow
http://bugs.9front.org/open/libdrawfont.c_buffer_overflow/readme

ray@raylai.com

Hi all,

In plan9port this bug keeps crashing mc when I run lc in a directory with Chinese characters. This is a diff from OpenBSD but it should apply cleanly to the various plan9 sources.

The code is basically trying to do a realloc (I guess realloc wasn't available back then?) but it copies too much from the original buffer.

Since realloc is available, just use it. If realloc isn't available outside plan9port (I haven't checked) the memmove line should be changed from:
	memmove(f->subf, of, (f->nsubf+DSUBF)*sizeof *subf);
to:
	memmove(f->subf, of, f->nsubf*sizeof *subf);

I hope this is helpful.

Ray
2016-04-05 11:24:07 +02:00
BurnZeZ 8c9d28f4f8 libdraw: have openfont() set error string 2016-03-19 17:47:25 -04:00
cinap_lenrek 7b8fcd1269 libdraw: don't flush in readmouse() when theres nothing to flush 2016-03-13 00:03:42 +01:00
cinap_lenrek 84851b33cf libdraw: remove flushimage calls from fontresize() and loadchar() 2016-03-12 22:01:43 +01:00
cinap_lenrek 9dc9c6c5ef rio, libdraw: experimental removal of redundant flushimage() calls for roundtrip latency reduction
- remove redundant flushimage() calls before readmouse()
- remove flushimage() calls for allocimage(),freeimage() and originwindow()

this is experimental. it will break allocimage() error handling unless the
caller does explicit flushimage() calls, tho the gains
in usability over high latency connections is huge. in most cases, programs
will just terminate when encountering these errors.
2016-03-08 16:45:29 +01:00
cinap_lenrek 75186be2c2 libdraw: remove unused static log2[] array 2016-02-28 01:38:29 +01:00
cinap_lenrek 95cfc30788 libdraw: remove unneeded check (thanks BurnZeZ) 2015-09-20 21:52:47 +02:00
cinap_lenrek d1315ade41 libdraw, screenrc: bind devdraw and devmouse in screenrc instead of handling it in libdraw
libdraw was attempting to bind '#i' and '#m' to /dev when it could not find
/dev/mouse or /dev/draw. a library shouldnt be that clever and do namespace
manipulations on behalf of the caller. so instead, we setup the graphics
environment in screenrc on boot time.
2015-09-20 12:25:01 +02:00
glenda c4fdc6bfdb fix fuckup 2015-08-25 09:35:10 +00:00
mischief 6b402b83cf import E script from bell labs 2015-08-25 02:07:46 -07:00
ftrvxmtrx a314302e64 libdraw: sync allocimage/allocwindow prototypes with man pages 2015-06-09 10:33:30 +02:00
cinap_lenrek e2a5d674d9 libdraw: consistent use of nil for pointers, error handling 2015-06-09 01:42:59 +02:00
cinap_lenrek 6198954859 libdraw: don't loop forever when getting eof on /dev/cons in keyboard ioproc 2015-05-19 20:04:47 +02:00
cinap_lenrek 2259f3fb9a libdraw: font->display->defaultsubfont vs. display->defaultsubfont, dead code, malloc erros
it is possible to have fonts belong to different or no display, so the
check for defaultsubfont has to be against font->display, not the global
display variable.

remove unused freeup() routine.

handle strdup() error in allocsubfont() and realloc() error in buildfont().
2015-03-02 11:01:12 +01:00
cinap_lenrek 0467b41972 libdraw: use multiple read() calls in openfont() to read .font file
font files might be bigger than the i/o unit, so do multiple reads
until eof to read it.
2015-03-01 05:45:22 +01:00
cinap_lenrek e725771b5d libdraw: use readn() to read headers and Fontchar array
the Fontchar array might be bigger than the i/o unit,
so we have to use readn() to properly read it.
2015-03-01 05:39:45 +01:00
cinap_lenrek 4235556c16 libdraw: check fontchar count in openmemsubfont() and readsubfont() 2015-02-24 03:30:21 +01:00
cinap_lenrek 5f8cacd2de libdraw: cleanup getsubfont() 2015-02-24 03:25:26 +01:00
cinap_lenrek 8b95dad208 libdraw: fix broken eenter()
eenter would go into a endless loop in the redraw avoidance case
because the label was misplaced.
2015-01-18 10:34:05 +01:00
mischief f6a9db1bd9 libdraw: don't redraw input box in enter/eenter when mouse is moved outside the rectangle
prevents some flickering when devdraw is used over a high latency connection.

Fixes issue 236
2015-01-09 15:41:00 -08:00
mischief fa06413db4 libdraw: don't deference nil display in freefont 2014-12-28 23:11:21 -08:00
cinap_lenrek ea80ea451d libdraw: fix atomouse 2014-11-06 04:42:20 +01:00
cinap_lenrek 168b9f3de4 libdraw: add missing borderop() (thanks aiju) 2014-07-21 18:10:58 +02:00
cinap_lenrek 2c0490a26e libdraw: fix zero stringwidth() bug
stringwidth() and string() sometimes failed spuriously due
to the wrong assumption that cachechars() will only fail
when a different subfont is needed. in fact, cachechars()
can fail for other reasons like when it resizes the fontcache
(or fails todo so).

theres also the case when loadchar() is unable to translate
a character and returns 0. this case needs to be differentiated
from such temporary conditions like fontcache resize or subfont
load to stop the retry loop in string() and stringwidth().

now cachechars() returns -1 to indicate that it cannot
proceed and we test this in string() and stringwidth()
to skip over untranslatable characters to make progress
instead of retrying.
2014-03-10 06:41:45 +01:00
cinap_lenrek b5d47d6deb libdraw: fix typo: 0xfffff -> 0xffff 2014-02-03 03:56:01 +01:00
cinap_lenrek 5fd52f6241 libdraw: work arround devdraw truncating screenid as 16bit 2014-02-03 03:53:18 +01:00
cinap_lenrek d77455ab2d libdraw: use pid as initial screenid so one can have more than 25 windows. 2014-02-01 09:53:08 +01:00
cinap_lenrek aa8f8d866b libdraw: cleanup string() and stringwidth()
getting rid of the goto at the end of the while
loop by moving the if(subfontnae) case before
the cachechars() call.
2014-01-10 01:19:14 +01:00
cinap_lenrek e3b4950966 libdraw: fix stringwidth problems
cachechars() used to skip over characters on its own when
loadchar() could not find the character or a PJW replacement.
this resulted in wrong width calculation. now we just return
and handle the case inside _string and _stringwidth.

fix subfont leak in stringwidth()

remove annoying prints in stringwidth()
2014-01-06 03:49:14 +01:00
cinap_lenrek 0be917ff4d libdraw: make newwindow() unmount the old window
newwindow() used to mount the new window directly on /dev, resulting
in the old window and the new one being mounted over each other.

we now try to unmount the old window from /dev first, mount new
window to /mnt/wsys (replacing the old) and then bind /mnt/wsys
before /dev.

if theres no /mnt/wsys, just mount window directly before /dev.
2013-10-04 15:57:05 +02:00
cinap_lenrek 8556b8dae1 libevent: drop queued mouse events
the changeset r541ead66e8af:

"libdraw: make ebread() return buffer immidiately if available"

makes mouse sluggish when the program cant keep up as mouse
events queue up. this more or less restores the original
behaviour but only for mouse events.
2013-09-18 01:54:22 +02:00
cinap_lenrek 508b53a29a libdraw: fix leftover processes or programs failing to restore window labels when receiving interrupt note
fix the default note handler for event programs. only handle non system
notes or notes in the slave processes. for interrupt in the main process,
just call exits() which will do the cleanup and restore window label
properly.

this makes completely overriding the note handler in gping and
stats uneccesary.
2013-08-13 21:46:13 +02:00
cinap_lenrek 09d465a976 libdraw: make ebread() return buffer immidiately if available, cleanup
this reduces number of syscalls and improves performance for vt
2013-08-11 08:31:53 +02:00