Implement SetMainWindowGestureFlags and MSG_SETGESTUREFLAGS

This commit is contained in:
Vincent Wei
2021-04-01 15:42:58 +08:00
parent de315cf780
commit 285a8e1101
7 changed files with 152 additions and 2 deletions

View File

@@ -82,6 +82,11 @@ extern "C" {
#define ZOF_MAXIMIZED 0x00000004 // Since 5.0.0
#define ZOF_MINIMIZED 0x00000008 // Since 5.0.0
/* Since 5.0.6 */
#define ZOF_GESTURE_FLAGS_MASK 0X000000F0
#define ZOF_GF_SWIPE_HORZ 0x00000010
#define ZOF_GF_SWIPE_VERT 0x00000020
/* Since 5.0.0 */
#define ZOF_INTERNAL_FLAGS_MASK 0X000F0000
#define ZOF_IF_REFERENCE 0x00010000

View File

@@ -1448,6 +1448,17 @@ extern DWORD __mg_interval_time;
*/
#define MSG_HELP 0x006A
/**
* \def MSG_GESTURETEST
* \brief This message will be sent to a main window for gesture test.
*
* The client should call \a SetMainWindowGestureFlags to set the gesture flags
* for a main window after got this message.
*
* Since 5.0.6.
*/
#define MSG_GESTURETEST 0x006B
#define MSG_LASTCREATEMSG 0x006F
/** @} end of creation_msgs */
@@ -2463,6 +2474,9 @@ typedef struct _COMPOSITINGINFO {
/* Since 5.0.0 */
#define MSG_SETAUTOREPEAT 0x0107
/* Since 5.0.6 */
#define MSG_SETGESTUREFLAGS 0x0108
#define MSG_SHOWGLOBALCTRL 0x010A
#define MSG_HIDEGLOBALCTRL 0x010B
@@ -7173,7 +7187,7 @@ MG_EXPORT BOOL GUIAPI SetWindowMaskEx (HWND hWnd, HDC hdc, const BITMAP* mask);
* \param hWnd The handle to the window.
* \param fSet Set or cancel the always top style; TRUE to set, FALSE to cancel.
*
* \return return TRUE on success, otherwise FALSE.
* \return TRUE on success, otherwise FALSE.
*
* \sa GetWindowStyle, WS_ALWAYSTOP
*
@@ -7181,6 +7195,39 @@ MG_EXPORT BOOL GUIAPI SetWindowMaskEx (HWND hWnd, HDC hdc, const BITMAP* mask);
*/
MG_EXPORT BOOL GUIAPI SetMainWindowAlwaysTop (HWND hWnd, BOOL fSet);
#define GF_SWIPE_HORZ ZOF_GF_SWIPE_HORZ
#define GF_SWIPE_VERT ZOF_GF_SWIPE_VERT
/**
* \fn BOOL GUIAPI SetMainWindowGestureFlags (HWND hWnd, DWORD dwFlags)
* \brief Set the gesture flags of a main window.
*
* This function sets the gesture flags of a specific main window.
*
* Generally, a main window which needs a specific gesture should handle
* \a MSG_GESTURETEST and call this function to set the correct gesture flags for
* the main window.
*
* The MiniGUI Core will send the MSG_GESTURETEST message as a notification
* to a main window when it tries to handle a gesture globally. If the main window
* sets the flag of the gesture in a specific time, e.g. 100ms, MiniGUI Core will
* pass the gesture events to the main window other than handle the gesture by itself.
*
* \param hWnd The handle to the main window.
* \param dwFlags The new gesture flags, can be OR'd with the following values:
* - GF_SWIPE_HORZ\n
* The main window handles horizontal swipe gesture.
* - GF_SWIPE_VERT\n
* The main window handles vertical swipe gesture.
*
* \return TRUE on success, otherwise FALSE.
*
* \sa MSG_GESTURETEST
*
* Since 5.0.6
*/
MG_EXPORT BOOL GUIAPI SetMainWindowGestureFlags (HWND hWnd, DWORD dwFlags);
#ifdef _MGSCHEMA_COMPOSITING
/**

View File

@@ -7026,6 +7026,19 @@ BOOL GUIAPI SetMainWindowAlwaysTop (HWND hMainWnd, BOOL fSet)
MSG_SETALWAYSTOP, (WPARAM)pMainWin, (LPARAM)fSet);
}
/* Since 5.0.6 */
BOOL GUIAPI SetMainWindowGestureFlags (HWND hMainWnd, DWORD dwFlags)
{
PMAINWIN pMainWin;
if (!(pMainWin = checkAndGetMainWinIfMainWin (hMainWnd))) {
return FALSE;
}
return (BOOL)SendMessage (HWND_DESKTOP,
MSG_SETGESTUREFLAGS, (WPARAM)pMainWin, (LPARAM)dwFlags);
}
#ifdef _MGSCHEMA_COMPOSITING
BOOL GUIAPI SetMainWindowCompositing (HWND hMainWnd, int type, DWORD arg)
{

View File

@@ -223,6 +223,8 @@ typedef struct _MovedClientInfo {
#define ID_ZOOP_MASKRECT_SET 17
#define ID_ZOOP_MASKRECT_FREE 18
#define ID_ZOOP_SETGESTUREFLAGS 19 /* since 5.0.6 */
#ifndef MAX_CAPTION_LEN
#define MAX_CAPTION_LEN 39 //40
#endif

View File

@@ -368,6 +368,15 @@ static BOOL dskSetMainWindowAlwaysTop (PMAINWIN pWin, BOOL fSet)
return TRUE;
}
/* Since 5.0.6 */
static inline int dskSetMainWindowGestureFlags (PMAINWIN pWin, DWORD dwFlags)
{
if (dskSetZNodeGestureFlags (0, pWin->idx_znode, dwFlags))
return FALSE;
return TRUE;
}
/* Since 5.0.0 */
static int dskSetWindowMask (HWND pWin, const WINMASKINFO* mask_info)
{
@@ -1424,7 +1433,11 @@ static LRESULT WindowMessageHandler(UINT message, PMAINWIN pWin, LPARAM lParam)
/* Since 5.0.0 */
case MSG_SETALWAYSTOP:
return dskSetMainWindowAlwaysTop(pWin, (BOOL)lParam);
return dskSetMainWindowAlwaysTop (pWin, (BOOL)lParam);
/* Since 5.0.6 */
case MSG_SETGESTUREFLAGS:
return dskSetMainWindowGestureFlags (pWin, (DWORD)lParam);
/* Since 5.0.0 */
case MSG_SETWINDOWMASK:

View File

@@ -700,6 +700,27 @@ static intptr_t cliSetMainWinAlwaysTop (PMAINWIN pWin, BOOL fSet)
return ret;
}
/* Since 5.0.6 */
static intptr_t cliSetMainWinGestureFlags (PMAINWIN pWin, DWORD dwFlags)
{
intptr_t ret;
REQUEST req;
ZORDEROPINFO info;
info.id_op = ID_ZOOP_SETGESTUREFLAGS;
info.idx_znode = pWin->idx_znode;
info.flags = dwFlags;
req.id = REQID_ZORDEROP;
req.data = &info;
req.len_data = sizeof (ZORDEROPINFO);
if (ClientRequest (&req, &ret, sizeof (intptr_t)) < 0)
return -1;
return ret;
}
#ifdef _MGSCHEMA_COMPOSITING
static intptr_t cliSetMainWinCompositing (PMAINWIN pWin,
const COMPOSITINGINFO* my_info)
@@ -1311,6 +1332,12 @@ static inline int srvSetZNodeAlwaysTop (int cli, int idx_znode, BOOL fSet)
return dskSetZNodeAlwaysTop (cli, idx_znode, fSet);
}
/* Since 5.0.6 */
static inline int srvSetZNodeGestureFlags (int cli, int idx_znode, DWORD dwFlags)
{
return dskSetZNodeGestureFlags (cli, idx_znode, dwFlags);
}
#ifdef _MGSCHEMA_COMPOSITING
static inline int srvSetZNodeCompositing (int cli, int idx_znode,
int type, DWORD arg)
@@ -1438,6 +1465,9 @@ intptr_t __mg_do_zorder_operation (int cli, const ZORDEROPINFO* info,
case ID_ZOOP_SETALWAYSTOP:
srvSetZNodeAlwaysTop (cli, info->idx_znode, info->flags);
break;
case ID_ZOOP_SETGESTUREFLAGS:
srvSetZNodeGestureFlags (cli, info->idx_znode, info->flags);
break;
#ifdef _MGSCHEMA_COMPOSITING
case ID_ZOOP_SETCOMPOSITING:
srvSetZNodeCompositing (cli, info->idx_znode,
@@ -2513,6 +2543,21 @@ static BOOL dskSetMainWinAlwaysTop (PMAINWIN pWin, BOOL fSet)
return TRUE;
}
/* Since 5.0.6 */
static inline BOOL dskSetMainWindowGestureFlags (PMAINWIN pWin, DWORD dwFlags)
{
if (mgIsServer) {
if (srvSetZNodeGestureFlags (0, pWin->idx_znode, dwFlags))
return FALSE;
}
else {
if (cliSetMainWinGestureFlags (pWin, dwFlags))
return FALSE;
}
return TRUE;
}
/* Since 5.0.0 */
static int dskSetWindowMask (HWND pWin, const WINMASKINFO* mask_info)
{
@@ -2689,6 +2734,10 @@ static LRESULT dskWindowMessageHandler (UINT message,
case MSG_SETALWAYSTOP:
return dskSetMainWinAlwaysTop (pWin, (BOOL)lParam);
/* Since 5.0.6 */
case MSG_SETGESTUREFLAGS:
return dskSetMainWindowGestureFlags (pWin, (DWORD)lParam);
/* Since 5.0.0 */
case MSG_SETWINDOWMASK:
return dskSetWindowMask (pWin, (WINMASKINFO*)lParam);

View File

@@ -2921,6 +2921,27 @@ static int dskSetZNodeAlwaysTop (int cli, int idx_znode, BOOL fSet)
return 0;
}
/* Since 5.0.6 */
static int dskSetZNodeGestureFlags (int cli, int idx_znode, DWORD flags)
{
ZORDERINFO* zi = get_zorder_info (cli);
ZORDERNODE* nodes;
if (IS_INVALID_ZIDX (zi, idx_znode)) {
return -1;
}
nodes = GET_ZORDERNODE(zi);
flags &= ZOF_GESTURE_FLAGS_MASK;
lock_zi_for_change (zi);
nodes[idx_znode].flags &= ~ZOF_GESTURE_FLAGS_MASK;
nodes[idx_znode].flags |= flags;
unlock_zi_for_change (zi);
return 0;
}
#ifdef _MGSCHEMA_COMPOSITING
/* Since 5.0.0 */
static int dskSetZNodeCompositing (int cli, int idx_znode, int ct, DWORD ct_arg)