Fix the bug which always reallocated the cut buffer whenever

the screen mode is changed even if another vty has larger size.
Reallocate the buffer only when the new screen size is larger than
the current cut buffer size.
This commit is contained in:
yokota 1998-08-03 09:17:06 +00:00
parent 5f159ea0f8
commit 90b8790965
3 changed files with 54 additions and 21 deletions

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.268 1998/08/03 09:09:34 yokota Exp $
* $Id: syscons.c,v 1.269 1998/08/03 09:15:36 yokota Exp $
*/
#include "sc.h"
@ -184,6 +184,7 @@ static char vgaregs[MODE_PARAM_SIZE];
static char vgaregs2[MODE_PARAM_SIZE];
static int rows_offset = 1;
static char *cut_buffer;
static int cut_buffer_size;
static int mouse_level = 0; /* sysmouse protocol level */
static mousestatus_t mouse_status = { 0, 0, 0, 0, 0, 0 };
static u_short mouse_and_mask[16] = {
@ -720,7 +721,10 @@ scattach(struct isa_device *dev)
scp = console[0];
if (crtc_vga) {
cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
cut_buffer_size = scp->xsize * scp->ysize + 1;
cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
if (cut_buffer != NULL)
cut_buffer[0] = '\0';
}
scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short),
@ -1289,7 +1293,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
else
psignal(cur_console->mouse_proc, cur_console->mouse_signal);
}
else if (mouse->operation == MOUSE_ACTION) {
else if (mouse->operation == MOUSE_ACTION && cut_buffer != NULL) {
/* process button presses */
if ((cur_console->mouse_buttons ^ mouse->u.data.buttons) &&
!(cur_console->status & UNKNOWN_MODE)) {
@ -1356,7 +1360,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
break;
}
if (cur_console->status & UNKNOWN_MODE)
if ((cur_console->status & UNKNOWN_MODE) || (cut_buffer == NULL))
break;
switch (mouse->u.event.id) {
@ -1641,9 +1645,16 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
scp->mouse_pos = scp->mouse_oldpos =
scp->scr_buf + (scp->mouse_ypos / scp->font_size) * scp->xsize
+ scp->mouse_xpos / 8;
free(cut_buffer, M_DEVBUF);
cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
cut_buffer[0] = 0x00;
/* allocate a larger cut buffer if necessary */
if ((cut_buffer == NULL)
|| (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
if (cut_buffer != NULL)
free(cut_buffer, M_DEVBUF);
cut_buffer_size = scp->xsize * scp->ysize + 1;
cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
if (cut_buffer != NULL)
cut_buffer[0] = '\0';
}
splx(s);
usp = scp->history;

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.268 1998/08/03 09:09:34 yokota Exp $
* $Id: syscons.c,v 1.269 1998/08/03 09:15:36 yokota Exp $
*/
#include "sc.h"
@ -184,6 +184,7 @@ static char vgaregs[MODE_PARAM_SIZE];
static char vgaregs2[MODE_PARAM_SIZE];
static int rows_offset = 1;
static char *cut_buffer;
static int cut_buffer_size;
static int mouse_level = 0; /* sysmouse protocol level */
static mousestatus_t mouse_status = { 0, 0, 0, 0, 0, 0 };
static u_short mouse_and_mask[16] = {
@ -720,7 +721,10 @@ scattach(struct isa_device *dev)
scp = console[0];
if (crtc_vga) {
cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
cut_buffer_size = scp->xsize * scp->ysize + 1;
cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
if (cut_buffer != NULL)
cut_buffer[0] = '\0';
}
scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short),
@ -1289,7 +1293,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
else
psignal(cur_console->mouse_proc, cur_console->mouse_signal);
}
else if (mouse->operation == MOUSE_ACTION) {
else if (mouse->operation == MOUSE_ACTION && cut_buffer != NULL) {
/* process button presses */
if ((cur_console->mouse_buttons ^ mouse->u.data.buttons) &&
!(cur_console->status & UNKNOWN_MODE)) {
@ -1356,7 +1360,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
break;
}
if (cur_console->status & UNKNOWN_MODE)
if ((cur_console->status & UNKNOWN_MODE) || (cut_buffer == NULL))
break;
switch (mouse->u.event.id) {
@ -1641,9 +1645,16 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
scp->mouse_pos = scp->mouse_oldpos =
scp->scr_buf + (scp->mouse_ypos / scp->font_size) * scp->xsize
+ scp->mouse_xpos / 8;
free(cut_buffer, M_DEVBUF);
cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
cut_buffer[0] = 0x00;
/* allocate a larger cut buffer if necessary */
if ((cut_buffer == NULL)
|| (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
if (cut_buffer != NULL)
free(cut_buffer, M_DEVBUF);
cut_buffer_size = scp->xsize * scp->ysize + 1;
cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
if (cut_buffer != NULL)
cut_buffer[0] = '\0';
}
splx(s);
usp = scp->history;

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.268 1998/08/03 09:09:34 yokota Exp $
* $Id: syscons.c,v 1.269 1998/08/03 09:15:36 yokota Exp $
*/
#include "sc.h"
@ -184,6 +184,7 @@ static char vgaregs[MODE_PARAM_SIZE];
static char vgaregs2[MODE_PARAM_SIZE];
static int rows_offset = 1;
static char *cut_buffer;
static int cut_buffer_size;
static int mouse_level = 0; /* sysmouse protocol level */
static mousestatus_t mouse_status = { 0, 0, 0, 0, 0, 0 };
static u_short mouse_and_mask[16] = {
@ -720,7 +721,10 @@ scattach(struct isa_device *dev)
scp = console[0];
if (crtc_vga) {
cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
cut_buffer_size = scp->xsize * scp->ysize + 1;
cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
if (cut_buffer != NULL)
cut_buffer[0] = '\0';
}
scp->scr_buf = (u_short *)malloc(scp->xsize*scp->ysize*sizeof(u_short),
@ -1289,7 +1293,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
else
psignal(cur_console->mouse_proc, cur_console->mouse_signal);
}
else if (mouse->operation == MOUSE_ACTION) {
else if (mouse->operation == MOUSE_ACTION && cut_buffer != NULL) {
/* process button presses */
if ((cur_console->mouse_buttons ^ mouse->u.data.buttons) &&
!(cur_console->status & UNKNOWN_MODE)) {
@ -1356,7 +1360,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
break;
}
if (cur_console->status & UNKNOWN_MODE)
if ((cur_console->status & UNKNOWN_MODE) || (cut_buffer == NULL))
break;
switch (mouse->u.event.id) {
@ -1641,9 +1645,16 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
scp->mouse_pos = scp->mouse_oldpos =
scp->scr_buf + (scp->mouse_ypos / scp->font_size) * scp->xsize
+ scp->mouse_xpos / 8;
free(cut_buffer, M_DEVBUF);
cut_buffer = (char *)malloc(scp->xsize*scp->ysize, M_DEVBUF, M_NOWAIT);
cut_buffer[0] = 0x00;
/* allocate a larger cut buffer if necessary */
if ((cut_buffer == NULL)
|| (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
if (cut_buffer != NULL)
free(cut_buffer, M_DEVBUF);
cut_buffer_size = scp->xsize * scp->ysize + 1;
cut_buffer = (char *)malloc(cut_buffer_size, M_DEVBUF, M_NOWAIT);
if (cut_buffer != NULL)
cut_buffer[0] = '\0';
}
splx(s);
usp = scp->history;