From 0f49db6e47ba8501ac0f1db2ceee49e3e04ad2c8 Mon Sep 17 00:00:00 2001 From: Aleksandr Rybalko Date: Mon, 9 Dec 2013 15:01:34 +0000 Subject: [PATCH] Respect SC_NO_CUTPASTE option. It disable mouse cursor and cut/paste support for vt(9). Note: /dev/sysmouse not affected. Sponsored by: The FreeBSD Foundation --- sys/dev/vt/font/vt_mouse_cursor.c | 2 ++ sys/dev/vt/vt.h | 12 +++++++++--- sys/dev/vt/vt_buf.c | 4 ++++ sys/dev/vt/vt_core.c | 12 +++++++++++- sys/dev/vt/vt_sysmouse.c | 6 ++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/sys/dev/vt/font/vt_mouse_cursor.c b/sys/dev/vt/font/vt_mouse_cursor.c index 20fbcd8a661e..a35de006a654 100644 --- a/sys/dev/vt/font/vt_mouse_cursor.c +++ b/sys/dev/vt/font/vt_mouse_cursor.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include +#ifndef SC_NO_CUTPASTE struct mouse_cursor vt_default_mouse_pointer = { .map = { 0x00, /* "__ " */ @@ -66,3 +67,4 @@ struct mouse_cursor vt_default_mouse_pointer = { .w = 8, .h = 13, }; +#endif diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index 3956cfc91daf..bec4e441a100 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -181,15 +181,17 @@ void vtbuf_init(struct vt_buf *, const term_pos_t *); void vtbuf_grow(struct vt_buf *, const term_pos_t *, int); void vtbuf_putchar(struct vt_buf *, const term_pos_t *, term_char_t); void vtbuf_cursor_position(struct vt_buf *, const term_pos_t *); -void vtbuf_mouse_cursor_position(struct vt_buf *vb, int col, int row); -void vtbuf_cursor_visibility(struct vt_buf *, int); void vtbuf_scroll_mode(struct vt_buf *vb, int yes); void vtbuf_undirty(struct vt_buf *, term_rect_t *, struct vt_bufmask *); void vtbuf_sethistory_size(struct vt_buf *, int); -int vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row); int vtbuf_iscursor(struct vt_buf *vb, int row, int col); +void vtbuf_cursor_visibility(struct vt_buf *, int); +#ifndef SC_NO_CUTPASTE +void vtbuf_mouse_cursor_position(struct vt_buf *vb, int col, int row); +int vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row); int vtbuf_get_marked_len(struct vt_buf *vb); void vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz); +#endif #define VTB_MARK_NONE 0 #define VTB_MARK_END 1 @@ -389,12 +391,14 @@ struct vt_font { unsigned int vf_refcount; }; +#ifndef SC_NO_CUTPASTE struct mouse_cursor { uint8_t map[64 * 64 / 8]; uint8_t mask[64 * 64 / 8]; uint8_t w; uint8_t h; }; +#endif const uint8_t *vtfont_lookup(const struct vt_font *vf, term_char_t c); struct vt_font *vtfont_ref(struct vt_font *vf); @@ -403,8 +407,10 @@ int vtfont_load(vfnt_t *f, struct vt_font **ret); /* Sysmouse. */ void sysmouse_process_event(mouse_info_t *mi); +#ifndef SC_NO_CUTPASTE void vt_mouse_event(int type, int x, int y, int event, int cnt); void vt_mouse_state(int show); +#endif #define VT_MOUSE_SHOW 1 #define VT_MOUSE_HIDE 0 diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index ad42312d0d7e..0b078ecbfd6c 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -135,6 +135,7 @@ vthistory_getpos(const struct vt_buf *vb, unsigned int *offset) *offset = vb->vb_roffset; } +#ifndef SC_NO_CUTPASTE /* Only mouse support use it now. */ /* Translate current view row number to history row. */ static int vtbuf_wth(struct vt_buf *vb, int row) @@ -142,6 +143,7 @@ vtbuf_wth(struct vt_buf *vb, int row) return ((vb->vb_roffset + row) % vb->vb_history_size); } +#endif /* Translate history row to current view row number. */ static int @@ -531,6 +533,7 @@ vtbuf_cursor_position(struct vt_buf *vb, const term_pos_t *p) } } +#ifndef SC_NO_CUTPASTE void vtbuf_mouse_cursor_position(struct vt_buf *vb, int col, int row) { @@ -691,6 +694,7 @@ vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row) vtbuf_flush_mark(vb); return (1); } +#endif void vtbuf_cursor_visibility(struct vt_buf *vb, int yes) diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index c59c95ee4e5e..c23341d96006 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -127,7 +127,9 @@ extern unsigned char vt_logo_image[]; /* Font. */ extern struct vt_font vt_font_default; +#ifndef SC_NO_CUTPASTE extern struct mouse_cursor vt_default_mouse_pointer; +#endif static int signal_vt_rel(struct vt_window *); static int signal_vt_acq(struct vt_window *); @@ -689,12 +691,14 @@ vt_flush(struct vt_device *vd) struct vt_window *vw = vd->vd_curwindow; struct vt_font *vf = vw->vw_font; struct vt_bufmask tmask; - struct mouse_cursor *m; unsigned int row, col; term_rect_t tarea; term_pos_t size; term_char_t *r; +#ifndef SC_NO_CUTPASTE + struct mouse_cursor *m; int bpl, h, w; +#endif if (vd->vd_flags & VDF_SPLASH || vw->vw_flags & VWF_BUSY) return; @@ -711,11 +715,13 @@ vt_flush(struct vt_device *vd) vd->vd_flags &= ~VDF_INVALID; } +#ifndef SC_NO_CUTPASTE if ((vw->vw_flags & VWF_MOUSE_HIDE) == 0) { /* Mark last mouse position as dirty to erase. */ vtbuf_mouse_cursor_position(&vw->vw_buf, vd->vd_mdirtyx, vd->vd_mdirtyy); } +#endif for (row = tarea.tr_begin.tp_row; row < tarea.tr_end.tp_row; row++) { if (!VTBUF_DIRTYROW(&tmask, row)) @@ -731,6 +737,7 @@ vt_flush(struct vt_device *vd) } } +#ifndef SC_NO_CUTPASTE /* Mouse disabled. */ if (vw->vw_flags & VWF_MOUSE_HIDE) return; @@ -759,6 +766,7 @@ vt_flush(struct vt_device *vd) vd->vd_mdirtyx = vd->vd_mx / vf->vf_width; vd->vd_mdirtyy = vd->vd_my / vf->vf_height; } +#endif } static void @@ -1106,6 +1114,7 @@ finish_vt_acq(struct vt_window *vw) return (EINVAL); } +#ifndef SC_NO_CUTPASTE void vt_mouse_event(int type, int x, int y, int event, int cnt) { @@ -1265,6 +1274,7 @@ vt_mouse_state(int show) break; } } +#endif static int vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data, diff --git a/sys/dev/vt/vt_sysmouse.c b/sys/dev/vt/vt_sysmouse.c index b0598e484a78..c46887fd5e24 100644 --- a/sys/dev/vt/vt_sysmouse.c +++ b/sys/dev/vt/vt_sysmouse.c @@ -190,9 +190,11 @@ sysmouse_process_event(mouse_info_t *mi) sysmouse_buf_store(buf); +#ifndef SC_NO_CUTPASTE mtx_unlock(&sysmouse_lock); vt_mouse_event(mi->operation, x, y, mi->u.event.id, mi->u.event.value); return; +#endif done: mtx_unlock(&sysmouse_lock); } @@ -345,7 +347,9 @@ sysmouse_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, return (EINVAL); sysmouse_level = level; +#ifndef SC_NO_CUTPASTE vt_mouse_state((level == 0)?VT_MOUSE_SHOW:VT_MOUSE_HIDE); +#endif return (0); } case MOUSE_SETMODE: { @@ -358,8 +362,10 @@ sysmouse_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, case 0: case 1: sysmouse_level = mode->level; +#ifndef SC_NO_CUTPASTE vt_mouse_state((mode->level == 0)?VT_MOUSE_SHOW: VT_MOUSE_HIDE); +#endif break; default: return (EINVAL);