Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/vt/vt_core.c
Show First 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | vt_schedule_flush(struct vt_device *vd, int ms) | ||||
callout_schedule(&vd->vd_timer, hz / (1000 / ms)); | callout_schedule(&vd->vd_timer, hz / (1000 / ms)); | ||||
} | } | ||||
static void | static void | ||||
vt_resume_flush_timer(struct vt_device *vd, int ms) | vt_resume_flush_timer(struct vt_device *vd, int ms) | ||||
{ | { | ||||
if (!atomic_cmpset_int(&vd->vd_timer_armed, 0, 1)) | if (!(vd->vd_flags & VDF_ASYNC) || | ||||
!atomic_cmpset_int(&vd->vd_timer_armed, 0, 1)) | |||||
return; | return; | ||||
vt_schedule_flush(vd, ms); | vt_schedule_flush(vd, ms); | ||||
} | } | ||||
static void | static void | ||||
vt_suspend_flush_timer(struct vt_device *vd) | vt_suspend_flush_timer(struct vt_device *vd) | ||||
{ | { | ||||
if (!atomic_cmpset_int(&vd->vd_timer_armed, 1, 0)) | if (!(vd->vd_flags & VDF_ASYNC) || | ||||
!atomic_cmpset_int(&vd->vd_timer_armed, 1, 0)) | |||||
return; | return; | ||||
callout_drain(&vd->vd_timer); | callout_drain(&vd->vd_timer); | ||||
} | } | ||||
static void | static void | ||||
vt_switch_timer(void *arg) | vt_switch_timer(void *arg) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | vt_scroll(struct vt_window *vw, int offset, int whence) | ||||
/* | /* | ||||
* Offset changed, please update Nth lines on screen. | * Offset changed, please update Nth lines on screen. | ||||
* +N - Nth lines at top; | * +N - Nth lines at top; | ||||
* -N - Nth lines at bottom. | * -N - Nth lines at bottom. | ||||
*/ | */ | ||||
if (diff < -size.tp_row || diff > size.tp_row) { | if (diff < -size.tp_row || diff > size.tp_row) { | ||||
vw->vw_device->vd_flags |= VDF_INVALID; | vw->vw_device->vd_flags |= VDF_INVALID; | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
return; | return; | ||||
} | } | ||||
vw->vw_device->vd_flags |= VDF_INVALID; /*XXX*/ | vw->vw_device->vd_flags |= VDF_INVALID; /*XXX*/ | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
} | } | ||||
static int | static int | ||||
vt_machine_kbdevent(int c) | vt_machine_kbdevent(int c) | ||||
{ | { | ||||
switch (c) { | switch (c) { | ||||
case SPCLKEY | DBG: | case SPCLKEY | DBG: | ||||
▲ Show 20 Lines • Show All 296 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void | static void | ||||
vtterm_cursor(struct terminal *tm, const term_pos_t *p) | vtterm_cursor(struct terminal *tm, const term_pos_t *p) | ||||
{ | { | ||||
struct vt_window *vw = tm->tm_softc; | struct vt_window *vw = tm->tm_softc; | ||||
vtbuf_cursor_position(&vw->vw_buf, p); | vtbuf_cursor_position(&vw->vw_buf, p); | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
} | } | ||||
static void | static void | ||||
vtterm_putchar(struct terminal *tm, const term_pos_t *p, term_char_t c) | vtterm_putchar(struct terminal *tm, const term_pos_t *p, term_char_t c) | ||||
{ | { | ||||
struct vt_window *vw = tm->tm_softc; | struct vt_window *vw = tm->tm_softc; | ||||
vtbuf_putchar(&vw->vw_buf, p, c); | vtbuf_putchar(&vw->vw_buf, p, c); | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
} | } | ||||
static void | static void | ||||
vtterm_fill(struct terminal *tm, const term_rect_t *r, term_char_t c) | vtterm_fill(struct terminal *tm, const term_rect_t *r, term_char_t c) | ||||
{ | { | ||||
struct vt_window *vw = tm->tm_softc; | struct vt_window *vw = tm->tm_softc; | ||||
vtbuf_fill_locked(&vw->vw_buf, r, c); | vtbuf_fill_locked(&vw->vw_buf, r, c); | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
} | } | ||||
static void | static void | ||||
vtterm_copy(struct terminal *tm, const term_rect_t *r, | vtterm_copy(struct terminal *tm, const term_rect_t *r, | ||||
const term_pos_t *p) | const term_pos_t *p) | ||||
{ | { | ||||
struct vt_window *vw = tm->tm_softc; | struct vt_window *vw = tm->tm_softc; | ||||
vtbuf_copy(&vw->vw_buf, r, p); | vtbuf_copy(&vw->vw_buf, r, p); | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
} | } | ||||
static void | static void | ||||
vtterm_param(struct terminal *tm, int cmd, unsigned int arg) | vtterm_param(struct terminal *tm, int cmd, unsigned int arg) | ||||
{ | { | ||||
struct vt_window *vw = tm->tm_softc; | struct vt_window *vw = tm->tm_softc; | ||||
switch (cmd) { | switch (cmd) { | ||||
case TP_SHOWCURSOR: | case TP_SHOWCURSOR: | ||||
vtbuf_cursor_visibility(&vw->vw_buf, arg); | vtbuf_cursor_visibility(&vw->vw_buf, arg); | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
break; | break; | ||||
case TP_MOUSE: | case TP_MOUSE: | ||||
vw->vw_mouse_level = arg; | vw->vw_mouse_level = arg; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
void | void | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | if (vf != NULL) { | ||||
area.tr_end.tp_col = x + 2; | area.tr_end.tp_col = x + 2; | ||||
area.tr_end.tp_row = y + 2; | area.tr_end.tp_row = y + 2; | ||||
} | } | ||||
vtbuf_dirty(&vw->vw_buf, &area); | vtbuf_dirty(&vw->vw_buf, &area); | ||||
} | } | ||||
#endif | #endif | ||||
static void | static int | ||||
vt_flush(struct vt_device *vd) | vt_flush(struct vt_device *vd) | ||||
{ | { | ||||
struct vt_window *vw; | struct vt_window *vw; | ||||
struct vt_font *vf; | struct vt_font *vf; | ||||
struct vt_bufmask tmask; | struct vt_bufmask tmask; | ||||
term_rect_t tarea; | term_rect_t tarea; | ||||
term_pos_t size; | term_pos_t size; | ||||
#ifndef SC_NO_CUTPASTE | #ifndef SC_NO_CUTPASTE | ||||
int cursor_was_shown, cursor_moved; | int cursor_was_shown, cursor_moved; | ||||
#endif | #endif | ||||
vw = vd->vd_curwindow; | vw = vd->vd_curwindow; | ||||
if (vw == NULL) | if (vw == NULL) | ||||
return; | return (0); | ||||
if (vd->vd_flags & VDF_SPLASH || vw->vw_flags & VWF_BUSY) | if (vd->vd_flags & VDF_SPLASH || vw->vw_flags & VWF_BUSY) | ||||
return; | return (0); | ||||
vf = vw->vw_font; | vf = vw->vw_font; | ||||
if (((vd->vd_flags & VDF_TEXTMODE) == 0) && (vf == NULL)) | if (((vd->vd_flags & VDF_TEXTMODE) == 0) && (vf == NULL)) | ||||
return; | return (0); | ||||
#ifndef SC_NO_CUTPASTE | #ifndef SC_NO_CUTPASTE | ||||
cursor_was_shown = vd->vd_mshown; | cursor_was_shown = vd->vd_mshown; | ||||
cursor_moved = (vd->vd_mx != vd->vd_mx_drawn || | cursor_moved = (vd->vd_mx != vd->vd_mx_drawn || | ||||
vd->vd_my != vd->vd_my_drawn); | vd->vd_my != vd->vd_my_drawn); | ||||
/* Check if the cursor should be displayed or not. */ | /* Check if the cursor should be displayed or not. */ | ||||
if ((vd->vd_flags & VDF_MOUSECURSOR) && /* Mouse support enabled. */ | if ((vd->vd_flags & VDF_MOUSECURSOR) && /* Mouse support enabled. */ | ||||
Show All 37 Lines | if (vd->vd_flags & VDF_INVALID) { | ||||
tarea.tr_end = size; | tarea.tr_end = size; | ||||
tmask.vbm_row = tmask.vbm_col = VBM_DIRTY; | tmask.vbm_row = tmask.vbm_col = VBM_DIRTY; | ||||
vd->vd_flags &= ~VDF_INVALID; | vd->vd_flags &= ~VDF_INVALID; | ||||
} | } | ||||
if (tarea.tr_begin.tp_col < tarea.tr_end.tp_col) { | if (tarea.tr_begin.tp_col < tarea.tr_end.tp_col) { | ||||
vd->vd_driver->vd_bitblt_text(vd, vw, &tarea); | vd->vd_driver->vd_bitblt_text(vd, vw, &tarea); | ||||
return (1); | |||||
} | } | ||||
return (0); | |||||
} | } | ||||
static void | static void | ||||
vt_timer(void *arg) | vt_timer(void *arg) | ||||
{ | { | ||||
struct vt_device *vd; | struct vt_device *vd; | ||||
int changed; | |||||
vd = arg; | vd = arg; | ||||
/* Update screen if required. */ | /* Update screen if required. */ | ||||
vt_flush(vd); | changed = vt_flush(vd); | ||||
/* Schedule for next update. */ | /* Schedule for next update. */ | ||||
if (changed) | |||||
vt_schedule_flush(vd, 0); | vt_schedule_flush(vd, 0); | ||||
else | |||||
vd->vd_timer_armed = 0; | |||||
} | } | ||||
static void | static void | ||||
vtterm_done(struct terminal *tm) | vtterm_done(struct terminal *tm) | ||||
{ | { | ||||
struct vt_window *vw = tm->tm_softc; | struct vt_window *vw = tm->tm_softc; | ||||
struct vt_device *vd = vw->vw_device; | struct vt_device *vd = vw->vw_device; | ||||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | if (vw->vw_font != vf) { | ||||
vtfont_unref(vw->vw_font); | vtfont_unref(vw->vw_font); | ||||
vw->vw_font = vtfont_ref(vf); | vw->vw_font = vtfont_ref(vf); | ||||
} | } | ||||
/* Force a full redraw the next timer tick. */ | /* Force a full redraw the next timer tick. */ | ||||
if (vd->vd_curwindow == vw) { | if (vd->vd_curwindow == vw) { | ||||
vt_set_border(vw, vf, TC_BLACK); | vt_set_border(vw, vf, TC_BLACK); | ||||
vd->vd_flags |= VDF_INVALID; | vd->vd_flags |= VDF_INVALID; | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
} | } | ||||
vw->vw_flags &= ~VWF_BUSY; | vw->vw_flags &= ~VWF_BUSY; | ||||
VT_UNLOCK(vd); | VT_UNLOCK(vd); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
vt_proc_alive(struct vt_window *vw) | vt_proc_alive(struct vt_window *vw) | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | case MOUSE_MOTION_EVENT: | ||||
y = MAX(y, 0); | y = MAX(y, 0); | ||||
x = MIN(x, (size.tp_col * vf->vf_width) - 1); | x = MIN(x, (size.tp_col * vf->vf_width) - 1); | ||||
y = MIN(y, (size.tp_row * vf->vf_height) - 1); | y = MIN(y, (size.tp_row * vf->vf_height) - 1); | ||||
vd->vd_mx = x; | vd->vd_mx = x; | ||||
vd->vd_my = y; | vd->vd_my = y; | ||||
if ((vd->vd_mstate & MOUSE_BUTTON1DOWN) && | if ((vd->vd_mstate & MOUSE_BUTTON1DOWN) && | ||||
(vtbuf_set_mark(&vw->vw_buf, VTB_MARK_MOVE, | (vtbuf_set_mark(&vw->vw_buf, VTB_MARK_MOVE, | ||||
vd->vd_mx / vf->vf_width, | vd->vd_mx / vf->vf_width, | ||||
vd->vd_my / vf->vf_height) == 1)) { | vd->vd_my / vf->vf_height) == 1)) { | ||||
/* | /* | ||||
* We have something marked to copy, so update pointer | * We have something marked to copy, so update pointer | ||||
* to window with selection. | * to window with selection. | ||||
*/ | */ | ||||
vd->vd_markedwin = vw; | vd->vd_markedwin = vw; | ||||
} | } | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
return; /* Done */ | return; /* Done */ | ||||
case MOUSE_BUTTON_EVENT: | case MOUSE_BUTTON_EVENT: | ||||
/* Buttons */ | /* Buttons */ | ||||
break; | break; | ||||
default: | default: | ||||
return; /* Done */ | return; /* Done */ | ||||
} | } | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | vt_mouse_event(int type, int x, int y, int event, int cnt, int mlevel) | ||||
if (vtbuf_set_mark(&vw->vw_buf, mark, vd->vd_mx / vf->vf_width, | if (vtbuf_set_mark(&vw->vw_buf, mark, vd->vd_mx / vf->vf_width, | ||||
vd->vd_my / vf->vf_height) == 1) { | vd->vd_my / vf->vf_height) == 1) { | ||||
/* | /* | ||||
* We have something marked to copy, so update pointer to | * We have something marked to copy, so update pointer to | ||||
* window with selection. | * window with selection. | ||||
*/ | */ | ||||
vd->vd_markedwin = vw; | vd->vd_markedwin = vw; | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
} | } | ||||
} | } | ||||
void | void | ||||
vt_mouse_state(int show) | vt_mouse_state(int show) | ||||
{ | { | ||||
struct vt_device *vd; | struct vt_device *vd; | ||||
struct vt_window *vw; | struct vt_window *vw; | ||||
vd = main_vd; | vd = main_vd; | ||||
vw = vd->vd_curwindow; | vw = vd->vd_curwindow; | ||||
switch (show) { | switch (show) { | ||||
case VT_MOUSE_HIDE: | case VT_MOUSE_HIDE: | ||||
vw->vw_flags |= VWF_MOUSE_HIDE; | vw->vw_flags |= VWF_MOUSE_HIDE; | ||||
break; | break; | ||||
case VT_MOUSE_SHOW: | case VT_MOUSE_SHOW: | ||||
vw->vw_flags &= ~VWF_MOUSE_HIDE; | vw->vw_flags &= ~VWF_MOUSE_HIDE; | ||||
break; | break; | ||||
} | } | ||||
/* Mark mouse position as dirty. */ | /* Mark mouse position as dirty. */ | ||||
vt_mark_mouse_position_as_dirty(vd); | vt_mark_mouse_position_as_dirty(vd); | ||||
vt_resume_flush_timer(vw->vw_device, 0); | |||||
} | } | ||||
#endif | #endif | ||||
static int | static int | ||||
vtterm_mmap(struct terminal *tm, vm_ooffset_t offset, vm_paddr_t * paddr, | vtterm_mmap(struct terminal *tm, vm_ooffset_t offset, vm_paddr_t * paddr, | ||||
int nprot, vm_memattr_t *memattr) | int nprot, vm_memattr_t *memattr) | ||||
{ | { | ||||
struct vt_window *vw = tm->tm_softc; | struct vt_window *vw = tm->tm_softc; | ||||
▲ Show 20 Lines • Show All 635 Lines • Show Last 20 Lines |