From 46621017c86bec7c8e266c086011fd975fd6cfd0 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Thu, 16 Jan 2020 12:15:34 +0800 Subject: [PATCH] enhance to support compositing type and argument for CreateMainWindowEx2 --- include/minigui.h | 3 +++ src/gui/window.c | 6 +++-- src/kernel/desktop-comm.c | 7 +++--- src/kernel/desktop-procs.c | 42 +++++++++++++++++++++++++---------- src/kernel/desktop.c | 45 +++++++++++++++++++++----------------- 5 files changed, 66 insertions(+), 37 deletions(-) diff --git a/include/minigui.h b/include/minigui.h index df92f936..8b3368a8 100644 --- a/include/minigui.h +++ b/include/minigui.h @@ -735,6 +735,7 @@ typedef void (* ON_CHANGE_LAYER) (int op, MG_Layer* layer, #define ZNOP_STARTDRAG 13 #define ZNOP_CANCELDRAG 14 #define ZNOP_CHANGECAPTION 15 +#define ZNOP_COMPOSITINGCHANGED 16 /** * \var typedef void (* ON_ZNODE_OPERATION) (int op, int cli, int idx_znode) @@ -832,6 +833,8 @@ extern MG_EXPORT ON_CHANGE_LAYER OnChangeLayer; * Cancel to drag the z-node. * - ZNOP_CHANGECAPTION\n * The caption of the z-node has changed. + * - ZNOP_COMPOSITINGCHANGED\n + * The compositing type or the argument of the z-node has changed. * * The event will be passed through the argument of \a op; the * pointers to the layer, the identifier of the client, and the index of diff --git a/src/gui/window.c b/src/gui/window.c index 1642897a..556832b8 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -3605,10 +3605,11 @@ static void ResetMenuSize (HWND hwnd) HWND GUIAPI CreateMainWindowEx2 (PMAINWINCREATE pCreateInfo, const char* werdr_name, const WINDOW_ELEMENT_ATTR* we_attrs, - int compos_type, DWORD ct_arg, + int ct, DWORD ct_arg, const char* window_name, const char* layer_name) { PMAINWIN pWin; + COMPOSITINGINFO ct_info = { ct, ct_arg }; if (pCreateInfo == NULL) { return HWND_INVALID; @@ -3788,7 +3789,8 @@ HWND GUIAPI CreateMainWindowEx2 (PMAINWINCREATE pCreateInfo, pWin->pGCRInfo = &pWin->GCRInfo; #endif - if (SendMessage (HWND_DESKTOP, MSG_ADDNEWMAINWIN, (WPARAM) pWin, 0) < 0) + if (SendMessage (HWND_DESKTOP, MSG_ADDNEWMAINWIN, + (WPARAM)pWin, (LPARAM)&ct_info) < 0) goto err; /* houhh20081127, Move these code into dskAddNewMainWindow().*/ diff --git a/src/kernel/desktop-comm.c b/src/kernel/desktop-comm.c index 9724183f..296a7a8e 100644 --- a/src/kernel/desktop-comm.c +++ b/src/kernel/desktop-comm.c @@ -190,9 +190,10 @@ static int dskAllocZOrderNode (PMAINWIN pWin) dskGetWindowRectInScreen (pWin, &rc); return AllocZOrderNode (0, (HWND)pWin, - (HWND)pWin->pMainWin, - get_znode_flags_from_style (pWin), - &rc, pWin->spCaption, HDC_INVALID); + (HWND)pWin->pMainWin, + get_znode_flags_from_style (pWin), + &rc, pWin->spCaption, HDC_INVALID, + CT_OPAQUE, 0); } /* diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index d1ba95fd..1cfb0f0c 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -322,7 +322,7 @@ void __mg_start_client_desktop (void) SendMessage (HWND_DESKTOP, MSG_STARTSESSION, 0, 0); } -static intptr_t cliAllocZOrderNode (PMAINWIN pWin) +static intptr_t cliAllocZOrderNode (PMAINWIN pWin, const COMPOSITINGINFO* ct_info) { intptr_t ret; REQUEST req; @@ -354,6 +354,15 @@ static intptr_t cliAllocZOrderNode (PMAINWIN pWin) info.surf_flags = pWin->surf->flags; info.surf_size = pWin->surf->shared_header->buf_size; info.surf_size += sizeof (*pWin->surf->shared_header); + + if (ct_info) { + info.ct = ct_info->type; + info.ct_arg = ct_info->arg; + } + else { + info.ct = CT_OPAQUE; + info.ct_arg = 0; + } if (ClientRequestEx2 (&req, NULL, 0, pWin->surf->shared_header->fd, &ret, sizeof (intptr_t), NULL) < 0) return -1; @@ -786,7 +795,8 @@ ON_ZNODE_OPERATION OnZNodeOperation; static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win, DWORD flags, const RECT *rc, const char *caption, - Uint32 surf_flags, size_t surf_size, int fd) + Uint32 surf_flags, size_t surf_size, int fd, + int ct, DWORD ct_arg) { int free_slot; HDC memdc = HDC_INVALID; @@ -825,7 +835,7 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win, #endif /* def _MGSCHEMA_COMPOSITING */ free_slot = AllocZOrderNode (cli, hwnd, - main_win, flags, rc, caption, memdc); + main_win, flags, rc, caption, memdc, ct, ct_arg); if ((free_slot != -1) && OnZNodeOperation) OnZNodeOperation (ZNOP_ALLOCATE, cli, free_slot); @@ -1202,7 +1212,13 @@ static inline int srvSetZNodeAlwaysTop (int cli, int idx_znode, BOOL fSet) static inline int srvSetZNodeCompositing (int cli, int idx_znode, int type, DWORD arg) { - return dskSetZNodeCompositing (cli, idx_znode, type, arg); + int ret; + + ret = dskSetZNodeCompositing (cli, idx_znode, type, arg); + if (ret == 0 && OnZNodeOperation) + OnZNodeOperation (ZNOP_COMPOSITINGCHANGED, cli, idx_znode); + + return ret; } #endif /* _MGSCHEMA_COMPOSITING */ @@ -1233,11 +1249,12 @@ intptr_t __mg_do_zorder_operation (int cli, const ZORDEROPINFO* info, int fd) #ifdef _MGSCHEMA_COMPOSITING ret = srvAllocZOrderNode (cli, info->hwnd, info->main_win, info->flags, &info->rc, info->caption, - info->surf_flags, info->surf_size, fd); + info->surf_flags, info->surf_size, fd, + info->ct, info->ct_arg); #else ret = srvAllocZOrderNode (cli, info->hwnd, info->main_win, info->flags, &info->rc, info->caption, - 0, 0, fd); + 0, 0, fd, CT_OPAQUE, 0); #endif break; case ID_ZOOP_FREE: @@ -1591,7 +1608,7 @@ static HWND dskSetActiveWindow (PMAINWIN pWin) * * Return 0 if OK, else -1; */ -static int dskAddNewMainWindow (PMAINWIN pWin) +static int dskAddNewMainWindow (PMAINWIN pWin, const COMPOSITINGINFO* ct_info) { RECT rcWin; @@ -1599,10 +1616,11 @@ static int dskAddNewMainWindow (PMAINWIN pWin) memcpy (&rcWin, &pWin->left, sizeof (RECT)); pWin->idx_znode = srvAllocZOrderNode (0, (HWND)pWin, (HWND)pWin->pMainWin, get_znode_flags_from_style (pWin), - &rcWin, pWin->spCaption, 0, 0, -1); + &rcWin, pWin->spCaption, 0, 0, -1, + ct_info->type, ct_info->arg); } else - pWin->idx_znode = cliAllocZOrderNode (pWin); + pWin->idx_znode = cliAllocZOrderNode (pWin, ct_info); if (pWin->idx_znode <= 0) return -1; @@ -2295,7 +2313,7 @@ static LRESULT dskWindowMessageHandler (UINT message, PMAINWIN pWin, LPARAM lPar { switch (message) { case MSG_ADDNEWMAINWIN: - return dskAddNewMainWindow (pWin); + return dskAddNewMainWindow (pWin, (const COMPOSITINGINFO *)lParam); case MSG_REMOVEMAINWIN: dskRemoveMainWindow (pWin); @@ -2984,9 +3002,9 @@ static int dskOnNewCtrlInstance (PCONTROL pParent, PCONTROL pNewCtrl) pNewCtrl->idx_znode = srvAllocZOrderNode (0, (HWND)pNewCtrl, (HWND)pNewCtrl->pMainWin, get_znode_flags_from_style ((PMAINWIN)pNewCtrl), - &rcWin, pNewCtrl->spCaption, 0, 0, -1); + &rcWin, pNewCtrl->spCaption, 0, 0, -1, CT_OPAQUE, 0); else - pNewCtrl->idx_znode = cliAllocZOrderNode ((PMAINWIN)pNewCtrl); + pNewCtrl->idx_znode = cliAllocZOrderNode ((PMAINWIN)pNewCtrl, NULL); if (pNewCtrl->idx_znode <= 0) return -1; diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index c26646f8..a08d3643 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -1621,8 +1621,30 @@ int CreateNodeRoundMaskRect (ZORDERINFO* zi, ZORDERNODE* node, return 0; } +#ifdef _MGSCHEMA_COMPOSITING +static inline DWORD compositing_type_to_flag (int type) +{ + switch (type) { + case CT_OPAQUE: + default: + return ZOF_COMPOS_OPAQUE; + case CT_COLORKEY: + return ZOF_COMPOS_COLORKEY; + case CT_ALPHACHANNEL: + return ZOF_COMPOS_ALPHACHANNEL; + case CT_ALPHAPIXEL: + return ZOF_COMPOS_ALPHAPIXEL; + case CT_BLURRED: + return ZOF_COMPOS_BLURRED; + } + + return ZOF_COMPOS_OPAQUE; +} +#endif /* defined _MGSCHEMA_COMPOSITING */ + static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, - DWORD flags, const RECT *rc, const char *caption, HDC mem_dc) + DWORD flags, const RECT *rc, const char *caption, + HDC mem_dc, int ct, DWORD ct_arg) { DWORD type = flags & ZOF_TYPE_MASK; ZORDERINFO* zi = _get_zorder_info(cli); @@ -1700,6 +1722,8 @@ static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, nodes [free_slot].main_win = main_win; #ifdef _MGSCHEMA_COMPOSITING nodes [free_slot].mem_dc = mem_dc; + nodes [free_slot].flags |= compositing_type_to_flag(ct); + nodes [free_slot].ct_arg = ct_arg; #endif nodes [free_slot].idx_mask_rect = 0; @@ -2288,25 +2312,6 @@ void __mg_screensaver_destroy(void) #endif /* defined _MG_ENABLE_SCREENSAVER */ #ifdef _MGSCHEMA_COMPOSITING -static inline DWORD compositing_type_to_flag (int type) -{ - switch (type) { - case CT_OPAQUE: - default: - return ZOF_COMPOS_OPAQUE; - case CT_COLORKEY: - return ZOF_COMPOS_COLORKEY; - case CT_ALPHACHANNEL: - return ZOF_COMPOS_ALPHACHANNEL; - case CT_ALPHAPIXEL: - return ZOF_COMPOS_ALPHAPIXEL; - case CT_BLURRED: - return ZOF_COMPOS_BLURRED; - } - - return ZOF_COMPOS_OPAQUE; -} - /* Since 4.2.0 */ static int dskSetZNodeCompositing (int cli, int idx_znode, int ct, DWORD ct_arg) {