mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-24 00:54:18 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57bdcd4754 | ||
|
|
b95538a415 | ||
|
|
fa7c84b2b5 | ||
|
|
bc77048488 | ||
|
|
2f21b22a49 | ||
|
|
ec91986854 | ||
|
|
e7b03037be | ||
|
|
9ff822c7fd | ||
|
|
239924c63e | ||
|
|
2f85645e9d | ||
|
|
9a6b208a85 |
+2
-2
@@ -1,6 +1,6 @@
|
||||
MAJOR_VERSION = 3
|
||||
MAJOR_VERSION = 4
|
||||
MINOR_VERSION = 0
|
||||
MICRO_VERSION = 13
|
||||
MICRO_VERSION = 4
|
||||
EXTRAVERSION =
|
||||
|
||||
MINIGUI_RELEASE=$(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)$(EXTRAVERSION)
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
# Release Notes
|
||||
|
||||
## Version 4.0.5
|
||||
|
||||
The MiniGUI development team announces the availability of MiniGUI 4.0.5.
|
||||
We strongly recommend that you use this version for any new MiniGUI
|
||||
apps, especially if the new features of MiniGUI 4.0 are must for your
|
||||
new apps.
|
||||
|
||||
Please report any bugs and incompatibilities in
|
||||
|
||||
<https://github.com/VincentWei/minigui>
|
||||
|
||||
### What's new in this version
|
||||
|
||||
In this version, we mainly fixed some bugs found.
|
||||
|
||||
* BUGFIXING:
|
||||
- Always initialize BITMAP fields with explicit assignments.
|
||||
This bug makes the cursor messy.
|
||||
- Fix some conditional compilation of mg-tests.
|
||||
* ENHANCEMENTS:
|
||||
- The server of MiniGUI-Processes now can delete global System V IPC
|
||||
objects left by a previous failed run.
|
||||
|
||||
## Version 4.0.4
|
||||
|
||||
The MiniGUI development team announces the availability of MiniGUI 4.0.4.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Version 4.0.4 (2019/12/24)
|
||||
Version 4.0.5 (2020/01/10)
|
||||
|
||||
This release needs the following packages:
|
||||
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.60)
|
||||
AC_INIT(libminigui, 4.0.4)
|
||||
AC_INIT(libminigui, 4.0.5)
|
||||
AC_CONFIG_SRCDIR(src/main/main.c)
|
||||
|
||||
dnl Set various version strings - taken gratefully from the SDL sources
|
||||
@@ -16,9 +16,9 @@ dnl Set various version strings - taken gratefully from the SDL sources
|
||||
#
|
||||
MINIGUI_MAJOR_VERSION=4
|
||||
MINIGUI_MINOR_VERSION=0
|
||||
MINIGUI_MICRO_VERSION=4
|
||||
MINIGUI_INTERFACE_AGE=0
|
||||
MINIGUI_BINARY_AGE=0
|
||||
MINIGUI_MICRO_VERSION=5
|
||||
MINIGUI_INTERFACE_AGE=1
|
||||
MINIGUI_BINARY_AGE=1
|
||||
MINIGUI_VERSION=$MINIGUI_MAJOR_VERSION.$MINIGUI_MINOR_VERSION.$MINIGUI_MICRO_VERSION
|
||||
|
||||
AC_SUBST(MINIGUI_MAJOR_VERSION)
|
||||
|
||||
+28
-10
@@ -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/>.
|
||||
*/
|
||||
@@ -70,6 +70,24 @@ enum {
|
||||
_NR_SEM
|
||||
};
|
||||
|
||||
// key base for System V IPC
|
||||
#define IPC_KEY_BASE 0x464D4700
|
||||
|
||||
inline static key_t get_shm_key_for_system (void)
|
||||
{
|
||||
return (key_t)(IPC_KEY_BASE + 0x01);
|
||||
}
|
||||
|
||||
inline static key_t get_sem_key_for_system (void)
|
||||
{
|
||||
return (key_t)(IPC_KEY_BASE + 0x02);
|
||||
}
|
||||
|
||||
inline static key_t get_sem_key_for_layers (void)
|
||||
{
|
||||
return (key_t)(IPC_KEY_BASE + 0x03);
|
||||
}
|
||||
|
||||
typedef struct tagG_RES {
|
||||
int semid;
|
||||
int shmid;
|
||||
@@ -95,7 +113,7 @@ typedef struct tagG_RES {
|
||||
int mousebutton;
|
||||
int shiftstatus;
|
||||
Uint8 kbd_state [MGUI_NR_KEYS + 1];
|
||||
|
||||
|
||||
#ifdef _MGHAVE_CURSOR
|
||||
int cursorx, cursory;
|
||||
int oldboxleft, oldboxtop;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/* always initialize fields by explicitly 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,9 +108,7 @@ 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,
|
||||
@@ -242,6 +240,10 @@ BOOL mg_InitCursor(void)
|
||||
|
||||
csrimgsize = GAL_GetBoxSize (__gal_screen, CURSORWIDTH, CURSORHEIGHT, &csrimgpitch);
|
||||
|
||||
/* always initialize fields by explicitly 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.bmPitch = csrimgpitch;
|
||||
|
||||
+3
-6
@@ -139,9 +139,7 @@ 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,
|
||||
@@ -279,11 +277,10 @@ BOOL realInitCursor(void)
|
||||
&csrimgpitch);
|
||||
|
||||
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)) )
|
||||
|
||||
@@ -97,7 +97,7 @@ GHANDLE __mg_layer;
|
||||
/* always be zero for clients. */
|
||||
BOOL __mg_switch_away;
|
||||
|
||||
void lock_zi_for_read (const ZORDERINFO* zi)
|
||||
static void lock_zi_for_read (const ZORDERINFO* zi)
|
||||
{
|
||||
struct sembuf sb;
|
||||
|
||||
@@ -116,7 +116,7 @@ again:
|
||||
|
||||
}
|
||||
|
||||
void unlock_zi_for_read (const ZORDERINFO* zi)
|
||||
static void unlock_zi_for_read (const ZORDERINFO* zi)
|
||||
{
|
||||
struct sembuf sb;
|
||||
|
||||
@@ -134,7 +134,7 @@ again:
|
||||
}
|
||||
}
|
||||
|
||||
void lock_zi_for_change (const ZORDERINFO* zi)
|
||||
static void lock_zi_for_change (const ZORDERINFO* zi)
|
||||
{
|
||||
int clients = 0;
|
||||
struct sembuf sb;
|
||||
@@ -157,7 +157,7 @@ again:
|
||||
}
|
||||
}
|
||||
|
||||
void unlock_zi_for_change (const ZORDERINFO* zi)
|
||||
static void unlock_zi_for_change (const ZORDERINFO* zi)
|
||||
{
|
||||
int clients = 0;
|
||||
struct sembuf sb;
|
||||
@@ -176,7 +176,7 @@ again:
|
||||
}
|
||||
}
|
||||
|
||||
inline void* get_zi_from_client(int cli)
|
||||
static inline void* get_zi_from_client(int cli)
|
||||
{
|
||||
return (((cli>0)?mgClients[cli].layer:mgTopmostLayer)->zorder_info);
|
||||
}
|
||||
|
||||
+236
-236
File diff suppressed because it is too large
Load Diff
+16
-6
@@ -55,6 +55,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define _DEBUG
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifndef __NOUNIX__
|
||||
@@ -252,7 +254,7 @@ static void treat_longpress (PKEYEVENT ke, DWORD interval)
|
||||
ke->event = KE_KEYLONGPRESS;
|
||||
}
|
||||
else
|
||||
ke->event = 0;
|
||||
ke->event = KE_KEYDOWN;
|
||||
}
|
||||
else if (interval >= __mg_key_alwayspress_time) {
|
||||
if (flag2) {
|
||||
@@ -261,7 +263,7 @@ static void treat_longpress (PKEYEVENT ke, DWORD interval)
|
||||
ke->event = KE_KEYALWAYSPRESS;
|
||||
}
|
||||
else if (__mg_timer_counter - starttime < __mg_interval_time) {
|
||||
ke->event = 0;
|
||||
ke->event = KE_KEYDOWN;
|
||||
}
|
||||
else {
|
||||
starttime = __mg_timer_counter;
|
||||
@@ -278,7 +280,7 @@ static void treat_longpress (PKEYEVENT ke, DWORD interval)
|
||||
ke->event = KE_KEYALWAYSPRESS;
|
||||
}
|
||||
else if (__mg_timer_counter - starttime < __mg_interval_time) {
|
||||
ke->event = 0;
|
||||
ke->event = KE_KEYDOWN;
|
||||
}
|
||||
else {
|
||||
starttime = __mg_timer_counter;
|
||||
@@ -291,7 +293,7 @@ static void treat_longpress (PKEYEVENT ke, DWORD interval)
|
||||
ke->event = KE_KEYLONGPRESS;
|
||||
}
|
||||
else
|
||||
ke->event = 0;
|
||||
ke->event = KE_KEYDOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,8 +467,12 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
ke->scancode = olddownkey;
|
||||
interval = __mg_timer_counter - ke_time;
|
||||
treat_longpress (ke, interval);
|
||||
if (ke->event == 0)
|
||||
if (ke->event == 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (ke->event == KE_KEYDOWN) {
|
||||
status |= KS_REPEATED;
|
||||
}
|
||||
}
|
||||
|
||||
make = (ke->event == KE_KEYDOWN)?1:0;
|
||||
@@ -765,8 +771,12 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
ke->scancode = olddownkey;
|
||||
interval = __mg_timer_counter - ke_time;
|
||||
treat_longpress (ke, interval);
|
||||
if (ke->event == 0)
|
||||
if (ke->event == 0) {
|
||||
return 0;
|
||||
}
|
||||
else if (ke->event == KE_KEYDOWN) {
|
||||
status |= KS_REPEATED;
|
||||
}
|
||||
}
|
||||
|
||||
make = (ke->event == KE_KEYDOWN) ? 1 : 0;
|
||||
|
||||
+76
-50
@@ -11,41 +11,41 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
/*
|
||||
** sharedres.c: Load and init shared resource.
|
||||
**
|
||||
**
|
||||
** Create date: 2000/12/22
|
||||
*/
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
#define SEM_PARAM 0666
|
||||
|
||||
// define to use mmap instead of shared memory.
|
||||
#undef _USE_MMAP
|
||||
#undef _USE_MMAP
|
||||
// #define _USE_MMAP 1
|
||||
|
||||
#ifdef _MGHAVE_CURSOR
|
||||
@@ -125,7 +125,7 @@ static BOOL LoadCursorRes (void)
|
||||
mgSizeRes += __mg_csrimgsize;
|
||||
((PG_RES)mgSharedRes)->csroffset = mgSizeRes;
|
||||
|
||||
// pointer to begin of cursor struct,
|
||||
// pointer to begin of cursor struct,
|
||||
// and reserve a space for handles for system cursors.
|
||||
temp = (char*)mgSharedRes + mgSizeRes + sizeof (PCURSOR) * number;
|
||||
|
||||
@@ -133,12 +133,12 @@ static BOOL LoadCursorRes (void)
|
||||
if ( !(tempcsr = sysres_load_system_cursor (i)) )
|
||||
goto error;
|
||||
|
||||
memcpy (temp, tempcsr, sizeof(CURSOR));
|
||||
memcpy (temp, tempcsr, sizeof(CURSOR));
|
||||
temp += sizeof(CURSOR);
|
||||
memcpy (temp, tempcsr->AndBits, __mg_csrimgsize);
|
||||
temp += __mg_csrimgsize;
|
||||
temp += __mg_csrimgsize;
|
||||
memcpy (temp, tempcsr->XorBits, __mg_csrimgsize);
|
||||
temp += __mg_csrimgsize;
|
||||
temp += __mg_csrimgsize;
|
||||
free (tempcsr->AndBits);
|
||||
free (tempcsr->XorBits);
|
||||
free (tempcsr);
|
||||
@@ -153,23 +153,46 @@ error:
|
||||
|
||||
#endif /* _MGHAVE_CURSOR */
|
||||
|
||||
inline static key_t get_shm_key (void)
|
||||
{
|
||||
return (key_t)(IPC_KEY_BASE + 0x01);
|
||||
}
|
||||
|
||||
inline static key_t get_sem_key (void)
|
||||
{
|
||||
return (key_t)(IPC_KEY_BASE + 0x02);
|
||||
}
|
||||
|
||||
BOOL kernel_IsOnlyMe (void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if ((fd = open (LOCKFILE, O_RDONLY)) == -1)
|
||||
if ((fd = open (LOCKFILE, O_RDONLY)) == -1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (flock (fd, LOCK_EX | LOCK_NB) == 0) {
|
||||
// It is time to remove the old SysV IPC objects.
|
||||
key_t sem_key = get_sem_key_for_system ();
|
||||
|
||||
// remove system semaphore set.
|
||||
int semid = semget (sem_key, 0, SEM_PARAM);
|
||||
if (semid >= 0) {
|
||||
union semun ignored;
|
||||
if (semctl (semid, 0, IPC_RMID, ignored) < 0) {
|
||||
goto failed;
|
||||
}
|
||||
_WRN_PRINTF("The old semaphore set for system (0x%06x) dicarded\n",
|
||||
semid);
|
||||
}
|
||||
|
||||
// remove system semaphore set.
|
||||
sem_key = get_sem_key_for_layers ();
|
||||
semid = semget (sem_key, 0, SEM_PARAM);
|
||||
if (semid >= 0) {
|
||||
union semun ignored;
|
||||
if (semctl (semid, 0, IPC_RMID, ignored) < 0) {
|
||||
goto failed;
|
||||
}
|
||||
_WRN_PRINTF("The old semaphore set for layers (0x%06x) dicarded\n",
|
||||
semid);
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
failed:
|
||||
close (fd);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -186,6 +209,8 @@ error:
|
||||
perror("remove semaphore");
|
||||
}
|
||||
|
||||
static int lockfd;
|
||||
|
||||
void *kernel_LoadSharedResource (void)
|
||||
{
|
||||
key_t sem_key;
|
||||
@@ -193,7 +218,7 @@ void *kernel_LoadSharedResource (void)
|
||||
key_t shm_key;
|
||||
void *memptr;
|
||||
#endif
|
||||
int lockfd, semid;
|
||||
int semid;
|
||||
#ifndef _USE_MMAP
|
||||
int shmid;
|
||||
#endif
|
||||
@@ -205,30 +230,30 @@ void *kernel_LoadSharedResource (void)
|
||||
|
||||
#ifdef _MGHAVE_CURSOR
|
||||
if (!LoadCursorRes()) {
|
||||
perror ("InitCursor");
|
||||
perror ("InitCursor");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _USE_MMAP
|
||||
if ((shm_key = get_shm_key ()) == -1) {
|
||||
if ((shm_key = get_shm_key_for_system ()) == -1) {
|
||||
goto error;
|
||||
}
|
||||
shmid = shmget (shm_key, mgSizeRes, SHM_PARAM | IPC_CREAT | IPC_EXCL);
|
||||
if (shmid == -1) {
|
||||
shmid = shmget (shm_key, mgSizeRes, SHM_PARAM | IPC_CREAT | IPC_EXCL);
|
||||
if (shmid == -1) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
// Attach to the share memory.
|
||||
// Attach to the share memory.
|
||||
memptr = shmat (shmid, 0, 0);
|
||||
if (memptr == (char*)-1)
|
||||
if (memptr == (char*)-1)
|
||||
goto error;
|
||||
else {
|
||||
memcpy (memptr, mgSharedRes, mgSizeRes);
|
||||
free (mgSharedRes);
|
||||
}
|
||||
|
||||
if (shmctl (shmid, IPC_RMID, NULL) < 0)
|
||||
if (shmctl (shmid, IPC_RMID, NULL) < 0)
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
@@ -252,19 +277,19 @@ void *kernel_LoadSharedResource (void)
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
if (flock (lockfd, LOCK_EX | LOCK_NB) == -1)
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
close (lockfd);
|
||||
if (flock (lockfd, LOCK_EX) == -1)
|
||||
goto error;
|
||||
|
||||
// close lockfd will release the exclusive lock
|
||||
// close (lockfd);
|
||||
|
||||
// Obtain the semophore syncing drawing.
|
||||
if ((sem_key = get_sem_key ()) == -1) {
|
||||
if ((sem_key = get_sem_key_for_system ()) == -1) {
|
||||
goto error;
|
||||
}
|
||||
semid = semget (sem_key, _NR_SEM, SEM_PARAM | IPC_CREAT | IPC_EXCL);
|
||||
if (semid == -1) {
|
||||
semid = semget (sem_key, _NR_SEM, SEM_PARAM | IPC_CREAT | IPC_EXCL);
|
||||
if (semid == -1) {
|
||||
goto error;
|
||||
}
|
||||
atexit (__mg_delete_sharedres_sem);
|
||||
@@ -291,15 +316,16 @@ void *kernel_LoadSharedResource (void)
|
||||
#endif
|
||||
SHAREDRES_SEMID = semid;
|
||||
|
||||
return mgSharedRes;
|
||||
return mgSharedRes;
|
||||
|
||||
error:
|
||||
perror ("KERNEL>LoadSharedResource");
|
||||
perror ("KERNEL>LoadSharedResource");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void kernel_UnloadSharedResource (void)
|
||||
{
|
||||
close (lockfd);
|
||||
unlink (LOCKFILE);
|
||||
}
|
||||
|
||||
@@ -324,12 +350,12 @@ void* kernel_AttachSharedResource (void)
|
||||
|
||||
memptr = shmat (shmid, 0, SHM_RDONLY);
|
||||
#endif
|
||||
if (memptr == (char*)-1)
|
||||
if (memptr == (char*)-1)
|
||||
goto error;
|
||||
return memptr;
|
||||
|
||||
error:
|
||||
perror ("AttachSharedResource");
|
||||
perror ("AttachSharedResource");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -337,10 +363,10 @@ void kernel_UnattachSharedResource (void)
|
||||
{
|
||||
#ifdef _USE_MMAP
|
||||
if (munmap(mgSharedRes, mgSizeRes))
|
||||
perror("detaches shared resource");
|
||||
perror("detaches shared resource");
|
||||
#else
|
||||
if (shmdt (mgSharedRes) < 0)
|
||||
perror("detaches shared resource");
|
||||
perror("detaches shared resource");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -160,6 +160,12 @@ GAL_Surface * GAL_CreateRGBSurface (Uint32 flags,
|
||||
surface->flags &= ~GAL_HWSURFACE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* set a static buff to pixels for empty surface */
|
||||
static char buff[8];
|
||||
surface->flags |= GAL_PREALLOC;
|
||||
surface->pixels = buff;
|
||||
}
|
||||
|
||||
/* Allocate an empty mapping */
|
||||
surface->map = GAL_AllocBlitMap();
|
||||
|
||||
+29
-34
@@ -11,41 +11,41 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
/*
|
||||
** layer.c: maintain the layers in server.
|
||||
**
|
||||
**
|
||||
** Current maintainer: Wei Yongming.
|
||||
**
|
||||
** Create date: 2005/08/14
|
||||
@@ -83,7 +83,7 @@ ON_CHANGE_LAYER OnChangeLayer = NULL;
|
||||
static int sg_nr_layers = 0;
|
||||
static unsigned char sem_usage [(MAX_NR_LAYERS + 7)/8];
|
||||
|
||||
static BOOL do_alloc_layer (MG_Layer* layer, const char* name,
|
||||
static BOOL do_alloc_layer (MG_Layer* layer, const char* name,
|
||||
int nr_topmosts, int nr_normals)
|
||||
{
|
||||
ZORDERINFO* zi;
|
||||
@@ -97,10 +97,10 @@ static BOOL do_alloc_layer (MG_Layer* layer, const char* name,
|
||||
|
||||
/* Attach to the share memory. */
|
||||
zi = shmat (layer->zorder_shmid, 0, 0);
|
||||
if (zi == (void*)-1)
|
||||
if (zi == (void*)-1)
|
||||
return FALSE;
|
||||
|
||||
if (shmctl (layer->zorder_shmid, IPC_RMID, NULL) < 0)
|
||||
if (shmctl (layer->zorder_shmid, IPC_RMID, NULL) < 0)
|
||||
return FALSE;
|
||||
|
||||
strcpy (layer->name, name);
|
||||
@@ -148,7 +148,7 @@ static BOOL do_alloc_layer (MG_Layer* layer, const char* name,
|
||||
memset (maskrect_usage_bmp, 0xFF, zi->size_maskrect_usage_bmp);
|
||||
|
||||
/* init z-order node for desktop */
|
||||
znodes = (ZORDERNODE*) ((char*)(zi + 1) + zi->size_usage_bmp +
|
||||
znodes = (ZORDERNODE*) ((char*)(zi + 1) + zi->size_usage_bmp +
|
||||
sizeof (ZORDERNODE) * DEF_NR_POPUPMENUS);
|
||||
|
||||
znodes [0].flags = ZOF_TYPE_DESKTOP | ZOF_VISIBLE;
|
||||
@@ -239,11 +239,6 @@ BOOL __mg_is_valid_layer (MG_Layer* layer)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline static key_t get_sem_key (void)
|
||||
{
|
||||
return (key_t)(IPC_KEY_BASE + 0x03);
|
||||
}
|
||||
|
||||
void __mg_delete_zi_sem (void)
|
||||
{
|
||||
union semun ignored;
|
||||
@@ -268,11 +263,11 @@ int __mg_init_layers ()
|
||||
|
||||
memset (sem_usage, 0xFF, sizeof (sem_usage));
|
||||
|
||||
if ((sem_key = get_sem_key ()) == -1) {
|
||||
if ((sem_key = get_sem_key_for_layers ()) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
semid = semget (sem_key, MAX_NR_LAYERS, SEM_PARAM | IPC_CREAT | IPC_EXCL);
|
||||
semid = semget (sem_key, MAX_NR_LAYERS, SEM_PARAM | IPC_CREAT | IPC_EXCL);
|
||||
if (semid == -1)
|
||||
return -1;
|
||||
atexit (__mg_delete_zi_sem);
|
||||
@@ -280,7 +275,7 @@ int __mg_init_layers ()
|
||||
SHAREDRES_SEMID_LAYER = semid;
|
||||
|
||||
/* allocate the first layer for the default layer. */
|
||||
if (!do_alloc_layer (mgLayers, NAME_DEF_LAYER,
|
||||
if (!do_alloc_layer (mgLayers, NAME_DEF_LAYER,
|
||||
SHAREDRES_DEF_NR_TOPMOSTS, SHAREDRES_DEF_NR_NORMALS)) {
|
||||
|
||||
free (mgLayers);
|
||||
@@ -349,18 +344,18 @@ static MG_Layer* alloc_layer (const char* layer_name,
|
||||
|
||||
mgTopmostLayer = new_layer;
|
||||
|
||||
_WRN_PRINTF ("SERVER: alloc_layer, mgTopmostLayer->zi = %p\n",
|
||||
_WRN_PRINTF ("SERVER: alloc_layer, mgTopmostLayer->zi = %p\n",
|
||||
mgTopmostLayer->zorder_info);
|
||||
|
||||
/* Topmost layer changed */
|
||||
CHANGE_TOPMOST_LAYER(mgTopmostLayer);
|
||||
|
||||
__mg_do_change_topmost_layer ();
|
||||
_WRN_PRINTF ("SERVER: alloc_layer, mgTopmostLayer->zi = %p\n",
|
||||
_WRN_PRINTF ("SERVER: alloc_layer, mgTopmostLayer->zi = %p\n",
|
||||
mgTopmostLayer->zorder_info);
|
||||
|
||||
/* Notify that a new topmost layer have been set. */
|
||||
if (OnChangeLayer)
|
||||
if (OnChangeLayer)
|
||||
OnChangeLayer (LCO_TOPMOST_CHANGED, mgTopmostLayer, NULL);
|
||||
|
||||
PostMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, 0);
|
||||
@@ -421,7 +416,7 @@ void __mg_get_layer_info (int cli, const char* layer_name, LAYERINFO* info)
|
||||
}
|
||||
}
|
||||
|
||||
static void do_client_join_layer (int cli,
|
||||
static void do_client_join_layer (int cli,
|
||||
const JOINLAYERINFO* info, JOINEDCLIENTINFO* joined_info)
|
||||
{
|
||||
MG_Layer* layer = (MG_Layer*)(joined_info->layer);
|
||||
@@ -433,11 +428,11 @@ static void do_client_join_layer (int cli,
|
||||
return;
|
||||
}
|
||||
|
||||
_WRN_PRINTF ("SERVER: Join a client (%s) to layer %s\n",
|
||||
_WRN_PRINTF ("SERVER: Join a client (%s) to layer %s\n",
|
||||
info->client_name, layer->name);
|
||||
|
||||
strcpy (new_client->name, info->client_name);
|
||||
|
||||
|
||||
new_client->layer = layer;
|
||||
|
||||
/* Notify that a new client joined to this layer. */
|
||||
@@ -455,13 +450,13 @@ static void do_client_join_layer (int cli,
|
||||
}
|
||||
|
||||
/* Join a client to a layer, the server side of JoinLayer */
|
||||
void __mg_client_join_layer (int cli,
|
||||
void __mg_client_join_layer (int cli,
|
||||
const JOINLAYERINFO* info, JOINEDCLIENTINFO* joined_info)
|
||||
{
|
||||
MG_Layer* layer;
|
||||
|
||||
if ((layer = __mg_find_layer_by_name (info->layer_name)) == NULL) {
|
||||
layer = alloc_layer (info->layer_name,
|
||||
layer = alloc_layer (info->layer_name,
|
||||
(info->max_nr_topmosts <= 0)?SHAREDRES_DEF_NR_TOPMOSTS:
|
||||
info->max_nr_topmosts,
|
||||
(info->max_nr_normals<= 0)?SHAREDRES_DEF_NR_NORMALS:
|
||||
@@ -512,7 +507,7 @@ BOOL GUIAPI ServerSetTopmostLayer (MG_Layer* layer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
MG_Layer* GUIAPI ServerCreateLayer (const char* layer_name,
|
||||
MG_Layer* GUIAPI ServerCreateLayer (const char* layer_name,
|
||||
int max_nr_topmosts, int max_nr_normals)
|
||||
{
|
||||
MG_Layer* new_layer;
|
||||
@@ -604,7 +599,7 @@ int GUIAPI ServerGetNextZNode (MG_Layer* layer, int idx_znode, int* cli)
|
||||
return -1;
|
||||
|
||||
zi = (ZORDERINFO*)layer->zorder_info;
|
||||
if (idx_znode > zi->max_nr_globals
|
||||
if (idx_znode > zi->max_nr_globals
|
||||
+ zi->max_nr_topmosts + zi->max_nr_normals) {
|
||||
return -1;
|
||||
}
|
||||
@@ -680,7 +675,7 @@ BOOL GUIAPI ServerGetZNodeInfo (MG_Layer* layer, int idx_znode,
|
||||
return FALSE;
|
||||
|
||||
zi = (ZORDERINFO*)layer->zorder_info;
|
||||
if (idx_znode > zi->max_nr_globals
|
||||
if (idx_znode > zi->max_nr_globals
|
||||
+ zi->max_nr_topmosts + zi->max_nr_normals) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -713,7 +708,7 @@ BOOL GUIAPI ServerDoZNodeOperation (MG_Layer* layer,
|
||||
return FALSE;
|
||||
|
||||
zi = (ZORDERINFO*)layer->zorder_info;
|
||||
if (idx_znode > zi->max_nr_globals
|
||||
if (idx_znode > zi->max_nr_globals
|
||||
+ zi->max_nr_topmosts + zi->max_nr_normals) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user