diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-12-02 18:16:15 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-12-02 18:16:15 +0000 |
commit | 454e3933178feb98d9085f503b05f0fb02fb877d (patch) | |
tree | fbe6d492e38c59d0d533f650e8db62061834b4e5 | |
parent | cdb45c5afbeb2ba38f5dc9393f66045604b6b75d (diff) |
Use a better strategy to make the mouse pointer visible in inverse_char();
also check the return value of alloc_attr() for failure.
No functional change.
-rw-r--r-- | sys/dev/wscons/wsdisplay.c | 33 | ||||
-rw-r--r-- | sys/dev/wscons/wsmoused.h | 8 |
2 files changed, 29 insertions, 12 deletions
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c index e79c530e9ab..eba6c54609f 100644 --- a/sys/dev/wscons/wsdisplay.c +++ b/sys/dev/wscons/wsdisplay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsdisplay.c,v 1.73 2006/11/29 19:12:53 miod Exp $ */ +/* $OpenBSD: wsdisplay.c,v 1.74 2006/12/02 18:16:14 miod Exp $ */ /* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */ /* @@ -2401,16 +2401,39 @@ mouse_moverel(char dx, char dy) void inverse_char(unsigned short pos) { + struct wsscreen_internal *dconf; struct wsdisplay_charcell cell; int fg, bg, ul; + int flags; + int tmp; + long attr; + + dconf = sc->sc_focus->scr_dconf; GETCHAR(pos, &cell); - UNPACKATTR(cell.attr, &fg, &bg, &ul); - ALLOCATTR(bg, fg, WSATTR_WSCOLORS | (ul ? WSATTR_UNDERLINE : 0), - &cell.attr); + (*dconf->emulops->unpack_attr)(dconf->emulcookie, cell.attr, &fg, + &bg, &ul); - PUTCHAR(pos, cell.uc, cell.attr); + /* + * Display the mouse cursor as a color inverted cell whenever + * possible. If this is not possible, ask for the video reverse + * attribute. + */ + flags = 0; + if (dconf->scrdata->capabilities & WSSCREEN_WSCOLORS) { + flags |= WSATTR_WSCOLORS; + tmp = fg; + fg = bg; + bg = tmp; + } else if (dconf->scrdata->capabilities & WSSCREEN_REVERSE) { + flags |= WSATTR_REVERSE; + } + if ((*dconf->emulops->alloc_attr)(dconf->emulcookie, fg, bg, flags | + (ul ? WSATTR_UNDERLINE : 0), &attr) == 0) { + cell.attr = attr; + PUTCHAR(pos, cell.uc, cell.attr); + } } void diff --git a/sys/dev/wscons/wsmoused.h b/sys/dev/wscons/wsmoused.h index 1f04bec24c6..c25c429d409 100644 --- a/sys/dev/wscons/wsmoused.h +++ b/sys/dev/wscons/wsmoused.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmoused.h,v 1.6 2006/11/29 19:11:17 miod Exp $ */ +/* $OpenBSD: wsmoused.h,v 1.7 2006/12/02 18:16:14 miod Exp $ */ /* * Copyright (c) 2001 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon @@ -113,12 +113,6 @@ extern char Paste_avail; /* flag, to indicate whether a selection is in the ((*sc->sc_focus->scr_dconf->emulops->putchar) \ (sc->sc_focus->scr_dconf->emulcookie, ((pos) / N_COLS), \ ((pos) % N_COLS), (uc), (attr))) -#define UNPACKATTR(attr, fgp, bgp, ulp) \ - ((*sc->sc_focus->scr_dconf->emulops->unpack_attr) \ - (sc->sc_focus->scr_dconf->emulcookie, attr, fgp, bgp, ulp)) -#define ALLOCATTR(fg, bg, flags, attrp) \ - ((*sc->sc_focus->scr_dconf->emulops->alloc_attr) \ - (sc->sc_focus->scr_dconf->emulcookie, fg, bg, flags, attrp)) #define MOUSE_COPY_BUTTON 0 #define MOUSE_PASTE_BUTTON 1 |