From fde22991260b81a848e5320d4646ff46a4bf1013 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sun, 12 Jan 2020 14:27:13 +0800 Subject: [PATCH] Call GetScreenRect for usage of &g_rcScr --- src/control/ctrlmisc.c | 65 ++- src/gui/dialog.c | 10 +- src/include/dc.h | 4 +- src/include/newgal.h | 8 +- src/kernel/desktop-comm.c | 12 +- src/kernel/desktop-procs.c | 28 +- src/kernel/desktop-sa.c | 26 +- src/kernel/desktop-ths.c | 38 +- src/kernel/desktop.c | 512 +++++++++++---------- src/kernel/init-lite.c | 4 + src/kernel/init.c | 2 + src/misc/license.c | 46 +- src/newgal/bf533/bf533video.c | 3 +- src/newgal/commlcd/commlcd.c | 4 +- src/newgal/em85xxyuv/em85xxyuv.c | 87 ++-- src/newgal/mb93493/mb93493video.c | 4 +- src/newgal/mlshadow/mlshadow-proc.c | 294 ++++++------ src/newgal/mlshadow/mlshadow-ths.c | 178 +++---- src/newgal/mlshadow/test/window_mini_max.c | 4 +- src/newgal/shadow/shadow.c | 106 ++--- src/newgal/usvfb/usvfb.c | 36 +- src/newgal/utpmc/utpmcvideo-lite.c | 45 +- src/newgal/utpmc/utpmcvideo.c | 45 +- src/newgal/video.c | 2 +- src/newgdi/gdi.c | 10 +- src/newgdi/screen.c | 26 +- src/server/layer.c | 4 +- 27 files changed, 836 insertions(+), 767 deletions(-) diff --git a/src/control/ctrlmisc.c b/src/control/ctrlmisc.c index 18b06caf..791c407c 100644 --- a/src/control/ctrlmisc.c +++ b/src/control/ctrlmisc.c @@ -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 . - * + * * 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 * . */ @@ -76,34 +76,33 @@ static LRESULT ToolTipWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP SetTimer (hWnd, _ID_TIMER, timeout / 10); info = GetWindowInfo (hWnd); - iBorder = + iBorder = info->we_rdr->calc_we_area (hWnd, LFRDR_METRICS_BORDER, NULL); - SetWindowFont (hWnd, + SetWindowFont (hWnd, (PLOGFONT)GetWindowElementAttr(hWnd, WE_FONT_TOOLTIP)); break; } case MSG_TIMER: KillTimer (hWnd, _ID_TIMER); - if(IsWindowVisible(hWnd)) - { - ShowWindow (hWnd, SW_HIDE); - } + if(IsWindowVisible(hWnd)) { + ShowWindow (hWnd, SW_HIDE); + } break; case MSG_PAINT: { HDC hdc; const char* text; - + hdc = BeginPaint (hWnd); - + text = GetWindowCaption (hWnd); SetBkMode (hdc, BM_TRANSPARENT); SetTextColor (hdc, GetWindowElementPixel(hWnd, WE_FGC_TOOLTIP)); TabbedTextOut (hdc, iBorder, iBorder, text); - + EndPaint (hWnd, hdc); return 0; } @@ -125,12 +124,12 @@ static LRESULT ToolTipWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP break; } } - + return DefaultMainWinProc(hWnd, message, wParam, lParam); } /* ToolTip Win without border or frame. */ -HWND CreateToolTipWin (HWND hParentWnd, int x, int y, int timeout_ms, +HWND CreateToolTipWin (HWND hParentWnd, int x, int y, int timeout_ms, const char* text, ...) { HWND hwnd; @@ -152,8 +151,8 @@ HWND CreateToolTipWin (HWND hParentWnd, int x, int y, int timeout_ms, } while (i == size); va_end(args); } - - SelectFont (HDC_SCREEN, + + SelectFont (HDC_SCREEN, (PLOGFONT)GetWindowElementAttr(hParentWnd, WE_FONT_TOOLTIP)); GetTabbedTextExtent (HDC_SCREEN, buf ? buf : text, -1, &text_size); @@ -205,7 +204,7 @@ void ResetToolTipWin (HWND hwnd, int x, int y, const char* text, ...) va_end(args); } - SelectFont (HDC_SCREEN, + SelectFont (HDC_SCREEN, (PLOGFONT)GetWindowElementAttr(hwnd, WE_FONT_TOOLTIP)); GetTabbedTextExtent (HDC_SCREEN, buf ? buf : text, -1, &text_size); @@ -249,7 +248,7 @@ void GUIAPI NotifyParentEx (HWND hwnd, LINT id, int code, DWORD add_data) notif_proc (hwnd, id, code, add_data); } else { - SendNotifyMessage (GetParent (hwnd), MSG_COMMAND, + SendNotifyMessage (GetParent (hwnd), MSG_COMMAND, (WPARAM) MAKELONG (id, code), (LPARAM)hwnd); } } @@ -268,7 +267,7 @@ LRESULT GUIAPI DefaultPageProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM l return GetDlgCtrlID (hDef); return 0; } - + case MSG_DESTROY: DestroyAllControls (hWnd); break; @@ -292,10 +291,10 @@ LRESULT GUIAPI DefaultPageProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM l } break; } - + case MSG_KEYDOWN: if ((hCurFocus = GetFocusChild (hWnd))) { - if (SendMessage (hCurFocus, MSG_GETDLGCODE, 0, 0L) + if (SendMessage (hCurFocus, MSG_GETDLGCODE, 0, 0L) & DLGC_WANTALLKEYS) break; } @@ -326,7 +325,7 @@ LRESULT GUIAPI DefaultPageProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM l HWND hNewFocus; if (hCurFocus) { - if (SendMessage (hCurFocus, MSG_GETDLGCODE, 0, 0L) + if (SendMessage (hCurFocus, MSG_GETDLGCODE, 0, 0L) & DLGC_WANTTAB) break; } @@ -350,9 +349,9 @@ LRESULT GUIAPI DefaultPageProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM l case SCANCODE_CURSORBLOCKLEFT: { HWND hNewFocus; - + if (hCurFocus) { - if (SendMessage (hCurFocus, MSG_GETDLGCODE, 0, 0L) + if (SendMessage (hCurFocus, MSG_GETDLGCODE, 0, 0L) & DLGC_WANTARROWS) break; } @@ -362,9 +361,9 @@ LRESULT GUIAPI DefaultPageProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM l hNewFocus = GetNextDlgGroupItem (hWnd, hCurFocus, FALSE); else hNewFocus = GetNextDlgGroupItem (hWnd, hCurFocus, TRUE); - + if (hNewFocus != hCurFocus) { - if (SendMessage (hCurFocus, MSG_GETDLGCODE, 0, 0L) + if (SendMessage (hCurFocus, MSG_GETDLGCODE, 0, 0L) & DLGC_STATIC) return 0; @@ -385,7 +384,7 @@ LRESULT GUIAPI DefaultPageProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM l } break; } - + return DefaultControlProc (hWnd, message, wParam, lParam); } diff --git a/src/gui/dialog.c b/src/gui/dialog.c index 66c9c689..0cf5323b 100644 --- a/src/gui/dialog.c +++ b/src/gui/dialog.c @@ -912,7 +912,7 @@ static void get_box_xy (HWND hParentWnd, DWORD dwStyle, DLGTEMPLATE* MsgBoxData) GetWindowRect (hParentWnd, &rcTemp); } else { - rcTemp = g_rcDesktop; + rcTemp = g_rcScr; } switch (dwStyle & MB_ALIGNMASK) { @@ -942,12 +942,12 @@ static void get_box_xy (HWND hParentWnd, DWORD dwStyle, DLGTEMPLATE* MsgBoxData) break; } - if ((MsgBoxData->x + MsgBoxData->w) > g_rcDesktop.right) { - MsgBoxData->x = g_rcDesktop.right - MsgBoxData->w; + if ((MsgBoxData->x + MsgBoxData->w) > g_rcScr.right) { + MsgBoxData->x = g_rcScr.right - MsgBoxData->w; } - if ((MsgBoxData->y + MsgBoxData->h) > g_rcDesktop.bottom) { - MsgBoxData->y = g_rcDesktop.bottom - MsgBoxData->h; + if ((MsgBoxData->y + MsgBoxData->h) > g_rcScr.bottom) { + MsgBoxData->y = g_rcScr.bottom - MsgBoxData->h; } } diff --git a/src/include/dc.h b/src/include/dc.h index 29ac0fbe..cad829e8 100644 --- a/src/include/dc.h +++ b/src/include/dc.h @@ -88,8 +88,8 @@ void __mg_unlock_gcrinfo (PDC pdc); #define LOCK_GCRINFO(pdc) __mg_lock_recalc_gcrinfo (pdc) #define UNLOCK_GCRINFO(pdc) if (dc_IsGeneralDC(pdc)) __mg_unlock_gcrinfo (pdc) #else -RECT g_rcScr; -PLOGFONT g_SysLogFont[1]; +RECT g_rcScr; // TODO: bad coding +PLOGFONT g_SysLogFont[1]; // TODO: bad coding #define LOCK_GCRINFO(pdc) #define UNLOCK_GCRINFO(pdc) #define __mg_hwnd_desktop 0xFFFFFFFD diff --git a/src/include/newgal.h b/src/include/newgal.h index c578b88a..a439e751 100644 --- a/src/include/newgal.h +++ b/src/include/newgal.h @@ -828,11 +828,15 @@ GAL_Surface * GAL_DisplayFormat (GAL_Surface *surface); */ GAL_Surface * GAL_DisplayFormatAlpha (GAL_Surface *surface); -/* Not in public API at the moment - do not use! */ int GAL_SoftStretch (GAL_Surface *src, GAL_Rect *srcrect, GAL_Surface *dst, GAL_Rect *dstrect); -GAL_Surface* __gal_screen; +#ifdef _MGUSE_COMPOSITING +extern GAL_Surface* __gal_screen; +extern GAL_Surface* __gal_fake_screen; +#else +extern GAL_Surface* __gal_screen; +#endif #define WIDTHOFPHYGC (__gal_screen->w) #define HEIGHTOFPHYGC (__gal_screen->h) diff --git a/src/kernel/desktop-comm.c b/src/kernel/desktop-comm.c index 524d2850..62f7d5b2 100644 --- a/src/kernel/desktop-comm.c +++ b/src/kernel/desktop-comm.c @@ -446,6 +446,7 @@ static int dskEndTrackPopupMenu (PTRACKMENUINFO ptmi) ZORDERINFO* zi = __mg_zorder_info; PTRACKMENUINFO plast = NULL; RECT rc; + RECT rcScr = GetScreenRect(); if (sg_ptmi == ptmi) { sg_ptmi = NULL; @@ -475,7 +476,7 @@ static int dskEndTrackPopupMenu (PTRACKMENUINFO ptmi) } ptmi = ptmi->next; } - SelectClipRect (HDC_SCREEN_SYS, &g_rcScr); + SelectClipRect (HDC_SCREEN_SYS, &rcScr); return 0; } @@ -1260,6 +1261,8 @@ static int dskStartDragWindow (PMAINWIN pWin, const DRAGINFO* drag_info) static int dskCancelDragWindow (PMAINWIN pWin) { + RECT rcScr = GetScreenRect(); + if (!(pWin->dwStyle & WS_VISIBLE)) return -1; @@ -1268,8 +1271,7 @@ static int dskCancelDragWindow (PMAINWIN pWin) _dd_info.hwnd = (HWND)-1; unlock_zorder_info (); - SelectClipRect (HDC_SCREEN_SYS, &g_rcScr); - // SetDefaultCursor (GetSystemCursor (IDC_ARROW)); + SelectClipRect (HDC_SCREEN_SYS, &rcScr); return 0; } @@ -1338,6 +1340,8 @@ static int do_drag_drop_window (UINT msg, int x, int y) _dd_info.last_y = y; } else { + RECT rcScr = GetScreenRect(); + SetPenColor (HDC_SCREEN_SYS, PIXEL_lightwhite); FocusRect (HDC_SCREEN_SYS, _dd_info.rc.left, _dd_info.rc.top, _dd_info.rc.right, _dd_info.rc.bottom); @@ -1347,7 +1351,7 @@ static int do_drag_drop_window (UINT msg, int x, int y) MAKELONG (_dd_info.rc.left, _dd_info.rc.top), MAKELONG (_dd_info.rc.right, _dd_info.rc.bottom)); unlock_zorder_info (); - SelectClipRect (HDC_SCREEN_SYS, &g_rcScr); + SelectClipRect (HDC_SCREEN_SYS, &rcScr); if(_dd_info.hwnd != (HWND)gui_GetMainWindowPtrUnderPoint (x, y)) SetDefaultCursor (GetSystemCursor (IDC_ARROW)); diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index 80eec127..74c898e5 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -617,8 +617,10 @@ static intptr_t cliChangeCaption (PMAINWIN pWin) void __mg_start_server_desktop (void) { + RECT rcScr = GetScreenRect (); + InitClipRgn (&sg_ScrGCRInfo.crgn, &sg_FreeClipRectList); - SetClipRgn (&sg_ScrGCRInfo.crgn, &g_rcScr); + SetClipRgn (&sg_ScrGCRInfo.crgn, &rcScr); sg_ScrGCRInfo.age = 0; sg_ScrGCRInfo.old_zi_age = 0; @@ -721,6 +723,7 @@ static BOOL _cb_update_cli_znode (void* context, const ZORDERINFO* zi, ZORDERNODE* znode) { RECT rcInv; + RECT rcScr = GetScreenRect (); int cli = (int)(intptr_t)context; if (znode->cli == cli && znode->flags & ZOF_VISIBLE && znode->fortestinghwnd) { @@ -728,7 +731,7 @@ static BOOL _cb_update_cli_znode (void* context, if (!IsRectEmpty(&(znode->dirty_rc))) { - IntersectRect(&rcInv, &znode->dirty_rc, &g_rcScr); + IntersectRect(&rcInv, &znode->dirty_rc, &rcScr); msg.wParam = MAKELONG (rcInv.left, rcInv.top); msg.lParam = MAKELONG (rcInv.right, rcInv.bottom); @@ -844,6 +847,7 @@ static int srvStartDragWindow (int cli, int idx_znode, { ZORDERINFO* zi = _get_zorder_info(cli); ZORDERNODE* nodes; + RECT rcScr = GetScreenRect (); if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || @@ -899,7 +903,7 @@ static int srvStartDragWindow (int cli, int idx_znode, } SetPenColor (HDC_SCREEN_SYS, PIXEL_lightwhite); - SelectClipRect (HDC_SCREEN_SYS, &g_rcScr); + SelectClipRect (HDC_SCREEN_SYS, &rcScr); do_for_all_znodes (NULL, zi, _cb_exclude_rc, ZT_GLOBAL); FocusRect (HDC_SCREEN_SYS, _dd_info.rc.left, _dd_info.rc.top, _dd_info.rc.right, _dd_info.rc.bottom); @@ -913,6 +917,7 @@ static int srvStartDragWindow (int cli, int idx_znode, static int srvCancelDragWindow (int cli, int idx_znode) { ZORDERINFO* zi = _get_zorder_info(cli); + RECT rcScr = GetScreenRect (); if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || @@ -927,7 +932,7 @@ static int srvCancelDragWindow (int cli, int idx_znode) _dd_info.cli = -1; unlock_zi_for_change (zi); - SelectClipRect (HDC_SCREEN_SYS, &g_rcScr); + SelectClipRect (HDC_SCREEN_SYS, &rcScr); //SetDefaultCursor (GetSystemCursor (IDC_ARROW)); if (OnZNodeOperation) @@ -939,6 +944,7 @@ static int srvCancelDragWindow (int cli, int idx_znode) int __mg_do_drag_drop_window (int msg, int x, int y) { HWND hwnd; + RECT rcScr = GetScreenRect (); if (_dd_info.cli < 0) return 0; @@ -1023,7 +1029,7 @@ int __mg_do_drag_drop_window (int msg, int x, int y) } unlock_zi_for_change (_dd_info.zi); - SelectClipRect (HDC_SCREEN_SYS, &g_rcScr); + SelectClipRect (HDC_SCREEN_SYS, &rcScr); __mg_get_znode_at_point (__mg_zorder_info, x, y, &hwnd); if(_dd_info.hwnd != hwnd) SetDefaultCursor (GetSystemCursor (IDC_ARROW)); @@ -1191,6 +1197,7 @@ int __mg_remove_all_znodes_of_client (int cli) ZORDERNODE* nodes; int slot, slot2, old_active; RECT rc_bound = {0, 0, 0, 0}; + RECT rcScr = GetScreenRect(); nodes = GET_ZORDERNODE(zi); @@ -1212,7 +1219,7 @@ int __mg_remove_all_znodes_of_client (int cli) /* check influenced window zorder nodes */ do_for_all_znodes ((void*)(intptr_t)cli, zi, _cb_update_rc_nocli, ZT_ALL); - if (SubtractClipRect (&sg_UpdateRgn, &g_rcScr)) { + if (SubtractClipRect (&sg_UpdateRgn, &rcScr)) { nodes [0].age ++; nodes [0].flags |= ZOF_REFERENCE; } @@ -1251,7 +1258,7 @@ int __mg_remove_all_znodes_of_client (int cli) _cb_intersect_rc_no_cli, ZT_NORMAL); if (!(nodes [0].flags & ZOF_REFERENCE) && - SubtractClipRect (&sg_UpdateRgn, &g_rcScr)) { + SubtractClipRect (&sg_UpdateRgn, &rcScr)) { nodes [0].age ++; nodes [0].flags |= ZOF_REFERENCE; } @@ -1287,7 +1294,7 @@ int __mg_remove_all_znodes_of_client (int cli) } } if (!(nodes [0].flags & ZOF_REFERENCE) && - SubtractClipRect (&sg_UpdateRgn, &g_rcScr)) { + SubtractClipRect (&sg_UpdateRgn, &rcScr)) { nodes [0].age ++; nodes [0].flags |= ZOF_REFERENCE; } @@ -1754,6 +1761,7 @@ static int dskEndTrackPopupMenu (PTRACKMENUINFO ptmi) { PTRACKMENUINFO plast = NULL; RECT rc; + RECT rcScr = GetScreenRect (); if (sg_ptmi == ptmi) { sg_ptmi = NULL; @@ -1787,7 +1795,7 @@ static int dskEndTrackPopupMenu (PTRACKMENUINFO ptmi) } ptmi = ptmi->next; } - SelectClipRect (HDC_SCREEN_SYS, &g_rcScr); + SelectClipRect (HDC_SCREEN_SYS, &rcScr); return 0; } @@ -3283,7 +3291,7 @@ static void srvSaveScreen (BOOL active) if (cliActive == -1) { cliActive = 0; hwndActive = 0; - rcActive = g_rcScr; + rcActive = GetScreenRect(); } sprintf (buffer, "%d-%p-%d.bmp", cliActive, hwndActive, n); diff --git a/src/kernel/desktop-sa.c b/src/kernel/desktop-sa.c index 666fb7e4..74a74331 100644 --- a/src/kernel/desktop-sa.c +++ b/src/kernel/desktop-sa.c @@ -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 . - * + * * 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 * . */ @@ -102,7 +102,9 @@ static BOOL InitWndManagementInfo (void) BOOL mg_InitDesktop (void) { - int ret = 0; + int ret = 0; + RECT rcScr = GetScreenRect(); + /* * Init ZOrderInfo here. */ @@ -111,7 +113,7 @@ BOOL mg_InitDesktop (void) _WRN_PRINTF ("KERNEL>Desktop: Can not initialize ZOrderInfo!\n"); return FALSE; } - + /* * Init heap of clipping rects. */ @@ -129,7 +131,7 @@ BOOL mg_InitDesktop (void) init_desktop_win (); InitClipRgn (&sg_ScrGCRInfo.crgn, &sg_FreeClipRectList); - SetClipRgn (&sg_ScrGCRInfo.crgn, &g_rcScr); + SetClipRgn (&sg_ScrGCRInfo.crgn, &rcScr); sg_ScrGCRInfo.age = 0; sg_ScrGCRInfo.old_zi_age = 0; diff --git a/src/kernel/desktop-ths.c b/src/kernel/desktop-ths.c index b41c2e15..9c4a744f 100644 --- a/src/kernel/desktop-ths.c +++ b/src/kernel/desktop-ths.c @@ -11,39 +11,39 @@ // ////////////////////////////////////////////////////////////////////////////// /* - * 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 . - * + * * 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 * . */ -/* +/* ** desktop-ths.c: The desktop for MiniGUI-Threads. ** ** Current maintainer: Wei Yongming. @@ -85,6 +85,8 @@ PMSGQUEUE __mg_dsk_msg_queue; static BOOL InitWndManagementInfo (void) { + RECT rcScr = GetScreenRect(); + __mg_capture_wnd = 0; #ifdef _MGHAVE_MENU @@ -95,7 +97,7 @@ static BOOL InitWndManagementInfo (void) sg_hCaretWnd = 0; InitClipRgn (&sg_ScrGCRInfo.crgn, &sg_FreeClipRectList); - SetClipRgn (&sg_ScrGCRInfo.crgn, &g_rcScr); + SetClipRgn (&sg_ScrGCRInfo.crgn, &rcScr); pthread_mutex_init (&sg_ScrGCRInfo.lock, NULL); sg_ScrGCRInfo.age = 0; sg_ScrGCRInfo.old_zi_age = 0; @@ -108,13 +110,13 @@ static BOOL InitWndManagementInfo (void) BOOL mg_InitDesktop (void) { - int ret = 0; + int ret = 0; /* * Init ZOrderInfo here. */ ret = kernel_alloc_z_order_info (DEF_NR_TOPMOSTS, DEF_NR_NORMALS); - + if (ret < 0) { _WRN_PRINTF ("KERNEL>Desktop: Can not initialize ZOrderInfo!\n"); return FALSE; @@ -173,15 +175,15 @@ void* DesktopMain (void* data) } #endif - lRet = DesktopWinProc (HWND_DESKTOP, + lRet = DesktopWinProc (HWND_DESKTOP, Msg.message, Msg.wParam, Msg.lParam); if (Msg.pAdd) /* this is a sync message. */ { PSYNCMSG pSyncMsg = (PSYNCMSG)(Msg.pAdd); pSyncMsg->retval = lRet; - if(pSyncMsg->sem_handle) - sem_post(pSyncMsg->sem_handle); + if(pSyncMsg->sem_handle) + sem_post(pSyncMsg->sem_handle); } #ifdef _MGHAVE_TRACE_MSG @@ -200,7 +202,7 @@ void* DesktopMain (void* data) } pthread_t GUIAPI GetMainWinThread(HWND hMainWnd) -{ +{ #ifdef WIN32 pthread_t ret; memset(&ret, 0, sizeof(pthread_t)); @@ -208,7 +210,7 @@ pthread_t GUIAPI GetMainWinThread(HWND hMainWnd) #else MG_CHECK_RET (MG_IS_WINDOW(hMainWnd), 0); #endif - + return ((PMAINWIN)hMainWnd)->th; } diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index aafd3fb7..0823bc21 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -11,42 +11,42 @@ // ////////////////////////////////////////////////////////////////////////////// /* - * 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 . - * + * * 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 * . */ -/* +/* ** desktop.c: The Desktop module. ** -** Current maintainer: +** Current maintainer: ** */ @@ -55,8 +55,6 @@ # include "../sysres/license/c_files/00_minigui.dat.c" #endif -RECT g_rcScr; - ZORDERINFO* __mg_zorder_info; /* pointer to desktop window */ @@ -89,7 +87,7 @@ static BLOCKHEAP sg_FreeClipRectList; #define ZT_NORMAL 0x00000004 #define ZT_ALL 0x0000000F -typedef BOOL (* CB_ONE_ZNODE) (void* context, +typedef BOOL (* CB_ONE_ZNODE) (void* context, const ZORDERINFO* zi, ZORDERNODE* node); typedef struct _DEF_CONTEXT @@ -122,15 +120,15 @@ static BOOL subtract_rgn_by_node (PCLIPRGN region, const ZORDERINFO* zi, maskrect = firstmaskrect + idx; x = maskrect->left; y = maskrect->top; - + /* convert to screen coordinate*/ x = x + node->rc.left; y = y + node->rc.top; - SetRect(&tmprc, x, y, + SetRect(&tmprc, x, y, x+maskrect->right - maskrect->left, y+maskrect->bottom - maskrect->top); - + IntersectRect(&tmprc, &tmprc, &(node->rc)); SubtractClipRect(region, &tmprc); @@ -152,15 +150,15 @@ static int pt_in_maskrect (const ZORDERINFO* zi, MASKRECT *maskrect, *firstmaskrect; int idx = nodes->idx_mask_rect; - if (idx != 0 && PtInRect (&(nodes->rc), x, y)) - { + if (idx != 0 && PtInRect (&(nodes->rc), x, y)) + { cx = x - nodes->rc.left; cy = y - nodes->rc.top; firstmaskrect = GET_MASKRECT(zi); while(idx != 0) { maskrect = firstmaskrect + idx; - SetRect (&tmprc, maskrect->left, maskrect->top, + SetRect (&tmprc, maskrect->left, maskrect->top, maskrect->right, maskrect->bottom); if (PtInRect (&tmprc, cx, cy)) @@ -176,14 +174,14 @@ static int pt_in_maskrect (const ZORDERINFO* zi, } } -static int get_znode_at_point (const ZORDERINFO* zi, +static int get_znode_at_point (const ZORDERINFO* zi, const ZORDERNODE* nodes, int x, int y) { int slot = 0; slot = zi->first_global; for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && pt_in_maskrect(zi, &nodes[slot], x, y)) goto ret; } @@ -249,7 +247,7 @@ static void clean_znode_maskrect (ZORDERINFO* zi, ZORDERNODE* nodes, int idx_zno nodes[idx_znode].idx_mask_rect = 0; } -static int do_for_all_znodes (void* context, const ZORDERINFO* zi, +static int do_for_all_znodes (void* context, const ZORDERINFO* zi, CB_ONE_ZNODE cb, DWORD types) { int slot; @@ -282,8 +280,8 @@ static int do_for_all_znodes (void* context, const ZORDERINFO* zi, return count; } - -static void dskScreenToClient (PMAINWIN pWin, + +static void dskScreenToClient (PMAINWIN pWin, const RECT* rcScreen, RECT* rcClient) { PCONTROL pParent; @@ -302,7 +300,7 @@ static void dskScreenToClient (PMAINWIN pWin, } } -static void dskScreenToWindow (PMAINWIN pWin, +static void dskScreenToWindow (PMAINWIN pWin, const RECT* rcScreen, RECT* rcWindow) { PCONTROL pParent; @@ -321,7 +319,7 @@ static void dskScreenToWindow (PMAINWIN pWin, } } -static void dskClientToScreen (PMAINWIN pWin, +static void dskClientToScreen (PMAINWIN pWin, const RECT* rcClient, RECT* rcScreen) { PCONTROL pParent; @@ -359,17 +357,17 @@ static void dskGetWindowRectInScreen (PMAINWIN pWin, RECT* prc) } } -void __mg_update_window (HWND hwnd, +void __mg_update_window (HWND hwnd, int left, int top, int right, int bottom) { PMAINWIN pWin = (PMAINWIN)hwnd; - if (pWin + if (pWin && ((pWin->WinType == TYPE_CONTROL && (pWin->dwExStyle & WS_EX_CTRLASMAINWIN)) || pWin->WinType != TYPE_CONTROL) && pWin->dwStyle & WS_VISIBLE) { RECT invrc; - SetRect(&invrc, left, top, right, bottom); + SetRect(&invrc, left, top, right, bottom); if (IsRectEmpty (&invrc)) { SendAsyncMessage ((HWND)pWin, MSG_NCPAINT, 0, 0); @@ -384,10 +382,10 @@ void __mg_update_window (HWND hwnd, else GetWindowRect(hwnd, &rcWin); - if (IntersectRect (&rcTemp, + if (IntersectRect (&rcTemp, &rcWin, &invrc)) { dskScreenToWindow (pWin, &rcTemp, &rcInv); - SendAsyncMessage ((HWND)pWin, + SendAsyncMessage ((HWND)pWin, MSG_NCPAINT, 0, (LPARAM)(&rcInv)); dskScreenToClient (pWin, &rcTemp, &rcInv); InvalidateRect ((HWND)pWin, &rcInv, TRUE); @@ -406,20 +404,20 @@ static int update_client_window (ZORDERNODE* znode, const RECT* rc) if (rc) { if (IsRectEmpty (&znode->dirty_rc)){ - SetRect(&znode->dirty_rc, - rc->left, rc->top, rc->right, rc->bottom); + SetRect(&znode->dirty_rc, + rc->left, rc->top, rc->right, rc->bottom); } else{ - GetBoundRect (&znode->dirty_rc, &znode->dirty_rc, rc); + GetBoundRect (&znode->dirty_rc, &znode->dirty_rc, rc); } } mgClients [znode->cli].has_dirty = TRUE; } - else + else #endif { if (rc) - __mg_update_window (znode->fortestinghwnd, rc->left, rc->top, + __mg_update_window (znode->fortestinghwnd, rc->left, rc->top, rc->right, rc->bottom); else __mg_update_window (znode->fortestinghwnd, 0, 0, 0, 0); @@ -429,7 +427,7 @@ static int update_client_window (ZORDERNODE* znode, const RECT* rc) } -static BOOL _cb_update_znode (void* context, +static BOOL _cb_update_znode (void* context, const ZORDERINFO* zi, ZORDERNODE* znode) { const RECT* rc = (RECT*)context; @@ -443,7 +441,7 @@ static BOOL _cb_update_znode (void* context, return FALSE; } -static BOOL _cb_intersect_rc (void* context, +static BOOL _cb_intersect_rc (void* context, const ZORDERINFO* zi, ZORDERNODE* node) { RECT* rc = (RECT*)context; @@ -456,12 +454,12 @@ static BOOL _cb_intersect_rc (void* context, return FALSE; } -static BOOL _cb_update_rc (void* context, +static BOOL _cb_update_rc (void* context, const ZORDERINFO* zi, ZORDERNODE* node) { CLIPRGN* cliprgn = (CLIPRGN*)context; - if (node->flags & ZOF_VISIBLE && + if (node->flags & ZOF_VISIBLE && subtract_rgn_by_node(cliprgn, zi, node)) { node->age ++; node->flags |= ZOF_REFERENCE; @@ -471,7 +469,7 @@ static BOOL _cb_update_rc (void* context, return FALSE; } -static BOOL _cb_exclude_rc (void* context, +static BOOL _cb_exclude_rc (void* context, const ZORDERINFO* zi, ZORDERNODE* node) { if (!(node->flags & ZOF_VISIBLE)) @@ -486,7 +484,7 @@ static BOOL _cb_exclude_rc (void* context, while(idx != 0) { x = node->rc.left + (first+idx)->left; y = node->rc.top + (first+idx)->top; - SetRect(&rc, x, y, + SetRect(&rc, x, y, x+(first+idx)->right-(first+idx)->left, y+(first+idx)->bottom-(first+idx)->top); ExcludeClipRect (HDC_SCREEN_SYS, &rc); @@ -502,10 +500,11 @@ static BOOL _cb_exclude_rc (void* context, static void reset_window (PMAINWIN pWin, RECT* rcWin) { PGCRINFO pGCRInfo; - RECT rcTemp; + RECT rcScr, rcTemp; pGCRInfo = pWin->pGCRInfo; - IntersectRect (&rcTemp, rcWin, &g_rcScr); + rcScr = GetScreenRect(); + IntersectRect (&rcTemp, rcWin, &rcScr); SetClipRgn (&pGCRInfo->crgn, &rcTemp); } @@ -574,7 +573,7 @@ static int RestrictControlRect(PMAINWIN pWin, RECT *minimal) return FALSE; do { - PCONTROL pParent = pCtrl; + PCONTROL pParent = pCtrl; rcMove.left = pRoot->cl + off_x; rcMove.top = pRoot->ct + off_y; @@ -648,7 +647,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) SelectClipRect (hdc, &rcMove); - BitBlt (hdc, rcMove.left, rcMove.top, + BitBlt (hdc, rcMove.left, rcMove.top, rcMove.right - rcMove.left, rcMove.bottom - rcMove.top, hdc, pswi->iOffx + rcMove.left, pswi->iOffy + rcMove.top, 0); @@ -657,7 +656,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) pcrc = pcrc->next; } //ReleaseDC (hdc); - //BUGFIXED: we must update the secondaryDC to clientDC, to ensure + //BUGFIXED: we must update the secondaryDC to clientDC, to ensure //the secondaryDC and clientDC are same (dongjunjie 2010/07/08) if(pWin->pMainWin->secondaryDC){ HDC real_dc = GetClientDC((HWND)pWin->pMainWin); @@ -674,7 +673,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) pthread_mutex_lock (&pInvRgn->lock); #endif /*scroll whole screen, offset invalid region*/ - if (EqualRect (pswi->rc1, &rcClient)) + if (EqualRect (pswi->rc1, &rcClient)) OffsetRegion (&(pInvRgn->rgn), pswi->iOffx, pswi->iOffy); else OffsetRegionEx (&(pInvRgn->rgn), &rcClient, @@ -712,11 +711,11 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) rcInvalid.right = rcInvalid.left + pswi->iOffx; bNeedInvalidate = TRUE; } - + /* * BUGFIXED: offx and offy would make the two diffrent areas invalidate * we should invalid both them (dongjunjie) 2010/07/30 - * + * * content * --------------------------- * |//: offX | @@ -736,7 +735,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) bNeedInvalidate = FALSE; //resotre the inved value inved = TRUE; } - + if (pswi->iOffy < 0) { rcInvalid.top = rcInvalid.bottom + pswi->iOffy; bNeedInvalidate = TRUE; @@ -772,7 +771,7 @@ void __mg_unlock_gcrinfo (PDC pdc) return; } -static BOOL _cb_recalc_gcrinfo (void* context, +static BOOL _cb_recalc_gcrinfo (void* context, const ZORDERINFO* zi, ZORDERNODE* node) { PGCRINFO gcrinfo; @@ -796,7 +795,7 @@ void __mg_lock_recalc_gcrinfo (PDC pdc) gcrinfo = kernel_GetGCRgnInfo (pdc->hwnd); mainwin = (PMAINWIN)(pdc->hwnd); - + #ifdef _MGRM_THREADS pthread_mutex_lock (&pdc->pGCRInfo->lock); #endif @@ -829,14 +828,14 @@ void __mg_lock_recalc_gcrinfo (PDC pdc) switch (nodes[idx_znode].flags & ZOF_TYPE_MASK) { case ZOF_TYPE_NORMAL: - do_for_all_znodes (gcrinfo, zi, + do_for_all_znodes (gcrinfo, zi, _cb_recalc_gcrinfo, ZT_GLOBAL); - do_for_all_znodes (gcrinfo, zi, + do_for_all_znodes (gcrinfo, zi, _cb_recalc_gcrinfo, ZT_TOPMOST); slot = zi->first_normal; break; case ZOF_TYPE_TOPMOST: - do_for_all_znodes (gcrinfo, zi, + do_for_all_znodes (gcrinfo, zi, _cb_recalc_gcrinfo, ZT_GLOBAL); slot = zi->first_topmost; break; @@ -844,7 +843,7 @@ void __mg_lock_recalc_gcrinfo (PDC pdc) slot = zi->first_global; break; case ZOF_TYPE_DESKTOP: - do_for_all_znodes (gcrinfo, zi, + do_for_all_znodes (gcrinfo, zi, _cb_recalc_gcrinfo, ZT_ALL); break; default: @@ -857,7 +856,7 @@ void __mg_lock_recalc_gcrinfo (PDC pdc) } if (nodes [slot].flags & ZOF_VISIBLE) - subtract_rgn_by_node(&gcrinfo->crgn, zi, &nodes[slot]); + subtract_rgn_by_node(&gcrinfo->crgn, zi, &nodes[slot]); slot = nodes [slot].next; } @@ -870,7 +869,7 @@ void __mg_lock_recalc_gcrinfo (PDC pdc) */ static void dskInitGCRInfo (PMAINWIN pWin) { - RECT rcWin, rcTemp; + RECT rcWin, rcScr, rcTemp; dskGetWindowRectInScreen (pWin, &rcWin); @@ -881,7 +880,8 @@ static void dskInitGCRInfo (PMAINWIN pWin) pWin->pGCRInfo->old_zi_age = 0; InitClipRgn (&pWin->pGCRInfo->crgn, &sg_FreeClipRectList); - IntersectRect (&rcTemp, &rcWin, &g_rcScr); + rcScr = GetScreenRect(); + IntersectRect (&rcTemp, &rcWin, &rcScr); SetClipRgn (&pWin->pGCRInfo->crgn, &rcTemp); } @@ -908,7 +908,7 @@ static int get_next_visible_mainwin (const ZORDERINFO* zi, int from) while (next) { if (nodes [next].flags & ZOF_TF_MAINWIN - && (nodes [next].flags & ZOF_VISIBLE) + && (nodes [next].flags & ZOF_VISIBLE) && !(nodes [next].flags & ZOF_DISABLED)) return next; @@ -919,7 +919,7 @@ static int get_next_visible_mainwin (const ZORDERINFO* zi, int from) next = zi->first_global; while (next) { if (nodes [next].flags & ZOF_TF_MAINWIN - && (nodes [next].flags & ZOF_VISIBLE) + && (nodes [next].flags & ZOF_VISIBLE) && !(nodes [next].flags & ZOF_DISABLED)) return next; @@ -929,7 +929,7 @@ static int get_next_visible_mainwin (const ZORDERINFO* zi, int from) next = zi->first_topmost; while (next) { if (nodes [next].flags & ZOF_TF_MAINWIN - && (nodes [next].flags & ZOF_VISIBLE) + && (nodes [next].flags & ZOF_VISIBLE) && !(nodes [next].flags & ZOF_DISABLED)) return next; @@ -939,7 +939,7 @@ static int get_next_visible_mainwin (const ZORDERINFO* zi, int from) next = zi->first_normal; while (next) { if (nodes [next].flags & ZOF_TF_MAINWIN - && (nodes [next].flags & ZOF_VISIBLE) + && (nodes [next].flags & ZOF_VISIBLE) && !(nodes [next].flags & ZOF_DISABLED)) return next; @@ -955,7 +955,7 @@ static int get_next_visible_mainwin (const ZORDERINFO* zi, int from) static void dskAddNewHostedMainWindow (PMAINWIN pHosting, PMAINWIN pHosted) { PMAINWIN head, prev; - + pHosted->pNextHosted = NULL; head = pHosting->pFirstHosted; @@ -974,13 +974,13 @@ static void dskAddNewHostedMainWindow (PMAINWIN pHosting, PMAINWIN pHosted) return; } -/* +/* * Remove a hosted main window. */ void dskRemoveHostedMainWindow (PMAINWIN pHosting, PMAINWIN pHosted) { PMAINWIN head, prev; - + head = pHosting->pFirstHosted; if (head == pHosted) { @@ -991,7 +991,7 @@ void dskRemoveHostedMainWindow (PMAINWIN pHosting, PMAINWIN pHosted) while (head) { prev = head; head = head->pNextHosted; - + if (head == pHosted) { prev->pNextHosted = head->pNextHosted; return; @@ -1052,7 +1052,7 @@ static HMENU sg_DesktopMenu = 0; /* system global desktop menu handle */ // call back proc of tracking menu. // defined in Menu module. -int PopupMenuTrackProc (PTRACKMENUINFO ptmi, +int PopupMenuTrackProc (PTRACKMENUINFO ptmi, int message, WPARAM wParam, LPARAM lParam); static int srvForceCloseMenu (int cli) @@ -1064,7 +1064,7 @@ static int srvForceCloseMenu (int cli) #endif ZORDERNODE* menu_nodes; ZORDERNODE* win_nodes; - RECT rc_bound; + RECT rc_screen, rc_bound; if (zi->cli_trackmenu < 0 || zi->nr_popupmenus == 0) return 0; @@ -1086,7 +1086,8 @@ static int srvForceCloseMenu (int cli) /* check influenced window zorder nodes */ do_for_all_znodes (&sg_UpdateRgn, zi, _cb_update_rc, ZT_ALL); - if (SubtractClipRect (&sg_UpdateRgn, &g_rcScr)) { + rc_screen = GetScreenRect (); + if (SubtractClipRect (&sg_UpdateRgn, &rc_screen)) { win_nodes [0].age ++; win_nodes [0].flags |= ZOF_REFERENCE; } @@ -1104,7 +1105,7 @@ static int srvForceCloseMenu (int cli) do_for_all_znodes (&rc_bound, zi, _cb_update_znode, ZT_ALL); if (win_nodes [0].flags & ZOF_REFERENCE) { - SendMessage (HWND_DESKTOP, + SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, (LPARAM)&rc_bound); win_nodes [0].flags &= ~ZOF_REFERENCE; } @@ -1129,6 +1130,7 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi) ZORDERINFO* zi = _get_zorder_info(cli); ZORDERNODE* menu_nodes; ZORDERNODE* win_nodes; + RECT rc_screen; if (zi->cli_trackmenu >= 0 && zi->cli_trackmenu != cli) { srvForceCloseMenu (0); @@ -1139,14 +1141,15 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi) menu_nodes = GET_MENUNODE(zi); win_nodes = menu_nodes + DEF_NR_POPUPMENUS; - + /* lock zi for change */ lock_zi_for_change (zi); /* check influenced window zorder nodes */ do_for_all_znodes ((void*)rc, zi, _cb_intersect_rc, ZT_ALL); - if (DoesIntersect (rc, &g_rcScr)) { + rc_screen = GetScreenRect(); + if (DoesIntersect (rc, &rc_screen)) { win_nodes [0].age ++; } @@ -1168,7 +1171,7 @@ static int srvEndTrackPopupMenu (int cli, int idx_znode) ZORDERINFO* zi = _get_zorder_info(cli); ZORDERNODE* menu_nodes; ZORDERNODE* win_nodes; - RECT rc; + RECT rc, rc_screen; if (zi->cli_trackmenu != cli || zi->nr_popupmenus != (idx_znode + 1)) @@ -1176,7 +1179,7 @@ static int srvEndTrackPopupMenu (int cli, int idx_znode) menu_nodes = GET_MENUNODE(zi); win_nodes = menu_nodes + DEF_NR_POPUPMENUS; - + /* lock zi for change */ lock_zi_for_change (zi); @@ -1186,7 +1189,8 @@ static int srvEndTrackPopupMenu (int cli, int idx_znode) /* check influenced window zorder nodes */ do_for_all_znodes (&sg_UpdateRgn, zi, _cb_update_rc, ZT_ALL); - if (SubtractClipRect (&sg_UpdateRgn, &g_rcScr)) { + rc_screen = GetScreenRect(); + if (SubtractClipRect (&sg_UpdateRgn, &rc_screen)) { win_nodes [0].age ++; win_nodes [0].flags |= ZOF_REFERENCE; } @@ -1202,7 +1206,7 @@ static int srvEndTrackPopupMenu (int cli, int idx_znode) do_for_all_znodes (&rc, zi, _cb_update_znode, ZT_ALL); if (win_nodes [0].flags & ZOF_REFERENCE) { - SendMessage (HWND_DESKTOP, + SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, (LPARAM)&rc); win_nodes [0].flags &= ~ZOF_REFERENCE; } @@ -1215,8 +1219,8 @@ static BOOL dskCloseMenu (void) if (sg_ptmi == NULL) return FALSE; - SendNotifyMessage (sg_ptmi->hwnd, - MSG_DEACTIVEMENU, + SendNotifyMessage (sg_ptmi->hwnd, + MSG_DEACTIVEMENU, (WPARAM)sg_ptmi->pmb, (LPARAM)sg_ptmi->pmi); @@ -1229,7 +1233,7 @@ static BOOL dskCloseMenu (void) #endif -int __mg_post_msg_by_znode (const ZORDERINFO* zi, int znode, +int __mg_post_msg_by_znode (const ZORDERINFO* zi, int znode, int message, WPARAM wParam, LPARAM lParam) { int ret = 0; @@ -1241,12 +1245,12 @@ int __mg_post_msg_by_znode (const ZORDERINFO* zi, int znode, nodes = GET_ZORDERNODE(zi); if (nodes [znode].cli == 0) { - ret = PostMessage (nodes [znode].main_win, + ret = PostMessage (nodes [znode].main_win, message, wParam, lParam); } #if defined (_MGRM_PROCESSES) && !defined (_MGRM_STANDALONE) else { - MSG msg = {nodes [znode].main_win, + MSG msg = {nodes [znode].main_win, message, wParam, lParam, __mg_timer_counter}; ret = __mg_send2client (&msg, mgClients + nodes [znode].cli); @@ -1256,8 +1260,8 @@ int __mg_post_msg_by_znode (const ZORDERINFO* zi, int znode, return ret; } -static int -post_msg_by_znode_p (const ZORDERINFO* zi, const ZORDERNODE* znode, +static int +post_msg_by_znode_p (const ZORDERINFO* zi, const ZORDERNODE* znode, int message, WPARAM wParam, LPARAM lParam) { int ret = 0; @@ -1270,7 +1274,7 @@ post_msg_by_znode_p (const ZORDERINFO* zi, const ZORDERNODE* znode, } #if defined (_MGRM_PROCESSES) && !defined (_MGRM_STANDALONE) else { - MSG msg = {znode->main_win, + MSG msg = {znode->main_win, message, wParam, lParam, __mg_timer_counter}; ret = __mg_send2client (&msg, mgClients + znode->cli); @@ -1287,7 +1291,7 @@ static HWND dskSetActiveZOrderNode (int cli, int idx_znode) ZORDERNODE* nodes; HWND old_hwnd = HWND_NULL, new_hwnd = HWND_NULL; - if (idx_znode > zi->max_nr_globals + if (idx_znode > zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) { return HWND_INVALID; } @@ -1332,27 +1336,27 @@ static HWND dskSetActiveZOrderNode (int cli, int idx_znode) } if (old_active && (nodes [zi->active_win].flags & ZOF_VISIBLE)) { - post_msg_by_znode_p (zi, nodes + old_active, + post_msg_by_znode_p (zi, nodes + old_active, MSG_NCACTIVATE, FALSE, 0); - post_msg_by_znode_p (zi, nodes + old_active, + post_msg_by_znode_p (zi, nodes + old_active, MSG_ACTIVE, FALSE, 0); - post_msg_by_znode_p (zi, nodes + old_active, + post_msg_by_znode_p (zi, nodes + old_active, MSG_KILLFOCUS, (WPARAM)new_hwnd, 0); } if (idx_znode) { - post_msg_by_znode_p (zi, nodes + idx_znode, + post_msg_by_znode_p (zi, nodes + idx_znode, MSG_NCACTIVATE, TRUE, 0); - post_msg_by_znode_p (zi, nodes + idx_znode, + post_msg_by_znode_p (zi, nodes + idx_znode, MSG_ACTIVE, TRUE, 0); - post_msg_by_znode_p (zi, nodes + idx_znode, + post_msg_by_znode_p (zi, nodes + idx_znode, MSG_SETFOCUS, (WPARAM)old_hwnd, 0); } return old_hwnd; } -static void get_text_char_pos (PLOGFONT log_font, const char *text, +static void get_text_char_pos (PLOGFONT log_font, const char *text, int len, int fit_bytes, int *fit_chars, int *pos_chars) { DEVFONT* sbc_devfont = log_font->devfonts[0]; @@ -1365,8 +1369,8 @@ static void get_text_char_pos (PLOGFONT log_font, const char *text, if (pos_chars) { pos_chars[char_count] = len - left_bytes; } - if ((mbc_devfont) && - (len_cur_char = mbc_devfont->charset_ops->len_first_char + if ((mbc_devfont) && + (len_cur_char = mbc_devfont->charset_ops->len_first_char ((const unsigned char*)text, left_bytes)) > 0) { char_count ++; left_bytes -= len_cur_char; @@ -1384,7 +1388,7 @@ static void get_text_char_pos (PLOGFONT log_font, const char *text, } } } - + if (fit_chars) { *fit_chars = char_count; } @@ -1398,7 +1402,7 @@ int __mg_get_idle_slot (unsigned char* bitmap, int len_bmp) for (i = 0; i < len_bmp; i++) { for (j = 0; j < 8; j++) { - if (*bitmap & (0x80 >> j)) + if (*bitmap & (0x80 >> j)) idle++; } bitmap++; @@ -1425,9 +1429,9 @@ int __mg_get_idle_slot (unsigned char* bitmap, int len_bmp) else { \ CopyRect(&(drc[idx]), &src); \ idx++; \ - } + } -int CreateNodeRoundMaskRect (ZORDERINFO* zi, ZORDERNODE* node, +int CreateNodeRoundMaskRect (ZORDERINFO* zi, ZORDERNODE* node, const DWORD type, const RECT *rc) { RECT* roundrc = NULL; @@ -1474,7 +1478,7 @@ int CreateNodeRoundMaskRect (ZORDERINFO* zi, ZORDERNODE* node, for(i = 1; i < r; i++) { z = sqrt (r*r-i*i); - SetRect (&rect, rc->left+r-z, + SetRect (&rect, rc->left+r-z, rc->top+RECTHP(rc)-r+i-1, rc->left+RECTWP(rc)-r+z, rc->top+RECTHP(rc)-r+i+1); @@ -1487,8 +1491,8 @@ int CreateNodeRoundMaskRect (ZORDERINFO* zi, ZORDERNODE* node, rc->left+RECTWP(rc), rc->top+RECTHP(rc)); do_with_round_rect (rect, roundrc, rc_idx); } - - /* if have enough mask rect */ + + /* if have enough mask rect */ if ( rc_idx > __mg_get_idle_slot((unsigned char*)GET_MASKRECT_USAGEBMP(zi), zi->size_maskrect_usage_bmp)) { @@ -1502,7 +1506,7 @@ int CreateNodeRoundMaskRect (ZORDERINFO* zi, ZORDERNODE* node, idx = 0; for(i = 0; i < rc_idx; i++) { free_slot = __mg_lookfor_unused_slot ( - (unsigned char*)GET_MASKRECT_USAGEBMP(zi), + (unsigned char*)GET_MASKRECT_USAGEBMP(zi), zi->size_maskrect_usage_bmp, 1); if (free_slot == -1) { _WRN_PRINTF ("KERNEL: __mg_lookfor_unused_slot failed\n"); @@ -1514,7 +1518,7 @@ int CreateNodeRoundMaskRect (ZORDERINFO* zi, ZORDERNODE* node, (firstmaskrect+idx)->next = free_slot; } else { - node->idx_mask_rect = free_slot; + node->idx_mask_rect = free_slot; } idx = free_slot; } @@ -1522,7 +1526,7 @@ int CreateNodeRoundMaskRect (ZORDERINFO* zi, ZORDERNODE* node, if (idx != 0) { (firstmaskrect+idx)->prev = 0; } - + /*get value*/ idx = node->idx_mask_rect; i=0; @@ -1534,13 +1538,13 @@ int CreateNodeRoundMaskRect (ZORDERINFO* zi, ZORDERNODE* node, idx = (firstmaskrect+idx)->next; i++; } - + free (roundrc); return 0; } -static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, +static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, DWORD flags, const RECT *rc, const char *caption) { DWORD type = flags & ZOF_TYPE_MASK; @@ -1548,6 +1552,9 @@ static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, int *first = NULL, *nr_nodes = NULL; int free_slot, slot, old_first; ZORDERNODE* nodes; + RECT rc_screen; + + rc_screen = GetScreenRect(); switch (flags & ZOF_TYPE_MASK) { case ZOF_TYPE_GLOBAL: @@ -1589,11 +1596,11 @@ static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, /* the slot must be larger than zero */ if (type == ZOF_TYPE_GLOBAL) - free_slot = __mg_lookfor_unused_slot ((BYTE*)(zi + 1), + free_slot = __mg_lookfor_unused_slot ((BYTE*)(zi + 1), zi->max_nr_globals, 1); else { - free_slot = __mg_lookfor_unused_slot ((BYTE*)(zi + 1) - + (zi->max_nr_globals >> 3), + free_slot = __mg_lookfor_unused_slot ((BYTE*)(zi + 1) + + (zi->max_nr_globals >> 3), zi->size_usage_bmp - (zi->max_nr_globals >> 3), 1); if (free_slot >= 0) { @@ -1619,9 +1626,9 @@ static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, if (flags & ZOF_TW_TROUNDCNS || flags & ZOF_TW_BROUNDCNS) { RECT cli_rect; - SetRect(&cli_rect, 0, 0, RECTW(nodes[free_slot].rc), + SetRect(&cli_rect, 0, 0, RECTW(nodes[free_slot].rc), RECTH(nodes[free_slot].rc)); - CreateNodeRoundMaskRect (__mg_zorder_info, + CreateNodeRoundMaskRect (__mg_zorder_info, &nodes[free_slot], flags, &cli_rect); } @@ -1670,7 +1677,7 @@ static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, if (type >= ZOF_TYPE_TOPMOST) { slot = zi->first_topmost; for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && DoesIntersect (&nodes [free_slot].rc, &nodes [slot].rc)) { nodes [slot].age ++; } @@ -1679,19 +1686,19 @@ static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, if (type >= ZOF_TYPE_GLOBAL) { slot = zi->first_global; for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && DoesIntersect (&nodes [free_slot].rc, &nodes [slot].rc)) { nodes [slot].age ++; } } } - if (DoesIntersect (&nodes [free_slot].rc, &g_rcScr)) { + if (DoesIntersect (&nodes [free_slot].rc, &rc_screen)) { nodes [0].age ++; } } #if defined(_MG_ENABLE_SCREENSAVER) || defined(_MG_ENABLE_WATERMARK) - if (*first == 0 + if (*first == 0 || (nodes [*first].flags & ZOF_TF_TOPFOREVER) != ZOF_TF_TOPFOREVER ) { old_first = *first; @@ -1745,14 +1752,15 @@ static int FreeZOrderNode (int cli, int idx_znode) ZORDERINFO* zi = _get_zorder_info(cli); ZORDERNODE* nodes; int slot, old_active, next_active; - RECT rc; + RECT rc, rc_screen; - if (idx_znode > (zi->max_nr_globals + if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || idx_znode <= 0) { return -1; } + rc_screen = GetScreenRect (); nodes = GET_ZORDERNODE(zi); #ifdef _MGHAVE_MENU @@ -1791,7 +1799,7 @@ static int FreeZOrderNode (int cli, int idx_znode) lock_zi_for_change (zi); /* Free round corners mask rect. */ - if (type & ZOF_TW_TROUNDCNS || + if (type & ZOF_TW_TROUNDCNS || type & ZOF_TW_BROUNDCNS) { #if 0 @@ -1837,7 +1845,7 @@ static int FreeZOrderNode (int cli, int idx_znode) if (type > ZOF_TYPE_NORMAL) { slot = zi->first_normal; for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && subtract_rgn_by_node(&sg_UpdateRgn, zi, &nodes[slot])) { nodes [slot].age ++; nodes [slot].flags |= ZOF_REFERENCE; @@ -1845,7 +1853,7 @@ static int FreeZOrderNode (int cli, int idx_znode) } } - if (SubtractClipRect (&sg_UpdateRgn, &g_rcScr)) { + if (SubtractClipRect (&sg_UpdateRgn, &rc_screen)) { nodes [0].age ++; nodes [0].flags |= ZOF_REFERENCE; } @@ -1871,7 +1879,7 @@ static int FreeZOrderNode (int cli, int idx_znode) do_for_all_znodes (&rc, zi, _cb_update_znode, ZT_ALL); if (nodes [0].flags & ZOF_REFERENCE) { - SendMessage (HWND_DESKTOP, + SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, (WPARAM)&rc); nodes [0].flags &= ~ZOF_REFERENCE; } @@ -1889,15 +1897,15 @@ static DWORD get_znode_flags_from_style (PMAINWIN pWin) { DWORD zt_type = 0; -#if defined(_MGRM_PROCESSES) && !defined(_MGRM_STANDALONE) +#if defined(_MGRM_PROCESSES) && !defined(_MGRM_STANDALONE) if (mgIsServer) { zt_type |= ZOF_TYPE_GLOBAL; - } else + } else #endif { if (pWin->dwExStyle & WS_EX_TOPMOST) zt_type |= ZOF_TYPE_TOPMOST; - else if (pWin->WinType == TYPE_CONTROL && + else if (pWin->WinType == TYPE_CONTROL && (pWin->pMainWin->dwExStyle & WS_EX_TOPMOST)) zt_type |= ZOF_TYPE_TOPMOST; else @@ -1924,7 +1932,7 @@ static DWORD get_znode_flags_from_style (PMAINWIN pWin) return zt_type; } -static int AllocZOrderMaskRect (int cli, int idx_znode, +static int AllocZOrderMaskRect (int cli, int idx_znode, int flags, const RECT4MASK *rc, const int nr_rc) { MASKRECT *firstmaskrect; @@ -1932,7 +1940,7 @@ static int AllocZOrderMaskRect (int cli, int idx_znode, ZORDERINFO* zi = _get_zorder_info(cli); int free_slot, i, cur_idx, idx, old_num = 0; - if (idx_znode > (zi->max_nr_globals + if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || idx_znode <= 0) { return -1; @@ -1954,7 +1962,7 @@ static int AllocZOrderMaskRect (int cli, int idx_znode, if (nr_rc > old_num) { /* check the number of mask rect if enough */ - int idle = __mg_get_idle_slot((unsigned char*)GET_MASKRECT_USAGEBMP(zi), + int idle = __mg_get_idle_slot((unsigned char*)GET_MASKRECT_USAGEBMP(zi), zi->size_maskrect_usage_bmp); if (idle < nr_rc-old_num) { unlock_zi_for_change (zi); @@ -1965,13 +1973,13 @@ static int AllocZOrderMaskRect (int cli, int idx_znode, idx = nodes[idx_znode].idx_mask_rect; for(i = 0; i < nr_rc-old_num; i++) { free_slot = __mg_lookfor_unused_slot ( - (unsigned char*)GET_MASKRECT_USAGEBMP(zi), + (unsigned char*)GET_MASKRECT_USAGEBMP(zi), zi->size_maskrect_usage_bmp, 1); if (free_slot == -1) { unlock_zi_for_change (zi); return -1; } - + (firstmaskrect+free_slot)->next = idx; if (idx != 0) { (firstmaskrect+idx)->prev = free_slot; @@ -2010,7 +2018,7 @@ static int AllocZOrderMaskRect (int cli, int idx_znode, /* unlock zi for change ... */ unlock_zi_for_change (zi); - return 0; + return 0; } static int FreeZOrderMaskRect (int cli, int idx_znode) @@ -2018,7 +2026,7 @@ static int FreeZOrderMaskRect (int cli, int idx_znode) ZORDERINFO* zi = _get_zorder_info(cli); ZORDERNODE* nodes; - if (idx_znode > (zi->max_nr_globals + if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || idx_znode <= 0) { return -1; @@ -2066,7 +2074,7 @@ void dskRefreshAllClient (const RECT* invrc) #if defined(_MGRM_PROCESSES) && !defined(_MGRM_STANDALONE) if (mgIsServer) { ZORDERINFO* zi = _get_zorder_info (0); - SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, + SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, (LPARAM)(invrc)); lock_zi_for_read (zi); @@ -2110,7 +2118,7 @@ int dskSetTopForEver(int cli, int idx_znode, BOOL show) ZORDERINFO* zi = _get_zorder_info (cli); ZORDERNODE* nodes; - if (idx_znode > (zi->max_nr_globals + if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || idx_znode <= 0) { return -1; @@ -2127,7 +2135,7 @@ int dskSetTopForEver(int cli, int idx_znode, BOOL show) /* lock zi for change */ lock_zi_for_change (zi); - nodes[idx_znode].flags |= ZOF_TF_TOPFOREVER; + nodes[idx_znode].flags |= ZOF_TF_TOPFOREVER; /* unlock zi for change */ unlock_zi_for_change (zi); @@ -2149,7 +2157,7 @@ static int dskMove2Top (int cli, int idx_znode) int *first = NULL; ZORDERNODE* nodes; - if (idx_znode > (zi->max_nr_globals + if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || idx_znode <= 0) { return -1; @@ -2202,7 +2210,7 @@ static int dskMove2Top (int cli, int idx_znode) if (type == ZOF_TYPE_TOPMOST) { slot = zi->first_topmost; for (; slot != idx_znode; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && DoesIntersect (&rc, &nodes [slot].rc)) { nodes [slot].age ++; AddClipRect (&sg_UpdateRgn, &nodes [slot].rc); @@ -2212,7 +2220,7 @@ static int dskMove2Top (int cli, int idx_znode) if (type == ZOF_TYPE_GLOBAL) { slot = zi->first_global; for (; slot != idx_znode; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && DoesIntersect (&rc, &nodes [slot].rc)) { nodes [slot].age ++; AddClipRect (&sg_UpdateRgn, &nodes [slot].rc); @@ -2268,7 +2276,7 @@ static int dskMove2Top (int cli, int idx_znode) unlock_zi_for_change (zi); if ((nodes [idx_znode].flags & ZOF_VISIBLE) && nodes [idx_znode].fortestinghwnd) { - update_client_window_rgn (nodes [idx_znode].cli, + update_client_window_rgn (nodes [idx_znode].cli, nodes [idx_znode].fortestinghwnd); } @@ -2279,11 +2287,11 @@ static int dskMove2Top (int cli, int idx_znode) static int dskShowWindow (int cli, int idx_znode) { DWORD type; - ZORDERINFO* zi = _get_zorder_info(cli); + ZORDERINFO* zi = _get_zorder_info(cli); ZORDERNODE* nodes; int *first = NULL; - if (idx_znode > (zi->max_nr_globals + if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || idx_znode <= 0) { return -1; @@ -2295,7 +2303,7 @@ static int dskShowWindow (int cli, int idx_znode) #endif nodes = GET_ZORDERNODE(__mg_zorder_info); - + type = nodes [idx_znode].flags & ZOF_TYPE_MASK; switch (type) { case ZOF_TYPE_GLOBAL: @@ -2320,6 +2328,7 @@ static int dskShowWindow (int cli, int idx_znode) { int slot; RECT rc = nodes [idx_znode].rc; + RECT rc_screen = GetScreenRect(); if (type > ZOF_TYPE_NORMAL) { do_for_all_znodes (&rc, zi, _cb_intersect_rc, ZT_NORMAL); @@ -2334,13 +2343,13 @@ static int dskShowWindow (int cli, int idx_znode) slot = nodes [idx_znode].next; for (; slot != 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && DoesIntersect (&rc, &nodes [slot].rc)) { nodes [slot].age ++; } } - if (DoesIntersect (&rc, &g_rcScr)) { + if (DoesIntersect (&rc, &rc_screen)) { nodes [0].age ++; } nodes [idx_znode].age ++; @@ -2360,7 +2369,7 @@ static int dskHideWindow (int cli, int idx_znode) int *first = NULL; ZORDERNODE* nodes; - if (idx_znode > zi->max_nr_globals + if (idx_znode > zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) { return -1; } @@ -2371,7 +2380,7 @@ static int dskHideWindow (int cli, int idx_znode) #endif nodes = GET_ZORDERNODE(zi); - + type = nodes [idx_znode].flags & ZOF_TYPE_MASK; switch (type) { case ZOF_TYPE_GLOBAL: @@ -2397,10 +2406,11 @@ static int dskHideWindow (int cli, int idx_znode) SetClipRgn (&sg_UpdateRgn, &nodes [idx_znode].rc); if (nodes [idx_znode].flags & ZOF_VISIBLE) { int slot; + RECT rcScr = GetScreenRect (); slot = nodes [idx_znode].next; for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && subtract_rgn_by_node(&sg_UpdateRgn, zi, &nodes[slot])) { nodes [slot].age ++; nodes [slot].flags |= ZOF_REFERENCE; @@ -2412,7 +2422,7 @@ static int dskHideWindow (int cli, int idx_znode) if (type > ZOF_TYPE_NORMAL) { do_for_all_znodes (&sg_UpdateRgn, zi, _cb_update_rc, ZT_NORMAL); } - if (SubtractClipRect (&sg_UpdateRgn, &g_rcScr)) { + if (SubtractClipRect (&sg_UpdateRgn, &rcScr)) { nodes [0].age ++; nodes [0].flags |= ZOF_REFERENCE; } @@ -2420,11 +2430,11 @@ static int dskHideWindow (int cli, int idx_znode) if (idx_znode && (nodes [idx_znode].flags & ZOF_TF_MAINWIN && (nodes [idx_znode].flags & ZOF_VISIBLE))) { - post_msg_by_znode_p (zi, nodes + idx_znode, + post_msg_by_znode_p (zi, nodes + idx_znode, MSG_NCACTIVATE, FALSE, 0); - post_msg_by_znode_p (zi, nodes + idx_znode, + post_msg_by_znode_p (zi, nodes + idx_znode, MSG_ACTIVE, FALSE, 0); - post_msg_by_znode_p (zi, nodes + idx_znode, + post_msg_by_znode_p (zi, nodes + idx_znode, MSG_KILLFOCUS, 0, 0); } @@ -2441,7 +2451,7 @@ static int dskHideWindow (int cli, int idx_znode) do_for_all_znodes (&nodes [idx_znode].rc, zi, _cb_update_znode, ZT_ALL); if (nodes [0].flags & ZOF_REFERENCE) { - SendMessage (HWND_DESKTOP, + SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, (WPARAM)&nodes [idx_znode].rc); nodes [0].flags &= ~ZOF_REFERENCE; } @@ -2456,12 +2466,12 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) ZORDERNODE* nodes; RECT rcInv[4], rcOld, rcInter, tmprc; int i, slot, nInvCount; - unsigned short idx; + unsigned short idx; CLIPRGN bblt_rgn; MASKRECT *firstmaskrect, *maskrect; ZORDERINFO* zi = _get_zorder_info(cli); - - if (idx_znode > (zi->max_nr_globals + + if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || idx_znode < 0) { return -1; @@ -2490,10 +2500,10 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) if (memcmp (&nodes [idx_znode].rc, rcWin, sizeof (RECT)) == 0) return 0; - if ( (RECTW(nodes[idx_znode].rc) != RECTWP(rcWin) || - RECTH(nodes[idx_znode].rc) != RECTHP(rcWin)) && - (nodes[idx_znode].flags & ZOF_TW_TROUNDCNS || - nodes[idx_znode].flags & ZOF_TW_BROUNDCNS) ) + if ( (RECTW(nodes[idx_znode].rc) != RECTWP(rcWin) || + RECTH(nodes[idx_znode].rc) != RECTHP(rcWin)) && + (nodes[idx_znode].flags & ZOF_TW_TROUNDCNS || + nodes[idx_znode].flags & ZOF_TW_BROUNDCNS) ) { RECT cli_rect; SetRect(&cli_rect, 0, 0, RECTWP(rcWin), RECTHP(rcWin)); @@ -2502,7 +2512,7 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) if (nodes[idx_znode].idx_mask_rect != 0) { - idx = nodes[idx_znode].idx_mask_rect; + idx = nodes[idx_znode].idx_mask_rect; firstmaskrect = GET_MASKRECT(zi); while (idx) { @@ -2511,7 +2521,7 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) } } - CreateNodeRoundMaskRect (zi, &nodes[idx_znode], + CreateNodeRoundMaskRect (zi, &nodes[idx_znode], nodes[idx_znode].flags, &cli_rect); unlock_zi_for_change(zi); @@ -2525,6 +2535,8 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) nInvCount = SubtractRect (rcInv, &nodes [idx_znode].rc, rcWin); if (nodes [idx_znode].flags & ZOF_VISIBLE) { + RECT rcScr = GetScreenRect (); + /* lock zi for change */ lock_zi_for_change (zi); @@ -2538,61 +2550,59 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) slot = nodes [idx_znode].next; for (; slot != 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && DoesIntersect (rcWin, &nodes [slot].rc)) { nodes [slot].age ++; } } - if (DoesIntersect (rcWin, &g_rcScr)) { + if (DoesIntersect (rcWin, &rcScr)) { nodes [0].age ++; } /* check influenced zorder nodes */ - // for (i = 0; i < nInvCount; i++) { - //SetClipRgn (&sg_UpdateRgn, rcInv + i); - SetClipRgn (&sg_UpdateRgn, &(nodes [idx_znode].rc)); + //SetClipRgn (&sg_UpdateRgn, rcInv + i); + SetClipRgn (&sg_UpdateRgn, &(nodes [idx_znode].rc)); - slot = nodes [idx_znode].next; + slot = nodes [idx_znode].next; + for (; slot > 0; slot = nodes [slot].next) { + if (nodes [slot].flags & ZOF_VISIBLE && + !(nodes [slot].flags & ZOF_REFERENCE) && + subtract_rgn_by_node(&sg_UpdateRgn, zi, &nodes[slot])) { + nodes [slot].age ++; + nodes [slot].flags |= ZOF_REFERENCE; + } + } + + if (type > ZOF_TYPE_TOPMOST) { + slot = zi->first_topmost; for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && !(nodes [slot].flags & ZOF_REFERENCE) && subtract_rgn_by_node(&sg_UpdateRgn, zi, &nodes[slot])) { nodes [slot].age ++; nodes [slot].flags |= ZOF_REFERENCE; } } + } - if (type > ZOF_TYPE_TOPMOST) { - slot = zi->first_topmost; - for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && - !(nodes [slot].flags & ZOF_REFERENCE) && - subtract_rgn_by_node(&sg_UpdateRgn, zi, &nodes[slot])) { - nodes [slot].age ++; - nodes [slot].flags |= ZOF_REFERENCE; - } + if (type > ZOF_TYPE_NORMAL) { + slot = zi->first_normal; + for (; slot > 0; slot = nodes [slot].next) { + if (nodes [slot].flags & ZOF_VISIBLE && + !(nodes [slot].flags & ZOF_REFERENCE) && + subtract_rgn_by_node(&sg_UpdateRgn, zi, &nodes[slot])) { + nodes [slot].age ++; + nodes [slot].flags |= ZOF_REFERENCE; } } + } - if (type > ZOF_TYPE_NORMAL) { - slot = zi->first_normal; - for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && - !(nodes [slot].flags & ZOF_REFERENCE) && - subtract_rgn_by_node(&sg_UpdateRgn, zi, &nodes[slot])) { - nodes [slot].age ++; - nodes [slot].flags |= ZOF_REFERENCE; - } - } - } - - if (!(nodes [0].flags & ZOF_REFERENCE) && - SubtractClipRect (&sg_UpdateRgn, &g_rcScr)) { - nodes [0].age ++; - nodes [0].flags |= ZOF_REFERENCE; - } - // } + if (!(nodes [0].flags & ZOF_REFERENCE) && + SubtractClipRect (&sg_UpdateRgn, &rcScr)) { + nodes [0].age ++; + nodes [0].flags |= ZOF_REFERENCE; + } rcOld = nodes [idx_znode].rc; nodes [idx_znode].rc = *rcWin; @@ -2611,30 +2621,30 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) while (idx) { maskrect = firstmaskrect + idx; - SetRect (&tmprc, rcWin->left + maskrect->left, - rcWin->top + maskrect->top, - rcWin->left + maskrect->right, + SetRect (&tmprc, rcWin->left + maskrect->left, + rcWin->top + maskrect->top, + rcWin->left + maskrect->right, rcWin->top + maskrect->bottom); - if ( DoesIntersect (&tmprc, &g_rcScr)) { - IntersectRect (&tmprc, &tmprc, &g_rcScr); + if ( DoesIntersect (&tmprc, &rcScr)) { + IntersectRect (&tmprc, &tmprc, &rcScr); AddClipRect (&bblt_rgn, &tmprc); } idx = maskrect->next; } SelectClipRegion(HDC_SCREEN_SYS, &bblt_rgn); } - + slot = 0; switch (type) { case ZOF_TYPE_NORMAL: - do_for_all_znodes (NULL, zi, + do_for_all_znodes (NULL, zi, _cb_exclude_rc, ZT_GLOBAL); - do_for_all_znodes (NULL, zi, + do_for_all_znodes (NULL, zi, _cb_exclude_rc, ZT_TOPMOST); slot = zi->first_normal; break; case ZOF_TYPE_TOPMOST: - do_for_all_znodes (NULL, zi, + do_for_all_znodes (NULL, zi, _cb_exclude_rc, ZT_GLOBAL); slot = zi->first_topmost; break; @@ -2642,7 +2652,7 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) slot = zi->first_global; break; case ZOF_TYPE_DESKTOP: - do_for_all_znodes (NULL, zi, + do_for_all_znodes (NULL, zi, _cb_exclude_rc, ZT_ALL); break; default: @@ -2669,12 +2679,12 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) idx = nodes [slot].idx_mask_rect; while (idx) { maskrect = firstmaskrect + idx; - SetRect (&tmprc, rc.left + maskrect->left, - rc.top + maskrect->top, - rc.left + maskrect->right, + SetRect (&tmprc, rc.left + maskrect->left, + rc.top + maskrect->top, + rc.left + maskrect->right, rc.top + maskrect->bottom); - if ( DoesIntersect (&tmprc, &g_rcScr)) { - IntersectRect (&tmprc, &tmprc, &g_rcScr); + if ( DoesIntersect (&tmprc, &rcScr)) { + IntersectRect (&tmprc, &tmprc, &rcScr); ExcludeClipRect (HDC_SCREEN_SYS, &tmprc); } idx = maskrect->next; @@ -2683,13 +2693,13 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) } slot = nodes [slot].next; } - BitBlt (HDC_SCREEN_SYS, rcOld.left, rcOld.top, - MIN (RECTWP (rcWin), RECTW (rcOld)), + BitBlt (HDC_SCREEN_SYS, rcOld.left, rcOld.top, + MIN (RECTWP (rcWin), RECTW (rcOld)), MIN (RECTHP (rcWin), RECTH (rcOld)), HDC_SCREEN_SYS, rcWin->left, rcWin->top, 0); - + /* Restore the clip region of HDC_SCREEN_SYS */ - SelectClipRect (HDC_SCREEN_SYS, &g_rcScr); + SelectClipRect (HDC_SCREEN_SYS, &rcScr); EmptyClipRgn(&bblt_rgn); #if defined (_MGRM_PROCESSES) && !defined (_MGRM_STANDALONE) } @@ -2700,7 +2710,7 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) /* check the invalid rect of the window */ EmptyClipRgn (&sg_UpdateRgn); - nInvCount = SubtractRect (rcInv, &rcOld, &g_rcScr); + nInvCount = SubtractRect (rcInv, &rcOld, &rcScr); for (i = 0; i < nInvCount; i++) { AddClipRect (&sg_UpdateRgn, rcInv + i); } @@ -2708,7 +2718,7 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) if (type < ZOF_TYPE_GLOBAL) { slot = zi->first_global; for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && IntersectRect (&rcInter, &rcOld, &nodes [slot].rc)) AddClipRect(&sg_UpdateRgn, &rcInter); } @@ -2717,7 +2727,7 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) if (type < ZOF_TYPE_TOPMOST) { slot = zi->first_topmost; for (; slot > 0; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && IntersectRect (&rcInter, &rcOld, &nodes [slot].rc)) AddClipRect(&sg_UpdateRgn, &rcInter); } @@ -2725,23 +2735,23 @@ static int dskMoveWindow (int cli, int idx_znode, const RECT* rcWin) slot = *first; for (; slot != idx_znode; slot = nodes [slot].next) { - if (nodes [slot].flags & ZOF_VISIBLE && + if (nodes [slot].flags & ZOF_VISIBLE && IntersectRect (&rcInter, &rcOld, &nodes [slot].rc)) AddClipRect(&sg_UpdateRgn, &rcInter); } do_for_all_znodes (&rcOld, zi, _cb_update_znode, ZT_ALL); if (nodes [0].flags & ZOF_REFERENCE) { - SendMessage (HWND_DESKTOP, - MSG_ERASEDESKTOP, 0, (LPARAM)&rcOld); + SendMessage (HWND_DESKTOP, + MSG_ERASEDESKTOP, 0, (LPARAM)&rcOld); nodes [0].flags &= ~ZOF_REFERENCE; } - OffsetRegion (&sg_UpdateRgn, - rcWin->left - rcOld.left, + OffsetRegion (&sg_UpdateRgn, + rcWin->left - rcOld.left, rcWin->top - rcOld.top); - update_client_window_rgn (nodes [idx_znode].cli, + update_client_window_rgn (nodes [idx_znode].cli, nodes [idx_znode].fortestinghwnd); } else { @@ -2761,14 +2771,14 @@ static int dskEnableZOrderNode (int cli, int idx_znode, int flags) ZORDERINFO* zi = _get_zorder_info(cli); ZORDERNODE* nodes; - if (idx_znode > (zi->max_nr_globals + if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || idx_znode < 0) { return -1; } nodes = GET_ZORDERNODE(zi); - + /* lock zi for change */ lock_zi_for_change (zi); @@ -2784,12 +2794,13 @@ static int dskEnableZOrderNode (int cli, int idx_znode, int flags) } /*======================== customize desktop =========================*/ -static void +static void def_paint_desktop (void* context, HDC dc_desktop, const RECT* inv_rc) { PBITMAP bg_bmp = NULL; int pic_x = 0, pic_y = 0; - + RECT rcScr = GetScreenRect (); + if(context) { bg_bmp = ((DEF_CONTEXT *)context)->bg; @@ -2797,19 +2808,18 @@ def_paint_desktop (void* context, HDC dc_desktop, const RECT* inv_rc) pic_y = ((DEF_CONTEXT *)context)->y; } - SetBrushColor (dc_desktop, + SetBrushColor (dc_desktop, GetWindowElementPixel (HWND_DESKTOP, WE_BGC_DESKTOP)); if (inv_rc) { SelectClipRect (dc_desktop, inv_rc); - FillBox (dc_desktop, inv_rc->left, inv_rc->top, + FillBox (dc_desktop, inv_rc->left, inv_rc->top, RECTWP (inv_rc), RECTHP (inv_rc)); } else { - SelectClipRect (dc_desktop, &g_rcDesktop); - FillBox(dc_desktop, g_rcDesktop.left, g_rcDesktop.top, - g_rcDesktop.right, - g_rcDesktop.bottom); + SelectClipRect (dc_desktop, &rcScr); + FillBox(dc_desktop, rcScr.left, rcScr.top, + rcScr.right, rcScr.bottom); } if (bg_bmp) { @@ -2819,7 +2829,7 @@ def_paint_desktop (void* context, HDC dc_desktop, const RECT* inv_rc) } -static void def_keyboard_handler(void* context, int message, +static void def_keyboard_handler(void* context, int message, WPARAM wParam, LPARAM lParam) { switch(message) @@ -2852,7 +2862,7 @@ static void def_customize_desktop_menu (void* context, HMENU hmnu, int start_pos #endif } -static void def_mouse_handler(void* context, int message, +static void def_mouse_handler(void* context, int message, WPARAM wParam, LPARAM lParam) { #ifdef _MGHAVE_MENU @@ -2911,7 +2921,7 @@ static int dskGetBgPicturePos (void) { char szValue [21]; - if(GetMgEtcValue (__mg_def_renderer->name, + if(GetMgEtcValue (__mg_def_renderer->name, SYSBMP_BGPICPOS, szValue, 20) < 0) { strcpy (szValue, "center"); } @@ -2942,7 +2952,7 @@ static int dskGetBgPicturePos (void) static PBITMAP dskLoadBgPicture (void) { - return (PBITMAP)GetSystemBitmapEx (__mg_def_renderer->name, + return (PBITMAP)GetSystemBitmapEx (__mg_def_renderer->name, SYSBMP_BGPICTURE); } @@ -3012,7 +3022,7 @@ static void* def_init(void) bg_bmp = dskLoadBgPicture (); if (bg_bmp) - dskGetBgPictureXY (pos, + dskGetBgPictureXY (pos, bg_bmp->bmWidth, bg_bmp->bmHeight, &pic_x, &pic_y); con->bg = bg_bmp; @@ -3039,7 +3049,7 @@ static void *dt_context; DESKTOPOPS* GUIAPI SetCustomDesktopOperationSet (DESKTOPOPS* usr_dsk_ops) { DESKTOPOPS *tmp_ops = NULL; - + if (usr_dsk_ops == NULL) { return dsk_ops; } @@ -3060,7 +3070,7 @@ DESKTOPOPS* GUIAPI SetCustomDesktopOperationSet (DESKTOPOPS* usr_dsk_ops) return tmp_ops; } -static BOOL _cb_bcast_msg (void* context, +static BOOL _cb_bcast_msg (void* context, const ZORDERINFO* zi, ZORDERNODE* node) { PMAINWIN pWin; @@ -3206,12 +3216,12 @@ void GUIAPI DumpWindow (FILE* fp, HWND hWnd) } if (pWin->WinType == TYPE_MAINWIN) { - fprintf (fp, "=============== Main Window %#x==================\n", + fprintf (fp, "=============== Main Window %#x==================\n", hWnd); - fprintf (fp, "Rect -- (%d, %d, %d, %d)\n", + fprintf (fp, "Rect -- (%d, %d, %d, %d)\n", pWin->left, pWin->top, pWin->right, pWin->bottom); - fprintf (fp, "Client -- (%d, %d, %d, %d)\n", + fprintf (fp, "Client -- (%d, %d, %d, %d)\n", pWin->cl, pWin->ct, pWin->cr, pWin->cb); fprintf (fp, "Style -- %lx\n", pWin->dwStyle); @@ -3230,7 +3240,7 @@ void GUIAPI DumpWindow (FILE* fp, HWND hWnd) fprintf (fp, "FirstChild -- %#x\n", pWin->hFirstChild); pCtrl = (PCONTROL)pWin->hFirstChild; while (pCtrl) { - fprintf (fp, " Child -- %p(%d), %s(%d)\n", pCtrl, pCtrl->id, + fprintf (fp, " Child -- %p(%d), %s(%d)\n", pCtrl, pCtrl->id, pCtrl->pcci->name, pCtrl->pcci->nUseCount); pCtrl = pCtrl->next; } @@ -3251,9 +3261,9 @@ void GUIAPI DumpWindow (FILE* fp, HWND hWnd) fprintf (fp, "=============== Control %#x==================\n", hWnd); pCtrl = (PCONTROL)hWnd; - fprintf (fp, "Rect -- (%d, %d, %d, %d)\n", + fprintf (fp, "Rect -- (%d, %d, %d, %d)\n", pCtrl->left, pCtrl->top, pCtrl->right, pCtrl->bottom); - fprintf (fp, "Client -- (%d, %d, %d, %d)\n", + fprintf (fp, "Client -- (%d, %d, %d, %d)\n", pCtrl->cl, pCtrl->ct, pCtrl->cr, pCtrl->cb); fprintf (fp, "Style -- %lx\n", pCtrl->dwStyle); @@ -3276,14 +3286,14 @@ void GUIAPI DumpWindow (FILE* fp, HWND hWnd) pCtrl = (PCONTROL)pCtrl->children; while (pCtrl) { - fprintf (fp, " Child -- %p(%d), %s(%d)\n", pCtrl, pCtrl->id, + fprintf (fp, " Child -- %p(%d), %s(%d)\n", pCtrl, pCtrl->id, pCtrl->pcci->name, pCtrl->pcci->nUseCount); pCtrl = pCtrl->next; } } fprintf (fp, "=================== End ==================\n"); - return; + return; } #endif /* _DEBUG */ @@ -3302,7 +3312,7 @@ int kernel_get_window_region (HWND pWin, CLIPRGN* region) #endif idx_znode = ((PMAINWIN)pWin)->idx_znode; - if (idx_znode > (zi->max_nr_globals + if (idx_znode > (zi->max_nr_globals + zi->max_nr_topmosts + zi->max_nr_normals) || idx_znode <= 0) { return -1; diff --git a/src/kernel/init-lite.c b/src/kernel/init-lite.c index d572b580..308b6f40 100644 --- a/src/kernel/init-lite.c +++ b/src/kernel/init-lite.c @@ -165,10 +165,12 @@ int InitGUI (int argc, const char* agr[]) step++; atexit (mg_TerminateScreenDC); +#if 0 g_rcScr.left = 0; g_rcScr.top = 0; g_rcScr.right = GetGDCapability (HDC_SCREEN_SYS, GDCAP_MAXX) + 1; g_rcScr.bottom = GetGDCapability (HDC_SCREEN_SYS, GDCAP_MAXY) + 1; +#endif mg_TerminateMgEtc (); return 0; @@ -454,10 +456,12 @@ int InitGUI (int argc, const char* agr[]) step++; atexit (mg_TerminateScreenDC); +#if 0 g_rcScr.left = 0; g_rcScr.top = 0; g_rcScr.right = GetGDCapability (HDC_SCREEN_SYS, GDCAP_MAXX) + 1; g_rcScr.bottom = GetGDCapability (HDC_SCREEN_SYS, GDCAP_MAXY) + 1; +#endif #ifdef _MGRM_PROCESSES if (_is_server) { diff --git a/src/kernel/init.c b/src/kernel/init.c index c72df572..4a08671c 100644 --- a/src/kernel/init.c +++ b/src/kernel/init.c @@ -511,10 +511,12 @@ int GUIAPI InitGUI (int args, const char *agr[]) goto failure1; } +#if 0 g_rcScr.left = 0; g_rcScr.top = 0; g_rcScr.right = GetGDCapability (HDC_SCREEN_SYS, GDCAP_MAXX) + 1; g_rcScr.bottom = GetGDCapability (HDC_SCREEN_SYS, GDCAP_MAXY) + 1; +#endif license_create(); splash_draw_framework(); diff --git a/src/misc/license.c b/src/misc/license.c index aecf58a6..f1dc6248 100644 --- a/src/misc/license.c +++ b/src/misc/license.c @@ -158,18 +158,20 @@ static void watermark_update(void) static void watermark_init(void) { + RECT rcScr = GetScreenRect(); + fourcorner_info[0].bmp = &g_license_bitmaps[WATERMARK_1]; fourcorner_info[1].bmp = &g_license_bitmaps[WATERMARK_2]; fourcorner_info[2].bmp = &g_license_bitmaps[WATERMARK_3]; fourcorner_info[3].bmp = &g_license_bitmaps[WATERMARK_3]; /* right-top.*/ - fourcorner_info[1].pos.x += RECTW(g_rcScr) - fourcorner_info[1].bmp->bmWidth; + fourcorner_info[1].pos.x += RECTW(rcScr) - fourcorner_info[1].bmp->bmWidth; /* left-bottom.*/ - fourcorner_info[2].pos.y += RECTH(g_rcScr) - fourcorner_info[2].bmp->bmHeight; + fourcorner_info[2].pos.y += RECTH(rcScr) - fourcorner_info[2].bmp->bmHeight; /* right-bottom.*/ - fourcorner_info[3].pos.x += RECTW(g_rcScr) - fourcorner_info[3].bmp->bmWidth; - fourcorner_info[3].pos.y += RECTH(g_rcScr) - fourcorner_info[3].bmp->bmHeight; + fourcorner_info[3].pos.x += RECTW(rcScr) - fourcorner_info[3].bmp->bmWidth; + fourcorner_info[3].pos.y += RECTH(rcScr) - fourcorner_info[3].bmp->bmHeight; } #else @@ -197,8 +199,8 @@ void screensaver_create(void) { /* create screensaver node. */ if (!s_screensaver_node) { - RECT rc = g_rcScr; - s_screensaver_node = dskCreateTopZOrderNode(0, &rc); + RECT rcScr = GetScreenRect(); + s_screensaver_node = dskCreateTopZOrderNode(0, &rcScr); dskSetTopForEver(0, s_screensaver_node, TRUE); screensaver_hide(); } @@ -215,21 +217,23 @@ void screensaver_destroy(void) static void screensaver_update(void) { + RECT rcScr = GetScreenRect(); + /* fixed size 200 * 99 */ /* g_bitmap_minigui 200 * 55 at 0 * 44 */ /* g_bitmap_feiman 118 * 41 at 61 * 0 */ /* g_bitmap_fmsoft 50 * 11 at 4 * 30 */ - int pos_x = (RECTW(g_rcScr) > 200) - ? (rand() % (RECTW(g_rcScr) - 200)) + int pos_x = (RECTW(rcScr) > 200) + ? (rand() % (RECTW(rcScr) - 200)) : 0; - int pos_y = (RECTH(g_rcScr) > 99) - ? (rand() % (RECTH(g_rcScr) - 99)) + int pos_y = (RECTH(rcScr) > 99) + ? (rand() % (RECTH(rcScr) - 99)) : 0; /* clean screen */ SetBrushColor (HDC_SCREEN_SYS, PIXEL_black); - FillBox (HDC_SCREEN_SYS, 0, 0, RECTW(g_rcScr), RECTH(g_rcScr)); + FillBox (HDC_SCREEN_SYS, 0, 0, RECTW(rcScr), RECTH(rcScr)); /* put picture to screen */ /* g_bitmap_minigui */ @@ -280,12 +284,15 @@ static int splash_bar_direction; #define SPLASH_BAR_LEFT 0 #define SPLASH_BAR_RIGHT 1 -static void splash_init(void) { +static void splash_init(void) +{ + RECT rcScr = GetScreenRect(); + splash_bar_postion = 0; splash_bar_direction = SPLASH_BAR_RIGHT; - splash_adjust_x = (RECTW(g_rcScr) - SPLASH_W) / 2; - splash_adjust_y = (RECTH(g_rcScr) - SPLASH_H)*3 / 5; + splash_adjust_x = (RECTW(rcScr) - SPLASH_W) / 2; + splash_adjust_y = (RECTH(rcScr) - SPLASH_H)*3 / 5; } void splash_draw_framework (void) @@ -293,6 +300,7 @@ void splash_draw_framework (void) char text[64]; RECT rc_text; PLOGFONT font, old_font; + RECT rcScr = GetScreenRect(); gal_pixel old_brush = SetBrushColor(HDC_SCREEN_SYS, PIXEL_black); gal_pixel old_text = SetTextColor(HDC_SCREEN_SYS, RGB2Pixel(HDC_SCREEN_SYS, 0x32, 0xa0, 0xe4)); @@ -304,7 +312,7 @@ void splash_draw_framework (void) 8, 0); old_font = SelectFont(HDC_SCREEN_SYS, font); - FillBox(HDC_SCREEN_SYS, 0 ,0, RECTW(g_rcScr), RECTH(g_rcScr)); + FillBox(HDC_SCREEN_SYS, 0 ,0, RECTW(rcScr), RECTH(rcScr)); FillBoxWithBitmap(HDC_SCREEN_SYS, SPLASH_FEIMAN_X, SPLASH_FEIMAN_Y, 0, 0, &g_bitmap_feiman); FillBoxWithBitmap(HDC_SCREEN_SYS, SPLASH_FMSOFT_X, SPLASH_FMSOFT_Y, 0, 0, &g_bitmap_fmsoft); @@ -313,7 +321,7 @@ void splash_draw_framework (void) FillBoxWithBitmap(HDC_SCREEN_SYS, SPLASH_BAR_X, SPLASH_BAR_Y, 0, 0, &g_bitmap_progressbar); memset(text, 0, sizeof(text)); - SetRect(&rc_text, SPLASH_ID_X, SPLASH_ID_Y, SPLASH_ID_X+SPLASH_ID_W, RECTH(g_rcScr)); + SetRect(&rc_text, SPLASH_ID_X, SPLASH_ID_Y, SPLASH_ID_X+SPLASH_ID_W, RECTH(rcScr)); #ifdef _MG_PRODUCTID int customer_id = license_get_customer_id(); @@ -542,6 +550,10 @@ void license_destroy (void) { #if defined(_MG_ENABLE_SCREENSAVER) || defined(_MG_ENABLE_WATERMARK) void license_on_input(void) { +#ifdef _MGRM_PROCESSES + RECT rcScr = GetScreenRect(); +#endif + s_tick_last_input = GetTickCount(); if (screensaver_running == TRUE) { @@ -560,7 +572,7 @@ void license_on_input(void) #else screensaver_hide(); #if defined(_MGRM_PROCESSES) - dskRefreshAllClient (&g_rcScr); + dskRefreshAllClient (&rcScr); #elif defined(_MGRM_STANDALONE) SendNotifyMessage (HWND_DESKTOP, MSG_PAINT, 0, 0); #else diff --git a/src/newgal/bf533/bf533video.c b/src/newgal/bf533/bf533video.c index af17e5b7..0ce477c3 100644 --- a/src/newgal/bf533/bf533video.c +++ b/src/newgal/bf533/bf533video.c @@ -416,7 +416,8 @@ static void BF533_UpdateRects (_THIS, int numrects, GAL_Rect *rects) } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + if (IntersectRect (&bound, &bound, &rcScr)) { this->hidden->update = bound; this->hidden->dirty = TRUE; } diff --git a/src/newgal/commlcd/commlcd.c b/src/newgal/commlcd/commlcd.c index 7ecf3bdd..ff5ba255 100644 --- a/src/newgal/commlcd/commlcd.c +++ b/src/newgal/commlcd/commlcd.c @@ -147,7 +147,9 @@ static void COMMLCD_UpdateRects_Async (_THIS, int numrects, GAL_Rect *rects) } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + + if (IntersectRect (&bound, &bound, &rcScr)) { this->hidden->rc_dirty = bound; this->hidden->dirty = TRUE; } diff --git a/src/newgal/em85xxyuv/em85xxyuv.c b/src/newgal/em85xxyuv/em85xxyuv.c index 3cdf16ee..c30aa537 100644 --- a/src/newgal/em85xxyuv/em85xxyuv.c +++ b/src/newgal/em85xxyuv/em85xxyuv.c @@ -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 . - * + * * 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 * . */ @@ -47,7 +47,7 @@ ** $Id: em85xxyuv.c 8944 2007-12-29 08:29:16Z xwyan $ ** ** em85xxyuv.c: NEWGAL driver for EM85xx YUV. -** +** ** Copyright (C) 2007 Feynman Software. */ @@ -99,9 +99,9 @@ union semun { #endif /* Initialization/Query functions */ static int EM85XXYUV_VideoInit(_THIS, GAL_PixelFormat *vformat); -static GAL_Rect **EM85XXYUV_ListModes(_THIS, GAL_PixelFormat *format, +static GAL_Rect **EM85XXYUV_ListModes(_THIS, GAL_PixelFormat *format, Uint32 flags); -static GAL_Surface *EM85XXYUV_SetVideoMode(_THIS, GAL_Surface *current, +static GAL_Surface *EM85XXYUV_SetVideoMode(_THIS, GAL_Surface *current, int width, int height, int bpp, Uint32 flags); static int EM85XXYUV_SetColors(_THIS, int first, int count, GAL_Color *palette); static void EM85XXYUV_VideoQuit(_THIS); @@ -164,7 +164,7 @@ static __inline BYTE rgb2y (BYTE r, BYTE g, BYTE b) { DWORD y = 257*(DWORD)r + 504*(DWORD)g + 98*(DWORD)b + 16000; if (y > 255000) - y = 255000; + y = 255000; y >>= 10; return (BYTE)y; } @@ -173,7 +173,7 @@ static __inline BYTE rgb2u (BYTE r, BYTE g, BYTE b) { DWORD u = -148*(DWORD)r - 291*(DWORD)g + 449*(DWORD)b + 128000; if (u > 255000) - u = 255000; + u = 255000; u >>= 10; return (BYTE)u; } @@ -182,7 +182,7 @@ static __inline BYTE rgb2v (BYTE r, BYTE g, BYTE b) { DWORD v = 439*(DWORD)r - 368*(DWORD)g - 71*(DWORD)b + 128000; if (v > 255000) - v = 255000; + v = 255000; v >>= 10; return (BYTE)v; } @@ -206,7 +206,7 @@ static YUV* init_rgb2yuv_map_16bit (void) tmp = map; for (i = 0; i < 65536; i++) { - RGB2YUV (((i & 0xF800) >> 8), ((i & 0x07E0) >> 3), ((i & 0x001F) << 3), + RGB2YUV (((i & 0xF800) >> 8), ((i & 0x07E0) >> 3), ((i & 0x001F) << 3), &tmp->y, &tmp->u, &tmp->v); tmp++; } @@ -303,7 +303,7 @@ static void transfer_yuv_frame (_THIS, int x, int y, int width, int height) int y_offset, uv_offset, y_xferlen, uv_xferlen, y_left, uv_left; BYTE* Y = plane_Y; BYTE* UV = plane_UV; - + #if 0 Wnd_type Wnd; evYUVWriteParams_type yuv_param; @@ -316,7 +316,7 @@ static void transfer_yuv_frame (_THIS, int x, int y, int width, int height) yuv_param.wWidth = FRAME_WIDTH; yuv_param.wHeight = FRAME_HEIGHT; yuv_param.YUVFormat = YUV_420_UNPACKED; - RUA_DECODER_SET_PROPERTY(h, VIDEO_SET, evYUVWriteParams, + RUA_DECODER_SET_PROPERTY(h, VIDEO_SET, evYUVWriteParams, sizeof(yuv_param), &yuv_param); RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, evSourceWindow, sizeof(Wnd), &Wnd); RUA_DECODER_CLEAR_SCREEN(h); @@ -330,7 +330,7 @@ static void transfer_yuv_frame (_THIS, int x, int y, int width, int height) * so we do a loop for the complete transfer */ - y_offset = 0; + y_offset = 0; uv_offset = 0; y_left = FRAME_WIDTH * FRAME_HEIGHT; uv_left = FRAME_WIDTH * FRAME_HEIGHT / 2; @@ -347,16 +347,16 @@ static void transfer_yuv_frame (_THIS, int x, int y, int width, int height) /* do the transfer */ f.Yaddr = y_offset; - /* - * don't worry about the warning from the compiler here + /* + * don't worry about the warning from the compiler here * we know that this cast is safe */ f.pY = (DWORD *)Y; f.nYbytes = y_xferlen; f.UVaddr = uv_offset; - /* - * don't worry about the warning from the compiler here + /* + * don't worry about the warning from the compiler here * we know that this cast is safe */ f.pUV = (DWORD *)UV; @@ -396,14 +396,14 @@ static int task_do_update (void* data) bound = this->hidden->update; round_rect_to_even (&bound); - convert2yuv (this, bound.left, bound.top, + convert2yuv (this, bound.left, bound.top, RECTW (bound), RECTH (bound)); this->hidden->dirty = FALSE; SetRect (&this->hidden->update, 0, 0, 0, 0); update_unlock (this->hidden->lock); - transfer_yuv_frame (this, bound.left, bound.top, + transfer_yuv_frame (this, bound.left, bound.top, RECTW (bound), RECTH (bound)); } } @@ -515,7 +515,7 @@ static int EM85XXYUV_VideoInit(_THIS, GAL_PixelFormat *vformat) if (RUA_OSDFB_REFRESH (this->hidden->handle, &osdbuffer) != 0) { fprintf (stderr, "NEWGAL>EM85xxYUV: Error getting the OSD buffer.\n"); goto fail; - } + } else { this->hidden->osd_buffer = osdbuffer.framebuffer; this->hidden->w = osdbuffer.width; @@ -524,7 +524,7 @@ static int EM85XXYUV_VideoInit(_THIS, GAL_PixelFormat *vformat) this->hidden->fb = osdbuffer.framebuffer + 8 + 1024; } #endif - + /* set the tv output to be ntsc */ Wnd.x = 0; Wnd.y = 0; @@ -533,36 +533,36 @@ static int EM85XXYUV_VideoInit(_THIS, GAL_PixelFormat *vformat) TvStandard = evTvStandard_NTSC; TvOutputFormat = evTvOutputFormat_COMPOSITE; OutputDevice = evOutputDevice_TV; - RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, + RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, evTvOutputFormat, sizeof(TvOutputFormat), &TvOutputFormat); - RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, + RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, evTvStandard, sizeof(TvStandard), &TvStandard); - RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, + RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, evOutputDevice, sizeof(OutputDevice), &OutputDevice); - RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, + RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, evDestinationWindow, sizeof(Wnd), &Wnd); yuv_param.wWidth = FRAME_WIDTH; yuv_param.wHeight = FRAME_HEIGHT; yuv_param.YUVFormat = YUV_420_UNPACKED; - RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, + RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, evYUVWriteParams, sizeof(yuv_param), &yuv_param); - RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, + RUA_DECODER_SET_PROPERTY (h, VIDEO_SET, evSourceWindow, sizeof(Wnd), &Wnd); RUA_DECODER_CLEAR_SCREEN (h); #if 0 /* Setup the flicker filter - * XXX - its also set in the kernel module, but it seems not to work - * very well. - * We reset it here, so that the microcode as already seen an osd frame. + * XXX - its also set in the kernel module, but it seems not to work + * very well. + * We reset it here, so that the microcode as already seen an osd frame. * 0 <= flicker <= 15 */ flicker = 15; - RUA_DECODER_SET_PROPERTY (this->hidden->handle, + RUA_DECODER_SET_PROPERTY (this->hidden->handle, DECODER_SET, edecOsdFlicker, sizeof(flicker), &flicker); - /* + /* * set the osd window destination * do not scale - just center the image */ @@ -570,7 +570,7 @@ static int EM85XXYUV_VideoInit(_THIS, GAL_PixelFormat *vformat) Wnd.y = (480 - osdbuffer.height) / 2; Wnd.w = osdbuffer.width; Wnd.h = osdbuffer.height; - RUA_DECODER_SET_PROPERTY (h, OSD_SET, + RUA_DECODER_SET_PROPERTY (h, OSD_SET, eOsdDestinationWindow, sizeof(Wnd), &Wnd); #endif @@ -603,7 +603,7 @@ static GAL_Rect* modes [] = { NULL }; -static GAL_Rect **EM85XXYUV_ListModes(_THIS, GAL_PixelFormat *format, +static GAL_Rect **EM85XXYUV_ListModes(_THIS, GAL_PixelFormat *format, Uint32 flags) { if (format->BitsPerPixel == 16) { @@ -627,7 +627,7 @@ static GAL_Surface *EM85XXYUV_SetVideoMode(_THIS, GAL_Surface *current, return (NULL); } - clone (task_do_update, stack_updater + 512, + clone (task_do_update, stack_updater + 512, CLONE_VM | CLONE_FS | CLONE_FILES, this); /* We're done */ @@ -662,7 +662,7 @@ static void EM85XXYUV_UpdateRects (_THIS, int numrects, GAL_Rect *rects) for (i = 0; i < numrects; i++) { RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -671,7 +671,8 @@ static void EM85XXYUV_UpdateRects (_THIS, int numrects, GAL_Rect *rects) } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + if (IntersectRect (&bound, &bound, &rcScr)) { this->hidden->update = bound; this->hidden->dirty = TRUE; } diff --git a/src/newgal/mb93493/mb93493video.c b/src/newgal/mb93493/mb93493video.c index 93d63457..3475f72a 100644 --- a/src/newgal/mb93493/mb93493video.c +++ b/src/newgal/mb93493/mb93493video.c @@ -481,7 +481,9 @@ static void MB93493_UpdateRects (_THIS, int numrects, GAL_Rect *rects) } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + + if (IntersectRect (&bound, &bound, &rcScr)) { this->hidden->update = bound; this->hidden->dirty = TRUE; } diff --git a/src/newgal/mlshadow/mlshadow-proc.c b/src/newgal/mlshadow/mlshadow-proc.c index 65365733..015f8b6c 100644 --- a/src/newgal/mlshadow/mlshadow-proc.c +++ b/src/newgal/mlshadow/mlshadow-proc.c @@ -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 . - * + * * 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 * . */ @@ -116,10 +116,10 @@ typedef struct _MLShadowFBHeader { int semid; } MLShadowFBHeader; -static void unlock_fbh (const MLShadowFBHeader* fbh) +static void unlock_fbh (const MLShadowFBHeader* fbh) { struct sembuf sb; - + again: sb.sem_num = 1; sb.sem_op = 1; @@ -135,7 +135,7 @@ again: static void lock_fbh (const MLShadowFBHeader* fbh) { struct sembuf sb; - + again: sb.sem_num = 1; sb.sem_op = -1; @@ -152,7 +152,7 @@ static list_t mlshadow_list; /* * * request_id = REQ_MLSHADOW_OPERATE * * request data type: int - * * op_id = MLSOP_ID_GET_MASTERINFO + * * op_id = MLSOP_ID_GET_MASTERINFO * * request_data_len = sizeof (int) * * reply data type: MLSHADOW_REPLY_MASTER_INFO * * reply_data_len = sizeof (MLSHADOW_REPLY_MASTER_INFO) @@ -163,7 +163,7 @@ static list_t mlshadow_list; /* * * request_id = REQ_MLSHADOW_OPERATE * * request data type: MLSHADOW_REQ_SLAVE_CREATE - * * op_id = MLSOP_ID_CREATE_SLAVE + * * op_id = MLSOP_ID_CREATE_SLAVE * * request_data_len = sizeof (MLSHADOW_REQ_SLAVE_CREATE) * * reply data type: MLSHADOW_REPLY_SLAVE_CREATE * * reply_data_len = sizeof (MLSHADOW_REPLY_SLAVE_CREATE) @@ -192,7 +192,7 @@ typedef struct _MLSHADOW_REQ_SLAVE_GETINFO { /* * * request_id = REQ_MLSHADOW_OPERATE * * request data type: MLSHADOW_REQ_SLAVE_SETINFO - * * op_id = MLSOP_ID_SET_SLAVEINFO + * * op_id = MLSOP_ID_SET_SLAVEINFO * * request_data_len = sizeof (MLSHADOW_REQ_SLAVE_SETINFO) * * reply data type: BOOL * * reply_data_len = sizeof (BOOL) @@ -202,9 +202,9 @@ typedef struct _MLSHADOW_REQ_SLAVE_SETINFO { unsigned int surface_key; DWORD mask; - int offset_x; + int offset_x; int offset_y; - int enable; + int enable; DWORD blend_flags; gal_pixel color_key; int alpha; @@ -214,7 +214,7 @@ typedef struct _MLSHADOW_REQ_SLAVE_SETINFO { /* * * request_id = REQ_MLSHADOW_OPERATE * * request data type: (MLSHADOW_REQ_SLAVE_DESTROY - * * op_id = MLSOP_ID_DESTROY_SLAVE + * * op_id = MLSOP_ID_DESTROY_SLAVE * * request_data_len = sizeof (MLSHADOW_REQ_SLAVE_DESTROY) * * reply data type: BOOL * * reply_data_len = sizeof (BOOL) @@ -224,7 +224,7 @@ typedef struct _MLSHADOW_REQ_SLAVE_DESTROY { unsigned int surface_key; }MLSHADOW_REQ_SLAVE_DESTROY; -typedef struct _mlshadow_node +typedef struct _mlshadow_node { list_t node; BOOL enabled; @@ -239,8 +239,8 @@ typedef struct _mlshadow_node BOOL GAL_ParseVideoMode (const char* mode, int* w, int* h, int* depth); void Slave_FreeSurface (GAL_Surface *surface); static mlshadow_node* get_master_node(void); -static int MLSHADOW_GetSurface(MLSHADOW_REQ_SLAVE_GETINFO* request, - MLSHADOW_REPLY_SLAVE_GETINFO* reply); +static int MLSHADOW_GetSurface(MLSHADOW_REQ_SLAVE_GETINFO* request, + MLSHADOW_REPLY_SLAVE_GETINFO* reply); /* Initialization/Query functions */ int MLSHADOW_Server(void* request, void* reply); @@ -248,23 +248,23 @@ static int MLSHADOW_SetSurface(MLSHADOW_REQ_SLAVE_SETINFO *request, BOOL *reply) void MLSHADOW_Del_List(void); static int MLSHADOW_CreateFrameBuffer(MLSHADOW_REQ_SURFACE_CREATE* request, MLSHADOW_REPLY_SURFACE_CREATE* reply); -static int MLSHADOW_SetSurfaceColors (GAL_Surface* surface, +static int MLSHADOW_SetSurfaceColors (GAL_Surface* surface, int firstcolor, int ncolors, GAL_Color *colors); -static void MLSHADOW_DeleteMLSurface (MLSHADOW_REQ_SLAVE_DESTROY *request, +static void MLSHADOW_DeleteMLSurface (MLSHADOW_REQ_SLAVE_DESTROY *request, BOOL *reply); static mlshadow_node* get_node(GAL_Surface* surface); static int MLSHADOW_VideoInit (_THIS, GAL_PixelFormat *vformat); -static GAL_Rect **MLSHADOW_ListModes (_THIS, GAL_PixelFormat *format, +static GAL_Rect **MLSHADOW_ListModes (_THIS, GAL_PixelFormat *format, Uint32 flags); -static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, +static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, int width, int height, int bpp, Uint32 flags); static GAL_VideoDevice *MLSHADOW_CreateDevice(int devindex); -static int MLSHADOW_SetColors (_THIS, int firstcolor, int ncolors, +static int MLSHADOW_SetColors (_THIS, int firstcolor, int ncolors, GAL_Color *colors); static void MLSHADOW_VideoQuit (_THIS); static void MLSHADOW_UpdateRects (_THIS, int numrects, GAL_Rect *rects); -static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrects, +static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrects, GAL_Rect *rects); static void MLSHADOW_DeleteSurface (_THIS, GAL_Surface* surface); static void MLSHADOW_DeleteDevice(GAL_VideoDevice *device); @@ -328,7 +328,7 @@ static GAL_VideoDevice *MLSHADOW_CreateDevice (int devindex) device->VideoInit = MLSHADOW_VideoInit; device->ListModes = MLSHADOW_ListModes; device->SetVideoMode = MLSHADOW_SetVideoMode; - device->UpdateSurfaceRects = MLSHADOW_UpdateSurfaceRects; + device->UpdateSurfaceRects = MLSHADOW_UpdateSurfaceRects; device->SetColors = MLSHADOW_SetColors; device->SetSurfaceColors = MLSHADOW_SetSurfaceColors; device->VideoQuit = MLSHADOW_VideoQuit; @@ -366,30 +366,30 @@ static int MLSHADOW_VideoInit (_THIS, GAL_PixelFormat *vformat) return (-1); } memset (&real_vformat, 0, sizeof(real_vformat)); - if (this->hidden->_real_device->VideoInit (this->hidden->_real_device, - &real_vformat) < 0 ) + if (this->hidden->_real_device->VideoInit (this->hidden->_real_device, + &real_vformat) < 0 ) { return (-1); } - if (GetMgEtcValue (MLSHADOW_NAME, "def_bgcolor", real_engine, - LEN_ENGINE_NAME) < 0) + if (GetMgEtcValue (MLSHADOW_NAME, "def_bgcolor", real_engine, + LEN_ENGINE_NAME) < 0) { return -1; } - GetMgEtcValue (MLSHADOW_NAME, "double_buffer", double_buffer, LEN_ENGINE_NAME); + GetMgEtcValue (MLSHADOW_NAME, "double_buffer", double_buffer, LEN_ENGINE_NAME); this->hidden->_real_def_bgcolor = PIXEL_blue; - if(this->hidden->_real_def_bgcolor > 0xffffff || + if(this->hidden->_real_def_bgcolor > 0xffffff || this->hidden->_real_def_bgcolor < 0) { this->hidden->_real_def_bgcolor = 0; } - this->hidden->_real_surface = GAL_CreateRGBSurface (GAL_SWSURFACE, 0, 0, - real_vformat.BitsPerPixel, real_vformat.Rmask, + this->hidden->_real_surface = GAL_CreateRGBSurface (GAL_SWSURFACE, 0, 0, + real_vformat.BitsPerPixel, real_vformat.Rmask, real_vformat.Gmask, real_vformat.Bmask, 0); if (this->hidden->_real_surface == NULL ) { this->hidden->_real_device->free (this->hidden->_real_device); return (-1); - } + } this->hidden->_real_surface->video = this->hidden->_real_device; this->hidden->_real_device->info.vfmt = this->hidden->_real_surface->format; if(!strncmp(double_buffer, "enable", sizeof("enable"))) { @@ -399,9 +399,9 @@ static int MLSHADOW_VideoInit (_THIS, GAL_PixelFormat *vformat) this->hidden->_real_device->GetFBInfo(&video_mem_info); if (video_mem_info.video_mem_len > 0) { /* bugfixed, houhh 20071116, 1.mmap para error! 2.do mmap here, not in SetVideoMode.*/ - if(video_mem_info.type == MLS_FB_TYPE_VIDEOMEM) { + if(video_mem_info.type == MLS_FB_TYPE_VIDEOMEM) { int fd = open(video_mem_info.video_dev_name, O_RDWR/*O_RDONLY*/); - //_mmaped_mem = mmap(NULL, video_mem_info.video_mem_len, fd, + //_mmaped_mem = mmap(NULL, video_mem_info.video_mem_len, fd, // PROT_READ|PROT_WRITE, MAP_SHARED, video_mem_info.video_mem_offset); _mmaped_mem = mmap(NULL, video_mem_info.video_mem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); @@ -409,11 +409,11 @@ static int MLSHADOW_VideoInit (_THIS, GAL_PixelFormat *vformat) video_mem_info.type = MLS_FB_TYPE_VIDEOMEM; fprintf(stderr, "video_mem_info = %d\n", video_mem_info.video_mem_len); } - else - video_mem_info.type = MLS_FB_TYPE_SYSTEMMEM; + else + video_mem_info.type = MLS_FB_TYPE_SYSTEMMEM; } else - video_mem_info.type = MLS_FB_TYPE_SYSTEMMEM; + video_mem_info.type = MLS_FB_TYPE_SYSTEMMEM; } else if(!mgIsServer){ int request; @@ -435,9 +435,9 @@ static int MLSHADOW_VideoInit (_THIS, GAL_PixelFormat *vformat) return NULL; } _mmaped_flag = TRUE; - video_mem_info.type = MLS_FB_TYPE_VIDEOMEM; + video_mem_info.type = MLS_FB_TYPE_VIDEOMEM; video_mem_info.video_mem_len = reply.video_mem_len; - memcpy(video_mem_info.video_dev_name, reply.video_dev_name, + memcpy(video_mem_info.video_dev_name, reply.video_dev_name, sizeof(reply.video_dev_name)); video_mem_info.video_mem_offset = reply.video_mem_offset; video_mem_info.video_pitch = reply.pitch; @@ -479,7 +479,7 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, } if (mgIsServer && list_empty (&mlshadow_list)) { - if (GetMgEtcValue (MLSHADOW_NAME, "real_engine", + if (GetMgEtcValue (MLSHADOW_NAME, "real_engine", real_engine, LEN_ENGINE_NAME) < 0) { fprintf (stderr, "NEWGAL>MLShadow: real_engine not defined.\n"); return NULL; @@ -497,10 +497,10 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, , mode); return NULL; } - if (!(this->hidden->_real_surface + if (!(this->hidden->_real_surface = this->hidden->_real_device->SetVideoMode ( - this->hidden->_real_device, - this->hidden->_real_surface, + this->hidden->_real_device, + this->hidden->_real_surface, w, h, depth, GAL_HWPALETTE))) { fprintf (stderr, "NEWGAL>MLShadow: can not set video mode for real " "engine: %s.\n", mode); @@ -522,12 +522,12 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, int swap_fb_pitch; GAL_PixelFormat real_vformat = *this->hidden->_real_surface->format; __mg_bmp_compute_pitch(depth, (unsigned int)w, (unsigned int* )&swap_fb_pitch, 1); - swap_fb_size = swap_fb_pitch * h; - // bugfixed 20071116, should GAL_ReallocFormat the swap surface's palette. - // memcpy(this->hidden->swap_surface, this->hidden->_real_surface, + swap_fb_size = swap_fb_pitch * h; + // bugfixed 20071116, should GAL_ReallocFormat the swap surface's palette. + // memcpy(this->hidden->swap_surface, this->hidden->_real_surface, // sizeof(GAL_Surface)); - this->hidden->swap_surface = GAL_CreateRGBSurface (GAL_SWSURFACE, w, h, - real_vformat.BitsPerPixel, real_vformat.Rmask, + this->hidden->swap_surface = GAL_CreateRGBSurface (GAL_SWSURFACE, w, h, + real_vformat.BitsPerPixel, real_vformat.Rmask, real_vformat.Gmask, real_vformat.Bmask, 0); if (this->hidden->swap_surface) { this->hidden->swap_surface->pixels = calloc(1, swap_fb_size); @@ -541,17 +541,17 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, if(video_mem_info.type == MLS_FB_TYPE_VIDEOMEM){ int fb_size, fb_pitch; __mg_bmp_compute_pitch(depth, (unsigned int)w, (unsigned int* )&fb_pitch, 1); - fb_size = fb_pitch * h; + fb_size = fb_pitch * h; video_mem_info.video_mem_offset += fb_size; } - + pthread_attr_t new_attr; pthread_attr_init (&new_attr); #ifndef __LINUX__ pthread_attr_setstacksize (&new_attr, 512); #endif pthread_attr_setdetachstate (&new_attr, PTHREAD_CREATE_DETACHED); - ret = pthread_create (&this->hidden->update_th, + ret = pthread_create (&this->hidden->update_th, &new_attr, (void*)task_do_update, this); pthread_attr_destroy (&new_attr); } @@ -562,7 +562,7 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, MLSHADOW_REPLY_SURFACE_CREATE reply; MLSHADOW_REQ_SLAVE_SETINFO request_enable; BOOL reply_enable; - + request.op_id = MLSOP_ID_CREATE_SURFACE; request.width = width; request.height = height; @@ -574,13 +574,13 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, if(!reply.ret_value) { header = shmat(reply.shm_id_header, 0, 0); switch(header->type) { - case MLS_FB_TYPE_VIDEOMEM : - if(video_mem_info.type == MLS_FB_TYPE_VIDEOMEM) { + case MLS_FB_TYPE_VIDEOMEM : + if(video_mem_info.type == MLS_FB_TYPE_VIDEOMEM) { /* houhh 20071116, move these code to VideoInit().*/ //fd = open(video_mem_info.video_dev_name, O_RDONLY); - //_mmaped_mem = mmap(NULL, video_mem_info.video_mem_len, fd, + //_mmaped_mem = mmap(NULL, video_mem_info.video_mem_len, fd, // PROT_WRITE, MAP_SHARED, video_mem_info.video_mem_offset); - current->pixels = _mmaped_mem + header->video_offset; + current->pixels = _mmaped_mem + header->video_offset; current->pitch = video_mem_info.video_pitch; } break; @@ -591,12 +591,12 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, current->pitch = header->pitch; current->hwdata = (struct private_hwdata*)header; - + request_enable.op_id = MLSOP_ID_SET_SLAVEINFO; request_enable.surface_key = header->surface_key; request_enable.mask = MLS_INFOMASK_ENABLE; request_enable.enable = 1; - + MLSHADOW_SetSurface(&request_enable, &reply_enable); } } @@ -616,7 +616,7 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, if(video_mem_info.type == MLS_FB_TYPE_VIDEOMEM) { __mg_bmp_compute_pitch(depth, (unsigned int)w, (unsigned int* )&fb_pitch, 1); - fb_size = fb_pitch * h; + fb_size = fb_pitch * h; video_mem_info.video_mem_offset += fb_size; } if(ClientRequest(&req, &reply, sizeof(reply)) < 0){ @@ -627,23 +627,23 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, header = shmat(reply.shm_id_header, 0, 0); switch(header->type) { case MLS_FB_TYPE_VIDEOMEM : - if(reply.type == MLS_FB_TYPE_VIDEOMEM) { + if(reply.type == MLS_FB_TYPE_VIDEOMEM) { /* - video_mem_info.type = MLS_FB_TYPE_VIDEOMEM; + video_mem_info.type = MLS_FB_TYPE_VIDEOMEM; video_mem_info.video_mem_len = reply.video_mem_len; - memcpy(video_mem_info.video_dev_name, reply.video_dev_name, + memcpy(video_mem_info.video_dev_name, reply.video_dev_name, sizeof(reply.video_dev_name)); video_mem_info.video_mem_offset = reply.video_mem_offset; video_mem_info.video_pitch = reply.pitch; fd = open(reply.video_dev_name, O_RDONLY); - _mmaped_mem = mmap(NULL, reply.video_mem_len, fd, PROT_WRITE, + _mmaped_mem = mmap(NULL, reply.video_mem_len, fd, PROT_WRITE, MAP_SHARED, reply.video_mem_offset); */ /* houhh 20071116. add the real_surface's fb_size. */ current->pitch = reply.pitch; - current->pixels = _mmaped_mem + header->video_offset; + current->pixels = _mmaped_mem + header->video_offset; } break; case MLS_FB_TYPE_SYSTEMMEM : @@ -684,7 +684,7 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, switch(header->type) { case MLS_FB_TYPE_VIDEOMEM : current->pitch = video_mem_info.video_pitch; - current->pixels = _mmaped_mem + header->video_offset; + current->pixels = _mmaped_mem + header->video_offset; break; case MLS_FB_TYPE_SYSTEMMEM : current->pixels = (char*)header + sizeof(*header); @@ -701,11 +701,11 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, /* save surface address */ this->info.mlt_surfaces = 1; - + return (current); } - -static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrects, + +static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrects, GAL_Rect *rects) { int i; @@ -713,11 +713,11 @@ static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrec MLShadowFBHeader *header; header = (MLShadowFBHeader*)surface->hwdata; lock_fbh(header); - if(surface){ + if(surface){ bound = header->dirty_rect; for(i = 0; i < numrects; i++) { RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -725,10 +725,12 @@ static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrec GetBoundRect (&bound, &bound, &rc); } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + + if (IntersectRect (&bound, &bound, &rcScr)) { /* bugfixed houhh 20071116, the surface's dirty_rect can not beyond it's rect */ RECT rect = {0}; - SetRect(&rect, header->offset_x, header->offset_y, + SetRect(&rect, header->offset_x, header->offset_y, header->width + header->offset_x, header->height + header->offset_y); if(IntersectRect (&bound, &bound, &rect)){ header->dirty_rect = bound; @@ -739,11 +741,11 @@ static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrec } } } - unlock_fbh(header); + unlock_fbh(header); } -static int MLSHADOW_SetSurfaceColors (GAL_Surface* surface, +static int MLSHADOW_SetSurfaceColors (GAL_Surface* surface, int firstcolor, int ncolors, GAL_Color *colors) { GAL_Palette *pal; @@ -779,7 +781,7 @@ static int MLSHADOW_SetSurfaceColors (GAL_Surface* surface, /* houhh 20071115. * it will called by the palette_update_check(), when task_do_update(). - * called in mlshadow server. + * called in mlshadow server. */ static int MLSHADOW_SetColors (_THIS, int firstcolor, int ncolors, GAL_Color *colors) @@ -811,11 +813,11 @@ static int MLSHADOW_SetColors (_THIS, int firstcolor, int ncolors, static void MLSHADOW_UpdateRects (_THIS, int numrects, GAL_Rect *rects) { - return; + return; } -static int MLSHADOW_CreateFrameBuffer(MLSHADOW_REQ_SURFACE_CREATE* request, +static int MLSHADOW_CreateFrameBuffer(MLSHADOW_REQ_SURFACE_CREATE* request, MLSHADOW_REPLY_SURFACE_CREATE* reply) { int width, height; @@ -833,13 +835,13 @@ static int MLSHADOW_CreateFrameBuffer(MLSHADOW_REQ_SURFACE_CREATE* request, depth = request->depth; flags = request->flags; - reply->ret_value = -1; - + reply->ret_value = -1; + memset (&real_vformat, 0, sizeof(real_vformat)); - surface = GAL_CreateRGBSurface(flags, width, height, depth, 0, 0, 0, 0); - - if (!GAL_ReallocFormat (surface, depth, real_vformat.Rmask, real_vformat.Gmask, - real_vformat.Bmask, 0)) + surface = GAL_CreateRGBSurface(flags, width, height, depth, 0, 0, 0, 0); + + if (!GAL_ReallocFormat (surface, depth, real_vformat.Rmask, real_vformat.Gmask, + real_vformat.Bmask, 0)) return -1; @@ -876,7 +878,7 @@ static int MLSHADOW_CreateFrameBuffer(MLSHADOW_REQ_SURFACE_CREATE* request, } /* houhh 20071116, alloc slave surface from system memory. */ - if(video_mem_info.type == MLS_FB_TYPE_SYSTEMMEM || !videomem_enough) { + if(video_mem_info.type == MLS_FB_TYPE_SYSTEMMEM || !videomem_enough) { __mg_bmp_compute_pitch(depth, (unsigned int)width, (unsigned int* )&pitch, 1); fb_size = pitch * height; shm_size = fb_size + sizeof(MLShadowFBHeader); @@ -906,27 +908,27 @@ static int MLSHADOW_CreateFrameBuffer(MLSHADOW_REQ_SURFACE_CREATE* request, header->height = height; header->surface_key = (unsigned int)surface; surface->pixels = (char*)header + sizeof(*header); - surface->hwdata = (struct private_hwdata*)header; + surface->hwdata = (struct private_hwdata*)header; node = malloc(sizeof(*node)); memset(node, 0 ,sizeof(*node)); header->semid = semget(0, 1, IPC_CREAT | 0666 | IPC_EXCL); - reply->surface_key = (unsigned int)surface; + reply->surface_key = (unsigned int)surface; node->surface = surface; - node->enabled = FALSE; + node->enabled = FALSE; node->shmid = reply->shm_id_header; node->rect.left = 0; node->rect.top = 0; node->rect.right = width; node->rect.bottom = height; - + SetRect (&header->dirty_rect, 0, 0, 0, 0); list_add_tail(&node->node, &mlshadow_list); return 0; } -BOOL GUIAPI mlsGetSlaveScreenInfo (HDC dc_mls, DWORD mask, int* offset_x, int* offset_y, +BOOL GUIAPI mlsGetSlaveScreenInfo (HDC dc_mls, DWORD mask, int* offset_x, int* offset_y, DWORD blend_flags, gal_pixel* color_key, int* alpha, int* z_order) { BOOL flag = FALSE; @@ -995,8 +997,8 @@ BOOL GUIAPI mlsGetSlaveScreenInfo (HDC dc_mls, DWORD mask, int* offset_x, int* o return TRUE; } -static int MLSHADOW_GetSurface(MLSHADOW_REQ_SLAVE_GETINFO* request, - MLSHADOW_REPLY_SLAVE_GETINFO* reply) +static int MLSHADOW_GetSurface(MLSHADOW_REQ_SLAVE_GETINFO* request, + MLSHADOW_REPLY_SLAVE_GETINFO* reply) { mlshadow_node* node = NULL; list_t* pos, *back; @@ -1004,7 +1006,7 @@ static int MLSHADOW_GetSurface(MLSHADOW_REQ_SLAVE_GETINFO* request, BOOL flag = FALSE; reply->ret_value = -1; - + list_for_each_safe(pos, back, &mlshadow_list){ node = (mlshadow_node*)pos; index++; @@ -1030,7 +1032,7 @@ static int MLSHADOW_GetSurface(MLSHADOW_REQ_SLAVE_GETINFO* request, return 0; } -static int MLSHADOW_SetSurface(MLSHADOW_REQ_SLAVE_SETINFO *request, BOOL *reply) +static int MLSHADOW_SetSurface(MLSHADOW_REQ_SLAVE_SETINFO *request, BOOL *reply) { GAL_Surface* surface; mlshadow_node * node; @@ -1052,21 +1054,21 @@ static int MLSHADOW_SetSurface(MLSHADOW_REQ_SLAVE_SETINFO *request, BOOL *reply) rect.x = node->rect.left; rect.y = node->rect.top; rect.w = RECTW(node->rect); rect.h = RECTH(node->rect); - /* bugfixed houhh 20071116, should update the surface's old rect + /* bugfixed houhh 20071116, should update the surface's old rect * by update the master surface. before update surface, should be * set current surface's offset. */ node->rect.left = request->offset_x; node->rect.top = request->offset_y; node->rect.right = request->offset_x + surface->w; - node->rect.bottom = request->offset_y + surface->h; + node->rect.bottom = request->offset_y + surface->h; MLSHADOW_UpdateSurfaceRects(this, dc_HDC2PDC(HDC_SCREEN)->surface, 1, &rect); } *reply = TRUE; } if (request->mask & MLS_INFOMASK_BLEND) { if (request->blend_flags == MLS_BLENDMODE_COLORKEY) { - GAL_SetColorKey (surface, GAL_SRCCOLORKEY, request->color_key); + GAL_SetColorKey (surface, GAL_SRCCOLORKEY, request->color_key); node->blend_flags |= MLS_BLENDMODE_COLORKEY; *reply = TRUE; } @@ -1099,7 +1101,7 @@ static int MLSHADOW_SetSurface(MLSHADOW_REQ_SLAVE_SETINFO *request, BOOL *reply) int MLSHADOW_GetMasterSurface(MLSHADOW_REPLY_MASTER_INFO *reply) { mlshadow_node *master_node; - + if ((master_node = get_master_node()) == NULL) { reply->ret_value = -1; return -1; @@ -1126,7 +1128,7 @@ int MLSHADOW_Server(void* request, void* reply) case MLSOP_ID_GET_MASTERINFO : MLSHADOW_GetMasterSurface(reply); break; - case MLSOP_ID_CREATE_SURFACE : + case MLSOP_ID_CREATE_SURFACE : MLSHADOW_CreateFrameBuffer(request, reply); break; case MLSOP_ID_SET_SLAVEINFO : @@ -1135,13 +1137,13 @@ int MLSHADOW_Server(void* request, void* reply) case MLSOP_ID_GET_SLAVEINFO : MLSHADOW_GetSurface(request, reply); break; - case MLSOP_ID_DESTROY_SLAVE : + case MLSOP_ID_DESTROY_SLAVE : MLSHADOW_DeleteMLSurface(request, reply); break; default : return -1; } - return 0; + return 0; } static mlshadow_node* get_node(GAL_Surface* surface) @@ -1169,14 +1171,14 @@ static mlshadow_node* get_master_node(void) list_for_each_safe (pos, back, &mlshadow_list) { pdc = dc_HDC2PDC (HDC_SCREEN); - + if (pdc == NULL || pdc->surface == NULL || pdc->surface->hwdata == NULL){ fprintf(stderr, "Can't get master node\n"); return NULL; } header = (MLShadowFBHeader*) pdc->surface->hwdata; - + pnode = (mlshadow_node*)pos; if (pnode->surface == (GAL_Surface*)header->surface_key) { if(pnode->surface->video == NULL) @@ -1193,8 +1195,8 @@ void refresh_fb(RECT *dirty_rect, _THIS) mlshadow_node* master_node = NULL; mlshadow_node* slave_node = NULL; MLShadowFBHeader *header = NULL; - - list_t* me; + + list_t* me; GAL_Rect src = {0}; GAL_Rect dst = {0}; @@ -1206,27 +1208,27 @@ void refresh_fb(RECT *dirty_rect, _THIS) GAL_dirty_rect.h = RECTHP(dirty_rect); RECT intersect_rect; - node = node; + node = node; master_node = get_master_node(); if(master_node == NULL) return ; - if (master_node && (master_node->blend_flags & MLS_BLENDMODE_ALPHA)) { - GAL_FillRect (this->hidden->_real_surface, + if (master_node && (master_node->blend_flags & MLS_BLENDMODE_ALPHA)) { + GAL_FillRect (this->hidden->_real_surface, &GAL_dirty_rect, this->hidden->_real_def_bgcolor); } list_for_each (me, &mlshadow_list){ - slave_node = list_entry (me, mlshadow_node, node); + slave_node = list_entry (me, mlshadow_node, node); if(slave_node->enabled ){ header = (MLShadowFBHeader*)(slave_node->surface->hwdata); if(IntersectRect (&intersect_rect, &slave_node->rect, dirty_rect)){ dst.x = intersect_rect.left; - dst.y = intersect_rect.top; + dst.y = intersect_rect.top; dst.w = intersect_rect.right - intersect_rect.left; - dst.h = intersect_rect.bottom - intersect_rect.top; + dst.h = intersect_rect.bottom - intersect_rect.top; src.x = dst.x - slave_node->rect.left; src.y = dst.y - slave_node->rect.top; @@ -1235,11 +1237,11 @@ void refresh_fb(RECT *dirty_rect, _THIS) //fprintf(stderr, "(%d,%d):l=%d,t=%d,w=%d,h=%d\n", slave_node->rect.left, slave_node->rect.top, // dst.x, dst.y, dst.w, dst.h); if (this->hidden->swap_surface != NULL){ - GAL_BlitSurface (slave_node->surface, &src, + GAL_BlitSurface (slave_node->surface, &src, this->hidden->swap_surface, &dst); } else{ - GAL_BlitSurface (slave_node->surface, &src, + GAL_BlitSurface (slave_node->surface, &src, this->hidden->_real_surface, &dst); } } @@ -1247,7 +1249,7 @@ void refresh_fb(RECT *dirty_rect, _THIS) } if (this->hidden->swap_surface != NULL){ - GAL_BlitSurface (this->hidden->swap_surface, &GAL_dirty_rect, + GAL_BlitSurface (this->hidden->swap_surface, &GAL_dirty_rect, this->hidden->_real_surface, &GAL_dirty_rect); } @@ -1259,9 +1261,9 @@ void refresh_fb(RECT *dirty_rect, _THIS) /* houhh 20071115. * when mlshadow client change surface's palette, the relative - * surface's palette_offset data is changed synchronous. + * surface's palette_offset data is changed synchronous. * but mlshadow server check and update surface's palette in the - * task_do_update, it get palette data from MLShadowFBHeader's palette_offset + * task_do_update, it get palette data from MLShadowFBHeader's palette_offset * note: 1.if you have enable the double_surface, update palette when have. * 2.if anyone mlshadow client have changed the master surface's palette * the real_surface's palette is changed for all client. @@ -1280,14 +1282,14 @@ static void palette_update_check(MLShadowFBHeader *header, mlshadow_node* pnode) src_colors = (char*)header + header->palette_offset; memcpy(dst_colors, src_colors, PALETTE_SIZE); - // if the surface is master surface, set master surface's palette - // and _real_device's palette... + // if the surface is master surface, set master surface's palette + // and _real_device's palette... // include swap_surface/real_surface palette... pmaster_node = get_master_node(); if(pmaster_node && pmaster_node->surface == pnode->surface){ - this = pmaster_node->surface->video; + this = pmaster_node->surface->video; if(this->SetColors) - this->SetColors(this, 0, 256, (GAL_Color*)dst_colors); + this->SetColors(this, 0, 256, (GAL_Color*)dst_colors); } header->palette_changed = FALSE; @@ -1299,7 +1301,7 @@ static void palette_update_check(MLShadowFBHeader *header, mlshadow_node* pnode) static void* task_do_update (_THIS) { mlshadow_node* slave_node = NULL; - list_t* me, *back; + list_t* me, *back; MLShadowFBHeader *header = NULL; while (1) { @@ -1309,7 +1311,7 @@ static void* task_do_update (_THIS) slave_node = (mlshadow_node*)me; /* bugfixed houhh 20071116, if mlsEnableScreenInfo disable surface, surface can not update. * it should let other surface do update in current dirty_rect. - */ + */ //if(slave_node->enabled) { header = (MLShadowFBHeader*)(slave_node->surface->hwdata); @@ -1348,7 +1350,7 @@ void MLSHADOW_Del_List(void) } } node->surface->pixels = NULL; - Slave_FreeSurface (node->surface); + Slave_FreeSurface (node->surface); list_del(pos); } } @@ -1358,7 +1360,7 @@ static void MLSHADOW_DeleteDevice (GAL_VideoDevice *device) if(mgIsServer){ if(device && device->hidden){ /* check the real device if created success...*/ - if(device->hidden->_real_device){ + if(device->hidden->_real_device){ device->hidden->_real_device->VideoQuit(device->hidden->_real_device); GAL_FreeSurface (device->hidden->_real_surface); @@ -1411,7 +1413,7 @@ static void MLSHADOW_DeleteSurface(_THIS, GAL_Surface* surface) req.data = &request; req.id = REQID_MLSHADOW_CLIREQ; surface->pixels = NULL; - + if (shmdt (surface->hwdata) == -1){ fprintf(stderr, "shmdt failed.\n"); } @@ -1431,7 +1433,7 @@ static void MLSHADOW_DeleteMLSurface (MLSHADOW_REQ_SLAVE_DESTROY *request, BOOL GAL_VideoDevice* this; surface_key = (GAL_Surface*)request->surface_key; - *reply = FALSE; + *reply = FALSE; if (surface_key == NULL) { return; @@ -1443,13 +1445,13 @@ static void MLSHADOW_DeleteMLSurface (MLSHADOW_REQ_SLAVE_DESTROY *request, BOOL header = (MLShadowFBHeader*)(surface_key->hwdata); deleted_rect = node->rect; semctl(header->semid, 1, IPC_RMID); - + /* bugfixed houhh 20071116, before detach share memory: * note: 1.delete surface from mlsahdow_list first, else * task_do_update use the surface's share head will result error. * note: 2.must set surface->pixels = NULL. - * because the later GAL_FreeSurface() will free it again, this - * result error! + * because the later GAL_FreeSurface() will free it again, this + * result error! */ list_del(pos); semctl(header->semid, 1, IPC_RMID); @@ -1457,20 +1459,20 @@ static void MLSHADOW_DeleteMLSurface (MLSHADOW_REQ_SLAVE_DESTROY *request, BOOL if(shmctl(node->shmid, IPC_RMID, NULL) != 0) perror("shmctl"); - /* houhh 20061116, free server's slave surface, client's slave + /* houhh 20061116, free server's slave surface, client's slave * surface is free in Slave_VideoQuit(). */ node->surface->pixels = NULL; - Slave_FreeSurface (node->surface); + Slave_FreeSurface (node->surface); *reply = TRUE; - /* bugfixed houhh 20071116, should update the surface's old rect + /* bugfixed houhh 20071116, should update the surface's old rect * by update the master surface.*/ /* node = get_master_node(); - refresh_fb(&deleted_rect, node->surface->video); + refresh_fb(&deleted_rect, node->surface->video); */ rect.x = node->rect.left; rect.y = node->rect.top; rect.w = RECTW(node->rect); - rect.h = RECTH(node->rect); + rect.h = RECTH(node->rect); MLSHADOW_UpdateSurfaceRects(this, (dc_HDC2PDC(HDC_SCREEN))->surface, 1, &rect); /* bugfixed houhh 20071116, free slave surface node.*/ free(pos); @@ -1483,7 +1485,7 @@ static void MLSHADOW_VideoQuit (_THIS) { /* houhh 20071116, if user had delete slave surface, here will only * left master surface, else all the surface will free here. - * note: master surface->pixels = NULL first, else GAL_FreeSurface() + * note: master surface->pixels = NULL first, else GAL_FreeSurface() * free(surface->pixels) will error. * */ if(GAL_VideoSurface) @@ -1536,8 +1538,8 @@ BOOL mlsEnableSlaveScreen (HDC dc_mls, BOOL enable) return TRUE; } -BOOL GUIAPI mlsSetSlaveScreenInfo (HDC dc_mls, DWORD mask, - int offset_x, int offset_y, DWORD blend_flags, +BOOL GUIAPI mlsSetSlaveScreenInfo (HDC dc_mls, DWORD mask, + int offset_x, int offset_y, DWORD blend_flags, gal_pixel color_key, int alpha, int z_order) { MLSHADOW_REQ_SLAVE_SETINFO request; @@ -1563,7 +1565,7 @@ BOOL GUIAPI mlsSetSlaveScreenInfo (HDC dc_mls, DWORD mask, request.offset_x = offset_x; request.offset_y = offset_y; request.blend_flags = blend_flags; - request.z_order = z_order; + request.z_order = z_order; request.color_key = color_key; request.alpha = alpha; @@ -1583,7 +1585,7 @@ BOOL GUIAPI mlsSetSlaveScreenInfo (HDC dc_mls, DWORD mask, return TRUE; } -static GAL_Rect **MLSHADOW_ListModes (_THIS, GAL_PixelFormat *format, +static GAL_Rect **MLSHADOW_ListModes (_THIS, GAL_PixelFormat *format, Uint32 flags) { return (GAL_Rect **) -1; @@ -1600,7 +1602,7 @@ static void MLSHADOW_FreeHWSurface (_THIS, GAL_Surface *surface) surface->pixels = NULL; } -#if 0 +#if 0 void mlshadow_show_list (void) { list_t * pos; @@ -1611,11 +1613,11 @@ void mlshadow_show_list (void) node = (mlshadow_node *)pos; fprintf(stderr, "\nstruct __mlshadow_node \n " "node = %p\n " - "offset_x = %d\n " + "offset_x = %d\n " "offset_y = %d\n " "flags = %d\n " "shadow_surface = %p\n", - node, node->offset_x, node->offset_y, + node, node->offset_x, node->offset_y, node->flags, node->shadow_surface); } diff --git a/src/newgal/mlshadow/mlshadow-ths.c b/src/newgal/mlshadow/mlshadow-ths.c index 982f1169..26496cd0 100644 --- a/src/newgal/mlshadow/mlshadow-ths.c +++ b/src/newgal/mlshadow/mlshadow-ths.c @@ -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 . - * + * * 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 * . */ @@ -94,12 +94,12 @@ } /* Initialization/Query functions */ static int MLSHADOW_VideoInit (_THIS, GAL_PixelFormat *vformat); -static GAL_Rect **MLSHADOW_ListModes (_THIS, GAL_PixelFormat *format, +static GAL_Rect **MLSHADOW_ListModes (_THIS, GAL_PixelFormat *format, Uint32 flags); -static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, +static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, int width, int height, int bpp, Uint32 flags); static GAL_VideoDevice *MLSHADOW_CreateDevice(int devindex); -static int MLSHADOW_SetColors (_THIS, int firstcolor, int ncolors, +static int MLSHADOW_SetColors (_THIS, int firstcolor, int ncolors, GAL_Color *colors); static void MLSHADOW_VideoQuit (_THIS); static void MLSHADOW_UpdateRects (_THIS, int numrects, GAL_Rect *rects); @@ -112,7 +112,7 @@ static void MLSHADOW_DeleteDevice(GAL_VideoDevice *device); static int MLSHADOW_AllocHWSurface (_THIS, GAL_Surface *surface); static void MLSHADOW_FreeHWSurface (_THIS, GAL_Surface *surface); -static int MLSHADOW_SetSurfaceColors(GAL_Surface* surface, +static int MLSHADOW_SetSurfaceColors(GAL_Surface* surface, int firstcolor, int ncolors, GAL_Color *colors); static int MLSHADOW_Available(void); @@ -128,11 +128,11 @@ VideoBootStrap MLSHADOW_bootstrap = { }; /****************************/ -typedef struct __mlshadow_node +typedef struct __mlshadow_node { list_t node; - int offset_x; - int offset_y; + int offset_x; + int offset_y; DWORD flags; RECT updaterect; GAL_Surface* shadow_surface; @@ -175,7 +175,7 @@ BOOL mlsEnableSlaveScreen (HDC dc_mls, BOOL enable) if(enable == TRUE) //bugfix... node->flags |= MLSF_ENABLED; else if(enable == FALSE) - node->flags &= ~MLSF_ENABLED; + node->flags &= ~MLSF_ENABLED; pthread_mutex_unlock (&this->hidden->update_lock); @@ -198,11 +198,11 @@ void mlshadow_show_list (_THIS) node = (mlshadow_node *)pos; fprintf(stderr, "\nstruct __mlshadow_node \n " "node = %p\n " - "offset_x = %d\n " + "offset_x = %d\n " "offset_y = %d\n " "flags = %d\n " "shadow_surface = %p\n", - node, node->offset_x, node->offset_y, + node, node->offset_x, node->offset_y, node->flags, node->shadow_surface); } @@ -237,7 +237,7 @@ BOOL GUIAPI mlsGetSlaveScreenInfo (HDC dc_mls, DWORD mask,int* offset_x, int* of if (node->shadow_surface == dc_HDC2PDC(dc_mls)->surface) { flag = TRUE; break; - } + } } if (!flag){ pthread_mutex_unlock (&this->hidden->update_lock); @@ -274,8 +274,8 @@ BOOL GUIAPI mlsGetSlaveScreenInfo (HDC dc_mls, DWORD mask,int* offset_x, int* of return flag; } -BOOL GUIAPI mlsSetSlaveScreenInfo (HDC dc_mls, DWORD mask, - int offset_x, int offset_y, DWORD blend_flags, +BOOL GUIAPI mlsSetSlaveScreenInfo (HDC dc_mls, DWORD mask, + int offset_x, int offset_y, DWORD blend_flags, gal_pixel color_key, int alpha, int z_order) { list_t * pos; @@ -300,7 +300,7 @@ BOOL GUIAPI mlsSetSlaveScreenInfo (HDC dc_mls, DWORD mask, if (node->shadow_surface == dc_HDC2PDC(dc_mls)->surface) { flag = TRUE; break; - } + } } if (!flag){ @@ -315,7 +315,7 @@ BOOL GUIAPI mlsSetSlaveScreenInfo (HDC dc_mls, DWORD mask, rect.x = node->offset_x; rect.y = node->offset_y; rect.w = node->shadow_surface->w + rect.x; rect.h = node->shadow_surface->h + rect.y; - /* bugfixed houhh 20071116, should update the surface's old rect + /* bugfixed houhh 20071116, should update the surface's old rect * by update the master surface. before update surface, should be * set current surface's offset. */ @@ -333,9 +333,9 @@ BOOL GUIAPI mlsSetSlaveScreenInfo (HDC dc_mls, DWORD mask, if (mask & MLS_INFOMASK_BLEND) { if ((blend_flags & MLS_BLENDMODE_COLORKEY) == MLS_BLENDMODE_COLORKEY) { - GAL_SetColorKey (node->shadow_surface, GAL_SRCCOLORKEY, color_key); - // node->flags |= MLSF_ALPHA; - node->flags |= MLSF_COLORKEY; //bugfix... + GAL_SetColorKey (node->shadow_surface, GAL_SRCCOLORKEY, color_key); + // node->flags |= MLSF_ALPHA; + node->flags |= MLSF_COLORKEY; //bugfix... } if ((blend_flags & MLS_BLENDMODE_ALPHA) == MLS_BLENDMODE_ALPHA) { @@ -374,11 +374,11 @@ static mlshadow_node* get_node(_THIS, GAL_Surface* surface) } return NULL; } - + /* houhh 20071115 * save the updaterect for each surface (master and slave surface). * GAL_Rect *rects's coordinate is relative slave surface. - * the mlshadow_list's node is saved the updaterect that is relatived + * the mlshadow_list's node is saved the updaterect that is relatived * the master surface, not himself slave surface. */ static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrects, GAL_Rect *rects) @@ -386,7 +386,7 @@ static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrec int i; RECT bound; mlshadow_node* pnode = NULL; - if(surface && this){ + if(surface && this){ pthread_mutex_lock (&this->hidden->update_lock); // bound = this->hidden->update; pnode = get_node(surface->video, surface); @@ -399,7 +399,7 @@ static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrec RECT rc; rects[i].x += pnode->offset_x; rects[i].y += pnode->offset_y; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -407,10 +407,12 @@ static void MLSHADOW_UpdateSurfaceRects (_THIS, GAL_Surface* surface, int numrec GetBoundRect (&bound, &bound, &rc); } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + + if (IntersectRect (&bound, &bound, &rcScr)) { /* bugfixed houhh 20071116, the surface's dirty_rect can not beyond it's rect */ RECT rect = {0}; - SetRect(&rect, pnode->offset_x, pnode->offset_y, + SetRect(&rect, pnode->offset_x, pnode->offset_y, surface->w + pnode->offset_x, surface->h + pnode->offset_y); if(IntersectRect (&bound, &bound, &rect)){ pnode->updaterect = bound; @@ -432,7 +434,7 @@ static void MLSHADOW_UpdateRects (_THIS, int numrects, GAL_Rect *rects) bound = this->hidden->update; for (i = 0; i < numrects; i++) { RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -440,7 +442,9 @@ static void MLSHADOW_UpdateRects (_THIS, int numrects, GAL_Rect *rects) GetBoundRect (&bound, &bound, &rc); } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + + if (IntersectRect (&bound, &bound, &rcScr)) { this->hidden->update = bound; this->hidden->dirty = TRUE; } @@ -502,7 +506,7 @@ static int MLSHADOW_VideoInit (_THIS, GAL_PixelFormat *vformat) char system_engine [LEN_ENGINE_NAME + 1]; char double_buffer[20]; GAL_PixelFormat real_vformat; - + /* houhh 20071116, if mlshadow is not the gal_engine, but call InitSlaveScreen. */ if (GetMgEtcValue ("system", "gal_engine", system_engine, LEN_ENGINE_NAME) < 0) { return -1; @@ -511,14 +515,14 @@ static int MLSHADOW_VideoInit (_THIS, GAL_PixelFormat *vformat) return -1; } - if (this->hidden->_real_surface != NULL) + if (this->hidden->_real_surface != NULL) return 0; this->hidden->dirty = FALSE; SetRect (&this->hidden->update, 0, 0, 0, 0); pthread_mutex_init (&this->hidden->update_lock, NULL); - if (GetMgEtcValue (MLSHADOW_NAME, "real_engine", + if (GetMgEtcValue (MLSHADOW_NAME, "real_engine", real_engine, LEN_ENGINE_NAME) < 0) { return -1; } @@ -530,35 +534,35 @@ static int MLSHADOW_VideoInit (_THIS, GAL_PixelFormat *vformat) } memset (&real_vformat, 0, sizeof(real_vformat)); - if (this->hidden->_real_device->VideoInit (this->hidden->_real_device, + if (this->hidden->_real_device->VideoInit (this->hidden->_real_device, &real_vformat) < 0 ) { return (-1); } - if (GetMgEtcValue (MLSHADOW_NAME, "def_bgcolor", + if (GetMgEtcValue (MLSHADOW_NAME, "def_bgcolor", real_engine, LEN_ENGINE_NAME) < 0) { return -1; } this->hidden->_real_def_bgcolor = strtoul(real_engine, NULL, 0); - if(this->hidden->_real_def_bgcolor > 0xffffff + if(this->hidden->_real_def_bgcolor > 0xffffff || this->hidden->_real_def_bgcolor < 0) { this->hidden->_real_def_bgcolor = 0; } - GetMgEtcValue (MLSHADOW_NAME, "double_buffer", double_buffer, LEN_ENGINE_NAME); + GetMgEtcValue (MLSHADOW_NAME, "double_buffer", double_buffer, LEN_ENGINE_NAME); if(!strncmp(double_buffer, "enable", sizeof("enable"))) { this->hidden->swap_surface = malloc(sizeof(GAL_Surface)); } - this->hidden->_real_surface = GAL_CreateRGBSurface (GAL_SWSURFACE, - 0, 0, real_vformat.BitsPerPixel, real_vformat.Rmask, + this->hidden->_real_surface = GAL_CreateRGBSurface (GAL_SWSURFACE, + 0, 0, real_vformat.BitsPerPixel, real_vformat.Rmask, real_vformat.Gmask, real_vformat.Bmask, 0); if (this->hidden->_real_surface == NULL ) { this->hidden->_real_device->free (this->hidden->_real_device); return (-1); - } + } this->hidden->_real_surface->video = this->hidden->_real_device; this->hidden->_real_device->info.vfmt = this->hidden->_real_surface->format; @@ -589,7 +593,7 @@ static void refresh_surface (_THIS, RECT* updaterect) RECT intersect_rect; GAL_Rect cache_rect; mlshadow_node* pnode = NULL, *pnode2 = NULL, *master_node = NULL; - GAL_Rect src = {0}, dst = {0}; + GAL_Rect src = {0}, dst = {0}; RECT* dirty_rect = NULL; RECT updatecache_rect = {0}; @@ -597,7 +601,7 @@ static void refresh_surface (_THIS, RECT* updaterect) updaterect = updaterect; list_for_each (me, &this->hidden->_mlshadow_list) { - pnode = list_entry (me, mlshadow_node, node); + pnode = list_entry (me, mlshadow_node, node); if (pnode && pnode->shadow_surface) { dirty_rect = &pnode->updaterect; if(IsRectEmpty(dirty_rect)) @@ -607,35 +611,35 @@ static void refresh_surface (_THIS, RECT* updaterect) cache_rect.w = RECTWP(dirty_rect); cache_rect.h = RECTHP(dirty_rect); - if (master_node->shadow_surface && (master_node->flags & MLSF_ALPHA)) { - Uint32 color = this->hidden->_real_def_bgcolor; - GAL_FillRect (this->hidden->_real_surface, &cache_rect, + if (master_node->shadow_surface && (master_node->flags & MLSF_ALPHA)) { + Uint32 color = this->hidden->_real_def_bgcolor; + GAL_FillRect (this->hidden->_real_surface, &cache_rect, RGB2Pixel(HDC_SCREEN, color & 0xff, (color & 0xff00) >> 8, (color & 0xff0000) >> 16)); } startnode = me->prev; if((pnode->flags & MLSF_ALPHA) || (pnode->flags & MLSF_COLORKEY)){ startnode = &this->hidden->_mlshadow_list; // even surface is not enabled, it will affect other surface... - } - // list_for_each (me2, &this->hidden->_mlshadow_list) // refresh the all list's surface... + } + // list_for_each (me2, &this->hidden->_mlshadow_list) // refresh the all list's surface... list_for_each (me2, startnode){ // only refresh the surface zorder hight... - if(me2 == &this->hidden->_mlshadow_list){ // have reach end... + if(me2 == &this->hidden->_mlshadow_list){ // have reach end... break; } - pnode2 = list_entry (me2, mlshadow_node, node); + pnode2 = list_entry (me2, mlshadow_node, node); if(pnode2 && pnode2->shadow_surface){ dst.x = pnode2->offset_x; dst.y = pnode2->offset_y; - dst.w = pnode2->shadow_surface->w; + dst.w = pnode2->shadow_surface->w; dst.h = pnode2->shadow_surface->h; src = dst; if (pnode2->flags & MLSF_ENABLED) { - SetRect(&intersect_rect, dst.x, dst.y, + SetRect(&intersect_rect, dst.x, dst.y, dst.x + dst.w, dst.y + dst.h); if (IntersectRect (&intersect_rect, &intersect_rect, dirty_rect)) { - dst.x = intersect_rect.left; dst.y = intersect_rect.top; - dst.w = RECTW(intersect_rect); - dst.h = RECTH(intersect_rect); + dst.x = intersect_rect.left; dst.y = intersect_rect.top; + dst.w = RECTW(intersect_rect); + dst.h = RECTH(intersect_rect); src.x = dst.x - src.x; src.y = dst.y - src.y; src.w = dst.w; src.h = dst.h; @@ -648,20 +652,20 @@ static void refresh_surface (_THIS, RECT* updaterect) else GetBoundRect (&updatecache_rect, &updatecache_rect, &intersect_rect); #if 0 - fprintf(stderr, "update_rect:(%d,%d)%d,%d,%d,%d\n", pnode2->offset_x, pnode2->offset_y, + fprintf(stderr, "update_rect:(%d,%d)%d,%d,%d,%d\n", pnode2->offset_x, pnode2->offset_y, dirty_rect->left, dirty_rect->top, RECTWP(dirty_rect), RECTHP(dirty_rect)); - fprintf(stderr, "clip_rect:%d,%d,%d,%d\n", intersect_rect.left, intersect_rect.top, + fprintf(stderr, "clip_rect:%d,%d,%d,%d\n", intersect_rect.left, intersect_rect.top, RECTW(intersect_rect), RECTH(intersect_rect)); #endif } else{ - //fprintf(stderr, "no swap_surface:clip_rect:%d,%d,%d,%d\n", intersect_rect.left, intersect_rect.top, + //fprintf(stderr, "no swap_surface:clip_rect:%d,%d,%d,%d\n", intersect_rect.left, intersect_rect.top, // RECTW(intersect_rect), RECTH(intersect_rect)); GAL_BlitSurface (pnode2->shadow_surface, &src, this->hidden->_real_surface, &dst); } } - } + } } } // if has enable the double_buffer, do real surface blit now... @@ -676,7 +680,7 @@ static void refresh_surface (_THIS, RECT* updaterect) /* houhh 2007116, if has enable the double_buffer, do _real_surface blit here... * paint the cache surface to real surface... - */ + */ if(this->hidden->swap_surface && !IsRectEmpty(&updatecache_rect)){ //static int cc = 0; GAL_Rect rect = {0}; @@ -688,7 +692,7 @@ static void refresh_surface (_THIS, RECT* updaterect) this->hidden->_real_surface, &rect); //fprintf(stderr, "%d:cacherect:%d,%d,%d,%d\n", cc++, rect.x, rect.y, rect.w, rect.h); if(this->hidden->_real_device->UpdateRects){ - this->hidden->_real_device->UpdateRects (this->hidden->_real_device, + this->hidden->_real_device->UpdateRects (this->hidden->_real_device, 1, &rect); } updatecache_rect.right = updatecache_rect.left; @@ -700,7 +704,7 @@ static void* task_do_update (void* data) { _THIS; this = data; - while (1) { + while (1) { __mg_os_time_delay (20); if (this->hidden->dirty) { pthread_mutex_lock (&this->hidden->update_lock); @@ -732,13 +736,13 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, if (list_empty (&this->hidden->_mlshadow_list)) { - /* create real surface. */ - if (GetMgEtcValue (MLSHADOW_NAME, "real_engine", + /* create real surface. */ + if (GetMgEtcValue (MLSHADOW_NAME, "real_engine", real_engine, LEN_ENGINE_NAME) < 0) { fprintf (stderr, "NEWGAL>MLShadow: real_engine not defined.\n"); return NULL; } - + if (GetMgEtcValue (real_engine, "defaultmode", mode, LEN_MODE) < 0) { if (GetMgEtcValue ("system", "defaultmode", mode, LEN_MODE) < 0) { fprintf (stderr, "NEWGAL>MLShadow: default mode not defined.\n"); @@ -750,10 +754,10 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, fprintf (stderr, "NEWGAL>MLShadow: bad real video mode parameter: %s.\n", mode); return NULL; } - if (!(this->hidden->_real_surface + if (!(this->hidden->_real_surface = this->hidden->_real_device->SetVideoMode ( - this->hidden->_real_device, - this->hidden->_real_surface, + this->hidden->_real_device, + this->hidden->_real_surface, w, h, depth, GAL_HWPALETTE))) { fprintf (stderr, "NEWGAL>MLShadow: can not set video mode for real engine: %s.\n", mode); return NULL; @@ -761,8 +765,8 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, /* houhh 20071116 bugfix, reset the surface w/h/pitch. * if the input width/height/bpp is diffirent with the real_device. - */ - + */ + current->w = w; current->h = h; current->pitch = w * ((depth + 7) / 8); @@ -778,13 +782,13 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, GAL_PixelFormat real_vformat = *this->hidden->_real_surface->format; __mg_bmp_compute_pitch(depth, (unsigned int)w, (unsigned int* )&swap_fb_pitch, 1); swap_fb_size = swap_fb_pitch * h; - - /* bugfixed 20071116, This will result GAL_FreeSurface() error. + + /* bugfixed 20071116, This will result GAL_FreeSurface() error. * memcpy(this->hidden->swap_surface, this->hidden->_real_surface. * sizeof(GAL_Surface)); */ - this->hidden->swap_surface = GAL_CreateRGBSurface (GAL_SWSURFACE, w, h, - real_vformat.BitsPerPixel, real_vformat.Rmask, + this->hidden->swap_surface = GAL_CreateRGBSurface (GAL_SWSURFACE, w, h, + real_vformat.BitsPerPixel, real_vformat.Rmask, real_vformat.Gmask, real_vformat.Bmask, 0); if (this->hidden->swap_surface) { this->hidden->swap_surface->pixels = calloc(1, swap_fb_size); @@ -816,7 +820,7 @@ static GAL_Surface *MLSHADOW_SetVideoMode (_THIS, GAL_Surface *current, pthread_attr_setstacksize (&new_attr, 512); #endif pthread_attr_setdetachstate (&new_attr, PTHREAD_CREATE_DETACHED); - ret = pthread_create (&this->hidden->update_th, + ret = pthread_create (&this->hidden->update_th, &new_attr, task_do_update, this); pthread_attr_destroy (&new_attr); } @@ -875,7 +879,7 @@ static void MLSHADOW_DeleteSurface (_THIS, GAL_Surface* surface) if (!flag) { pthread_mutex_unlock (&this->hidden->update_lock); - return; + return; } list_del(pos); if (list_empty(&this->hidden->_mlshadow_list)) { @@ -911,7 +915,7 @@ static void MLSHADOW_VideoQuit (_THIS) pthread_mutex_destroy (&this->hidden->update_lock); } -static GAL_Rect **MLSHADOW_ListModes (_THIS, GAL_PixelFormat *format, +static GAL_Rect **MLSHADOW_ListModes (_THIS, GAL_PixelFormat *format, Uint32 flags) { return (GAL_Rect **) -1; @@ -933,8 +937,8 @@ static void MLSHADOW_FreeHWSurface (_THIS, GAL_Surface *surface) * SetSurfaceColors() is used to set surface's palette when need. * it is distinguish with the SetColors(). * it will call SetColors() when set the master surface. - */ -static int MLSHADOW_SetSurfaceColors (GAL_Surface* surface, + */ +static int MLSHADOW_SetSurfaceColors (GAL_Surface* surface, int firstcolor, int ncolors, GAL_Color *colors) { list_t * pos, *back; @@ -983,10 +987,10 @@ static int MLSHADOW_SetSurfaceColors (GAL_Surface* surface, } /* houhh 20071115. - * if the surface is master surface, then set the master. - * surface's palette and the _real_device's palette. + * if the surface is master surface, then set the master. + * surface's palette and the _real_device's palette. * set the swap_surface and real_surface and _real_device palette. - */ + */ static int MLSHADOW_SetColors (_THIS, int firstcolor, int ncolors, GAL_Color *colors) { @@ -1008,7 +1012,7 @@ static int MLSHADOW_SetColors (_THIS, int firstcolor, int ncolors, } } } - this->hidden->_real_device->SetColors(this->hidden->_real_device, + this->hidden->_real_device->SetColors(this->hidden->_real_device, firstcolor, ncolors, colors); return 0; } diff --git a/src/newgal/mlshadow/test/window_mini_max.c b/src/newgal/mlshadow/test/window_mini_max.c index 766d6e4e..b1af20a5 100644 --- a/src/newgal/mlshadow/test/window_mini_max.c +++ b/src/newgal/mlshadow/test/window_mini_max.c @@ -68,8 +68,8 @@ static void* do_update (void* data) int timer = 0; int screen_w, screen_h; - screen_w =g_rcDesktop.right - g_rcDesktop.left; - screen_h =g_rcDesktop.bottom - g_rcDesktop.top; + screen_w =g_rcScr.right - g_rcScr.left; + screen_h =g_rcScr.bottom - g_rcScr.top; while (1) { usleep (10000); diff --git a/src/newgal/shadow/shadow.c b/src/newgal/shadow/shadow.c index 776b4812..66ff1f4f 100644 --- a/src/newgal/shadow/shadow.c +++ b/src/newgal/shadow/shadow.c @@ -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 . - * + * * 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 * . */ @@ -69,12 +69,12 @@ #ifdef _MGRM_PROCESSES -#include +#include #include #include #include #include -#include +#include union semun { int val; /* value for SETVAL */ @@ -83,7 +83,7 @@ union semun { struct seminfo *__buf; /* buffer for IPC_INFO */ }; -#endif +#endif #include "minigui.h" #include "newgal.h" @@ -99,8 +99,8 @@ union semun { #define _ROT_DIR_HFLIP 0x08 #define _ROT_DIR_VFLIP 0x10 -#define SHADOW_SHM_KEY 0x4D475344 -#define SHADOW_SEM_KEY 0x4D475344 +#define SHADOW_SHM_KEY 0x4D475344 +#define SHADOW_SEM_KEY 0x4D475344 #define LEN_ENGINE_NAME 10 #define LEN_MODE 20 @@ -173,7 +173,7 @@ again: } } } -#endif +#endif static ShadowFBHeader* _shadowfbheader; @@ -208,7 +208,7 @@ static void SHADOW_UpdateRects (_THIS, int numrects, GAL_Rect *rects) for (i = 0; i < numrects; i++) { RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -217,7 +217,9 @@ static void SHADOW_UpdateRects (_THIS, int numrects, GAL_Rect *rects) } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + + if (IntersectRect (&bound, &bound, &rcScr)) { _shadowfbheader->dirty_rect = bound; _shadowfbheader->dirty = TRUE; } @@ -239,7 +241,7 @@ static GAL_VideoDevice *SHADOW_CreateDevice(int devindex) device = (GAL_VideoDevice *)malloc(sizeof(GAL_VideoDevice)); if (device) { memset (device, 0, (sizeof *device)); - device->hidden = (struct GAL_PrivateVideoData *) + device->hidden = (struct GAL_PrivateVideoData *) malloc (sizeof(struct GAL_PrivateVideoData)); } if ( (device == NULL) || (device->hidden == NULL)) { @@ -312,13 +314,13 @@ static int RealEngine_GetInfo (RealFBInfo * realfb_info) real_device->VideoInit(realfb_info->real_device, &real_vformat); real_device->screen = GAL_CreateRGBSurface (GAL_SWSURFACE, - 0, 0, real_vformat.BitsPerPixel, real_vformat.Rmask, + 0, 0, real_vformat.BitsPerPixel, real_vformat.Rmask, real_vformat.Gmask, real_vformat.Bmask, 0); if (real_device->screen == NULL) - fprintf (stderr, "NEWGAL>SHADOW: can't create screen of real engine.\n"); + fprintf (stderr, "NEWGAL>SHADOW: can't create screen of real engine.\n"); - real_device->SetVideoMode(realfb_info->real_device, + real_device->SetVideoMode(realfb_info->real_device, real_device->screen, w, h, depth, GAL_HWPALETTE); realfb_info->height = real_device->screen->h; @@ -326,7 +328,7 @@ static int RealEngine_GetInfo (RealFBInfo * realfb_info) realfb_info->depth = real_device->screen->format->BitsPerPixel; realfb_info->fb = real_device->screen->pixels; realfb_info->pitch = real_device->screen->pitch; - realfb_info->flags = 0; + realfb_info->flags = 0; if (realfb_info->depth <= 8) pitch_size = realfb_info->width; @@ -383,8 +385,8 @@ static int RealEngine_Release(RealFBInfo * realfb_info) if (realfb_info->flags == FLAG_REALFB_PREALLOC) realfb_info->fb = NULL; - video->VideoQuit (this); - if (video->physpal) + video->VideoQuit (this); + if (video->physpal) { free (video->physpal->colors); free (video->physpal); @@ -398,14 +400,14 @@ static int RealEngine_Release(RealFBInfo * realfb_info) return 0; } -static int RealEngine_SetPalette(RealFBInfo *realfb_info, int firstcolor, +static int RealEngine_SetPalette(RealFBInfo *realfb_info, int firstcolor, int ncolors, void *colors) { GAL_Color* pal_colors; pal_colors = (GAL_Color*)((char*)_shadowfbheader + _shadowfbheader->palette_offset); if (colors != pal_colors + firstcolor) - memcpy (pal_colors + firstcolor, colors, ncolors * sizeof(GAL_Color)); + memcpy (pal_colors + firstcolor, colors, ncolors * sizeof(GAL_Color)); return 1; } @@ -428,7 +430,7 @@ static int RealEngine_Init(void) fprintf(stderr, "NEWGAL>SHADOW: RealEngine_Init failure.\n"); return -1; } - memset(__mg_shadow_fb_ops, 0, sizeof(ShadowFBOps)); + memset(__mg_shadow_fb_ops, 0, sizeof(ShadowFBOps)); __mg_shadow_fb_ops->get_realfb_info = RealEngine_GetInfo; __mg_shadow_fb_ops->init = RealEngine_Init; @@ -507,7 +509,7 @@ static void* task_do_update (void* data) break; } - if (_shadowfbheader->dirty || _shadowfbheader->palette_changed) + if (_shadowfbheader->dirty || _shadowfbheader->palette_changed) { #ifdef _MGRM_PROCESSES _sysvipc_sem_op (this->hidden->semid, 0, -1); @@ -521,25 +523,25 @@ static void* task_do_update (void* data) _shadowfbheader->ncolors, (GAL_Color*)((char*)_shadowfbheader + _shadowfbheader->palette_offset)); SetRect (&_shadowfbheader->dirty_rect, 0, 0, - _shadowfbheader->width, _shadowfbheader->height); + _shadowfbheader->width, _shadowfbheader->height); } __mg_shadow_fb_ops->refresh (_shadowfbheader, this->hidden->realfb_info, &(_shadowfbheader->dirty_rect)); if (this->hidden->realfb_info->flags & _ROT_DIR_CW) { - _get_dst_rect_cw (&qvfb_rect, &(_shadowfbheader->dirty_rect), + _get_dst_rect_cw (&qvfb_rect, &(_shadowfbheader->dirty_rect), this->hidden->realfb_info); } - else if (this->hidden->realfb_info->flags & _ROT_DIR_CCW) - _get_dst_rect_ccw (&qvfb_rect, &(_shadowfbheader->dirty_rect), + else if (this->hidden->realfb_info->flags & _ROT_DIR_CCW) + _get_dst_rect_ccw (&qvfb_rect, &(_shadowfbheader->dirty_rect), this->hidden->realfb_info); - else if (this->hidden->realfb_info->flags & _ROT_DIR_HFLIP) + else if (this->hidden->realfb_info->flags & _ROT_DIR_HFLIP) { qvfb_rect = _shadowfbheader->dirty_rect; _get_dst_rect_hflip (&qvfb_rect, this->hidden->realfb_info); } - else if (this->hidden->realfb_info->flags & _ROT_DIR_VFLIP) + else if (this->hidden->realfb_info->flags & _ROT_DIR_VFLIP) { qvfb_rect = _shadowfbheader->dirty_rect; _get_dst_rect_vflip (&qvfb_rect, this->hidden->realfb_info); @@ -682,7 +684,7 @@ static GAL_Surface *SHADOW_SetVideoMode(_THIS, GAL_Surface *current, _shadowfbheader->info_size = size; _shadowfbheader->dirty = FALSE; - SetRect (&(_shadowfbheader->dirty_rect), 0, 0, 0, 0); + SetRect (&(_shadowfbheader->dirty_rect), 0, 0, 0, 0); _shadowfbheader->palette_changed = FALSE; _shadowfbheader->palette_offset = sizeof(ShadowFBHeader); @@ -692,11 +694,11 @@ static GAL_Surface *SHADOW_SetVideoMode(_THIS, GAL_Surface *current, _shadowfbheader->fb_offset = _shadowfbheader->palette_offset; if ((realfb_info->real_device)) - GAL_SetClipRect (real_device->screen, NULL); + GAL_SetClipRect (real_device->screen, NULL); - if (!GAL_ReallocFormat (current, _shadowfbheader->depth, - real_device->screen->format->Rmask, - real_device->screen->format->Gmask, + if (!GAL_ReallocFormat (current, _shadowfbheader->depth, + real_device->screen->format->Rmask, + real_device->screen->format->Gmask, real_device->screen->format->Bmask, real_device->screen->format->Amask)) { @@ -725,7 +727,7 @@ static GAL_Surface *SHADOW_SetVideoMode(_THIS, GAL_Surface *current, pthread_attr_setstacksize (&new_attr, 512); #endif pthread_attr_setdetachstate (&new_attr, PTHREAD_CREATE_DETACHED); - ret = pthread_create (&this->hidden->update_th, &new_attr, + ret = pthread_create (&this->hidden->update_th, &new_attr, task_do_update, this); pthread_attr_destroy (&new_attr); } @@ -772,7 +774,7 @@ static GAL_Surface *SHADOW_SetVideoMode(_THIS, GAL_Surface *current, RealFBInfo * realfb_info; GAL_VideoDevice* real_device = NULL; realfb_info = NULL; - shmid = 0; + shmid = 0; size = 0; ret = 0; @@ -839,7 +841,7 @@ static GAL_Surface *SHADOW_SetVideoMode(_THIS, GAL_Surface *current, return NULL; } - _shadowfbheader = (ShadowFBHeader *) shmat (shmid, 0, 0); + _shadowfbheader = (ShadowFBHeader *) shmat (shmid, 0, 0); memcpy (_shadowfbheader, &shadowfbheader, sizeof (ShadowFBHeader)); this->hidden->realfb_info = realfb_info; @@ -849,13 +851,13 @@ static GAL_Surface *SHADOW_SetVideoMode(_THIS, GAL_Surface *current, /* INIT Share Memory ShadowFBHeader */ _shadowfbheader->info_size = size; _shadowfbheader->dirty = FALSE; - SetRect (&(_shadowfbheader->dirty_rect), 0, 0, 0, 0); + SetRect (&(_shadowfbheader->dirty_rect), 0, 0, 0, 0); _shadowfbheader->palette_changed = FALSE; _shadowfbheader->palette_offset = sizeof(ShadowFBHeader); if(shadowfbheader.depth <= 8) _shadowfbheader->fb_offset = _shadowfbheader->palette_offset + PALETTE_SIZE; - else + else _shadowfbheader->fb_offset = _shadowfbheader->palette_offset; _shadowfbheader->Rmask = real_device->screen->format->Rmask; @@ -864,7 +866,7 @@ static GAL_Surface *SHADOW_SetVideoMode(_THIS, GAL_Surface *current, _shadowfbheader->Amask = real_device->screen->format->Amask; if ((realfb_info->real_device)) - GAL_SetClipRect (real_device->screen, NULL); + GAL_SetClipRect (real_device->screen, NULL); } else { shmid = shmget(SHADOW_SHM_KEY, 0, 0); @@ -872,8 +874,8 @@ static GAL_Surface *SHADOW_SetVideoMode(_THIS, GAL_Surface *current, } /* Allocate the new pixel format for the screen */ - if (!GAL_ReallocFormat (current, _shadowfbheader->depth, - _shadowfbheader->Rmask, _shadowfbheader->Gmask, + if (!GAL_ReallocFormat (current, _shadowfbheader->depth, + _shadowfbheader->Rmask, _shadowfbheader->Gmask, _shadowfbheader->Bmask, _shadowfbheader->Amask)){ if (__mg_shadow_fb_ops->release) __mg_shadow_fb_ops->release (realfb_info); @@ -902,7 +904,7 @@ static GAL_Surface *SHADOW_SetVideoMode(_THIS, GAL_Surface *current, pthread_attr_setstacksize (&new_attr, 512); #endif pthread_attr_setdetachstate (&new_attr, PTHREAD_CREATE_DETACHED); - ret = pthread_create (&this->hidden->update_th, &new_attr, + ret = pthread_create (&this->hidden->update_th, &new_attr, task_do_update, this); pthread_attr_destroy (&new_attr); @@ -944,7 +946,7 @@ static void SHADOW_VideoQuit (_THIS) #endif -static GAL_Rect **SHADOW_ListModes (_THIS, GAL_PixelFormat *format, +static GAL_Rect **SHADOW_ListModes (_THIS, GAL_PixelFormat *format, Uint32 flags) { return (GAL_Rect **) -1; @@ -961,15 +963,15 @@ static void SHADOW_FreeHWSurface (_THIS, GAL_Surface *surface) surface->pixels = NULL; } -static int SHADOW_SetColors (_THIS, int firstcolor, int ncolors, +static int SHADOW_SetColors (_THIS, int firstcolor, int ncolors, GAL_Color *colors) { _shadowfbheader->firstcolor = firstcolor; _shadowfbheader->ncolors = ncolors; #ifdef _MGRM_PROCESSES if(mgIsServer) { -#endif - if ((__mg_shadow_fb_ops->set_palette != NULL) +#endif + if ((__mg_shadow_fb_ops->set_palette != NULL) && (_shadowfbheader->depth <= 8)){ __mg_shadow_fb_ops->set_palette(this->hidden->realfb_info, firstcolor, ncolors, colors); diff --git a/src/newgal/usvfb/usvfb.c b/src/newgal/usvfb/usvfb.c index ab79eb83..d2318774 100644 --- a/src/newgal/usvfb/usvfb.c +++ b/src/newgal/usvfb/usvfb.c @@ -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 . - * + * * 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 * . */ @@ -70,7 +70,7 @@ via the UNIX socket. 5. Note that the resolution of the virtual frame buffer should be sent by the server as - the first message. + the first message. 6. The server accepts the connection request from the MiniGUI client, gets the identifier of the shared memory sent by the client via the UNIX socket, @@ -313,7 +313,7 @@ static void USVFB_UpdateRects (_THIS, int numrects, GAL_Rect *rects) SetRect (&bound, 0, 0, 0, 0); for (i = 0; i < numrects; i++) { RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -333,7 +333,7 @@ static void USVFB_UpdateRects (_THIS, int numrects, GAL_Rect *rects) bound = this->hidden->rc_dirty; for (i = 0; i < numrects; i++) { RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -342,7 +342,9 @@ static void USVFB_UpdateRects (_THIS, int numrects, GAL_Rect *rects) } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + + if (IntersectRect (&bound, &bound, &rcScr)) { this->hidden->rc_dirty = bound; this->hidden->dirty = TRUE; } @@ -437,7 +439,7 @@ static GAL_Surface *USVFB_SetVideoMode(_THIS, GAL_Surface *current, { Uint32 Rmask = 0, Gmask = 0, Bmask = 0, Amask = 0; int retval; - struct _vfb_info li; + struct _vfb_info li; memset (&li, 0, sizeof (struct _vfb_info)); if ((retval = a_getinfo (&li, width, height, bpp))) { @@ -510,7 +512,7 @@ static GAL_Surface *USVFB_SetVideoMode(_THIS, GAL_Surface *current, pthread_attr_init (&new_attr); pthread_attr_setdetachstate (&new_attr, PTHREAD_CREATE_DETACHED); - pthread_create (&this->hidden->update_th, &new_attr, + pthread_create (&this->hidden->update_th, &new_attr, task_do_update, this); pthread_attr_destroy (&new_attr); pthread_mutex_init(&this->hidden->update_lock, NULL); @@ -537,7 +539,7 @@ static void USVFB_VideoQuit (_THIS) return; } -static GAL_Rect **USVFB_ListModes (_THIS, GAL_PixelFormat *format, +static GAL_Rect **USVFB_ListModes (_THIS, GAL_PixelFormat *format, Uint32 flags) { return (GAL_Rect **) -1; @@ -554,7 +556,7 @@ static void USVFB_FreeHWSurface (_THIS, GAL_Surface *surface) surface->pixels = NULL; } -static int USVFB_SetColors (_THIS, int firstcolor, int ncolors, +static int USVFB_SetColors (_THIS, int firstcolor, int ncolors, GAL_Color *colors) { return 0; diff --git a/src/newgal/utpmc/utpmcvideo-lite.c b/src/newgal/utpmc/utpmcvideo-lite.c index 65c0d8e3..779d73a7 100644 --- a/src/newgal/utpmc/utpmcvideo-lite.c +++ b/src/newgal/utpmc/utpmcvideo-lite.c @@ -11,42 +11,42 @@ // ////////////////////////////////////////////////////////////////////////////// /* - * 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 . - * + * * 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 * . */ /* ** $Id: utpmcvideo-lite.c 8944 2007-12-29 08:29:16Z xwyan $ -** -** This is NEWGAL engine for UTStarcom PocketMedia Center based-on +** +** This is NEWGAL engine for UTStarcom PocketMedia Center based-on ** ARM7TDMI/uClinux/uClibc for MiniGUI-Lite. ** ** Copyright (C) 2004 ~ 2007 Feynman Software. @@ -126,7 +126,7 @@ static YCRCB* init_rgb2ycrcb_map_16bit (void) tmp = map; for (i = 0; i < 65536; i++) { - RGB2YCrCb (((i & 0xF800) >> 8), ((i & 0x07E0) >> 3), ((i & 0x001F) << 3), + RGB2YCrCb (((i & 0xF800) >> 8), ((i & 0x07E0) >> 3), ((i & 0x001F) << 3), &tmp->yy, &tmp->cb, &tmp->cr); tmp++; } @@ -195,7 +195,7 @@ static int task_do_update_16bit (void* data) else { dst_line [1] = yy; } - + src_line++; dst_line += 2; } @@ -274,7 +274,7 @@ static int task_do_update_8bit (void* data) else { dst_line [1] = yy; } - + src_line++; dst_line += 2; } @@ -395,7 +395,7 @@ static int UTPMC_VideoInit (_THIS, GAL_PixelFormat *vformat) this->hidden->fb_size = finfo.smem_len; this->hidden->fb = mmap (NULL, finfo.smem_len, PROT_READ | PROT_WRITE, 0, this->hidden->fd, 0); - + fprintf (stderr, "UTPMC NEWGAL Engine: mapped address: %p, length: %d.\n", this->hidden->fb, this->hidden->fb_size); @@ -417,7 +417,7 @@ static int UTPMC_VideoInit (_THIS, GAL_PixelFormat *vformat) fprintf (stderr, "UTPMC NEWGAL Engine: can not open lock file: %s!\n", LOCK_FILE); return -1; } - + read (this->hidden->fd_lock, &this->hidden->shadow_info, sizeof (UTPMC_SHADOWINFO*)); _MY_PRINTF ("Shadow info read from the lock file: %p\n", this->hidden->shadow_info); @@ -550,8 +550,8 @@ static GAL_Surface *UTPMC_SetVideoMode (_THIS, GAL_Surface *current, { int ret; - ret = clone ((bpp == 8) ? task_do_update_8bit : task_do_update_16bit, - this->hidden->stack + _MY_STACK_SIZE, + ret = clone ((bpp == 8) ? task_do_update_8bit : task_do_update_16bit, + this->hidden->stack + _MY_STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES, this); if (ret < 0) { @@ -593,7 +593,7 @@ static int UTPMC_SetColors (_THIS, int firstcolor, int ncolors, GAL_Color *color ycrcb += firstcolor; for (i = 0; i < ncolors; i++) { - RGB2YCrCb (colors->r, colors->g, colors->b, + RGB2YCrCb (colors->r, colors->g, colors->b, &ycrcb->yy, &ycrcb->cb, &ycrcb->cr); ycrcb++; colors++; @@ -613,7 +613,7 @@ static void UTPMC_UpdateRects (_THIS, int numrects, GAL_Rect *rects) for (i = 0; i < numrects; i++) { RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -622,7 +622,8 @@ static void UTPMC_UpdateRects (_THIS, int numrects, GAL_Rect *rects) } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + if (IntersectRect (&bound, &bound, &rcScr)) { this->hidden->shadow_info->update = bound; this->hidden->shadow_info->dirty = TRUE; } @@ -652,4 +653,4 @@ static void UTPMC_VideoQuit (_THIS) } #endif /* _MGGAL_UTPMC */ -#endif +#endif diff --git a/src/newgal/utpmc/utpmcvideo.c b/src/newgal/utpmc/utpmcvideo.c index 58c03b7a..54523801 100644 --- a/src/newgal/utpmc/utpmcvideo.c +++ b/src/newgal/utpmc/utpmcvideo.c @@ -11,42 +11,42 @@ // ////////////////////////////////////////////////////////////////////////////// /* - * 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 . - * + * * 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 * . */ /* ** $Id: utpmcvideo.c 8944 2007-12-29 08:29:16Z xwyan $ -** -** This is NEWGAL engine for UTStarcom PocketMedia +** +** This is NEWGAL engine for UTStarcom PocketMedia ** based-on ARM7TDMI + uClinux + uClibc. ** ** Copyright (C) 2004 ~ 2007 Feynman Software. @@ -146,7 +146,7 @@ static void get_ycrcb_16bit (RGB_YCRCB_MAP* map, Uint16 pixel, Uint8* yy, Uint8* } /* not found, calculate YCrCb. */ - RGB2YCrCb (((pixel & 0xF800) >> 8), ((pixel & 0x07E0) >> 3), ((pixel & 0x001F) << 3), + RGB2YCrCb (((pixel & 0xF800) >> 8), ((pixel & 0x07E0) >> 3), ((pixel & 0x001F) << 3), yy, cb, cr); /* try to find a free pair and insert it to the cache line. */ @@ -301,7 +301,7 @@ static YCRCB* init_rgb2ycrcb_map_16bit (void) tmp = map; for (i = 0; i < 65536; i++) { - RGB2YCrCb (((i & 0xF800) >> 8), ((i & 0x07E0) >> 3), ((i & 0x001F) << 3), + RGB2YCrCb (((i & 0xF800) >> 8), ((i & 0x07E0) >> 3), ((i & 0x001F) << 3), &tmp->yy, &tmp->cb, &tmp->cr); tmp++; } @@ -344,7 +344,7 @@ static void* task_do_update_16bit (void* data) w = RECTW (bound); h = RECTH (bound); - src_buff = this->hidden->shadow + src_buff = this->hidden->shadow + this->screen->pitch * bound.top + this->screen->format->BytesPerPixel * bound.left; @@ -372,7 +372,7 @@ static void* task_do_update_16bit (void* data) else { dst_line [1] = yy; } - + src_line++; dst_line += 2; } @@ -418,7 +418,7 @@ static void* task_do_update_8bit (void* data) w = RECTW (bound); h = RECTH (bound); - src_buff = this->hidden->shadow + src_buff = this->hidden->shadow + this->screen->pitch * bound.top + this->screen->format->BytesPerPixel * bound.left; @@ -442,7 +442,7 @@ static void* task_do_update_8bit (void* data) else { dst_line [1] = yy; } - + src_line++; dst_line += 2; } @@ -544,7 +544,7 @@ static int UTPMC_VideoInit (_THIS, GAL_PixelFormat *vformat) this->hidden->fb_size = finfo.smem_len; this->hidden->fb = mmap (NULL, finfo.smem_len, PROT_READ | PROT_WRITE, 0, this->hidden->fd, 0); - + fprintf (stderr, "UTPMC NEWGAL Engine: mapped address: %p, length: %d.\n", this->hidden->fb, this->hidden->fb_size); #else @@ -677,7 +677,7 @@ static GAL_Surface *UTPMC_SetVideoMode (_THIS, GAL_Surface *current, pthread_attr_destroy (&new_attr); #endif - ret = pthread_create (&this->hidden->th, NULL, + ret = pthread_create (&this->hidden->th, NULL, (bpp == 8) ? task_do_update_8bit : task_do_update_16bit, this); if (ret != 0) { @@ -718,7 +718,7 @@ static int UTPMC_SetColors (_THIS, int firstcolor, int ncolors, GAL_Color *color ycrcb += firstcolor; for (i = 0; i < ncolors; i++) { - RGB2YCrCb (colors->r, colors->g, colors->b, + RGB2YCrCb (colors->r, colors->g, colors->b, &ycrcb->yy, &ycrcb->cb, &ycrcb->cr); ycrcb++; colors++; @@ -738,7 +738,7 @@ static void UTPMC_UpdateRects (_THIS, int numrects, GAL_Rect *rects) for (i = 0; i < numrects; i++) { RECT rc; - SetRect (&rc, rects[i].x, rects[i].y, + SetRect (&rc, rects[i].x, rects[i].y, rects[i].x + rects[i].w, rects[i].y + rects[i].h); if (IsRectEmpty (&bound)) bound = rc; @@ -747,7 +747,8 @@ static void UTPMC_UpdateRects (_THIS, int numrects, GAL_Rect *rects) } if (!IsRectEmpty (&bound)) { - if (IntersectRect (&bound, &bound, &g_rcScr)) { + RECT rcScr = GetScreenRect(); + if (IntersectRect (&bound, &bound, &rcScr)) { this->hidden->update = bound; this->hidden->dirty = TRUE; } diff --git a/src/newgal/video.c b/src/newgal/video.c index adfadc34..998302f5 100644 --- a/src/newgal/video.c +++ b/src/newgal/video.c @@ -503,7 +503,7 @@ static int GAL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags) return(supported); } -/* This should probably go somewhere else -- like GAL_surface.c */ +/* This should probably go somewhere else -- like surface.c */ static void GAL_ClearSurface(GAL_Surface *surface) { Uint32 black; diff --git a/src/newgdi/gdi.c b/src/newgdi/gdi.c index d69a1154..9e4393f0 100644 --- a/src/newgdi/gdi.c +++ b/src/newgdi/gdi.c @@ -207,18 +207,20 @@ BOOL mg_InitScreenDC (void* surface) void mg_TerminateScreenDC (void) { - SelectClipRect (HDC_SCREEN, &g_rcScr); + RECT rcScr = GetScreenRect (); + + SelectClipRect (HDC_SCREEN, &rcScr); SetBrushColor (HDC_SCREEN, 0); #ifdef _MGRM_PROCESSES if (mgIsServer) #endif - FillBox (HDC_SCREEN, g_rcScr.left, g_rcScr.top, - g_rcScr.right, g_rcScr.bottom); + FillBox (HDC_SCREEN, rcScr.left, rcScr.top, + rcScr.right, rcScr.bottom); if (__mg_screen_dc.alpha_pixel_format) free (__mg_screen_dc.alpha_pixel_format); - SelectClipRect (HDC_SCREEN_SYS, &g_rcScr); + SelectClipRect (HDC_SCREEN_SYS, &rcScr); if (__mg_screen_sys_dc.alpha_pixel_format) free (__mg_screen_sys_dc.alpha_pixel_format); diff --git a/src/newgdi/screen.c b/src/newgdi/screen.c index 7a0e660e..7639f286 100644 --- a/src/newgdi/screen.c +++ b/src/newgdi/screen.c @@ -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 . - * + * * 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 * . */ @@ -68,11 +68,11 @@ #ifdef _MGMISC_SAVESCREEN BOOL GUIAPI SaveScreenRectContent (const RECT* rc, const char* filename) { - RECT rcWin; + RECT rcWin, rcScr = GetScreenRect(); BITMAP bitmap; int save_ret; - if (!IntersectRect (&rcWin, rc, &g_rcScr)) + if (!IntersectRect (&rcWin, rc, &rcScr)) return FALSE; bitmap.bmWidth = RECTW (rcWin); @@ -84,7 +84,7 @@ BOOL GUIAPI SaveScreenRectContent (const RECT* rc, const char* filename) #endif return FALSE; } - + bitmap.bmBits = NULL; GetBitmapFromDC (HDC_SCREEN, rcWin.left, rcWin.top, RECTW (rcWin), RECTH (rcWin), &bitmap); @@ -95,7 +95,7 @@ BOOL GUIAPI SaveScreenRectContent (const RECT* rc, const char* filename) #endif return FALSE; } - + save_ret = SaveBitmap (HDC_SCREEN, &bitmap, filename); free (bitmap.bmBits); return (save_ret == 0); diff --git a/src/server/layer.c b/src/server/layer.c index f05b292e..9fe8709a 100644 --- a/src/server/layer.c +++ b/src/server/layer.c @@ -579,7 +579,9 @@ void GUIAPI UpdateTopmostLayer (const RECT* dirty_rc) if (dirty_rc) { RECT eff_rc; - IntersectRect (&eff_rc, dirty_rc, &g_rcScr); + RECT rcScr = GetScreenRect(); + + IntersectRect (&eff_rc, dirty_rc, &rcScr); msg.wParam = MAKELONG (eff_rc.left, eff_rc.top); msg.lParam = MAKELONG (eff_rc.right, eff_rc.bottom); }