From e242cbe32f878e12d7b1cb87fa20a98f7931dc63 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Fri, 14 Jul 2023 11:19:04 +0800 Subject: [PATCH] handle all implementations of kernel_ShowCursorForGDI --- src/kernel/cursor-procs.c | 51 ++++++++++++++++++++++++++++----------- src/kernel/cursor-sa.c | 22 +++++++++++++++-- src/kernel/cursor.c | 9 +++---- 3 files changed, 61 insertions(+), 21 deletions(-) diff --git a/src/kernel/cursor-procs.c b/src/kernel/cursor-procs.c index d5a311b4..dcc1ac61 100644 --- a/src/kernel/cursor-procs.c +++ b/src/kernel/cursor-procs.c @@ -1081,6 +1081,12 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) const RECT* prc; prc = &cur_pdc->rc_output; + + /* Since 5.0.13 */ + if (!fShow) { + GAL_LockSurface(cur_pdc->surface); + } + if (cur_pdc->surface != __gal_screen) { if (fShow) { GAL_UpdateRect (cur_pdc->surface, @@ -1090,7 +1096,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) } else { if (!mgIsServer && (SHAREDRES_TOPMOST_LAYER != __mg_layer)) { - return; + goto done; } if (!fShow) { @@ -1109,6 +1115,12 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) UNLOCK_CURSOR_SEM (); } } + +done: + /* Since 5.0.13 */ + if (fShow) { + GAL_UnlockSurface(cur_pdc->surface); + } } #else /* defined _MGSCHEMA_SHAREDFB */ @@ -1124,6 +1136,12 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) } prc = &cur_pdc->rc_output; + + /* Since 5.0.13 */ + if (!fShow) { + GAL_LockSurface(cur_pdc->surface); + } + if (cur_pdc->surface == __gal_screen) { // Under compositing schema, we never call SyncUpdate in // kernel_ShowCursorForGDI for __gal_screen. @@ -1150,6 +1168,12 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) // For surface other than screen, we call SyncUpdate. GAL_SyncUpdate (cur_pdc->surface); } + +done: + /* Since 5.0.13 */ + if (fShow) { + GAL_UnlockSurface(cur_pdc->surface); + } } #endif /* not defined _MGSCHEMA_SHAREDFB */ @@ -1228,26 +1252,25 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) PDC cur_pdc = (PDC)pdc; const RECT* prc = NULL; - prc = &cur_pdc->rc_output; - - /* houhh20080827, if --disable-cursor, mginit can not update auto(qvfb). */ -#if 0 - if (cur_pdc->surface == __gal_screen - && mgIsServer && (SHAREDRES_TOPMOST_LAYER != __mg_layer)) - return; - - if (fShow) - GAL_UpdateRect (cur_pdc->surface, - prc->left, prc->top, RECTWP(prc), RECTHP(prc)); -#else if (!mgIsServer && (SHAREDRES_TOPMOST_LAYER != __mg_layer)) { return; } + prc = &cur_pdc->rc_output; + + /* Since 5.0.13 */ + if (!fShow) { + GAL_LockSurface(cur_pdc->surface); + } + if (fShow) GAL_UpdateRect (cur_pdc->surface, prc->left, prc->top, RECTWP(prc), RECTHP(prc)); -#endif + + /* Since 5.0.13 */ + if (fShow) { + GAL_UnlockSurface(cur_pdc->surface); + } } #endif /* _MGHAVE_CURSOR */ diff --git a/src/kernel/cursor-sa.c b/src/kernel/cursor-sa.c index ca9fe51e..87e08a41 100644 --- a/src/kernel/cursor-sa.c +++ b/src/kernel/cursor-sa.c @@ -448,6 +448,11 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) prc = &cur_pdc->rc_output; + /* Since 5.0.13 */ + if (!fShow) { + GAL_LockSurface(cur_pdc->surface); + } + if (cur_pdc->surface != __gal_screen) { if (fShow) { GAL_UpdateRect (cur_pdc->surface, @@ -472,7 +477,7 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) prc->left, prc->top, RECTWP(prc), RECTHP(prc)); //GAL_SyncUpdate (cur_pdc->surface); } - return; + goto done; } if (fShow && nShowCount >= 0 && pCurCsr) { @@ -488,6 +493,12 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) //GAL_SyncUpdate (cur_pdc->surface); } } + +done: + /* Since 5.0.13 */ + if (fShow) { + GAL_UnlockSurface(cur_pdc->surface); + } } int GUIAPI ShowCursor (BOOL fShow) @@ -516,9 +527,16 @@ void kernel_ShowCursorForGDI(BOOL fShow, void* pdc) prc = &cur_pdc->rc_output; - if (fShow) + /* Since 5.0.13 */ + if (!fShow) { + GAL_LockSurface(cur_pdc->surface); + } + else { GAL_UpdateRect (cur_pdc->surface, prc->left, prc->top, RECTWP(prc), RECTHP(prc)); + /* Since 5.0.13 */ + GAL_UnlockSurface(cur_pdc->surface); + } } #endif /* _MGHAVE_CURSOR */ diff --git a/src/kernel/cursor.c b/src/kernel/cursor.c index 3a82b8f6..e6911c9b 100644 --- a/src/kernel/cursor.c +++ b/src/kernel/cursor.c @@ -566,19 +566,18 @@ void kernel_ShowCursorForGDI (BOOL fShow, void* pdc) PDC cur_pdc = (PDC)pdc; const RECT* prc = NULL; + prc = &cur_pdc->rc_output; + /* Since 5.0.13 */ if (!fShow) { GAL_LockSurface(cur_pdc->surface); } - - prc = &cur_pdc->rc_output; - - if (fShow) { + else { GAL_UpdateRect (cur_pdc->surface, prc->left, prc->top, RECTWP(prc), RECTHP(prc)); /* Since 5.0.13 */ - GAL_UnLockSurface(cur_pdc->surface); + GAL_UnlockSurface(cur_pdc->surface); } }