mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-06 10:21:57 +08:00
BUGFIXING: bad initialization of a BITMAP structure (the saved bitmap under cursor); CLEANUP
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -265,9 +265,9 @@ extern DC __mg_screen_sys_dc;
|
||||
static inline PDC dc_HDC2PDC (HDC hdc)
|
||||
{
|
||||
if (hdc == HDC_SCREEN_SYS)
|
||||
return &__mg_screen_sys_dc;
|
||||
return &__mg_screen_sys_dc;
|
||||
else if (hdc == HDC_SCREEN)
|
||||
return &__mg_screen_dc;
|
||||
return &__mg_screen_dc;
|
||||
return (PDC) hdc;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,35 +11,35 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
* This file is part of MiniGUI, a mature cross-platform windowing
|
||||
* This file is part of MiniGUI, a mature cross-platform windowing
|
||||
* and Graphics User Interface (GUI) support system for embedded systems
|
||||
* and smart IoT devices.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
|
||||
* Copyright (C) 1998~2002, WEI Yongming
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* Or,
|
||||
*
|
||||
*
|
||||
* As this program is a library, any link to this program must follow
|
||||
* GNU General Public License version 3 (GPLv3). If you cannot accept
|
||||
* GPLv3, you need to be licensed from FMSoft.
|
||||
*
|
||||
*
|
||||
* If you have got a commercial license of this program, please use it
|
||||
* under the terms and conditions of the commercial license.
|
||||
*
|
||||
*
|
||||
* For more information about the commercial license, please refer to
|
||||
* <http://www.minigui.com/blog/minigui-licensing-policy/>.
|
||||
*/
|
||||
@@ -108,7 +108,7 @@ static BYTE* cursorbits = NULL;
|
||||
Uint8* GetPixelUnderCursor (int x, int y, gal_pixel* pixel)
|
||||
{
|
||||
Uint8* dst = NULL;
|
||||
|
||||
|
||||
lock_cursor_sem ();
|
||||
if (CSR_SHOW_COUNT >= 0 && CSR_CURRENT
|
||||
&& x >= CSR_OLDBOXLEFT && y >= CSR_OLDBOXTOP
|
||||
@@ -133,7 +133,7 @@ static HCURSOR srvCreateCursor (int xhotspot, int yhotspot, int w, int h,
|
||||
const BYTE* pANDBits, const BYTE* pXORBits, int colornum)
|
||||
{
|
||||
PCURSOR pcsr;
|
||||
|
||||
|
||||
if (w != CURSORWIDTH || h != CURSORHEIGHT) return 0;
|
||||
|
||||
if (!(pcsr = (PCURSOR)malloc (sizeof (CURSOR)))) return 0;
|
||||
@@ -153,21 +153,21 @@ static HCURSOR srvCreateCursor (int xhotspot, int yhotspot, int w, int h,
|
||||
pcsr->height = h;
|
||||
|
||||
if (colornum == 1) {
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, __mg_csrimgpitch,
|
||||
pANDBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, __mg_csrimgpitch,
|
||||
pANDBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0xFF, 0xFF, 0xFF, 0xFF));
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->XorBits, __mg_csrimgpitch,
|
||||
pXORBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0x00),
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->XorBits, __mg_csrimgpitch,
|
||||
pXORBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0x00),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0xFF, 0xFF, 0xFF, 0x00));
|
||||
}
|
||||
else if (colornum == 4) {
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, __mg_csrimgpitch,
|
||||
pANDBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, __mg_csrimgpitch,
|
||||
pANDBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0xFF, 0xFF, 0xFF, 0xFF));
|
||||
Expand16CBitmapEx (HDC_SCREEN_SYS, pcsr->XorBits, __mg_csrimgpitch,
|
||||
Expand16CBitmapEx (HDC_SCREEN_SYS, pcsr->XorBits, __mg_csrimgpitch,
|
||||
pXORBits, MONOPITCH*4, w, h, MYBMP_FLOW_UP, NULL, FALSE, 0x00);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ static HCURSOR GUIAPI srvCopyCursor (HCURSOR hcsr)
|
||||
{
|
||||
PCURSOR pcsr = (PCURSOR)hcsr;
|
||||
PCURSOR pdcsr;
|
||||
|
||||
|
||||
if (!(pdcsr = (PCURSOR)malloc (sizeof (CURSOR)))) return 0;
|
||||
if (!(pdcsr->AndBits = malloc (__mg_csrimgsize))) {
|
||||
free(pdcsr);
|
||||
@@ -226,7 +226,7 @@ HCURSOR GUIAPI CreateCursor (int xhotspot, int yhotspot, int w, int h,
|
||||
const BYTE* pANDBits, const BYTE* pXORBits, int colornum)
|
||||
{
|
||||
if (mgIsServer) {
|
||||
return srvCreateCursor (xhotspot, yhotspot, w, h,
|
||||
return srvCreateCursor (xhotspot, yhotspot, w, h,
|
||||
pANDBits, pXORBits, colornum);
|
||||
}
|
||||
else {
|
||||
@@ -360,7 +360,7 @@ static void init_system_cursor (void)
|
||||
HCURSOR GUIAPI GetSystemCursor (int csrid)
|
||||
{
|
||||
if (csrid >= ((PG_RES)mgSharedRes)->csrnum || csrid < 0)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
return (HCURSOR) (sys_cursors [csrid]);
|
||||
}
|
||||
@@ -370,9 +370,7 @@ HCURSOR GUIAPI GetDefaultCursor (void)
|
||||
return def_cursor;
|
||||
}
|
||||
|
||||
static BITMAP csr_bmp = {
|
||||
BMP_TYPE_NORMAL, 0, 0, 0, 0, CURSORWIDTH, CURSORHEIGHT
|
||||
};
|
||||
static BITMAP csr_bmp;
|
||||
|
||||
BOOL mg_InitCursor (void)
|
||||
{
|
||||
@@ -392,10 +390,14 @@ BOOL mg_InitCursor (void)
|
||||
CSR_OLDBOXTOP = -100;
|
||||
}
|
||||
|
||||
/* NOTE: Always initialize the structue fields with explicit assignments */
|
||||
csr_bmp.bmType = BMP_TYPE_NORMAL;
|
||||
csr_bmp.bmBitsPerPixel = __gal_screen->format->BitsPerPixel;
|
||||
csr_bmp.bmBytesPerPixel = __gal_screen->format->BytesPerPixel;
|
||||
csr_bmp.bmWidth = CURSORWIDTH;
|
||||
csr_bmp.bmHeight = CURSORHEIGHT;
|
||||
csr_bmp.bmPitch = __gal_screen->format->BytesPerPixel * CURSORWIDTH;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -410,7 +412,7 @@ void mg_TerminateCursor (void)
|
||||
|
||||
CSR_CURRENT_SET = 0;
|
||||
CSR_SHOW_COUNT = 0;
|
||||
|
||||
|
||||
for (i = 0; i < ((PG_RES)mgSharedRes)->csrnum; i++) {
|
||||
if (sys_cursors [i]) {
|
||||
free (sys_cursors [i]);
|
||||
@@ -443,8 +445,19 @@ static void hidecursor (void)
|
||||
csr_bmp.bmBits = CSR_SAVEDBITS;
|
||||
|
||||
GAL_SetClipRect (__gal_screen, NULL);
|
||||
GAL_PutBox (__gal_screen, &csr_rect, &csr_bmp);
|
||||
GAL_PutBox (__gal_screen, &csr_rect, &csr_bmp);
|
||||
GAL_UpdateRects (__gal_screen, 1, &csr_rect);
|
||||
|
||||
#if 0 // Debug code
|
||||
if (!mgIsServer) {
|
||||
char filename [PATH_MAX + 1];
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
sprintf (filename, "saved-cursor-bits-%d.%d.bmp", (int)tv.tv_sec, (int)tv.tv_usec);
|
||||
SaveBitmapToFile(HDC_SCREEN, &csr_bmp, filename);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void _dc_restore_alpha_in_bitmap (const GAL_PixelFormat* format,
|
||||
@@ -513,14 +526,17 @@ BOOL kernel_RefreshCursor (int* x, int* y, int* button)
|
||||
|
||||
#ifdef _MGHAVE_CURSOR
|
||||
lock_cursor_sem ();
|
||||
|
||||
CSR_CURSORX = curx;
|
||||
CSR_CURSORY = cury;
|
||||
if (CSR_SHOW_COUNT >= 0 && CSR_CURRENT) {
|
||||
if (get_hidecursor_sem_val ()) {
|
||||
reset_hidecursor_sem ();
|
||||
}
|
||||
else
|
||||
else {
|
||||
hidecursor ();
|
||||
}
|
||||
|
||||
showcursor ();
|
||||
}
|
||||
unlock_cursor_sem ();
|
||||
@@ -636,8 +652,9 @@ inline static BOOL does_need_hide (const RECT* prc)
|
||||
intright = (csrright < prc->right) ? csrright : prc->right;
|
||||
intbottom = (csrbottom < prc->bottom) ? csrbottom : prc->bottom;
|
||||
|
||||
if (intleft >= intright || inttop >= intbottom)
|
||||
if (intleft >= intright || inttop >= intbottom) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -651,7 +668,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
|
||||
|
||||
if (cur_pdc->surface != __gal_screen) {
|
||||
if (fShow)
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
}
|
||||
else {
|
||||
@@ -669,7 +686,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
|
||||
}
|
||||
}
|
||||
else {
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
unlock_cursor_sem ();
|
||||
}
|
||||
@@ -723,7 +740,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
|
||||
return;
|
||||
|
||||
if (fShow)
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
#else
|
||||
if (!mgIsServer && (SHAREDRES_TOPMOST_LAYER != __mg_layer)) {
|
||||
@@ -731,7 +748,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
|
||||
}
|
||||
|
||||
if (fShow)
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -11,35 +11,35 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
* This file is part of MiniGUI, a mature cross-platform windowing
|
||||
* This file is part of MiniGUI, a mature cross-platform windowing
|
||||
* and Graphics User Interface (GUI) support system for embedded systems
|
||||
* and smart IoT devices.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
|
||||
* Copyright (C) 1998~2002, WEI Yongming
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* Or,
|
||||
*
|
||||
*
|
||||
* As this program is a library, any link to this program must follow
|
||||
* GNU General Public License version 3 (GPLv3). If you cannot accept
|
||||
* GPLv3, you need to be licensed from FMSoft.
|
||||
*
|
||||
*
|
||||
* If you have got a commercial license of this program, please use it
|
||||
* under the terms and conditions of the commercial license.
|
||||
*
|
||||
*
|
||||
* For more information about the commercial license, please refer to
|
||||
* <http://www.minigui.com/blog/minigui-licensing-policy/>.
|
||||
*/
|
||||
@@ -90,7 +90,7 @@ static BYTE* savedbits = NULL;
|
||||
static BYTE* cursorbits = NULL;
|
||||
static int csrimgsize;
|
||||
static unsigned int csrimgpitch;
|
||||
|
||||
|
||||
static int oldboxleft = -100, oldboxtop = -100;
|
||||
static int nShowCount = 0;
|
||||
static PCURSOR pCurCsr = NULL;
|
||||
@@ -108,16 +108,14 @@ HCURSOR GUIAPI LoadCursorFromMem (const void* area)
|
||||
return load_cursor_from_mem (area);
|
||||
}
|
||||
|
||||
static BITMAP csr_bmp = {
|
||||
BMP_TYPE_NORMAL, 0, 0, 0, 0, CURSORWIDTH, CURSORHEIGHT
|
||||
};
|
||||
static BITMAP csr_bmp;
|
||||
|
||||
/* Only called from InitCursor and client code. */
|
||||
HCURSOR GUIAPI CreateCursor(int xhotspot, int yhotspot, int w, int h,
|
||||
const BYTE* pANDBits, const BYTE* pXORBits, int colornum)
|
||||
{
|
||||
PCURSOR pcsr;
|
||||
|
||||
|
||||
if( w != CURSORWIDTH || h != CURSORHEIGHT ) return 0;
|
||||
|
||||
/* allocate memory. */
|
||||
@@ -138,21 +136,21 @@ HCURSOR GUIAPI CreateCursor(int xhotspot, int yhotspot, int w, int h,
|
||||
pcsr->height = h;
|
||||
|
||||
if (colornum == 1) {
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, csrimgpitch,
|
||||
pANDBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, csrimgpitch,
|
||||
pANDBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0xFF, 0xFF, 0xFF, 0xFF));
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->XorBits, csrimgpitch,
|
||||
pXORBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0x00),
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->XorBits, csrimgpitch,
|
||||
pXORBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0x00),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0xFF, 0xFF, 0xFF, 0x00));
|
||||
}
|
||||
else if (colornum == 4) {
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, csrimgpitch,
|
||||
pANDBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, csrimgpitch,
|
||||
pANDBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0xFF, 0xFF, 0xFF, 0xFF));
|
||||
Expand16CBitmapEx (HDC_SCREEN_SYS, pcsr->XorBits, csrimgpitch,
|
||||
Expand16CBitmapEx (HDC_SCREEN_SYS, pcsr->XorBits, csrimgpitch,
|
||||
pXORBits, MONOPITCH*4, w, h, MYBMP_FLOW_UP, NULL, FALSE, 0x00);
|
||||
}
|
||||
|
||||
@@ -224,7 +222,7 @@ BOOL GUIAPI DestroyCursor(HCURSOR hcsr)
|
||||
HCURSOR GUIAPI GetSystemCursor(int csrid)
|
||||
{
|
||||
if(csrid > MAX_SYSCURSORINDEX || csrid < 0)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
return (HCURSOR)(SysCursor[csrid]);
|
||||
}
|
||||
@@ -242,8 +240,12 @@ BOOL mg_InitCursor(void)
|
||||
|
||||
csrimgsize = GAL_GetBoxSize (__gal_screen, CURSORWIDTH, CURSORHEIGHT, &csrimgpitch);
|
||||
|
||||
/* NOTE: Always initialize the structue fields with explicit assignments */
|
||||
csr_bmp.bmType = BMP_TYPE_NORMAL;
|
||||
csr_bmp.bmBitsPerPixel = __gal_screen->format->BitsPerPixel;
|
||||
csr_bmp.bmBytesPerPixel = __gal_screen->format->BytesPerPixel;
|
||||
csr_bmp.bmWidth = CURSORWIDTH;
|
||||
csr_bmp.bmHeight = CURSORHEIGHT;
|
||||
csr_bmp.bmPitch = csrimgpitch;
|
||||
|
||||
if( !(savedbits = malloc(csrimgsize)) )
|
||||
@@ -259,18 +261,18 @@ BOOL mg_InitCursor(void)
|
||||
goto error;
|
||||
|
||||
number = atoi(szValue);
|
||||
|
||||
|
||||
if(number <= 0)
|
||||
return TRUE;
|
||||
|
||||
number = number < (MAX_SYSCURSORINDEX + 1) ?
|
||||
number = number < (MAX_SYSCURSORINDEX + 1) ?
|
||||
number : (MAX_SYSCURSORINDEX + 1);
|
||||
|
||||
for(i = 0; i < number; i++) {
|
||||
if ( !(SysCursor[i] = sysres_load_system_cursor(i)) )
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
error:
|
||||
mg_TerminateCursor();
|
||||
@@ -289,7 +291,7 @@ void mg_TerminateCursor( void )
|
||||
savedbits = NULL;
|
||||
pCurCsr = NULL;
|
||||
nShowCount = 0;
|
||||
|
||||
|
||||
for(i = 0; i<= MAX_SYSCURSORINDEX; i++) {
|
||||
if( SysCursor[i] ) {
|
||||
free(SysCursor[i]->AndBits);
|
||||
@@ -327,7 +329,7 @@ static void hidecursor (void)
|
||||
csr_bmp.bmBits = savedbits;
|
||||
|
||||
GAL_SetClipRect (__gal_screen, NULL);
|
||||
GAL_PutBox (__gal_screen, &csr_rect, &csr_bmp);
|
||||
GAL_PutBox (__gal_screen, &csr_rect, &csr_bmp);
|
||||
GAL_UpdateRects (__gal_screen, 1, &csr_rect);
|
||||
}
|
||||
|
||||
@@ -449,7 +451,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
|
||||
|
||||
if (cur_pdc->surface != __gal_screen) {
|
||||
if (fShow)
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
}
|
||||
else {
|
||||
@@ -465,7 +467,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
|
||||
|
||||
if (intleft >= intright || inttop >= intbottom) {
|
||||
if (fShow)
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
return;
|
||||
}
|
||||
@@ -508,7 +510,7 @@ void kernel_ShowCursorForGDI(BOOL fShow, void* pdc)
|
||||
prc = &cur_pdc->rc_output;
|
||||
|
||||
if (fShow)
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,35 +11,35 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
* This file is part of MiniGUI, a mature cross-platform windowing
|
||||
* This file is part of MiniGUI, a mature cross-platform windowing
|
||||
* and Graphics User Interface (GUI) support system for embedded systems
|
||||
* and smart IoT devices.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
|
||||
* Copyright (C) 1998~2002, WEI Yongming
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* Or,
|
||||
*
|
||||
*
|
||||
* As this program is a library, any link to this program must follow
|
||||
* GNU General Public License version 3 (GPLv3). If you cannot accept
|
||||
* GPLv3, you need to be licensed from FMSoft.
|
||||
*
|
||||
*
|
||||
* If you have got a commercial license of this program, please use it
|
||||
* under the terms and conditions of the commercial license.
|
||||
*
|
||||
*
|
||||
* For more information about the commercial license, please refer to
|
||||
* <http://www.minigui.com/blog/minigui-licensing-policy/>.
|
||||
*/
|
||||
@@ -89,9 +89,9 @@ static RECT cliprc = { 0, 0, 0, 0};
|
||||
#ifdef _MGHAVE_CURSOR
|
||||
|
||||
#if defined(__THREADX__) && defined(__TARGET_VFANVIL__)
|
||||
#ifndef fgetc
|
||||
#ifndef fgetc
|
||||
#define fgetc my_fgetc
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static PCURSOR SysCursor [MAX_SYSCURSORINDEX + 1];
|
||||
@@ -100,7 +100,7 @@ static BYTE* savedbits = NULL;
|
||||
static BYTE* cursorbits = NULL;
|
||||
static unsigned int csrimgsize;
|
||||
static unsigned int csrimgpitch;
|
||||
|
||||
|
||||
static int oldboxleft = -100, oldboxtop = -100;
|
||||
static int nShowCount = 0;
|
||||
static PCURSOR pCurCsr = NULL;
|
||||
@@ -108,7 +108,7 @@ static PCURSOR pCurCsr = NULL;
|
||||
Uint8* GetPixelUnderCursor (int x, int y, gal_pixel* pixel)
|
||||
{
|
||||
Uint8* dst = NULL;
|
||||
|
||||
|
||||
pthread_mutex_lock (&__mg_mouselock);
|
||||
if (nShowCount >= 0 && pCurCsr
|
||||
&& x >= oldboxleft && y >= oldboxtop
|
||||
@@ -139,16 +139,14 @@ HCURSOR GUIAPI LoadCursorFromMem (const void* area)
|
||||
return load_cursor_from_mem (area);
|
||||
}
|
||||
|
||||
static BITMAP csr_bmp = {
|
||||
BMP_TYPE_NORMAL, 0, 0, 0, 0, CURSORWIDTH, CURSORHEIGHT
|
||||
};
|
||||
static BITMAP csr_bmp;
|
||||
|
||||
/* Only called from InitCursor and client code. */
|
||||
HCURSOR GUIAPI CreateCursor(int xhotspot, int yhotspot, int w, int h,
|
||||
const BYTE* pANDBits, const BYTE* pXORBits, int colornum)
|
||||
{
|
||||
PCURSOR pcsr;
|
||||
|
||||
|
||||
if( w != CURSORWIDTH || h != CURSORHEIGHT ) return 0;
|
||||
|
||||
/* allocate memory. */
|
||||
@@ -169,23 +167,23 @@ HCURSOR GUIAPI CreateCursor(int xhotspot, int yhotspot, int w, int h,
|
||||
pcsr->height = h;
|
||||
|
||||
if (colornum == 1) {
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, csrimgpitch,
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, csrimgpitch,
|
||||
pANDBits, MONOPITCH, w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0xFF, 0xFF, 0xFF, 0xFF));
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->XorBits, csrimgpitch,
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->XorBits, csrimgpitch,
|
||||
pXORBits, MONOPITCH,
|
||||
w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0x00),
|
||||
w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0x00),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0xFF, 0xFF, 0xFF, 0x00));
|
||||
}
|
||||
else if (colornum == 4) {
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, csrimgpitch,
|
||||
ExpandMonoBitmap (HDC_SCREEN_SYS, pcsr->AndBits, csrimgpitch,
|
||||
pANDBits, MONOPITCH,
|
||||
w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
w, h, MYBMP_FLOW_UP,
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0, 0, 0, 0xFF),
|
||||
RGBA2Pixel (HDC_SCREEN_SYS, 0xFF, 0xFF, 0xFF, 0xFF));
|
||||
Expand16CBitmapEx (HDC_SCREEN_SYS, pcsr->XorBits, csrimgpitch, pXORBits,
|
||||
Expand16CBitmapEx (HDC_SCREEN_SYS, pcsr->XorBits, csrimgpitch, pXORBits,
|
||||
MONOPITCH*4, w, h, MYBMP_FLOW_UP, NULL, FALSE, 0x00);
|
||||
}
|
||||
|
||||
@@ -257,7 +255,7 @@ BOOL GUIAPI DestroyCursor(HCURSOR hcsr)
|
||||
HCURSOR GUIAPI GetSystemCursor(int csrid)
|
||||
{
|
||||
if(csrid > MAX_SYSCURSORINDEX || csrid < 0)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
return (HCURSOR)(SysCursor[csrid]);
|
||||
}
|
||||
@@ -275,15 +273,15 @@ BOOL realInitCursor(void)
|
||||
int number;
|
||||
int i;
|
||||
|
||||
csrimgsize = GAL_GetBoxSize (__gal_screen, CURSORWIDTH, CURSORHEIGHT,
|
||||
csrimgsize = GAL_GetBoxSize (__gal_screen, CURSORWIDTH, CURSORHEIGHT,
|
||||
&csrimgpitch);
|
||||
|
||||
/* NOTE: Always initialize the structue fields with explicit assignments */
|
||||
csr_bmp.bmType = BMP_TYPE_NORMAL;
|
||||
csr_bmp.bmWidth = CURSORWIDTH;
|
||||
csr_bmp.bmHeight = CURSORHEIGHT;
|
||||
|
||||
csr_bmp.bmBitsPerPixel = __gal_screen->format->BitsPerPixel;
|
||||
csr_bmp.bmBytesPerPixel = __gal_screen->format->BytesPerPixel;
|
||||
csr_bmp.bmWidth = CURSORWIDTH;
|
||||
csr_bmp.bmHeight = CURSORHEIGHT;
|
||||
csr_bmp.bmPitch = csrimgpitch;
|
||||
|
||||
if( !(savedbits = malloc(csrimgsize)) )
|
||||
@@ -298,20 +296,20 @@ BOOL realInitCursor(void)
|
||||
|
||||
if( GetMgEtcValue (CURSORSECTION, "cursornumber", szValue, 10) < 0 )
|
||||
goto error;
|
||||
|
||||
|
||||
number = atoi(szValue);
|
||||
|
||||
if(number <= 0)
|
||||
return TRUE;
|
||||
|
||||
number = number < (MAX_SYSCURSORINDEX + 1) ?
|
||||
number = number < (MAX_SYSCURSORINDEX + 1) ?
|
||||
number : (MAX_SYSCURSORINDEX + 1);
|
||||
|
||||
for(i = 0; i < number; i++) {
|
||||
if ( !(SysCursor[i] = sysres_load_system_cursor(i)) )
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return TRUE;
|
||||
error:
|
||||
@@ -333,7 +331,7 @@ void mg_TerminateCursor( void )
|
||||
savedbits = NULL;
|
||||
pCurCsr = NULL;
|
||||
nShowCount = 0;
|
||||
|
||||
|
||||
for(i = 0; i<= MAX_SYSCURSORINDEX; i++)
|
||||
{
|
||||
if( SysCursor[i] ) {
|
||||
@@ -350,7 +348,7 @@ HCURSOR GUIAPI GetCurrentCursor(void)
|
||||
HCURSOR hcsr;
|
||||
|
||||
pthread_mutex_lock (&__mg_mouselock);
|
||||
|
||||
|
||||
hcsr = (HCURSOR)pCurCsr;
|
||||
pthread_mutex_unlock(&__mg_mouselock);
|
||||
|
||||
@@ -379,7 +377,7 @@ static void hidecursor (void)
|
||||
csr_bmp.bmBits = savedbits;
|
||||
|
||||
GAL_SetClipRect (__gal_screen, NULL);
|
||||
GAL_PutBox (__gal_screen, &csr_rect, &csr_bmp);
|
||||
GAL_PutBox (__gal_screen, &csr_rect, &csr_bmp);
|
||||
GAL_UpdateRects (__gal_screen, 1, &csr_rect);
|
||||
}
|
||||
|
||||
@@ -475,7 +473,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void *pdc)
|
||||
|
||||
if (cur_pdc->surface != __gal_screen) {
|
||||
if (fShow) {
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
}
|
||||
}
|
||||
@@ -495,7 +493,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void *pdc)
|
||||
|
||||
if (intleft >= intright || inttop >= intbottom) {
|
||||
if (fShow) {
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
pthread_mutex_unlock(&__mg_mouselock);
|
||||
}
|
||||
@@ -510,7 +508,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void *pdc)
|
||||
}
|
||||
|
||||
if (fShow) {
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
pthread_mutex_unlock(&__mg_mouselock);
|
||||
}
|
||||
@@ -552,7 +550,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc)
|
||||
prc = &cur_pdc->rc_output;
|
||||
|
||||
if (fShow)
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
GAL_UpdateRect (cur_pdc->surface,
|
||||
prc->left, prc->top, RECTWP(prc), RECTHP(prc));
|
||||
}
|
||||
|
||||
|
||||
@@ -565,7 +565,7 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat)
|
||||
|
||||
fwrite (&shmid, sizeof(int), 1, fp);
|
||||
fclose(fp);
|
||||
#endif
|
||||
#endif /* _MGRM_PROCESSES */
|
||||
}
|
||||
|
||||
#if defined(_MGRM_PROCESSES)
|
||||
@@ -589,7 +589,7 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat)
|
||||
data->shmrgn = (unsigned char *)shmat (shmid, 0, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* _MGRM_PROCESSES */
|
||||
#endif //end of os (windows, cygwin, linux)
|
||||
|
||||
if ((INT_PTR)data->shmrgn == -1 || data->shmrgn == NULL) {
|
||||
@@ -608,7 +608,7 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat)
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
#endif
|
||||
#endif /* _MGGAL_SHADOW */
|
||||
case 8:
|
||||
vformat->BytesPerPixel = 1;
|
||||
break;
|
||||
|
||||
@@ -2775,7 +2775,8 @@ Uint8* GUIAPI LockDC (HDC hdc, const RECT* rw_rc, int* width, int* height,
|
||||
goto fail1;
|
||||
*/
|
||||
LOCK (&__mg_gdilock);
|
||||
if (!dc_IsMemDC (pdc)) kernel_ShowCursorForGDI (FALSE, pdc);
|
||||
if (!dc_IsMemDC (pdc))
|
||||
kernel_ShowCursorForGDI (FALSE, pdc);
|
||||
|
||||
if (width) *width = RECTW(pdc->rc_output);
|
||||
if (height) *height = RECTH(pdc->rc_output);
|
||||
|
||||
Reference in New Issue
Block a user