From 766ddb5555ef75affb306cb6aa949c2bc0010abb Mon Sep 17 00:00:00 2001 From: VincentWei Date: Fri, 19 Jan 2018 15:35:26 +0800 Subject: [PATCH] tune code for 64b (MiniGUI-Processes runmode) --- include/common.h | 34 ++++++-- include/window.h | 4 +- src/include/client.h | 1 + src/include/newgal.h | 4 +- src/include/ourhdr.h | 4 +- src/include/server.h | 7 +- src/kernel/Makefile.am | 2 +- src/kernel/cursor-comm.c | 174 +++++++++++++++++++++++++++++++++++++ src/kernel/cursor-procs.c | 132 ++-------------------------- src/kernel/cursor-sa.c | 124 +------------------------- src/kernel/cursor.c | 172 ++---------------------------------- src/kernel/desktop-procs.c | 150 ++++++++++++++++---------------- src/kernel/desktop.c | 3 +- src/kernel/timer.c | 1 + src/misc/about.c | 2 +- src/newgal/pcxvfb/pcxvfb.c | 58 ++++++------- src/server/client.c | 16 ++-- src/server/layer.c | 2 +- src/server/request.c | 10 +-- 19 files changed, 347 insertions(+), 553 deletions(-) create mode 100644 src/kernel/cursor-comm.c diff --git a/include/common.h b/include/common.h index 57667980..86848eec 100644 --- a/include/common.h +++ b/include/common.h @@ -1883,17 +1883,26 @@ int init_minigui_printf (int (*output_char) (int ch), #endif /* _MGUSE_OWN_STDIO */ #if defined(__GNUC__) -#ifdef _DEBUG -# define _MG_PRINTF(fmt...) fprintf (stderr, fmt) -# define _DBG_PRINTF(fmt...) fprintf (stdout, fmt) -#else -# define _MG_PRINTF(fmt...) -# define _DBG_PRINTF(fmt...) -#endif +# define _ERR_PRINTF(fmt...) fprintf (stderr, fmt) +# ifdef _DEBUG +# define _MG_PRINTF(fmt...) fprintf (stderr, fmt) +# define _DBG_PRINTF(fmt...) fprintf (stdout, fmt) +# else +# define _MG_PRINTF(fmt...) +# define _DBG_PRINTF(fmt...) +# endif #else /* __GNUC__ */ #include #include +static inline void _ERR_PRINTF(const char* fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} static inline void _MG_PRINTF(const char* fmt, ...) { #ifdef _DEBUG @@ -1904,6 +1913,17 @@ static inline void _MG_PRINTF(const char* fmt, ...) va_end(ap); #endif } + +static inline void _DBG_PRINTF(const char* fmt, ...) +{ +#ifdef _DEBUG + va_list ap; + va_start(ap, fmt); + vfprintf(stdout, fmt, ap); + fprintf(stdout, "\n"); + va_end(ap); +#endif +} #endif /* __GNUC__ */ #ifdef _MGRM_THREADS diff --git a/include/window.h b/include/window.h index 760e42b7..b9694e83 100644 --- a/include/window.h +++ b/include/window.h @@ -2443,7 +2443,7 @@ MG_EXPORT void GUIAPI SetAutoRepeatMessage (HWND hwnd, UINT msg, #define CLIENT_ACTIVE -4 /** - * \fn int Send2Client (MSG* msg, int cli) + * \fn int Send2Client (const MSG* msg, int cli) * \brief Sends a message to a client. * * This function sends a message to the specified client \a cli. @@ -2472,7 +2472,7 @@ MG_EXPORT void GUIAPI SetAutoRepeatMessage (HWND hwnd, UINT msg, * * \sa Send2TopMostClients, Send2ActiveWindow */ -int GUIAPI Send2Client (MSG* msg, int cli); +int GUIAPI Send2Client (const MSG* msg, int cli); /** * \fn BOOL Send2TopMostClients (UINT nMsg, WPARAM wParam, LPARAM lParam) diff --git a/src/include/client.h b/src/include/client.h index 6f8fc956..838dece4 100644 --- a/src/include/client.h +++ b/src/include/client.h @@ -144,6 +144,7 @@ typedef struct ZorderOpInfo HWND main_win; RECT rc; RECT rcA; + int location; char caption[MAX_CAPTION_LEN + 1]; } ZORDEROPINFO; diff --git a/src/include/newgal.h b/src/include/newgal.h index b87f15c0..33a0c550 100644 --- a/src/include/newgal.h +++ b/src/include/newgal.h @@ -31,8 +31,8 @@ extern "C" { #define GAL_LIL_ENDIAN MGUI_LIL_ENDIAN #define GAL_BIG_ENDIAN MGUI_BIG_ENDIAN -#define GAL_OutOfMemory() fprintf (stderr, "Out of memory\n") -#define GAL_SetError printf +#define GAL_OutOfMemory() _ERR_PRINTF("NEWGAL: Out of memory\n") +#define GAL_SetError _ERR_PRINTF #define GAL_ClearError() /* Transparency definitions: These define alpha as the opacity of a surface */ diff --git a/src/include/ourhdr.h b/src/include/ourhdr.h index 94a499c4..39dda6a2 100644 --- a/src/include/ourhdr.h +++ b/src/include/ourhdr.h @@ -62,9 +62,9 @@ void log_sys(const char *, ...); #endif typedef struct listen_fd { - int fd; - int hwnd; int type; + int fd; + void* hwnd; void* context; } LISTEN_FD; diff --git a/src/include/server.h b/src/include/server.h index b3c29fbf..bba1d043 100644 --- a/src/include/server.h +++ b/src/include/server.h @@ -56,15 +56,14 @@ void __mg_remove_client (int cli, int clifd); int __mg_handle_request (int clifd, int req_id, int cli); -int __mg_send2client (MSG* msg, MG_Client* client); +int __mg_send2client (const MSG* msg, MG_Client* client); void __mg_set_active_client (MG_Client* client); void __mg_start_server_desktop (void); int __mg_post_msg_by_znode (const ZORDERINFO* zi, int znode, int message, WPARAM wParam, LPARAM lParam); -int __mg_do_zorder_operation (int cli, const ZORDEROPINFO* info); -int __mg_do_zorder_maskrect_operation (int cli, - const ZORDERMASKRECTOPINFO* info); +intptr_t __mg_do_zorder_operation (int cli, const ZORDEROPINFO* info); +intptr_t __mg_do_zorder_maskrect_operation (int cli, const ZORDERMASKRECTOPINFO* info); int __mg_remove_all_znodes_of_client (int cli); int __mg_handle_normal_mouse_move (const ZORDERINFO* zi, int x, int y); diff --git a/src/kernel/Makefile.am b/src/kernel/Makefile.am index 87ae70bc..0bbedde8 100644 --- a/src/kernel/Makefile.am +++ b/src/kernel/Makefile.am @@ -18,7 +18,7 @@ libkernel_la_SOURCES = timer.c \ endif # hash.c -EXTRA_DIST= desktop.c desktop-comm.c makefile.ng makefile.msvc +EXTRA_DIST= desktop.c desktop-comm.c cursor-comm.c makefile.ng makefile.msvc # for makefile.ng and makefile.msvc LIB_NAME = libkernel diff --git a/src/kernel/cursor-comm.c b/src/kernel/cursor-comm.c new file mode 100644 index 00000000..c293ae21 --- /dev/null +++ b/src/kernel/cursor-comm.c @@ -0,0 +1,174 @@ + +static HCURSOR load_cursor_from_file (const char* filename) +{ + FILE* fp; + WORD16 wTemp; + int w, h, xhot, yhot, colornum; +#if 0 + DWORD32 size; +#endif + DWORD32 offset, imagesize, imagew, imageh; + BYTE* image; + HCURSOR csr = 0; + + if (!(fp = fopen(filename, "rb"))) + return 0; + + fseek(fp, sizeof(WORD16), SEEK_SET); + + /* the cbType of struct CURSORDIR. */ + wTemp = MGUI_ReadLE16FP (fp); + if(wTemp != 2) { + _MG_PRINTF ("LoadCursorFromFile: bad file type: %d\n", wTemp); + goto error; + } + + /* skip the cdCount of struct CURSORDIR, we always use the first cursor. */ + fseek(fp, sizeof(WORD16), SEEK_CUR); + + /* cursor info, read the members of struct CURSORDIRENTRY. */ + w = fgetc (fp); /* the width of first cursor. */ + h = fgetc (fp); /* the height of first cursor. */ + if (w != CURSORWIDTH || h != CURSORHEIGHT) { + _MG_PRINTF ("LoadCursorFromFile: bad first cursor width (%d) and height (%d)\n", w, h); + goto error; + } + + fseek(fp, sizeof(BYTE)*2, SEEK_CUR); /* skip bColorCount and bReserved. */ + wTemp = MGUI_ReadLE16FP (fp); + xhot = wTemp; + wTemp = MGUI_ReadLE16FP (fp); + yhot = wTemp; +#if 0 + size = MGUI_ReadLE32FP (fp); +#else + fseek (fp, sizeof(DWORD32), SEEK_CUR); /* skip size. */ +#endif + offset = MGUI_ReadLE32FP (fp); + + /* read the cursor image info. */ + fseek(fp, offset, SEEK_SET); + fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biSize member. */ + imagew = MGUI_ReadLE32FP (fp); + imageh = MGUI_ReadLE32FP (fp); + if (imagew != CURSORWIDTH || imageh != (CURSORHEIGHT*2)) { + _MG_PRINTF ("LoadCursorFromFile: bad cursor image width (%d) and height (%d)\n", imagew, imageh); + goto error; + } + + /* check the biPlanes member; */ + wTemp = MGUI_ReadLE16FP (fp); + if (wTemp != 1) { + _MG_PRINTF ("LoadCursorFromFile: bad planes (%d)\n", wTemp); + goto error; + } + + /* check the biBitCount member; */ + wTemp = MGUI_ReadLE16FP (fp); + if (wTemp > 4) { + _MG_PRINTF ("LoadCursorFromFile: bad bit count (%d)\n", wTemp); + goto error; + } + + colornum = (int)wTemp; + fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biCompression members. */ + imagesize = MGUI_ReadLE32FP (fp); + + /* skip the rest members and the color table. */ + fseek(fp, sizeof(DWORD32)*4 + sizeof(BYTE)*(4< 32 || imageh > 32) { + goto error; + } + + /* check the biPlanes member; */ + wTemp = MGUI_ReadLE16Mem (&p); + if (wTemp != 1) goto error; + + /* check the biBitCount member; */ + wTemp = MGUI_ReadLE16Mem (&p); + if (wTemp > 4) goto error; + colornum = wTemp; + + /* skip the biCompression members. */ + p += sizeof (DWORD32); + imagesize = MGUI_ReadLE32Mem (&p); + + /* skip the rest members and the color table. */ + p += sizeof(DWORD32)*4 + sizeof(BYTE)*(4< 4) goto error; - colornum = (int)wTemp; - fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biCompression members. */ - imagesize = MGUI_ReadLE32FP (fp); - - /* skip the rest members and the color table. */ - fseek(fp, sizeof(DWORD32)*4 + sizeof(BYTE)*(4< 4) goto error; - colornum = wTemp; - - /* skip the biCompression members. */ - p += sizeof (DWORD32); - imagesize = MGUI_ReadLE32Mem (&p); - - /* skip the rest members and the color table. */ - p += sizeof(DWORD32)*4 + sizeof(BYTE)*(4< 4) goto error; - colornum = (int)wTemp; - fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biCompression members. */ - imagesize = MGUI_ReadLE32FP (fp); - - /* skip the rest members and the color table. */ - fseek(fp, sizeof(DWORD32)*4 + sizeof(BYTE)*(4< 4) goto error; - colornum = wTemp; - - /* skip the biCompression members. */ - p += sizeof (DWORD32); - imagesize = MGUI_ReadLE32Mem (&p); - - /* skip the rest members and the color table. */ - p += sizeof(DWORD32)*4 + sizeof(BYTE)*(4< 4) { - _MG_PRINTF ("LoadCursorFromFile: bad bit count (%d)\n", wTemp); - goto error; - } - - colornum = (int)wTemp; - fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biCompression members. */ - imagesize = MGUI_ReadLE32FP (fp); - - /* skip the rest members and the color table. */ - fseek(fp, sizeof(DWORD32)*4 + sizeof(BYTE)*(4< 32 || imageh > 32) { - goto error; - } - - /* check the biPlanes member; */ - wTemp = MGUI_ReadLE16Mem (&p); - if (wTemp != 1) goto error; - - /* check the biBitCount member; */ - wTemp = MGUI_ReadLE16Mem (&p); - if (wTemp > 4) goto error; - colornum = wTemp; - - /* skip the biCompression members. */ - p += sizeof (DWORD32); - imagesize = MGUI_ReadLE32Mem (&p); - - /* skip the rest members and the color table. */ - p += sizeof(DWORD32)*4 + sizeof(BYTE)*(4<idx_znode; - info.hwnd = (HWND)drag_info->location; + info.location = drag_info->location; info.rc.left = drag_info->init_x; info.rc.top = drag_info->init_y; @@ -521,15 +521,15 @@ static int cliStartDragWindow (PMAINWIN pWin, const DRAGINFO* drag_info) req.data = &info; req.len_data = sizeof (ZORDEROPINFO); - if (ClientRequest (&req, &ret, sizeof (int)) < 0) + if (ClientRequest (&req, &ret, sizeof (intptr_t)) < 0) return -1; return ret; } -static int cliCancelDragWindow (PMAINWIN pWin) +static intptr_t cliCancelDragWindow (PMAINWIN pWin) { - int ret; + intptr_t ret; REQUEST req; ZORDEROPINFO info; @@ -540,15 +540,15 @@ static int cliCancelDragWindow (PMAINWIN pWin) req.data = &info; req.len_data = sizeof (ZORDEROPINFO); - if (ClientRequest (&req, &ret, sizeof (int)) < 0) + if (ClientRequest (&req, &ret, sizeof (intptr_t)) < 0) return -1; return ret; } -static int cliChangeCaption (PMAINWIN pWin) +static intptr_t cliChangeCaption (PMAINWIN pWin) { - int ret; + intptr_t ret; REQUEST req; ZORDEROPINFO info; @@ -565,7 +565,7 @@ static int cliChangeCaption (PMAINWIN pWin) req.id = REQID_ZORDEROP; req.data = &info; req.len_data = sizeof (ZORDEROPINFO); - if ((ret = ClientRequest (&req, &ret, sizeof (int))) < 0) { + if ((ret = ClientRequest (&req, &ret, sizeof (intptr_t))) < 0) { return -1; } @@ -588,9 +588,9 @@ void __mg_start_server_desktop (void) SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, 0); } -static int cliAllocZOrderMaskRect (HWND pWin, const RECT4MASK* rc, int nr_rc) +static intptr_t cliAllocZOrderMaskRect (HWND pWin, const RECT4MASK* rc, int nr_rc) { - int ret; + intptr_t ret; REQUEST req; ZORDERMASKRECTOPINFO info; @@ -607,16 +607,16 @@ static int cliAllocZOrderMaskRect (HWND pWin, const RECT4MASK* rc, int nr_rc) req.len_data = sizeof (info); if ((ret = ClientRequestEx (&req, rc, sizeof(RECT4MASK)*nr_rc, - &ret, sizeof (int))) < 0) { + &ret, sizeof (intptr_t))) < 0) { return -1; } return ret; } -static int cliFreeZOrderMaskRect (PMAINWIN pWin) +static intptr_t cliFreeZOrderMaskRect (PMAINWIN pWin) { - int ret; + intptr_t ret; REQUEST req; ZORDERMASKRECTOPINFO info; @@ -628,7 +628,7 @@ static int cliFreeZOrderMaskRect (PMAINWIN pWin) req.data = &info; req.len_data = sizeof(ZORDERMASKRECTOPINFO); - if ((ret = ClientRequest (&req, &ret, sizeof (int))) < 0) { + if ((ret = ClientRequest (&req, &ret, sizeof (intptr_t))) < 0) { return -1; } return ret; @@ -680,7 +680,7 @@ static BOOL _cb_update_cli_znode (void* context, const ZORDERINFO* zi, ZORDERNODE* znode) { RECT rcInv; - int cli = (int)context; + int cli = (int)(intptr_t)context; if (znode->cli == cli && znode->flags & ZOF_VISIBLE && znode->fortestinghwnd) { MSG msg = {znode->fortestinghwnd, MSG_UPDATECLIWIN, 0, 0, __mg_timer_counter}; @@ -706,20 +706,20 @@ void __mg_check_dirty_znode (int cli) { ZORDERINFO* zi = (ZORDERINFO *)get_zi_from_client (cli); - do_for_all_znodes ((void*)cli, zi, + do_for_all_znodes ((void*)(intptr_t)cli, zi, _cb_update_cli_znode, ZT_TOPMOST | ZT_NORMAL); mgClients [cli].has_dirty = FALSE; } -static int srvSetActiveWindow (int cli, int idx_znode) +static intptr_t srvSetActiveWindow (int cli, int idx_znode) { - int ret = dskSetActiveZOrderNode (cli, idx_znode); + HWND hRet = dskSetActiveZOrderNode (cli, idx_znode); - if ((ret != HWND_INVALID) && OnZNodeOperation) + if ((hRet != HWND_INVALID) && OnZNodeOperation) OnZNodeOperation (ZNOP_SETACTIVE, cli, idx_znode); - return ret; + return (intptr_t)hRet; } static int srvFreeZOrderNode (int cli, int idx_znode) @@ -1024,10 +1024,10 @@ static int srvChangeCaption (int cli, int idx_znode, const char *caption) return 0; } -int __mg_do_zorder_maskrect_operation (int cli, +intptr_t __mg_do_zorder_maskrect_operation (int cli, const ZORDERMASKRECTOPINFO* info) { - int ret = -1; + intptr_t ret = -1; switch (info->id_op) { case ID_ZOOP_MASKRECT_SET: @@ -1042,9 +1042,9 @@ int __mg_do_zorder_maskrect_operation (int cli, return ret; } -int __mg_do_zorder_operation (int cli, const ZORDEROPINFO* info) +intptr_t __mg_do_zorder_operation (int cli, const ZORDEROPINFO* info) { - int ret = -1; + intptr_t ret = -1; switch (info->id_op) { case ID_ZOOP_ALLOC: @@ -1084,7 +1084,7 @@ int __mg_do_zorder_operation (int cli, const ZORDEROPINFO* info) ret = srvEnableWindow (cli, info->idx_znode, info->flags); break; case ID_ZOOP_STARTDRAG: - ret = srvStartDragWindow (cli, info->idx_znode, (int)info->hwnd, + ret = srvStartDragWindow (cli, info->idx_znode, info->location, info->rc.left, info->rc.top); break; case ID_ZOOP_CANCELDRAG: @@ -1131,7 +1131,7 @@ static BOOL _cb_intersect_rc_no_cli (void* context, static BOOL _cb_update_rc_nocli (void* context, const ZORDERINFO* zi, ZORDERNODE* node) { - int cli = (int)context; + int cli = (int)(intptr_t)context; if (node->flags & ZOF_VISIBLE && node->cli != cli && //SubtractClipRect (&sg_UpdateRgn, &node->rc)) { @@ -1169,7 +1169,7 @@ int __mg_remove_all_znodes_of_client (int cli) SetClipRgn (&sg_UpdateRgn, &rc_bound); /* check influenced window zorder nodes */ - do_for_all_znodes ((void*)cli, zi, _cb_update_rc_nocli, ZT_ALL); + do_for_all_znodes ((void*)(intptr_t)cli, zi, _cb_update_rc_nocli, ZT_ALL); if (SubtractClipRect (&sg_UpdateRgn, &g_rcScr)) { nodes [0].age ++; @@ -2038,7 +2038,7 @@ static int dskChangeCaption (PMAINWIN pWin) return cliChangeCaption (pWin); } -static int dskWindowMessageHandler (int message, PMAINWIN pWin, LPARAM lParam) +static LRESULT dskWindowMessageHandler (UINT message, PMAINWIN pWin, LPARAM lParam) { switch (message) { case MSG_ADDNEWMAINWIN: @@ -2068,16 +2068,16 @@ static int dskWindowMessageHandler (int message, PMAINWIN pWin, LPARAM lParam) break; case MSG_GETACTIVEMAIN: - return (int)dskGetActiveWindow (NULL); + return (LRESULT)dskGetActiveWindow (NULL); case MSG_SETACTIVEMAIN: - return (int)dskSetActiveWindow (pWin); + return (LRESULT)dskSetActiveWindow (pWin); case MSG_GETCAPTURE: - return (int)dskGetCaptureWindow (); + return (LRESULT)dskGetCaptureWindow (); case MSG_SETCAPTURE: - return (int)dskSetCaptureWindow (pWin); + return (LRESULT)dskSetCaptureWindow (pWin); #ifdef _MGHAVE_MENU case MSG_TRACKPOPUPMENU: @@ -2116,11 +2116,11 @@ static int dskWindowMessageHandler (int message, PMAINWIN pWin, LPARAM lParam) HCURSOR old = pWin->hCursor; pWin->hCursor = (HCURSOR)lParam; - return old; + return (LRESULT)old; } case MSG_GETNEXTMAINWIN: - return (int)dskGetNextMainWindow (pWin); + return (LRESULT)dskGetNextMainWindow (pWin); case MSG_SHOWGLOBALCTRL: { @@ -2375,7 +2375,7 @@ int __mg_handle_normal_mouse_move (const ZORDERINFO* zi, int x, int y) ZORDERNODE* nodes = GET_ZORDERNODE(zi); static int old_slot, old_cli; - static int old_hwnd; + static HWND old_hwnd; int cur_slot; int cur_cli = 0; @@ -3236,7 +3236,7 @@ static void srvSaveScreen (BOOL active) rcActive = g_rcScr; } - sprintf (buffer, "%d-%x-%d.bmp", cliActive, hwndActive, n); + sprintf (buffer, "%d-%p-%d.bmp", cliActive, hwndActive, n); if (SaveScreenRectContent (&rcActive, buffer)) { Ping (); n ++; @@ -3461,7 +3461,7 @@ static int srvSesseionMessageHandler (int message, WPARAM wParam, LPARAM lParam) } -int DesktopWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam) +LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int flags, x, y; @@ -3597,10 +3597,10 @@ int DesktopWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam) return dskOnRemoveCtrlInstance ((PCONTROL)wParam, (PCONTROL)lParam); case MSG_GETCTRLCLASSINFO: - return (int)gui_GetControlClassInfo ((const char*)lParam); + return (LRESULT)gui_GetControlClassInfo ((const char*)lParam); case MSG_CTRLCLASSDATAOP: - return (int)gui_ControlClassDataOp (wParam, (WNDCLASS*)lParam); + return (LRESULT)gui_ControlClassDataOp (wParam, (WNDCLASS*)lParam); case MSG_IME_REGISTER: if (mgIsServer) diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index 12ab2cc4..73da3379 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -2558,8 +2558,7 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) nodes [idx_znode].age ++; #if defined (_MGRM_PROCESSES) && !defined (_MGRM_STANDALONE) - if (cli == 0 - || (DWORD)mgClients [cli].layer == SHAREDRES_TOPMOST_LAYER) { + if (cli == 0 || mgClients [cli].layer == SHAREDRES_TOPMOST_LAYER) { #endif /* Copy window content to new postion */ InitClipRgn (&bblt_rgn, &sg_FreeClipRectList); diff --git a/src/kernel/timer.c b/src/kernel/timer.c index f38783b1..4875127c 100644 --- a/src/kernel/timer.c +++ b/src/kernel/timer.c @@ -28,6 +28,7 @@ #include "timer.h" #ifdef _MGRM_PROCESSES +#include "ourhdr.h" #include "client.h" #include "sharedres.h" #endif diff --git a/src/misc/about.c b/src/misc/about.c index d5939af5..2e09186b 100644 --- a/src/misc/about.c +++ b/src/misc/about.c @@ -78,6 +78,7 @@ static LRESULT AboutWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar case MSG_CLOSE: sg_AboutWnd = 0; DestroyAllControls (hWnd); + DestroyMainWindow (hWnd); #ifdef _MGRM_THREADS PostQuitMessage (hWnd); #endif @@ -138,7 +139,6 @@ static void* AboutDialogThread (void* data) DispatchMessage(&Msg); } - DestroyMainWindow (hMainWnd); MainWindowThreadCleanup(hMainWnd); return NULL; } diff --git a/src/newgal/pcxvfb/pcxvfb.c b/src/newgal/pcxvfb/pcxvfb.c index 2ef7db18..a0e59afc 100644 --- a/src/newgal/pcxvfb/pcxvfb.c +++ b/src/newgal/pcxvfb/pcxvfb.c @@ -156,11 +156,10 @@ static int execl_pcxvfb(void) skin[0] = '\0'; GetMgEtcValue("pc_xvfb", "skin", skin, sizeof(skin)-1); - - fprintf(stderr,"start-qvfb :%s pcxvfb %s %s %s %s\n", execl_file, ch_pid, window_caption, mode, skin); + _MG_PRINTF ("IAL>PCXVFB: start-qvfb :%s pcxvfb %s %s %s %s\n", execl_file, ch_pid, window_caption, mode, skin); if (execlp(execl_file, "pcxvfb", ch_pid, window_caption, mode, skin, NULL) < 0) { - fprintf(stderr, "execlp error!!\n"); + _MG_PRINTF ("IAL>PCXVFB: failed to start the virtual frame buffer process!\n"); } return 0; @@ -400,14 +399,12 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat) //shm_init_lock(getpid()); - if ((pid = fork()) < 0) - { - fprintf(stderr, "fork() error in pcxvfb\n"); + if ((pid = fork()) < 0) { + _MG_PRINTF ("NEWGAL>PCXVFB: fork() error.\n"); } - else if (pid == 0) - { + else if (pid == 0) { if (execl_pcxvfb() == ERR_CONFIG_FILE) - fprintf(stderr, "PCXVFB GAL: Reading configuration failure!\n"); + _MG_PRINTF ("NEWGAL>PCXVFB: failed to read configuration failure.\n"); perror ("execl"); _exit (1); @@ -431,7 +428,6 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat) close(fd); #else //-----------------linux---------------------- - int display; pid_t pid; int server_len; @@ -465,24 +461,21 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat) shm_init_lock(getpid()); if ((pid = fork()) < 0) { - fprintf(stderr, "fork() error in pcxvfb\n"); - }else if (pid > 0) { + GAL_SetError ("NEWGAL>PCXVFB: Error occurred when calling fork().\n"); + } else if (pid > 0) { ;/* do nothing */ - }else { + } else { if (setpgid(getpid(), 0) < 0) { - fprintf(stderr, "Warning: Failed to change the group id of the VFB process.\n"); + GAL_SetError ("NEWGAL>PCXVFB: Failed to change the group id of the XVFB process.\n"); } if (execl_pcxvfb() == ERR_CONFIG_FILE) - fprintf(stderr, "PCXVFB GAL: Reading configuration failure!\n"); + GAL_SetError ("NEWGAL>PCXVFB: Reading configuration failure!\n"); perror ("execl"); _exit (1); } - if (GetMgEtcIntValue ("qvfb", "display", &display) < 0) - display = 0; - { fd_set rset; struct timeval tv; @@ -527,24 +520,32 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat) if (shmid != -1) { data->shmrgn = (unsigned char *)shmat (shmid, 0, 0); #ifdef _MGRM_PROCESSES - fp = fopen("/tmp/.pcxvfb_tmp", "w+"); + fp = fopen("/var/tmp/.pcxvfb_tmp", "w+"); if (fp == NULL) { - fprintf(stderr, "mgServer can't open file /tmp/.pcxvfb_tmp\n"); + GAL_SetError ("NEWGAL>PCXVFB: mgServer can't open file /var/tmp/.pcxvfb_tmp\n"); return -1; } - fwrite(&shmid, sizeof(int), 1, fp); + + fwrite (&shmid, sizeof(int), 1, fp); fclose(fp); #endif } #if defined(_MGRM_PROCESSES) && !defined(_MGRM_STANDALONE) - } else { - fp = fopen("/tmp/.pcxvfb_tmp", "r"); + } + else { + fp = fopen ("/var/tmp/.pcxvfb_tmp", "r"); if (fp == NULL) { - fprintf(stderr, "minigui can't open file /tmp/.pcxvfb_tmp\n"); + GAL_SetError ("NEWGAL>PCXVFB: can't open file /var/tmp/.pcxvfb_tmp\n"); return -1; } - fread(&shmid, sizeof(int), 1, fp); + + if (fread(&shmid, sizeof(int), 1, fp) < 1) { + GAL_SetError ("NEWGAL>PCXVFB: can't read from /var/tmp/.pcxvfb_tmp\n"); + fclose (fp); + return -1; + } + fclose(fp); if (shmid != -1) { @@ -555,8 +556,7 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat) #endif //end of os (windows, cygwin, linux) if ((INT_PTR)data->shmrgn == -1 || data->shmrgn == NULL) { - GAL_SetError ("NEWGAL>PCXVFB: Unable to attach to " - "virtual FrameBuffer server.\n"); + GAL_SetError ("NEWGAL>PCXVFB: Unable to attach to virtual frame buffer server.\n"); return -1; } @@ -597,8 +597,8 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat) vformat->Bmask = data->hdr->Bmask; break; default: - GAL_SetError ("NEWGAL>PCXQVFB: Not supported depth: %d, " - "please try to use Shadow NEWGAL engine with targetname qvfb.\n", + GAL_SetError ("NEWGAL>PCXVFB: Not supported depth: %d, " + "please try to use Shadow NEWGAL engine with targetname pc_xvfb.\n", vformat->BitsPerPixel); return -1; } diff --git a/src/server/client.c b/src/server/client.c index 47bda1dc..3479d216 100644 --- a/src/server/client.c +++ b/src/server/client.c @@ -42,8 +42,8 @@ int mgClientSize = 0; #define off_pointer(p,off) \ do { \ if (p) { \ - unsigned int tmp; \ - tmp = (unsigned int)p; \ + intptr_t tmp; \ + tmp = (intptr_t)p; \ tmp += off; \ p = (void*)tmp; \ } \ @@ -190,7 +190,7 @@ void __mg_remove_client (int cli, int clifd) close (clifd); } -int __mg_send2client (MSG* msg, MG_Client* client) +int __mg_send2client (const MSG* msg, MG_Client* client) { int ret; @@ -243,7 +243,7 @@ void __mg_set_active_client (MG_Client* client) } /* send message to client(s) */ -int GUIAPI Send2Client (MSG* msg, int cli) +int GUIAPI Send2Client (const MSG* msg, int cli) { int i, n; @@ -296,9 +296,9 @@ int GUIAPI Send2Client (MSG* msg, int cli) return SOCKERR_OK; } -BOOL GUIAPI Send2TopMostClients (int iMsg, WPARAM wParam, LPARAM lParam) +BOOL GUIAPI Send2TopMostClients (UINT nMsg, WPARAM wParam, LPARAM lParam) { - MSG msg = {0, iMsg, wParam, lParam, __mg_timer_counter}; + MSG msg = {0, nMsg, wParam, lParam, __mg_timer_counter}; if (!mgIsServer) return FALSE; @@ -310,7 +310,7 @@ BOOL GUIAPI Send2TopMostClients (int iMsg, WPARAM wParam, LPARAM lParam) } BOOL GUIAPI Send2ActiveWindow (const MG_Layer* layer, - int iMsg, WPARAM wParam, LPARAM lParam) + UINT nMsg, WPARAM wParam, LPARAM lParam) { int active_win; @@ -322,7 +322,7 @@ BOOL GUIAPI Send2ActiveWindow (const MG_Layer* layer, return FALSE; if (__mg_post_msg_by_znode (layer->zorder_info, - active_win, iMsg, wParam, lParam) > 0) + active_win, nMsg, wParam, lParam) > 0) return TRUE; return FALSE; diff --git a/src/server/layer.c b/src/server/layer.c index 984d46fe..e7f4f555 100644 --- a/src/server/layer.c +++ b/src/server/layer.c @@ -89,7 +89,7 @@ static BOOL do_alloc_layer (MG_Layer* layer, const char* name, zi->active_win = 0; zi->cli_trackmenu = -1; - zi->ptmi_in_cli = -1; + zi->ptmi_in_cli = HWND_INVALID; zi->zi_semid = SHAREDRES_SEMID_LAYER; diff --git a/src/server/request.c b/src/server/request.c index d850de04..526986c3 100644 --- a/src/server/request.c +++ b/src/server/request.c @@ -170,7 +170,7 @@ static int create_cursor (int cli, int clifd, void* buff, size_t len) static int copy_cursor (int cli, int clifd, void* buff, size_t len) { - HCURSOR hcsr = CopyCursor ((HCURSOR)*(int*)buff); + HCURSOR hcsr = CopyCursor ((HCURSOR)*(intptr_t*)buff); #ifdef _MGHAVE_CURSOR if (hcsr) { add_global_res (cli, (void*) hcsr, (void*)hcsr, NULL); @@ -338,22 +338,22 @@ ret: static int zorder_op (int cli, int clifd, void* buff, size_t len) { - int ret_value; + intptr_t ret_value; ZORDEROPINFO* info = (ZORDEROPINFO*)buff; ret_value = __mg_do_zorder_operation (cli, info); - return ServerSendReply (clifd, &ret_value, sizeof (int)); + return ServerSendReply (clifd, &ret_value, sizeof (intptr_t)); } static int change_zorder_maskrect (int cli, int clifd, void* buff, size_t len) { - int ret_value; + intptr_t ret_value; ZORDERMASKRECTOPINFO* info = (ZORDERMASKRECTOPINFO *)buff; info->rc = (RECT4MASK*)(buff + sizeof (ZORDERMASKRECTOPINFO)); ret_value = __mg_do_zorder_maskrect_operation (cli, info); - return ServerSendReply (clifd, &ret_value, sizeof (int)); + return ServerSendReply (clifd, &ret_value, sizeof (intptr_t)); } #ifdef _MGGAL_SIGMA8654 extern int Sigma8654_ServerOnGetSurface(REQ_SIGMA8654_GETSURFACE *request, REP_SIGMA8654_GETSURFACE *reply);