diff --git a/lib/libvgl/main.c b/lib/libvgl/main.c index 09d646892c23..b409327b3f4c 100644 --- a/lib/libvgl/main.c +++ b/lib/libvgl/main.c @@ -77,7 +77,7 @@ struct vt_mode smode; signal(SIGUSR2, SIG_IGN); VGLSwitchPending = 0; VGLAbortPending = 0; - VGLMousePointerHide(); + VGLMouseMode(VGL_MOUSEHIDE); if (VGLMem != MAP_FAILED) { VGLClear(VGLDisplay, 0); diff --git a/lib/libvgl/mouse.c b/lib/libvgl/mouse.c index 0e058cdf9d16..6b3ebaa40e5a 100644 --- a/lib/libvgl/mouse.c +++ b/lib/libvgl/mouse.c @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include #include "vgl.h" +static void VGLMouseAction(int dummy); + #define BORDER 0xff /* default border -- light white in rgb 3:3:2 */ #define INTERIOR 0xa0 /* default interior -- red in rgb 3:3:2 */ #define X 0xff /* any nonzero in And mask means part of cursor */ @@ -88,7 +90,6 @@ static VGLBitmap VGLMouseStdAndMask = static VGLBitmap VGLMouseStdOrMask = VGLBITMAP_INITIALIZER(MEMBUF, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE, StdOrMask); static VGLBitmap *VGLMouseAndMask, *VGLMouseOrMask; -static int VGLMouseVisible = 0; static int VGLMouseShown = VGL_MOUSEHIDE; static int VGLMouseXpos = 0; static int VGLMouseYpos = 0; @@ -102,51 +103,44 @@ static volatile sig_atomic_t VGLMsuppressint; VGLMouseAction(0); \ } while (0) -void -VGLMousePointerShow() +int +__VGLMouseMode(int mode) { - if (!VGLMouseVisible) { - INTOFF(); - VGLMouseVisible = 1; - __VGLBitmapCopy(&VGLVDisplay, VGLMouseXpos, VGLMouseYpos, VGLDisplay, - VGLMouseXpos, VGLMouseYpos, MOUSE_IMG_SIZE, -MOUSE_IMG_SIZE); - INTON(); - } -} + int oldmode; -void -VGLMousePointerHide() -{ - if (VGLMouseVisible) { - INTOFF(); - VGLMouseVisible = 0; - __VGLBitmapCopy(&VGLVDisplay, VGLMouseXpos, VGLMouseYpos, VGLDisplay, - VGLMouseXpos, VGLMouseYpos, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); - INTON(); + INTOFF(); + oldmode = VGLMouseShown; + if (mode == VGL_MOUSESHOW) { + if (VGLMouseShown == VGL_MOUSEHIDE) { + VGLMouseShown = VGL_MOUSESHOW; + __VGLBitmapCopy(&VGLVDisplay, VGLMouseXpos, VGLMouseYpos, VGLDisplay, + VGLMouseXpos, VGLMouseYpos, + MOUSE_IMG_SIZE, -MOUSE_IMG_SIZE); + } } + else { + if (VGLMouseShown == VGL_MOUSESHOW) { + VGLMouseShown = VGL_MOUSEHIDE; + __VGLBitmapCopy(&VGLVDisplay, VGLMouseXpos, VGLMouseYpos, VGLDisplay, + VGLMouseXpos, VGLMouseYpos, + MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); + } + } + INTON(); + return oldmode; } void VGLMouseMode(int mode) { - if (mode == VGL_MOUSESHOW) { - if (VGLMouseShown == VGL_MOUSEHIDE) { - VGLMousePointerShow(); - VGLMouseShown = VGL_MOUSESHOW; - } - } - else { - if (VGLMouseShown == VGL_MOUSESHOW) { - VGLMousePointerHide(); - VGLMouseShown = VGL_MOUSEHIDE; - } - } + __VGLMouseMode(mode); } -void +static void VGLMouseAction(int dummy) { struct mouse_info mouseinfo; + int mousemode; if (VGLMsuppressint) { VGLMintpending = 1; @@ -157,13 +151,14 @@ VGLMouseAction(int dummy) VGLMintpending = 0; mouseinfo.operation = MOUSE_GETINFO; ioctl(0, CONS_MOUSECTL, &mouseinfo); - if (VGLMouseShown == VGL_MOUSESHOW) - VGLMousePointerHide(); - VGLMouseXpos = mouseinfo.u.data.x; - VGLMouseYpos = mouseinfo.u.data.y; + if (VGLMouseXpos != mouseinfo.u.data.x || + VGLMouseYpos != mouseinfo.u.data.y) { + mousemode = __VGLMouseMode(VGL_MOUSEHIDE); + VGLMouseXpos = mouseinfo.u.data.x; + VGLMouseYpos = mouseinfo.u.data.y; + __VGLMouseMode(mousemode); + } VGLMouseButtons = mouseinfo.u.data.buttons; - if (VGLMouseShown == VGL_MOUSESHOW) - VGLMousePointerShow(); /* * Loop to handle any new (suppressed) signals. This is INTON() without @@ -178,8 +173,9 @@ VGLMouseAction(int dummy) void VGLMouseSetImage(VGLBitmap *AndMask, VGLBitmap *OrMask) { - if (VGLMouseShown == VGL_MOUSESHOW) - VGLMousePointerHide(); + int mousemode; + + mousemode = __VGLMouseMode(VGL_MOUSEHIDE); VGLMouseAndMask = AndMask; @@ -191,8 +187,7 @@ VGLMouseSetImage(VGLBitmap *AndMask, VGLBitmap *OrMask) VGLBitmapAllocateBits(VGLMouseOrMask); VGLBitmapCvt(OrMask, VGLMouseOrMask); - if (VGLMouseShown == VGL_MOUSESHOW) - VGLMousePointerShow(); + __VGLMouseMode(mousemode); } void diff --git a/lib/libvgl/simple.c b/lib/libvgl/simple.c index 83a9c753efd8..91552bbc9ec1 100644 --- a/lib/libvgl/simple.c +++ b/lib/libvgl/simple.c @@ -465,14 +465,11 @@ void VGLClear(VGLBitmap *object, u_long color) { VGLBitmap src; - int i, len, mouseoverlap, offset; + int i, len, mousemode, offset; VGLCheckSwitch(); if (object == VGLDisplay) { VGLMouseFreeze(); - mouseoverlap = VGLMouseOverlap(0, 0, object->VXsize, object->VYsize); - if (mouseoverlap) - VGLMousePointerHide(); VGLClear(&VGLVDisplay, color); } else if (object->Type != MEMBUF) return; /* invalid */ @@ -503,14 +500,17 @@ VGLClear(VGLBitmap *object, u_long color) break; case VIDBUF8X: + mousemode = __VGLMouseMode(VGL_MOUSEHIDE); /* XXX works only for Xsize % 4 = 0 */ outb(0x3c6, 0xff); outb(0x3c4, 0x02); outb(0x3c5, 0x0f); memset(object->Bitmap, (byte)color, VGLAdpInfo.va_line_width*object->VYsize); + __VGLMouseMode(mousemode); break; case VIDBUF4: case VIDBUF4S: + mousemode = __VGLMouseMode(VGL_MOUSEHIDE); /* XXX works only for Xsize % 8 = 0 */ outb(0x3c4, 0x02); outb(0x3c5, 0x0f); outb(0x3ce, 0x05); outb(0x3cf, 0x02); /* mode 2 */ @@ -524,13 +524,11 @@ VGLClear(VGLBitmap *object, u_long color) offset += len; } outb(0x3ce, 0x05); outb(0x3cf, 0x00); + __VGLMouseMode(mousemode); break; } - if (object == VGLDisplay) { - if (mouseoverlap) - VGLMousePointerShow(); + if (object == VGLDisplay) VGLMouseUnFreeze(); - } } static inline u_long diff --git a/lib/libvgl/vgl.h b/lib/libvgl/vgl.h index 53e01b99e45b..aa0eda9eaa28 100644 --- a/lib/libvgl/vgl.h +++ b/lib/libvgl/vgl.h @@ -125,10 +125,8 @@ int VGLSetVScreenSize(VGLBitmap *object, int VXsize, int VYsize); int VGLPanScreen(VGLBitmap *object, int x, int y); int VGLSetSegment(unsigned int offset); /* mouse.c */ -void VGLMousePointerShow(void); -void VGLMousePointerHide(void); +int __VGLMouseMode(int mode); void VGLMouseMode(int mode); -void VGLMouseAction(int dummy); void VGLMouseSetImage(VGLBitmap *AndMask, VGLBitmap *OrMask); void VGLMouseSetStdImage(void); int VGLMouseInit(int mode);