From 32c5c3c58f8a66c04af43fcf1828a5ca07bcebb9 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Fri, 7 Feb 2020 10:18:30 +0800 Subject: [PATCH] cleanup; use MSG_SETWINDOWMASK instead of __kernel_change_z_node_mask_rect --- include/window.h | 10 + src/gui/window.c | 134 ++-- src/include/zorder.h | 1 - src/kernel/desktop-comm.c | 1230 ++++++++++++++++++------------------ src/kernel/desktop-procs.c | 896 +++++++++++++------------- src/kernel/desktop.c | 2 +- src/newgal/surface.c | 2 +- 7 files changed, 1156 insertions(+), 1119 deletions(-) diff --git a/include/window.h b/include/window.h index 50454b14..83321a28 100644 --- a/include/window.h +++ b/include/window.h @@ -2405,6 +2405,7 @@ typedef struct _COMPOSITINGINFO { DWORD arg; } COMPOSITINGINFO; +/* Since 4.2.0 */ #define MSG_SETCOMPOSITING 0x0105 #define MSG_SHOWGLOBALCTRL 0x010A @@ -2422,6 +2423,15 @@ typedef struct _DRAGINFO { #define MSG_CHANGECAPTION 0x010E +struct _RECT4MASK; +typedef struct _WINMASKINFO { + int nr_rcs; + struct _RECT4MASK* rcs; +} WINMASKINFO; + +/* Since 4.2.0 */ +#define MSG_SETWINDOWMASK 0x010F + #define MSG_LASTWINDOWMSG 0x010F /** @} end of window_msgs */ diff --git a/src/gui/window.c b/src/gui/window.c index 043c5386..0f3f351c 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -3615,7 +3615,7 @@ HWND GUIAPI CreateMainWindowEx2 (PMAINWINCREATE pCreateInfo, return HWND_INVALID; } - if (!(pWin = calloc(1, sizeof(MAINWIN)))) { + if (!(pWin = calloc (1, sizeof(MAINWIN)))) { return HWND_INVALID; } @@ -5828,13 +5828,13 @@ HICON SetWindowIcon (HWND hWnd, HICON hIcon, BOOL bRedraw) } /** - * CalcXYBannedRects: - * this function calculates x-y-banned rectangles of MYBITMAP - * which is 8 bits per pixels. + * calc_xybanned_rects: + * this function calculates x-y-banned rectangles of MYBITMAP or BITMAP. * * param hwnd : the window handle + * param type : the type of mask: TYPE_MYBITMAP or TYPE_BITMAP * param mask : MYBITMAP with 8 bits per pixels - * param rect_size(out) : number of the x-y-banned rectangles + * param nr_rcs(out) : number of the x-y-banned rectangles * * return : return NULL on failure, return the x-y-banned * rectangles on success. @@ -5853,7 +5853,8 @@ HICON SetWindowIcon (HWND hWnd, HICON hIcon, BOOL bRedraw) #include "../newgal/blit.h" -static RECT4MASK* CalcXYBannedRects (HDC hdc, const void* mask, int * rect_size, int type) +static RECT4MASK* calc_xybanned_rects (HDC hdc, int type, const void* mask, + int* nr_rcs) { Uint32 x, y; Uint32 pixel; @@ -5871,7 +5872,7 @@ static RECT4MASK* CalcXYBannedRects (HDC hdc, const void* mask, int * rect_size, if (!mask) return NULL; - if (type == TYPE_MYBITMAP){ + if (type == TYPE_MYBITMAP) { w = ((MYBITMAP*)mask)->w; h = ((MYBITMAP*)mask)->h; bits = ((MYBITMAP*)mask)->bits; @@ -5890,8 +5891,8 @@ static RECT4MASK* CalcXYBannedRects (HDC hdc, const void* mask, int * rect_size, } if (h <= 0) return NULL; - if (rect_size) - *rect_size = 0; + if (nr_rcs) + *nr_rcs = 0; max_calloced_nr = XYBANNED_RECT_NR_INIT; xybanned_rects = (RECT4MASK *) calloc (max_calloced_nr, sizeof (RECT4MASK)); @@ -5992,27 +5993,27 @@ static RECT4MASK* CalcXYBannedRects (HDC hdc, const void* mask, int * rect_size, } }// for (y = 1; y < h; ++y) - if (rect_size) - *rect_size = max_index + 1; + if (nr_rcs) + *nr_rcs = max_index + 1; return xybanned_rects; } -/* API for non-rectangle window.*/ -static int gui_GenerateMaskRect(HWND hWnd, RECT4MASK* rect, int rect_size) +/* Internal functions for non-rectangle window. */ +static int set_window_mask_rect (HWND hWnd, WINMASKINFO* mask_info) { MASKRECT *new_maskrect; PCONTROL pCtrl; int i, retval; - if (!rect) + if (!mask_info->rcs) return FALSE; if (IsControl (hWnd)) { /* * Because control without WS_EX_CTRLASMAINWIN has not * the own Z order node, we should allocate memory for an - * array of rect_size for mask_rects. + * array of mask_info->nr_rcs for mask_rects. * * The prev of first mask_rects indicates the number of the array. * The next of last mask_rects is 0. @@ -6024,11 +6025,11 @@ static int gui_GenerateMaskRect(HWND hWnd, RECT4MASK* rect, int rect_size) if (pCtrl->mask_rects == NULL) { pCtrl->mask_rects = - (MASKRECT *) calloc (rect_size, sizeof (MASKRECT)); + (MASKRECT *) calloc (mask_info->nr_rcs, sizeof (MASKRECT)); if (!pCtrl->mask_rects) { _WRN_PRINTF ("No enough memory!\n"); - free (rect); + free (mask_info->rcs); return FALSE; } } @@ -6037,13 +6038,13 @@ static int gui_GenerateMaskRect(HWND hWnd, RECT4MASK* rect, int rect_size) * when number of calloced mask_rects is not enough, * free the old memory and calloc more. */ - if (pCtrl->mask_rects->prev < rect_size) { + if (pCtrl->mask_rects->prev < mask_info->nr_rcs) { new_maskrect = - (MASKRECT *) calloc (rect_size, sizeof (MASKRECT)); + (MASKRECT *) calloc (mask_info->nr_rcs, sizeof (MASKRECT)); if (!new_maskrect) { _WRN_PRINTF ("No enough memory!\n"); - free (rect); + free (mask_info->rcs); return FALSE; } free (pCtrl->mask_rects); @@ -6051,23 +6052,22 @@ static int gui_GenerateMaskRect(HWND hWnd, RECT4MASK* rect, int rect_size) } } - for (i = 0; i < rect_size; ++i) - { - (pCtrl->mask_rects + i)->left = rect[i].left; - (pCtrl->mask_rects + i)->top = rect[i].top; - (pCtrl->mask_rects + i)->right = rect[i].right; - (pCtrl->mask_rects + i)->bottom = rect[i].bottom; + for (i = 0; i < mask_info->nr_rcs; ++i) { + (pCtrl->mask_rects + i)->left = mask_info->rcs[i].left; + (pCtrl->mask_rects + i)->top = mask_info->rcs[i].top; + (pCtrl->mask_rects + i)->right = mask_info->rcs[i].right; + (pCtrl->mask_rects + i)->bottom = mask_info->rcs[i].bottom; (pCtrl->mask_rects + i)->prev = i; (pCtrl->mask_rects + i)->next = i + 1; } /** the field [prev] is used to store number of mask_rects */ - pCtrl->mask_rects->prev = rect_size; + pCtrl->mask_rects->prev = mask_info->nr_rcs; /** mark the end with 0 */ - (pCtrl->mask_rects + rect_size - 1)->next = 0; + (pCtrl->mask_rects + mask_info->nr_rcs - 1)->next = 0; - free (rect); + free (mask_info->rcs); if (pCtrl->dwStyle & WS_VISIBLE) { ShowWindow (hWnd, SW_HIDE); @@ -6078,8 +6078,12 @@ static int gui_GenerateMaskRect(HWND hWnd, RECT4MASK* rect, int rect_size) } } - retval = __kernel_change_z_node_mask_rect (hWnd, rect, rect_size); - free (rect); + /* Since 4.2.0: use MSG_SETWINDOWMASK messasge instead of + __kernel_change_z_node_mask_rect */ + retval = (int)SendMessage (HWND_DESKTOP, + MSG_SETWINDOWMASK, (WPARAM)hWnd, (LPARAM)mask_info); + // retval = __kernel_change_z_node_mask_rect (hWnd, mask_info->rcs, mask_info->nr_rcs); + free (mask_info->rcs); /* Since 4.2.0. Under compositing schema, the compositor should refresh the screen for the change of region. */ @@ -6101,27 +6105,29 @@ static int gui_GenerateMaskRect(HWND hWnd, RECT4MASK* rect, int rect_size) BOOL GUIAPI SetWindowMask (HWND hWnd, const MYBITMAP* mask) { - int retval, rect_size; - RECT4MASK *rect; + WINMASKINFO mask_info; + int retval; - rect = CalcXYBannedRects (HDC_SCREEN, mask, &rect_size, TYPE_MYBITMAP); - if (!rect) + mask_info.rcs = calc_xybanned_rects (HDC_SCREEN, TYPE_MYBITMAP, mask, + &mask_info.nr_rcs); + if (!mask_info.rcs) return FALSE; - retval = gui_GenerateMaskRect(hWnd, rect, rect_size); + retval = set_window_mask_rect (hWnd, &mask_info); return (retval == 0 ? TRUE : FALSE); } BOOL GUIAPI SetWindowMaskEx (HWND hWnd, HDC hdc, const BITMAP* mask) { - int retval, rect_size; - RECT4MASK *rect; + WINMASKINFO mask_info; + int retval; - rect = CalcXYBannedRects (hdc, mask, &rect_size, TYPE_BITMAP); - if (!rect) + mask_info.rcs = calc_xybanned_rects (hdc, TYPE_BITMAP, mask, + &mask_info.nr_rcs); + if (!mask_info.rcs) return FALSE; - retval = gui_GenerateMaskRect(hWnd, rect, rect_size); + retval = set_window_mask_rect (hWnd, &mask_info); return (retval == 0 ? TRUE : FALSE); } @@ -6129,9 +6135,9 @@ BOOL GUIAPI SetWindowRegion (HWND hWnd, const CLIPRGN * region) { MASKRECT *new_maskrect; PCLIPRECT cliprc; - RECT4MASK *rect; + WINMASKINFO mask_info; PCONTROL pCtrl; - int retval, rect_size, i; + int retval, nr_rcs, i; MG_CHECK_RET (MG_IS_NORMAL_WINDOW(hWnd), FALSE); @@ -6139,14 +6145,14 @@ BOOL GUIAPI SetWindowRegion (HWND hWnd, const CLIPRGN * region) return FALSE; /** number of rect */ - for (rect_size = 1, cliprc = region->head; - cliprc && cliprc != region->tail; rect_size++, cliprc=cliprc->next); + for (nr_rcs = 1, cliprc = region->head; + cliprc && cliprc != region->tail; nr_rcs++, cliprc=cliprc->next); if (IsControl (hWnd)) { /* * Because control without WS_EX_CTRLASMAINWIN has not * the Z order node, we should allocate memory for an - * array of rect_size for mask_rects. + * array of nr_rcs for mask_rects. * * The prev of first mask_rects indicates the number of the array. * The next of last mask_rects is 0. @@ -6158,7 +6164,7 @@ BOOL GUIAPI SetWindowRegion (HWND hWnd, const CLIPRGN * region) if (pCtrl->mask_rects == NULL) { pCtrl->mask_rects = - (MASKRECT *) calloc (rect_size, sizeof (MASKRECT)); + (MASKRECT *) calloc (nr_rcs, sizeof (MASKRECT)); if (!pCtrl->mask_rects) { _WRN_PRINTF ("No enough memory!\n"); @@ -6170,9 +6176,9 @@ BOOL GUIAPI SetWindowRegion (HWND hWnd, const CLIPRGN * region) * when number of calloced mask_rects is not enough, * free the old memory and calloc more. */ - if (pCtrl->mask_rects->prev < rect_size) { + if (pCtrl->mask_rects->prev < nr_rcs) { new_maskrect = - (MASKRECT *) calloc (rect_size, sizeof (MASKRECT)); + (MASKRECT *) calloc (nr_rcs, sizeof (MASKRECT)); if (!new_maskrect) { _WRN_PRINTF ("No enough memory!\n"); @@ -6185,7 +6191,7 @@ BOOL GUIAPI SetWindowRegion (HWND hWnd, const CLIPRGN * region) cliprc = region->head; - for (i = 0; i < rect_size; ++i) { + for (i = 0; i < nr_rcs; ++i) { (pCtrl->mask_rects + i)->left = cliprc->rc.left; (pCtrl->mask_rects + i)->top = cliprc->rc.top; (pCtrl->mask_rects + i)->right = cliprc->rc.right; @@ -6196,10 +6202,10 @@ BOOL GUIAPI SetWindowRegion (HWND hWnd, const CLIPRGN * region) } /** the field [prev] is used to store number of mask_rects */ - pCtrl->mask_rects->prev = rect_size; + pCtrl->mask_rects->prev = nr_rcs; /** mark the end with 0 */ - (pCtrl->mask_rects + rect_size - 1)->next = 0; + (pCtrl->mask_rects + nr_rcs - 1)->next = 0; if (pCtrl->dwStyle & WS_VISIBLE) { ShowWindow (hWnd, SW_HIDE); @@ -6209,29 +6215,31 @@ BOOL GUIAPI SetWindowRegion (HWND hWnd, const CLIPRGN * region) } } - rect = (RECT4MASK *) calloc(rect_size, sizeof(RECT4MASK)); - if(rect == NULL) { + mask_info.nr_rcs = nr_rcs; + mask_info.rcs = (RECT4MASK *) calloc (nr_rcs, sizeof(RECT4MASK)); + if (mask_info.rcs == NULL) { _WRN_PRINTF ("No enough memory!\n"); return FALSE; } cliprc = region->head; - - for (i = 0; i < rect_size; ++i) { - (rect + i)->left = cliprc->rc.left; - (rect + i)->top = cliprc->rc.top; - (rect + i)->right = cliprc->rc.right; - (rect + i)->bottom = cliprc->rc.bottom; + for (i = 0; i < nr_rcs; ++i) { + mask_info.rcs[i].left = cliprc->rc.left; + mask_info.rcs[i].top = cliprc->rc.top; + mask_info.rcs[i].right = cliprc->rc.right; + mask_info.rcs[i].bottom = cliprc->rc.bottom; cliprc = cliprc->next; } - retval = __kernel_change_z_node_mask_rect (hWnd, rect, rect_size); - free (rect); + retval = (int)SendMessage (HWND_DESKTOP, + MSG_SETWINDOWMASK, (WPARAM)hWnd, (LPARAM)&mask_info); + // XXX: retval = __kernel_change_z_node_mask_rect (hWnd, rect, nr_rcs); + free (mask_info.rcs); /* Since 4.2.0. Under compositing schema, the compositor should refresh the screen for the change of region. */ #ifndef _MGSCHEMA_COMPOSITING - pCtrl = (PCONTROL) hWnd; + pCtrl = (PCONTROL)hWnd; if (!retval && pCtrl->dwStyle & WS_VISIBLE) { MoveWindow (hWnd, pCtrl->left, pCtrl->top, diff --git a/src/include/zorder.h b/src/include/zorder.h index c9431a2f..9159c1ee 100644 --- a/src/include/zorder.h +++ b/src/include/zorder.h @@ -177,7 +177,6 @@ extern "C" { int __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals); void __kernel_free_z_order_info (ZORDERINFO* zi); -int __kernel_change_z_node_mask_rect (HWND pWin, const RECT4MASK* rc, int nr_rc); int __kernel_get_window_region (HWND pWin, CLIPRGN* region); int __kernel_get_next_znode (const ZORDERINFO* zi, int from); int __kernel_get_prev_znode (const ZORDERINFO* zi, int from); diff --git a/src/kernel/desktop-comm.c b/src/kernel/desktop-comm.c index 2dd72210..b8512e78 100644 --- a/src/kernel/desktop-comm.c +++ b/src/kernel/desktop-comm.c @@ -59,14 +59,8 @@ extern int __mg_enter_terminategui; #if defined(_MGRM_THREADS) || defined(_MGRM_STANDALONE) -int __kernel_change_z_node_mask_rect (HWND pWin, const RECT4MASK* rc, int nr_rc) -{ - FreeZOrderMaskRect (0, ((PMAINWIN)pWin)->idx_znode); - return AllocZOrderMaskRect (0, ((PMAINWIN)pWin)->idx_znode, - get_znode_flags_from_style ((PMAINWIN)pWin), rc, nr_rc); -} - -static LRESULT DesktopWinProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +static LRESULT DesktopWinProc (HWND hWnd, UINT msg, + WPARAM wParam, LPARAM lParam); static void init_desktop_win (void) { @@ -161,11 +155,8 @@ static void dskShowMainWindow (PMAINWIN pWin, BOOL bActive) //dskUpdateGCRInfoOnShowMainWin (pWin); pWin->dwStyle |= WS_VISIBLE; - dskShowWindow (0, pWin->idx_znode); - SendAsyncMessage ((HWND)pWin, MSG_NCPAINT, 0, 0); - InvalidateRect ((HWND)pWin, NULL, TRUE); #if 0 @@ -211,11 +202,12 @@ static int dskAddNewMainWindow (PMAINWIN pWin) pWin->idx_znode = dskAllocZOrderNode (pWin); if (pWin->idx_znode <= 0) { - _WRN_PRINTF ("KERNEL>Desktop: Alloc zorder node for main window fail.\n"); + _WRN_PRINTF ("Failed to allocate znode for main window.\n"); return -1; } - /* Since 4.2.0: handle window style if failed to allocate znode for fixed ones */ + /* Since 4.2.0: handle window style if failed to allocate znode + for fixed ones */ if (pWin->dwExStyle & WS_EX_WINTYPE_MASK) { ZORDERNODE* nodes = GET_ZORDERNODE(__mg_zorder_info); @@ -263,7 +255,8 @@ static int dskAddNewMainWindow (PMAINWIN pWin) /* Create private client dc. */ if (pWin->dwExStyle & WS_EX_USEPRIVATECDC) { if (pWin->dwExStyle & WS_EX_AUTOSECONDARYDC) - pWin->privCDC = GetSecondarySubDC (pWin->secondaryDC, (HWND)pWin, TRUE); + pWin->privCDC = GetSecondarySubDC (pWin->secondaryDC, + (HWND)pWin, TRUE); else pWin->privCDC = CreatePrivateClientDC ((HWND)pWin); } @@ -271,14 +264,10 @@ static int dskAddNewMainWindow (PMAINWIN pWin) pWin->privCDC = 0; // show and active this main window. - if ( pWin->dwStyle & WS_VISIBLE ) { - + if (pWin->dwStyle & WS_VISIBLE) { SendAsyncMessage ((HWND)pWin, MSG_NCPAINT, 0, 0); - SendNotifyMessage ((HWND)pWin, MSG_SHOWWINDOW, SW_SHOWNORMAL, 0); - InvalidateRect ((HWND)pWin, NULL, TRUE); - dskSetActiveWindow (pWin); } @@ -388,6 +377,15 @@ static BOOL dskSetMainWindowAlwaysTop (PMAINWIN pWin, BOOL fSet) return TRUE; } +/* Since 4.2.0 */ +static int dskSetWindowMask (HWND pWin, const WINMASKINFO* mask_info) +{ + FreeZOrderMaskRect (0, ((PMAINWIN)pWin)->idx_znode); + return AllocZOrderMaskRect (0, ((PMAINWIN)pWin)->idx_znode, + get_znode_flags_from_style ((PMAINWIN)pWin), + mask_info->rcs, mask_info->nr_rcs); +} + static void dskHideMainWindow (PMAINWIN pWin) { if (!(pWin->dwStyle & WS_VISIBLE)) @@ -532,7 +530,7 @@ static int dskEndTrackPopupMenu (PTRACKMENUINFO ptmi) return 0; } -#endif +#endif /* defiend _MGHAVE_MENU */ static void dskEnableWindow (PMAINWIN pWin, int flags) { @@ -682,8 +680,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) * // - represent area need the Need invalidate * see the to area must be invalidate */ - if(bNeedInvalidate) - { + if (bNeedInvalidate) { InvalidateRect ((HWND)pWin, &rcInvalid, TRUE); rcInvalid = rcMove; //restore the invalidate area bNeedInvalidate = FALSE; //resotre the inved value @@ -699,8 +696,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) bNeedInvalidate = TRUE; } - if (bNeedInvalidate) - { + if (bNeedInvalidate) { InvalidateRect ((HWND)pWin, &rcInvalid, TRUE); inved = TRUE; } @@ -786,7 +782,8 @@ static int dskHandleMouseHooks (HWND dst_wnd, UINT message, int ret = HOOK_GOON; if (mousehook.hook) { - ret = mousehook.hook (mousehook.context, dst_wnd, message, wParam, lParam); + ret = mousehook.hook (mousehook.context, dst_wnd, + message, wParam, lParam); } return ret; @@ -996,197 +993,197 @@ static LRESULT MouseMessageHandler (UINT message, WPARAM flags, int x, int y) } switch (message) { - case MSG_MOUSEMOVE: - if (_mgs_button_down_main_window) { - PostMessage ((HWND)_mgs_button_down_main_window, - message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); + case MSG_MOUSEMOVE: + if (_mgs_button_down_main_window) { + PostMessage ((HWND)_mgs_button_down_main_window, + message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + } + else { + if (_mgs_old_under_p != pUnderPointer) { + if (_mgs_old_under_p) { + PostMessage ((HWND)_mgs_old_under_p, + MSG_MOUSEMOVEIN, FALSE, (LPARAM)pUnderPointer); + PostMessage ((HWND)_mgs_old_under_p, + MSG_NCMOUSEMOVE, HT_OUT, MAKELONG (x, y)); + } + if (pUnderPointer) + PostMessage ((HWND)pUnderPointer, + MSG_MOUSEMOVEIN, TRUE, (LPARAM)_mgs_old_under_p); + else + SetCursor (GetSystemCursor (IDC_ARROW)); + + _mgs_old_under_p = pUnderPointer; } - else { - if (_mgs_old_under_p != pUnderPointer) { - if (_mgs_old_under_p) { - PostMessage ((HWND)_mgs_old_under_p, - MSG_MOUSEMOVEIN, FALSE, (LPARAM)pUnderPointer); - PostMessage ((HWND)_mgs_old_under_p, - MSG_NCMOUSEMOVE, HT_OUT, MAKELONG (x, y)); - } - if (pUnderPointer) - PostMessage ((HWND)pUnderPointer, - MSG_MOUSEMOVEIN, TRUE, (LPARAM)_mgs_old_under_p); - else - SetCursor (GetSystemCursor (IDC_ARROW)); - _mgs_old_under_p = pUnderPointer; - } - - if (pUnderPointer) { - if (pUnderPointer->dwStyle & WS_DISABLED) { - HCURSOR def_cursor = GetDefaultCursor (); - - if (def_cursor) - SetCursor (def_cursor); - } - else - PostMessage ((HWND)pUnderPointer, - message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - } - else { + if (pUnderPointer) { + if (pUnderPointer->dwStyle & WS_DISABLED) { HCURSOR def_cursor = GetDefaultCursor (); if (def_cursor) SetCursor (def_cursor); - PostMessage (HWND_DESKTOP, MSG_DT_MOUSEMOVE, - flags, MAKELONG (x, y)); } - } - break; - - case MSG_LBUTTONDOWN: - case MSG_RBUTTONDOWN: - case MSG_MBUTTONDOWN: - if (_mgs_button_down_main_window) { - PostMessage ((HWND)_mgs_button_down_main_window, - message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - if (message == MSG_LBUTTONDOWN) - _mgs_down_buttons |= DOWN_BUTTON_LEFT; - else if (message == MSG_RBUTTONDOWN) - _mgs_down_buttons |= DOWN_BUTTON_RIGHT; else - _mgs_down_buttons |= DOWN_BUTTON_MIDDLE; + PostMessage ((HWND)pUnderPointer, + message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); } - else if (pUnderPointer) { + else { + HCURSOR def_cursor = GetDefaultCursor (); + + if (def_cursor) + SetCursor (def_cursor); + PostMessage (HWND_DESKTOP, MSG_DT_MOUSEMOVE, + flags, MAKELONG (x, y)); + } + } + break; + + case MSG_LBUTTONDOWN: + case MSG_RBUTTONDOWN: + case MSG_MBUTTONDOWN: + if (_mgs_button_down_main_window) { + PostMessage ((HWND)_mgs_button_down_main_window, + message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + if (message == MSG_LBUTTONDOWN) + _mgs_down_buttons |= DOWN_BUTTON_LEFT; + else if (message == MSG_RBUTTONDOWN) + _mgs_down_buttons |= DOWN_BUTTON_RIGHT; + else + _mgs_down_buttons |= DOWN_BUTTON_MIDDLE; + } + else if (pUnderPointer) { #ifdef _MGHAVE_MENU - if (sg_ptmi) - dskForceCloseMenu (); + if (sg_ptmi) + dskForceCloseMenu (); #endif - if (pUnderPointer->dwStyle & WS_DISABLED) { - Ping (); + if (pUnderPointer->dwStyle & WS_DISABLED) { + Ping (); + break; + } + + if (pCtrlPtrIn == NULL) { + if (!dskIsTopMost (pUnderPointer)) { + dskMoveToTopMost (pUnderPointer, + RCTM_CLICK, MAKELONG (x, y)); + } + + if (pUnderPointer != dskSetActiveWindow (pUnderPointer)) + SendNotifyMessage ((HWND) pUnderPointer, + MSG_MOUSEACTIVE, 0, 0); + } + + + PostMessage ((HWND)pUnderPointer, message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + + _mgs_button_down_main_window = pUnderPointer; + if (message == MSG_LBUTTONDOWN) + _mgs_down_buttons = DOWN_BUTTON_LEFT; + else if (message == MSG_RBUTTONDOWN) + _mgs_down_buttons = DOWN_BUTTON_RIGHT; + else + _mgs_down_buttons = DOWN_BUTTON_MIDDLE; + } + else { + dskSetActiveWindow (NULL); + PostMessage (HWND_DESKTOP, message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + _mgs_button_down_main_window = NULL; + _mgs_down_buttons = DOWN_BUTTON_NONE; + } + break; + + case MSG_LBUTTONUP: + case MSG_RBUTTONUP: + case MSG_MBUTTONUP: + if (_mgs_down_buttons == DOWN_BUTTON_LEFT && + message != MSG_LBUTTONUP) { + break; + } + if (_mgs_down_buttons == DOWN_BUTTON_RIGHT && + message != MSG_RBUTTONUP) { + break; + } + if (_mgs_down_buttons == DOWN_BUTTON_MIDDLE && + message != MSG_MBUTTONUP) { + break; + } + + if (_mgs_button_down_main_window) { + PostMessage ((HWND)_mgs_button_down_main_window, + message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + if (message == MSG_LBUTTONUP) + _mgs_down_buttons &= ~DOWN_BUTTON_LEFT; + else if (message == MSG_RBUTTONUP) + _mgs_down_buttons &= ~DOWN_BUTTON_RIGHT; + else + _mgs_down_buttons &= ~DOWN_BUTTON_MIDDLE; + + if (!(_mgs_down_buttons & DOWN_BUTTON_ANY)) { + _mgs_button_down_main_window = NULL; + _mgs_down_buttons = DOWN_BUTTON_NONE; + } + } + else { + /* fixed bug 4961: for deal with when _mgs_button_down_main_window was reset, + * but there real has a mouse up message. by humingming 2010.9.1 + */ + if (pUnderPointer == NULL) { + PostMessage (HWND_DESKTOP, + message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + } + else { + if ((pUnderPointer->dwStyle & WS_DISABLED)) { break; } - - if (pCtrlPtrIn == NULL) { - if (!dskIsTopMost (pUnderPointer)) { - dskMoveToTopMost (pUnderPointer, - RCTM_CLICK, MAKELONG (x, y)); - } - - if (pUnderPointer != dskSetActiveWindow (pUnderPointer)) - SendNotifyMessage ((HWND) pUnderPointer, - MSG_MOUSEACTIVE, 0, 0); - } - - - PostMessage ((HWND)pUnderPointer, message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - - _mgs_button_down_main_window = pUnderPointer; - if (message == MSG_LBUTTONDOWN) - _mgs_down_buttons = DOWN_BUTTON_LEFT; - else if (message == MSG_RBUTTONDOWN) - _mgs_down_buttons = DOWN_BUTTON_RIGHT; - else - _mgs_down_buttons = DOWN_BUTTON_MIDDLE; - } - else { - dskSetActiveWindow (NULL); - PostMessage (HWND_DESKTOP, message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - _mgs_button_down_main_window = NULL; - _mgs_down_buttons = DOWN_BUTTON_NONE; - } - break; - - case MSG_LBUTTONUP: - case MSG_RBUTTONUP: - case MSG_MBUTTONUP: - if (_mgs_down_buttons == DOWN_BUTTON_LEFT && - message != MSG_LBUTTONUP) { - break; - } - if (_mgs_down_buttons == DOWN_BUTTON_RIGHT && - message != MSG_RBUTTONUP) { - break; - } - if (_mgs_down_buttons == DOWN_BUTTON_MIDDLE && - message != MSG_MBUTTONUP) { - break; - } - - if (_mgs_button_down_main_window) { - PostMessage ((HWND)_mgs_button_down_main_window, - message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - if (message == MSG_LBUTTONUP) - _mgs_down_buttons &= ~DOWN_BUTTON_LEFT; - else if (message == MSG_RBUTTONUP) - _mgs_down_buttons &= ~DOWN_BUTTON_RIGHT; - else - _mgs_down_buttons &= ~DOWN_BUTTON_MIDDLE; - - if (!(_mgs_down_buttons & DOWN_BUTTON_ANY)) { - _mgs_button_down_main_window = NULL; - _mgs_down_buttons = DOWN_BUTTON_NONE; - } - } - else { - /* fixed bug 4961: for deal with when _mgs_button_down_main_window was reset, - * but there real has a mouse up message. by humingming 2010.9.1 - */ - if (pUnderPointer == NULL) { - PostMessage (HWND_DESKTOP, - message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - } else { - if ((pUnderPointer->dwStyle & WS_DISABLED)) { - break; - } - else { - PostMessage((HWND)pUnderPointer, - message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - } + PostMessage((HWND)pUnderPointer, + message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); } } - break; + } + break; - case MSG_LBUTTONDBLCLK: - case MSG_RBUTTONDBLCLK: - case MSG_MBUTTONDBLCLK: - if (_mgs_button_down_main_window) { - PostMessage ((HWND)_mgs_button_down_main_window, - message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - if (message == MSG_LBUTTONDBLCLK) - _mgs_down_buttons |= DOWN_BUTTON_LEFT; - else if (message == MSG_RBUTTONDBLCLK) - _mgs_down_buttons |= DOWN_BUTTON_RIGHT; - else - _mgs_down_buttons |= DOWN_BUTTON_MIDDLE; - } - else if (pUnderPointer) { - PostMessage ((HWND)pUnderPointer, - message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - _mgs_button_down_main_window = pUnderPointer; - if (message == MSG_LBUTTONDBLCLK) - _mgs_down_buttons = DOWN_BUTTON_LEFT; - else if (message == MSG_RBUTTONDBLCLK) - _mgs_down_buttons = DOWN_BUTTON_RIGHT; - else - _mgs_down_buttons = DOWN_BUTTON_MIDDLE; - } - else { - PostMessage (HWND_DESKTOP, + case MSG_LBUTTONDBLCLK: + case MSG_RBUTTONDBLCLK: + case MSG_MBUTTONDBLCLK: + if (_mgs_button_down_main_window) { + PostMessage ((HWND)_mgs_button_down_main_window, message + MSG_DT_MOUSEOFF, flags, MAKELONG (x, y)); - _mgs_button_down_main_window = NULL; - _mgs_down_buttons = DOWN_BUTTON_NONE; - } - break; + if (message == MSG_LBUTTONDBLCLK) + _mgs_down_buttons |= DOWN_BUTTON_LEFT; + else if (message == MSG_RBUTTONDBLCLK) + _mgs_down_buttons |= DOWN_BUTTON_RIGHT; + else + _mgs_down_buttons |= DOWN_BUTTON_MIDDLE; + } + else if (pUnderPointer) { + PostMessage ((HWND)pUnderPointer, + message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + _mgs_button_down_main_window = pUnderPointer; + if (message == MSG_LBUTTONDBLCLK) + _mgs_down_buttons = DOWN_BUTTON_LEFT; + else if (message == MSG_RBUTTONDBLCLK) + _mgs_down_buttons = DOWN_BUTTON_RIGHT; + else + _mgs_down_buttons = DOWN_BUTTON_MIDDLE; + } + else { + PostMessage (HWND_DESKTOP, + message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + _mgs_button_down_main_window = NULL; + _mgs_down_buttons = DOWN_BUTTON_NONE; + } + break; } return 0; @@ -1279,33 +1276,33 @@ static int dskStartDragWindow (PMAINWIN pWin, const DRAGINFO* drag_info) _dd_info.last_y = drag_info->init_y; switch (_dd_info.location) { - case HT_CAPTION: - //SetDefaultCursor (GetSystemCursor (IDC_MOVE)); - SetCursor (GetSystemCursor (IDC_MOVE)); - break; - case HT_BORDER_TOP: - case HT_BORDER_BOTTOM: - //SetDefaultCursor (GetSystemCursor (IDC_SIZENS)); - SetCursor (GetSystemCursor (IDC_SIZENS)); - break; - case HT_BORDER_LEFT: - case HT_BORDER_RIGHT: - //SetDefaultCursor (GetSystemCursor (IDC_SIZEWE)); - SetCursor (GetSystemCursor (IDC_SIZEWE)); - break; - case HT_CORNER_TL: - case HT_CORNER_BR: - //SetDefaultCursor (GetSystemCursor (IDC_SIZENWSE)); - SetCursor (GetSystemCursor (IDC_SIZENWSE)); - break; - case HT_CORNER_BL: - case HT_CORNER_TR: - //SetDefaultCursor (GetSystemCursor (IDC_SIZENESW)); - SetCursor (GetSystemCursor (IDC_SIZENESW)); - break; - default: - _WRN_PRINTF ("KERNEL>Desktop: Drag and drop window: bad location\n"); - break; + case HT_CAPTION: + //SetDefaultCursor (GetSystemCursor (IDC_MOVE)); + SetCursor (GetSystemCursor (IDC_MOVE)); + break; + case HT_BORDER_TOP: + case HT_BORDER_BOTTOM: + //SetDefaultCursor (GetSystemCursor (IDC_SIZENS)); + SetCursor (GetSystemCursor (IDC_SIZENS)); + break; + case HT_BORDER_LEFT: + case HT_BORDER_RIGHT: + //SetDefaultCursor (GetSystemCursor (IDC_SIZEWE)); + SetCursor (GetSystemCursor (IDC_SIZEWE)); + break; + case HT_CORNER_TL: + case HT_CORNER_BR: + //SetDefaultCursor (GetSystemCursor (IDC_SIZENWSE)); + SetCursor (GetSystemCursor (IDC_SIZENWSE)); + break; + case HT_CORNER_BL: + case HT_CORNER_TR: + //SetDefaultCursor (GetSystemCursor (IDC_SIZENESW)); + SetCursor (GetSystemCursor (IDC_SIZENESW)); + break; + default: + _WRN_PRINTF ("KERNEL>Desktop: Drag and drop window: bad location\n"); + break; } SetPenColor (HDC_SCREEN_SYS, PIXEL_lightwhite); @@ -1341,51 +1338,51 @@ static int do_drag_drop_window (UINT msg, int x, int y) _dd_info.rc.right, _dd_info.rc.bottom); switch (_dd_info.location) { - case HT_CAPTION: - OffsetRect (&_dd_info.rc, - x - _dd_info.last_x, - y - _dd_info.last_y); - break; + case HT_CAPTION: + OffsetRect (&_dd_info.rc, + x - _dd_info.last_x, + y - _dd_info.last_y); + break; - case HT_BORDER_TOP: - _dd_info.rc.top += y - _dd_info.last_y; - break; + case HT_BORDER_TOP: + _dd_info.rc.top += y - _dd_info.last_y; + break; - case HT_BORDER_BOTTOM: - _dd_info.rc.bottom += y - _dd_info.last_y; - break; + case HT_BORDER_BOTTOM: + _dd_info.rc.bottom += y - _dd_info.last_y; + break; - case HT_BORDER_LEFT: - _dd_info.rc.left += x - _dd_info.last_x; - break; + case HT_BORDER_LEFT: + _dd_info.rc.left += x - _dd_info.last_x; + break; - case HT_BORDER_RIGHT: - _dd_info.rc.right += x - _dd_info.last_x; - break; + case HT_BORDER_RIGHT: + _dd_info.rc.right += x - _dd_info.last_x; + break; - case HT_CORNER_TL: - _dd_info.rc.left += x - _dd_info.last_x; - _dd_info.rc.top += y - _dd_info.last_y; - break; + case HT_CORNER_TL: + _dd_info.rc.left += x - _dd_info.last_x; + _dd_info.rc.top += y - _dd_info.last_y; + break; - case HT_CORNER_TR: - _dd_info.rc.right += x - _dd_info.last_x; - _dd_info.rc.top += y - _dd_info.last_y; - break; + case HT_CORNER_TR: + _dd_info.rc.right += x - _dd_info.last_x; + _dd_info.rc.top += y - _dd_info.last_y; + break; - case HT_CORNER_BL: - _dd_info.rc.left += x - _dd_info.last_x; - _dd_info.rc.bottom += y - _dd_info.last_y; - break; + case HT_CORNER_BL: + _dd_info.rc.left += x - _dd_info.last_x; + _dd_info.rc.bottom += y - _dd_info.last_y; + break; - case HT_CORNER_BR: - _dd_info.rc.right += x - _dd_info.last_x; - _dd_info.rc.bottom += y - _dd_info.last_y; - break; + case HT_CORNER_BR: + _dd_info.rc.right += x - _dd_info.last_x; + _dd_info.rc.bottom += y - _dd_info.last_y; + break; - default: - _WRN_PRINTF ("KERNEL>Desktop: do_drag_drop_window: bad location\n"); - break; + default: + _WRN_PRINTF ("KERNEL>Desktop: do_drag_drop_window: bad location\n"); + break; } FocusRect (HDC_SCREEN_SYS, _dd_info.rc.left, _dd_info.rc.top, @@ -1408,7 +1405,7 @@ static int do_drag_drop_window (UINT msg, int x, int y) unlock_zorder_info (); SelectClipRect (HDC_SCREEN_SYS, &rcScr); - if(_dd_info.hwnd != (HWND)gui_GetMainWindowPtrUnderPoint (x, y)) + if (_dd_info.hwnd != (HWND)gui_GetMainWindowPtrUnderPoint (x, y)) SetDefaultCursor (GetSystemCursor (IDC_ARROW)); _dd_info.hwnd = 0; } @@ -1424,176 +1421,180 @@ static LRESULT WindowMessageHandler(UINT message, PMAINWIN pWin, LPARAM lParam) do_drag_drop_window (message, 0, 0); switch (message) { - case MSG_ADDNEWMAINWIN: + case MSG_ADDNEWMAINWIN: #ifdef _MGHAVE_MENU - if (sg_ptmi) - dskForceCloseMenu (); + if (sg_ptmi) + dskForceCloseMenu (); #endif - return dskAddNewMainWindow(pWin); + return dskAddNewMainWindow(pWin); - case MSG_REMOVEMAINWIN: + case MSG_REMOVEMAINWIN: #ifdef _MGHAVE_MENU - if (sg_ptmi) - dskForceCloseMenu (); + if (sg_ptmi) + dskForceCloseMenu (); #endif - dskRemoveMainWindow(pWin); - __mg_reset_desktop_capture_info (pWin); - return 0; + dskRemoveMainWindow(pWin); + __mg_reset_desktop_capture_info (pWin); + return 0; - case MSG_MOVETOTOPMOST: + case MSG_MOVETOTOPMOST: #ifdef _MGHAVE_MENU - if (sg_ptmi) - dskForceCloseMenu (); + if (sg_ptmi) + dskForceCloseMenu (); #endif - dskMoveToTopMost(pWin, RCTM_MESSAGE, 0); - return 0; + dskMoveToTopMost(pWin, RCTM_MESSAGE, 0); + return 0; - case MSG_SHOWMAINWIN: + case MSG_SHOWMAINWIN: #ifdef _MGHAVE_MENU - if (sg_ptmi) - dskForceCloseMenu (); + if (sg_ptmi) + dskForceCloseMenu (); #endif - dskShowMainWindow(pWin, TRUE); - return 0; + dskShowMainWindow(pWin, TRUE); + return 0; - case MSG_HIDEMAINWIN: + case MSG_HIDEMAINWIN: #ifdef _MGHAVE_MENU - if (sg_ptmi) - dskForceCloseMenu (); + if (sg_ptmi) + dskForceCloseMenu (); #endif - dskHideMainWindow (pWin); - __mg_reset_desktop_capture_info (pWin); - return 0; + dskHideMainWindow (pWin); + __mg_reset_desktop_capture_info (pWin); + return 0; - case MSG_MOVEMAINWIN: - if (pWin->WinType == TYPE_CONTROL) - lRet = (LRESULT)dskMoveGlobalControl (pWin, (RECT*)lParam); - else { - lRet = (LRESULT)dskMoveMainWindow (pWin, (RECT*)lParam); - } - return lRet; + case MSG_MOVEMAINWIN: + if (pWin->WinType == TYPE_CONTROL) + lRet = (LRESULT)dskMoveGlobalControl (pWin, (RECT*)lParam); + else { + lRet = (LRESULT)dskMoveMainWindow (pWin, (RECT*)lParam); + } + return lRet; - case MSG_GETACTIVEMAIN: - return (LRESULT)dskGetActiveWindow(); + case MSG_GETACTIVEMAIN: + return (LRESULT)dskGetActiveWindow(); - case MSG_SETACTIVEMAIN: - lRet = (LRESULT)dskSetActiveWindow (pWin); - return lRet; + case MSG_SETACTIVEMAIN: + lRet = (LRESULT)dskSetActiveWindow (pWin); + return lRet; - case MSG_GETCAPTURE: - return (LRESULT)__mg_capture_wnd; + case MSG_GETCAPTURE: + return (LRESULT)__mg_capture_wnd; - case MSG_SETCAPTURE: - return (LRESULT)DesktopSetCapture ((HWND)pWin); + case MSG_SETCAPTURE: + return (LRESULT)DesktopSetCapture ((HWND)pWin); #ifdef _MGHAVE_MENU - case MSG_TRACKPOPUPMENU: - return dskStartTrackPopupMenu((PTRACKMENUINFO)lParam); + case MSG_TRACKPOPUPMENU: + return dskStartTrackPopupMenu((PTRACKMENUINFO)lParam); - case MSG_ENDTRACKMENU: - return dskEndTrackPopupMenu((PTRACKMENUINFO)lParam); + case MSG_ENDTRACKMENU: + return dskEndTrackPopupMenu((PTRACKMENUINFO)lParam); - case MSG_CLOSEMENU: - return dskCloseMenu (); + case MSG_CLOSEMENU: + return dskCloseMenu (); #endif - case MSG_SCROLLMAINWIN: - lRet = dskScrollMainWindow (pWin, (PSCROLLWINDOWINFO)lParam); - return lRet; + case MSG_SCROLLMAINWIN: + lRet = dskScrollMainWindow (pWin, (PSCROLLWINDOWINFO)lParam); + return lRet; - case MSG_CARET_CREATE: - sg_hCaretWnd = (HWND)pWin; - sg_uCaretBTime = pWin->pCaretInfo->uTime; - return 0; + case MSG_CARET_CREATE: + sg_hCaretWnd = (HWND)pWin; + sg_uCaretBTime = pWin->pCaretInfo->uTime; + return 0; - case MSG_CARET_DESTROY: - sg_hCaretWnd = 0; - return 0; + case MSG_CARET_DESTROY: + sg_hCaretWnd = 0; + return 0; - case MSG_ENABLEMAINWIN: - dskEnableWindow (pWin, lParam); - return 0; + case MSG_ENABLEMAINWIN: + dskEnableWindow (pWin, lParam); + return 0; - case MSG_ISENABLED: - return !(pWin->dwStyle & WS_DISABLED); + case MSG_ISENABLED: + return !(pWin->dwStyle & WS_DISABLED); - case MSG_SETWINCURSOR: - { - HCURSOR old = pWin->hCursor; + case MSG_SETWINCURSOR: { + HCURSOR old = pWin->hCursor; - pWin->hCursor = (HCURSOR)lParam; - return (LRESULT)old; + pWin->hCursor = (HCURSOR)lParam; + return (LRESULT)old; + } + + /* TODO: bad implementation */ + case MSG_GETNEXTMAINWIN: { + HWND hWnd = HWND_NULL; + int slot; + ZORDERNODE* nodes = GET_ZORDERNODE(__mg_zorder_info); + int last_type; + + if (pWin) { + last_type = nodes[pWin->idx_znode].flags & ZOF_TYPE_MASK; + slot = nodes[pWin->idx_znode].next; + }else{ + last_type = ZOF_TYPE_TOPMOST; + slot = __mg_zorder_info->first_topmost; } - case MSG_GETNEXTMAINWIN: - { - HWND hWnd = HWND_NULL; - int slot; - ZORDERNODE* nodes = GET_ZORDERNODE(__mg_zorder_info); - int last_type; - - if (pWin) { - last_type = nodes[pWin->idx_znode].flags & ZOF_TYPE_MASK; - slot = nodes[pWin->idx_znode].next; - }else{ - last_type = ZOF_TYPE_TOPMOST; - slot = __mg_zorder_info->first_topmost; - } - - while (1) { - if (slot <= 0) { - if (last_type == ZOF_TYPE_TOPMOST) { - last_type = ZOF_TYPE_NORMAL; - slot = __mg_zorder_info->first_normal; - continue; - } - else { - return (LRESULT)HWND_NULL; - } - } - - hWnd = nodes[slot].hwnd; - if (0 - || !hWnd - || !(pWin = gui_CheckAndGetMainWindowPtr (hWnd)) - || (pWin->dwExStyle & WS_EX_CTRLASMAINWIN)) { - slot = nodes[slot].next; + while (1) { + if (slot <= 0) { + if (last_type == ZOF_TYPE_TOPMOST) { + last_type = ZOF_TYPE_NORMAL; + slot = __mg_zorder_info->first_normal; continue; - }else{ - return (LRESULT)hWnd; + } + else { + return (LRESULT)HWND_NULL; } } - break; + + hWnd = nodes[slot].hwnd; + if (0 + || !hWnd + || !(pWin = gui_CheckAndGetMainWindowPtr (hWnd)) + || (pWin->dwExStyle & WS_EX_CTRLASMAINWIN)) { + slot = nodes[slot].next; + continue; + } + else{ + return (LRESULT)hWnd; + } } + break; + } - /* Since 4.2.0 */ - case MSG_SETALWAYSTOP: - return dskSetMainWindowAlwaysTop(pWin, (BOOL)lParam); + /* Since 4.2.0 */ + case MSG_SETALWAYSTOP: + return dskSetMainWindowAlwaysTop(pWin, (BOOL)lParam); - case MSG_SHOWGLOBALCTRL: + /* Since 4.2.0 */ + case MSG_SETWINDOWMASK: + return dskSetWindowMask (pWin, (WINMASKINFO*)lParam); + + case MSG_SHOWGLOBALCTRL: #ifdef _MGHAVE_MENU - if (sg_ptmi) - dskForceCloseMenu (); + if (sg_ptmi) + dskForceCloseMenu (); #endif - dskMoveGlobalControl (pWin, (RECT*)&(pWin->left)); - dskMoveToTopMost (pWin, RCTM_SHOWCTRL, 0); - dskSetPrimitiveChildren (pWin, TRUE); - break; + dskMoveGlobalControl (pWin, (RECT*)&(pWin->left)); + dskMoveToTopMost (pWin, RCTM_SHOWCTRL, 0); + dskSetPrimitiveChildren (pWin, TRUE); + break; - case MSG_HIDEGLOBALCTRL: + case MSG_HIDEGLOBALCTRL: #ifdef _MGHAVE_MENU - if (sg_ptmi) - dskForceCloseMenu (); + if (sg_ptmi) + dskForceCloseMenu (); #endif - dskHideMainWindow (pWin); - dskSetPrimitiveChildren (pWin, FALSE); - break; + dskHideMainWindow (pWin); + dskSetPrimitiveChildren (pWin, FALSE); + break; - case MSG_STARTDRAGWIN: - return dskStartDragWindow (pWin, (DRAGINFO*)lParam); + case MSG_STARTDRAGWIN: + return dskStartDragWindow (pWin, (DRAGINFO*)lParam); - case MSG_CANCELDRAGWIN: - return dskCancelDragWindow (pWin); + case MSG_CANCELDRAGWIN: + return dskCancelDragWindow (pWin); } return lRet; @@ -1687,8 +1688,7 @@ static void dskUpdateDesktopMenu (HMENU hDesktopMenu) iPos = 0; slot = __mg_zorder_info->first_topmost; - for (; slot > 0; slot = nodes[slot].next) - { + for (; slot > 0; slot = nodes[slot].next) { pWin = (PMAINWIN)(nodes[slot].hwnd); if (pWin && pWin->WinType == TYPE_MAINWIN && !(nodes[slot].flags & ZOF_IF_ALWAYSTOP)) { @@ -1720,8 +1720,7 @@ static void dskUpdateDesktopMenu (HMENU hDesktopMenu) } slot = __mg_zorder_info->first_normal; - for (; slot > 0; slot = nodes[slot].next) - { + for (; slot > 0; slot = nodes[slot].next) { pWin = (PMAINWIN)(nodes[slot].hwnd); if (pWin && pWin->WinType == TYPE_MAINWIN) { if (pWin->dwStyle & WS_VISIBLE) @@ -1761,8 +1760,7 @@ static int dskDesktopCommand (HMENU hDesktopMenu, int id) PMAINWIN pWin; slot = __mg_zorder_info->first_topmost; - for (; slot > 0; slot = nodes[slot].next) - { + for (; slot > 0; slot = nodes[slot].next) { pWin = (PMAINWIN)(nodes[slot].hwnd); if (pWin && (pWin->WinType != TYPE_CONTROL) #ifndef _MGRM_THREADS @@ -1775,8 +1773,7 @@ static int dskDesktopCommand (HMENU hDesktopMenu, int id) } slot = __mg_zorder_info->first_normal; - for (; slot > 0; slot = nodes[slot].next) - { + for (; slot > 0; slot = nodes[slot].next) { pWin = (PMAINWIN)(nodes[slot].hwnd); if (pWin && (pWin->WinType == TYPE_MAINWIN) #ifndef _MGRM_THREADS @@ -1828,7 +1825,7 @@ static int dskOnNewCtrlInstance (PCONTROL pParent, PCONTROL pNewCtrl) pNewCtrl->idx_znode = dskAllocZOrderNode ((PMAINWIN)pNewCtrl); if (pNewCtrl->idx_znode <= 0) { - _WRN_PRINTF ("KERNEL>Desktop: Alloc zorder node for control fail.\n"); + _WRN_PRINTF ("Failed to allocate znode for control.\n"); return -1; } @@ -1925,7 +1922,8 @@ static BOOL _cb_refresh_znode (void* context, pTemp = (PMAINWIN)node->hwnd; if (pTemp - && ((pTemp->WinType == TYPE_CONTROL && (pTemp->dwExStyle & WS_EX_CTRLASMAINWIN)) + && ((pTemp->WinType == TYPE_CONTROL && + (pTemp->dwExStyle & WS_EX_CTRLASMAINWIN)) || pTemp->WinType != TYPE_CONTROL) && pTemp->dwStyle & WS_VISIBLE) { if (info->is_empty_invrc) { @@ -1935,7 +1933,8 @@ static BOOL _cb_refresh_znode (void* context, else { RECT rcTemp, rcInv, rcWin; - if (pTemp->WinType == TYPE_CONTROL && (pTemp->dwExStyle & WS_EX_CTRLASMAINWIN)){ + if (pTemp->WinType == TYPE_CONTROL && + (pTemp->dwExStyle & WS_EX_CTRLASMAINWIN)){ dskGetWindowRectInScreen (pTemp, &rcWin); } else @@ -2057,13 +2056,16 @@ void GUIAPI DesktopUpdateAllWindow(void) } #ifndef _MG_ENABLE_SCREENSAVER -# define HAS_NO_MAINWINDOW() ((__mg_zorder_info->nr_normals + __mg_zorder_info->nr_topmosts) == 0) +# define HAS_NO_MAINWINDOW() \ + ((__mg_zorder_info->nr_normals + __mg_zorder_info->nr_topmosts) == 0) #else /* The screensaver occupys one znode */ -# define HAS_NO_MAINWINDOW() ((__mg_zorder_info->nr_normals + __mg_zorder_info->nr_topmosts) == 1) +# define HAS_NO_MAINWINDOW() \ + ((__mg_zorder_info->nr_normals + __mg_zorder_info->nr_topmosts) == 1) #endif -static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +static LRESULT DesktopWinProc (HWND hWnd, UINT message, + WPARAM wParam, LPARAM lParam) { static HDC hDesktopDC; int flags, x, y; @@ -2076,7 +2078,8 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP PostMessage ((HWND)active_mainwnd, message, wParam, lParam); } // VW: Since 4.0.0 for extra input messages. - else if (message >= MSG_FIRSTEXTRAINPUTMSG && message <= MSG_LASTEXTRAINPUTMSG) { + else if (message >= MSG_FIRSTEXTRAINPUTMSG && + message <= MSG_LASTEXTRAINPUTMSG) { PostMessage ((HWND)active_mainwnd, message, wParam, lParam); } else if (message >= MSG_FIRSTKEYMSG && message <= MSG_LASTKEYMSG) { @@ -2144,8 +2147,7 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP dskDesktopCommand (sg_DesktopMenu, (int)wParam); #endif } - else - { + else { if(dsk_ops->desktop_menucmd_handler) dsk_ops->desktop_menucmd_handler(dt_context, (int)wParam); } @@ -2154,257 +2156,265 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP } switch (message) { - case MSG_STARTSESSION: - __mg_init_local_sys_text (); - hDesktopDC = GetDC (HWND_DESKTOP); + case MSG_STARTSESSION: + __mg_init_local_sys_text (); + hDesktopDC = GetDC (HWND_DESKTOP); - dsk_ops = &def_dsk_ops; - if(dsk_ops->init) - dt_context = dsk_ops->init(); + dsk_ops = &def_dsk_ops; + if(dsk_ops->init) + dt_context = dsk_ops->init(); #ifdef _MGHAVE_MENU - sg_DesktopMenu = dskCreateDesktopMenu (); + sg_DesktopMenu = dskCreateDesktopMenu (); +#endif + break; + + case MSG_REINITSESSION: + if (wParam) + __mg_init_local_sys_text (); + +#ifdef _MGHAVE_MENU + if (sg_DesktopMenu) { + DestroyMenu (sg_DesktopMenu); + sg_DesktopMenu = 0; + } + + sg_DesktopMenu = dskCreateDesktopMenu (); #endif - break; + SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, 0); + break; - case MSG_REINITSESSION: - if (wParam) - __mg_init_local_sys_text (); + case MSG_ENDSESSION: + if ( + HAS_NO_MAINWINDOW() +#ifdef _MGRM_THREADS + && __mg_enter_terminategui +#endif + ) { + __mg_screensaver_destroy(); + + if (hDesktopDC) + ReleaseDC (hDesktopDC); + hDesktopDC = 0; #ifdef _MGHAVE_MENU if (sg_DesktopMenu) { DestroyMenu (sg_DesktopMenu); sg_DesktopMenu = 0; } - - sg_DesktopMenu = dskCreateDesktopMenu (); #endif + if(dsk_ops->deinit) + dsk_ops->deinit(dt_context); - SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, 0); - break; + PostQuitMessage (HWND_DESKTOP); - case MSG_ENDSESSION: - if ( - HAS_NO_MAINWINDOW() -#ifdef _MGRM_THREADS - && __mg_enter_terminategui -#endif - ) { - __mg_screensaver_destroy(); - - if (hDesktopDC) ReleaseDC (hDesktopDC); - hDesktopDC = 0; - -#ifdef _MGHAVE_MENU - if (sg_DesktopMenu) { - DestroyMenu (sg_DesktopMenu); - sg_DesktopMenu = 0; - } -#endif - if(dsk_ops->deinit) - dsk_ops->deinit(dt_context); - - PostQuitMessage (HWND_DESKTOP); - - return 1; - } - break; - - case MSG_ERASEDESKTOP: - - if(dsk_ops->paint_desktop) - dsk_ops->paint_desktop(dt_context, hDesktopDC, (PRECT)lParam); - - break; -#ifndef _MGRM_THREADS - case MSG_SETFOCUS: - { - HWND active_win = (HWND)dskGetActiveWindow(); - if (active_win) { - SendNotifyMessage ((HWND)active_win, MSG_SETFOCUS, 0, 0); - } - break; - } -#endif - - case MSG_PAINT: - { - RECT invrc; - - invrc.left = LOWORD(wParam); - invrc.top = HIWORD(wParam); - invrc.right = LOWORD(lParam); - invrc.bottom = HIWORD(lParam); - - dskRefreshAllWindow (&invrc); + return 1; } break; - case MSG_BROADCASTMSG: - return dskBroadcastMessage ((PMSG)lParam); - - case MSG_REGISTERWNDCLASS: - return AddNewControlClass ((PWNDCLASS)lParam); - - case MSG_UNREGISTERWNDCLASS: - return gui_DeleteControlClass ((const char*)lParam); - - case MSG_NEWCTRLINSTANCE: - return dskOnNewCtrlInstance ((PCONTROL)wParam, (PCONTROL)lParam); - - case MSG_REMOVECTRLINSTANCE: - return dskOnRemoveCtrlInstance ((PCONTROL)wParam, (PCONTROL)lParam); - - case MSG_GETCTRLCLASSINFO: - return (LRESULT)gui_GetControlClassInfo ((const char*)lParam); - - case MSG_CTRLCLASSDATAOP: - return (LRESULT)gui_ControlClassDataOp (wParam, (WNDCLASS*)lParam); - - case MSG_REGISTERKEYHOOK: - return (LRESULT)dskRegisterKeyHook ((void*)wParam, - (MSGHOOK)lParam); - - case MSG_REGISTERMOUSEHOOK: - return (LRESULT)dskRegisterMouseHook ((void*)wParam, - (MSGHOOK)lParam); - - case MSG_IME_REGISTER: - return dskRegisterIMEWnd ((HWND)wParam); - - case MSG_IME_UNREGISTER: - return dskUnregisterIMEWnd ((HWND)wParam); - - case MSG_IME_SETSTATUS: - return dskSetIMEStatus ((int)wParam, (int)lParam); - - case MSG_IME_SET_TARGET_INFO: - return dskSetIMETargetInfo ((IME_TARGET_INFO*)lParam); - - case MSG_IME_GET_TARGET_INFO: - return dskGetIMETargetInfo ((IME_TARGET_INFO*)lParam); - - case MSG_IME_GETSTATUS: - return dskGetIMEStatus ((int)wParam); + case MSG_ERASEDESKTOP: + if (dsk_ops->paint_desktop) + dsk_ops->paint_desktop(dt_context, hDesktopDC, (PRECT)lParam); + break; #ifndef _MGRM_THREADS - case MSG_SRVNOTIFY: - BroadcastMessage (MSG_SRVNOTIFY, wParam, lParam); + case MSG_SETFOCUS: { + HWND active_win = (HWND)dskGetActiveWindow(); + if (active_win) { + SendNotifyMessage ((HWND)active_win, MSG_SETFOCUS, 0, 0); + } + break; + } +#endif + + case MSG_PAINT: { + RECT invrc; + + invrc.left = LOWORD(wParam); + invrc.top = HIWORD(wParam); + invrc.right = LOWORD(lParam); + invrc.bottom = HIWORD(lParam); + + dskRefreshAllWindow (&invrc); + break; + } + + case MSG_BROADCASTMSG: + return dskBroadcastMessage ((PMSG)lParam); + + case MSG_REGISTERWNDCLASS: + return AddNewControlClass ((PWNDCLASS)lParam); + + case MSG_UNREGISTERWNDCLASS: + return gui_DeleteControlClass ((const char*)lParam); + + case MSG_NEWCTRLINSTANCE: + return dskOnNewCtrlInstance ((PCONTROL)wParam, (PCONTROL)lParam); + + case MSG_REMOVECTRLINSTANCE: + return dskOnRemoveCtrlInstance ((PCONTROL)wParam, (PCONTROL)lParam); + + case MSG_GETCTRLCLASSINFO: + return (LRESULT)gui_GetControlClassInfo ((const char*)lParam); + + case MSG_CTRLCLASSDATAOP: + return (LRESULT)gui_ControlClassDataOp (wParam, (WNDCLASS*)lParam); + + case MSG_REGISTERKEYHOOK: + return (LRESULT)dskRegisterKeyHook ((void*)wParam, + (MSGHOOK)lParam); + + case MSG_REGISTERMOUSEHOOK: + return (LRESULT)dskRegisterMouseHook ((void*)wParam, + (MSGHOOK)lParam); + + case MSG_IME_REGISTER: + return dskRegisterIMEWnd ((HWND)wParam); + + case MSG_IME_UNREGISTER: + return dskUnregisterIMEWnd ((HWND)wParam); + + case MSG_IME_SETSTATUS: + return dskSetIMEStatus ((int)wParam, (int)lParam); + + case MSG_IME_SET_TARGET_INFO: + return dskSetIMETargetInfo ((IME_TARGET_INFO*)lParam); + + case MSG_IME_GET_TARGET_INFO: + return dskGetIMETargetInfo ((IME_TARGET_INFO*)lParam); + + case MSG_IME_GETSTATUS: + return dskGetIMEStatus ((int)wParam); + +#ifndef _MGRM_THREADS + case MSG_SRVNOTIFY: + BroadcastMessage (MSG_SRVNOTIFY, wParam, lParam); break; #endif - case MSG_TIMEOUT: - BroadcastMessage (MSG_IDLE, wParam, 0); - break; - case MSG_DT_KEYLONGPRESS: - case MSG_DT_KEYALWAYSPRESS: - case MSG_DT_KEYDOWN: - case MSG_DT_CHAR: - case MSG_DT_KEYUP: - case MSG_DT_SYSKEYDOWN: - case MSG_DT_SYSCHAR: - case MSG_DT_SYSKEYUP: - if(dsk_ops->keyboard_handler) - dsk_ops->keyboard_handler(dt_context, message, wParam, lParam); - break; + case MSG_TIMEOUT: + BroadcastMessage (MSG_IDLE, wParam, 0); + break; + + case MSG_DT_KEYLONGPRESS: + case MSG_DT_KEYALWAYSPRESS: + case MSG_DT_KEYDOWN: + case MSG_DT_CHAR: + case MSG_DT_KEYUP: + case MSG_DT_SYSKEYDOWN: + case MSG_DT_SYSCHAR: + case MSG_DT_SYSKEYUP: + if(dsk_ops->keyboard_handler) + dsk_ops->keyboard_handler(dt_context, message, wParam, lParam); + break; + #ifdef _MGHAVE_MENU - case MSG_DT_RBUTTONUP: - dskUpdateDesktopMenu (sg_DesktopMenu); + case MSG_DT_RBUTTONUP: + dskUpdateDesktopMenu (sg_DesktopMenu); #endif - case MSG_DT_LBUTTONDOWN: - case MSG_DT_LBUTTONUP: - case MSG_DT_LBUTTONDBLCLK: - case MSG_DT_MOUSEMOVE: - case MSG_DT_RBUTTONDOWN: - case MSG_DT_RBUTTONDBLCLK: - case MSG_DT_MBUTTONDOWN: - case MSG_DT_MBUTTONDBLCLK: - case MSG_DT_MBUTTONUP: - if(dsk_ops->mouse_handler) - dsk_ops->mouse_handler(dt_context, message, wParam, lParam); - break; + case MSG_DT_LBUTTONDOWN: + case MSG_DT_LBUTTONUP: + case MSG_DT_LBUTTONDBLCLK: + case MSG_DT_MOUSEMOVE: + case MSG_DT_RBUTTONDOWN: + case MSG_DT_RBUTTONDBLCLK: + case MSG_DT_MBUTTONDOWN: + case MSG_DT_MBUTTONDBLCLK: + case MSG_DT_MBUTTONUP: + if(dsk_ops->mouse_handler) + dsk_ops->mouse_handler(dt_context, message, wParam, lParam); + break; - case MSG_TIMER: // per 0.01s - { - static DWORD uCounter = 0; + // per 0.01s + case MSG_TIMER: { + static DWORD uCounter = 0; #ifndef _MGRM_THREADS - static DWORD blink_counter = 0; - static DWORD sg_old_counter = 0; + static DWORD blink_counter = 0; + static DWORD sg_old_counter = 0; - if (sg_old_counter == 0) - sg_old_counter = __mg_timer_counter; - - mg_dispatch_timer_message (__mg_timer_counter - sg_old_counter); + if (sg_old_counter == 0) sg_old_counter = __mg_timer_counter; - if (__mg_timer_counter < (blink_counter + 10)) - break; + mg_dispatch_timer_message (__mg_timer_counter - sg_old_counter); + sg_old_counter = __mg_timer_counter; - uCounter += (__mg_timer_counter - blink_counter) * 10; - blink_counter = __mg_timer_counter; + if (__mg_timer_counter < (blink_counter + 10)) + break; + + uCounter += (__mg_timer_counter - blink_counter) * 10; + blink_counter = __mg_timer_counter; #else - static DWORD blink_counter = 0; - static DWORD sg_old_counter = 0; + static DWORD blink_counter = 0; + static DWORD sg_old_counter = 0; - if (__mg_quiting_stage < 0) { - int slot; - PMSGQUEUE pMsgQueue; - ZORDERNODE* nodes = GET_ZORDERNODE(__mg_zorder_info); - PMAINWIN pWin; + if (__mg_quiting_stage < 0) { + int slot; + PMSGQUEUE pMsgQueue; + ZORDERNODE* nodes = GET_ZORDERNODE(__mg_zorder_info); + PMAINWIN pWin; - /* XXX: wake up other theads */ - for (slot=__mg_zorder_info->first_topmost; slot > 0; slot = nodes[slot].next) { - pWin = (PMAINWIN)(nodes[slot].hwnd); - if (pWin && (pWin->WinType != TYPE_CONTROL) && (pWin->pHosting == NULL)) { - if ((pMsgQueue = kernel_GetMsgQueue((HWND)pWin))) { - POST_MSGQ(pMsgQueue); - } + /* XXX: wake up other theads */ + for (slot=__mg_zorder_info->first_topmost; + slot > 0; slot = nodes[slot].next) { + pWin = (PMAINWIN)(nodes[slot].hwnd); + if (pWin && (pWin->WinType != TYPE_CONTROL) && + (pWin->pHosting == NULL)) { + if ((pMsgQueue = kernel_GetMsgQueue((HWND)pWin))) { + POST_MSGQ(pMsgQueue); } } - for (slot = __mg_zorder_info->first_normal; slot > 0; slot = nodes[slot].next) { - pWin = (PMAINWIN)(nodes[slot].hwnd); - if (pWin && (pWin->WinType == TYPE_MAINWIN) && (pWin->pHosting == NULL)){ - if ((pMsgQueue = kernel_GetMsgQueue((HWND)pWin))) { - POST_MSGQ(pMsgQueue); - } + } + for (slot = __mg_zorder_info->first_normal; + slot > 0; slot = nodes[slot].next) { + pWin = (PMAINWIN)(nodes[slot].hwnd); + if (pWin && (pWin->WinType == TYPE_MAINWIN) && + (pWin->pHosting == NULL)){ + if ((pMsgQueue = kernel_GetMsgQueue((HWND)pWin))) { + POST_MSGQ(pMsgQueue); } } - - if (__mg_quiting_stage > _MG_QUITING_STAGE_FORCE && __mg_quiting_stage <= _MG_QUITING_STAGE_START) { - -- __mg_quiting_stage; - /* printf("try to quit %d\n", __mg_quiting_stage); */ - }else if (__mg_quiting_stage <= _MG_QUITING_STAGE_FORCE) { - /* printf("force to quit !!!\n"); */ - } - - if (__mg_quiting_stage > _MG_QUITING_STAGE_DESKTOP - && HAS_NO_MAINWINDOW() - && __mg_enter_terminategui /* Let Desktop wait for MiniGUIMain() */ - ) { - __mg_quiting_stage = _MG_QUITING_STAGE_DESKTOP; - }else if (__mg_quiting_stage <= _MG_QUITING_STAGE_DESKTOP) { - PostMessage (HWND_DESKTOP, MSG_ENDSESSION, 0, 0); - } } - if (MG_UNLIKELY(sg_old_counter == 0)) - sg_old_counter = __mg_timer_counter; - mg_dispatch_timer_message (__mg_timer_counter - sg_old_counter); - sg_old_counter = __mg_timer_counter; + if (__mg_quiting_stage > _MG_QUITING_STAGE_FORCE && + __mg_quiting_stage <= _MG_QUITING_STAGE_START) { + __mg_quiting_stage--; + } + else if (__mg_quiting_stage <= _MG_QUITING_STAGE_FORCE) { + /* printf("force to quit !!!\n"); */ + } - if (__mg_timer_counter < (blink_counter + 10)) - break; - - uCounter += (__mg_timer_counter - blink_counter) * 10; - blink_counter = __mg_timer_counter; -#endif - if (sg_hCaretWnd != 0 - && gui_GetMainWindowPtrOfControl (sg_hCaretWnd) == dskGetActiveWindow() - && uCounter >= sg_uCaretBTime) { - PostMessage (sg_hCaretWnd, MSG_CARETBLINK, 0, 0); - uCounter = 0; + if (__mg_quiting_stage > _MG_QUITING_STAGE_DESKTOP + && HAS_NO_MAINWINDOW() + && __mg_enter_terminategui) { + /* Let Desktop wait for MiniGUIMain() */ + __mg_quiting_stage = _MG_QUITING_STAGE_DESKTOP; + } else if (__mg_quiting_stage <= _MG_QUITING_STAGE_DESKTOP) { + PostMessage (HWND_DESKTOP, MSG_ENDSESSION, 0, 0); } } + + if (MG_UNLIKELY(sg_old_counter == 0)) + sg_old_counter = __mg_timer_counter; + mg_dispatch_timer_message (__mg_timer_counter - sg_old_counter); + sg_old_counter = __mg_timer_counter; + + if (__mg_timer_counter < (blink_counter + 10)) + break; + + uCounter += (__mg_timer_counter - blink_counter) * 10; + blink_counter = __mg_timer_counter; +#endif + if (sg_hCaretWnd != 0 + && gui_GetMainWindowPtrOfControl (sg_hCaretWnd) == + dskGetActiveWindow() + && uCounter >= sg_uCaretBTime) { + PostMessage (sg_hCaretWnd, MSG_CARETBLINK, 0, 0); + uCounter = 0; + } + break; + } + + default: break; } diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index afa3a79e..0386258c 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -586,7 +586,7 @@ static intptr_t cliForceCloseMenu (void) return ret; } -#endif +#endif /* defined _MGHAVE_MENU */ static intptr_t cliEnableWindow (PMAINWIN pWin, int flags) { @@ -745,7 +745,7 @@ void __mg_start_server_desktop (void) InitClipRgn (&sg_UpdateRgn, &sg_FreeClipRectList); MAKE_REGION_INFINITE(&sg_UpdateRgn); -#endif +#endif /* not defiend _MGSCHEMA_COMPOSITING */ SendMessage (HWND_DESKTOP, MSG_STARTSESSION, 0, 0); SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, 0); @@ -808,23 +808,6 @@ static inline int srvFreeZOrderMaskRect (int cli, int idx_znode) return FreeZOrderMaskRect (cli, idx_znode); } -int __kernel_change_z_node_mask_rect (HWND pWin, const RECT4MASK* rc, int nr_rc) -{ - if (!rc || !nr_rc) - return -1; - - if (mgIsServer) { - return srvAllocZOrderMaskRect (0, - ((PMAINWIN)pWin)->idx_znode, - get_znode_flags_from_style((PMAINWIN)pWin), - rc, nr_rc); - } - else { - cliFreeZOrderMaskRect ((PMAINWIN)pWin); - return cliAllocZOrderMaskRect (pWin, rc, nr_rc); - } -} - ON_ZNODE_OPERATION OnZNodeOperation; static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win, @@ -847,7 +830,7 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win, close (fd); } else { - _ERR_PRINTF("KERNEL: not server but fd for shared surface is not valid\n"); + _ERR_PRINTF("KERNEL: not server but fd for shared surface is invalid\n"); return -1; } @@ -1009,7 +992,6 @@ static int srvMoveWindow (int cli, int idx_znode, const RECT* rcWin, _ERR_PRINTF("KERNEL: failed to attach to shared surface\n"); return -1; } - #endif /* def _MGSCHEMA_COMPOSITING */ ret = dskMoveWindow (cli, idx_znode, memdc, rcWin); @@ -1158,51 +1140,51 @@ int __mg_do_drag_drop_window (int msg, int x, int y) _dd_info.rc.right, _dd_info.rc.bottom); switch (_dd_info.location) { - case HT_CAPTION: - OffsetRect (&_dd_info.rc, - x - _dd_info.last_x, - y - _dd_info.last_y); - break; + case HT_CAPTION: + OffsetRect (&_dd_info.rc, + x - _dd_info.last_x, + y - _dd_info.last_y); + break; - case HT_BORDER_TOP: - _dd_info.rc.top += y - _dd_info.last_y; - break; + case HT_BORDER_TOP: + _dd_info.rc.top += y - _dd_info.last_y; + break; - case HT_BORDER_BOTTOM: - _dd_info.rc.bottom += y - _dd_info.last_y; - break; + case HT_BORDER_BOTTOM: + _dd_info.rc.bottom += y - _dd_info.last_y; + break; - case HT_BORDER_LEFT: - _dd_info.rc.left += x - _dd_info.last_x; - break; + case HT_BORDER_LEFT: + _dd_info.rc.left += x - _dd_info.last_x; + break; - case HT_BORDER_RIGHT: - _dd_info.rc.right += x - _dd_info.last_x; - break; + case HT_BORDER_RIGHT: + _dd_info.rc.right += x - _dd_info.last_x; + break; - case HT_CORNER_TL: - _dd_info.rc.left += x - _dd_info.last_x; - _dd_info.rc.top += y - _dd_info.last_y; - break; + case HT_CORNER_TL: + _dd_info.rc.left += x - _dd_info.last_x; + _dd_info.rc.top += y - _dd_info.last_y; + break; - case HT_CORNER_TR: - _dd_info.rc.right += x - _dd_info.last_x; - _dd_info.rc.top += y - _dd_info.last_y; - break; + case HT_CORNER_TR: + _dd_info.rc.right += x - _dd_info.last_x; + _dd_info.rc.top += y - _dd_info.last_y; + break; - case HT_CORNER_BL: - _dd_info.rc.left += x - _dd_info.last_x; - _dd_info.rc.bottom += y - _dd_info.last_y; - break; + case HT_CORNER_BL: + _dd_info.rc.left += x - _dd_info.last_x; + _dd_info.rc.bottom += y - _dd_info.last_y; + break; - case HT_CORNER_BR: - _dd_info.rc.right += x - _dd_info.last_x; - _dd_info.rc.bottom += y - _dd_info.last_y; - break; + case HT_CORNER_BR: + _dd_info.rc.right += x - _dd_info.last_x; + _dd_info.rc.bottom += y - _dd_info.last_y; + break; - default: - _WRN_PRINTF ("KERNEL>Desktop: __mg_do_drag_drop_window: bad location\n"); - break; + default: + _WRN_PRINTF ("bad location\n"); + break; } FocusRect (HDC_SCREEN_SYS, _dd_info.rc.left, _dd_info.rc.top, @@ -1260,8 +1242,8 @@ static int srvChangeCaption (int cli, int idx_znode, const char *caption) if (caplen < 32) { strcpy (nodes[idx_znode].caption, caption); } else { - get_text_char_pos (menufont, caption, caplen, (32 - 3), /* '...' = 3*/ - &fit_chars, pos_chars); + get_text_char_pos (menufont, caption, caplen, + (32 - 3), /* '...' = 3*/ &fit_chars, pos_chars); memcpy(nodes[idx_znode].caption, caption, pos_chars[fit_chars-1]); strcpy ((nodes[idx_znode].caption + pos_chars[fit_chars-1]), @@ -1316,14 +1298,14 @@ intptr_t __mg_do_zorder_maskrect_operation (int cli, #endif switch (info->id_op) { - case ID_ZOOP_MASKRECT_SET: - ret = srvAllocZOrderMaskRect (cli, info->idx_znode, - info->flags, info->rc, - info->nr_maskrect); - break; - case ID_ZOOP_MASKRECT_FREE: - ret = srvFreeZOrderMaskRect (cli, info->idx_znode); - break; + case ID_ZOOP_MASKRECT_SET: + ret = srvAllocZOrderMaskRect (cli, info->idx_znode, + info->flags, info->rc, + info->nr_maskrect); + break; + case ID_ZOOP_MASKRECT_FREE: + ret = srvFreeZOrderMaskRect (cli, info->idx_znode); + break; } /* Since 4.2.0 */ @@ -1908,10 +1890,11 @@ static int dskAddNewMainWindow (PMAINWIN pWin, const COMPOSITINGINFO* ct_info) if (mgIsServer) { 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, - ct_info->type, ct_info->arg); + pWin->idx_znode = srvAllocZOrderNode (0, (HWND)pWin, + (HWND)pWin->pMainWin, + get_znode_flags_from_style (pWin), + &rcWin, pWin->spCaption, 0, 0, -1, + ct_info->type, ct_info->arg); } else pWin->idx_znode = cliAllocZOrderNode (pWin, ct_info); @@ -2000,7 +1983,7 @@ static void dskRemoveMainWindow (PMAINWIN pWin) srvFreeZOrderNode (0, pWin->idx_znode); } else { - cliFreeZOrderMaskRect(pWin); + cliFreeZOrderMaskRect (pWin); cliFreeZOrderNode (pWin); } @@ -2560,6 +2543,7 @@ static HWND dskSetCaptureWindow (PMAINWIN pWin) return old; } +/* TODO: bad implementation */ static HWND dskGetNextMainWindow (PMAINWIN pWin) { HWND hWnd = HWND_NULL; @@ -2570,7 +2554,8 @@ static HWND dskGetNextMainWindow (PMAINWIN pWin) if (pWin) { last_type = nodes[pWin->idx_znode].flags & ZOF_TYPE_MASK; slot = nodes[pWin->idx_znode].next; - }else{ + } + else { last_type = ZOF_TYPE_GLOBAL; slot = __mg_zorder_info->first_global; } @@ -2676,6 +2661,26 @@ static BOOL dskSetMainWinAlwaysTop (PMAINWIN pWin, BOOL fSet) return TRUE; } +/* Since 4.2.0 */ +static int dskSetWindowMask (HWND pWin, const WINMASKINFO* mask_info) +{ + if (!mask_info->rcs || !mask_info->nr_rcs) + return -1; + + if (mgIsServer) { + /* XXX: free first */ + srvFreeZOrderMaskRect (0, ((PMAINWIN)pWin)->idx_znode); + return srvAllocZOrderMaskRect (0, + ((PMAINWIN)pWin)->idx_znode, + get_znode_flags_from_style((PMAINWIN)pWin), + mask_info->rcs, mask_info->nr_rcs); + } + else { + cliFreeZOrderMaskRect ((PMAINWIN)pWin); + return cliAllocZOrderMaskRect (pWin, mask_info->rcs, mask_info->nr_rcs); + } +} + /* Since 4.2.0 */ BOOL __mg_move_client_to_layer (MG_Client* client, MG_Layer* dst_layer) { @@ -2754,131 +2759,134 @@ static BOOL dskSetMainWinCompositing (PMAINWIN pWin, const COMPOSITINGINFO* info if (srvSetZNodeCompositing (0, pWin->idx_znode, info->type, info->arg)) return FALSE; } - else { - if (cliSetMainWinCompositing (pWin, info)) - return FALSE; + else if (cliSetMainWinCompositing (pWin, info)) { + return FALSE; } return TRUE; } #endif /* defined _MGSCHEMA_COMPOSITING */ -static LRESULT dskWindowMessageHandler (UINT message, PMAINWIN pWin, LPARAM lParam) +static LRESULT dskWindowMessageHandler (UINT message, + PMAINWIN pWin, LPARAM lParam) { switch (message) { - case MSG_ADDNEWMAINWIN: - return dskAddNewMainWindow (pWin, (const COMPOSITINGINFO *)lParam); + case MSG_ADDNEWMAINWIN: + return dskAddNewMainWindow (pWin, (const COMPOSITINGINFO *)lParam); - case MSG_REMOVEMAINWIN: - dskRemoveMainWindow (pWin); - break; + case MSG_REMOVEMAINWIN: + dskRemoveMainWindow (pWin); + break; - case MSG_MOVETOTOPMOST: - dskMoveToTopMost (pWin, RCTM_MESSAGE, 0); - break; + case MSG_MOVETOTOPMOST: + dskMoveToTopMost (pWin, RCTM_MESSAGE, 0); + break; - case MSG_SHOWMAINWIN: - dskShowMainWindow (pWin, TRUE); - break; + case MSG_SHOWMAINWIN: + dskShowMainWindow (pWin, TRUE); + break; - case MSG_HIDEMAINWIN: - dskHideMainWindow (pWin); - break; + case MSG_HIDEMAINWIN: + dskHideMainWindow (pWin); + break; - case MSG_MOVEMAINWIN: - if (pWin->WinType == TYPE_CONTROL) - dskMoveGlobalControl (pWin, (RECT*)lParam); - else - dskMoveMainWindow (pWin, (RECT*)lParam); - break; + case MSG_MOVEMAINWIN: + if (pWin->WinType == TYPE_CONTROL) + dskMoveGlobalControl (pWin, (RECT*)lParam); + else + dskMoveMainWindow (pWin, (RECT*)lParam); + break; - case MSG_GETACTIVEMAIN: - return (LRESULT)dskGetActiveWindow (NULL); + case MSG_GETACTIVEMAIN: + return (LRESULT)dskGetActiveWindow (NULL); - case MSG_SETACTIVEMAIN: - return (LRESULT)dskSetActiveWindow (pWin); + case MSG_SETACTIVEMAIN: + return (LRESULT)dskSetActiveWindow (pWin); - case MSG_GETCAPTURE: - return (LRESULT)dskGetCaptureWindow (); + case MSG_GETCAPTURE: + return (LRESULT)dskGetCaptureWindow (); - case MSG_SETCAPTURE: - return (LRESULT)dskSetCaptureWindow (pWin); + case MSG_SETCAPTURE: + return (LRESULT)dskSetCaptureWindow (pWin); #ifdef _MGHAVE_MENU - case MSG_TRACKPOPUPMENU: - return dskStartTrackPopupMenu ((PTRACKMENUINFO)lParam); + case MSG_TRACKPOPUPMENU: + return dskStartTrackPopupMenu ((PTRACKMENUINFO)lParam); - case MSG_ENDTRACKMENU: - return dskEndTrackPopupMenu ((PTRACKMENUINFO)lParam); + case MSG_ENDTRACKMENU: + return dskEndTrackPopupMenu ((PTRACKMENUINFO)lParam); - case MSG_CLOSEMENU: - dskCloseMenu (); - break; + case MSG_CLOSEMENU: + dskCloseMenu (); + break; #endif - case MSG_SCROLLMAINWIN: - dskScrollMainWindow (pWin, (PSCROLLWINDOWINFO)lParam); + case MSG_SCROLLMAINWIN: + dskScrollMainWindow (pWin, (PSCROLLWINDOWINFO)lParam); + break; + + case MSG_CARET_CREATE: + sg_hCaretWnd = (HWND)pWin; + sg_uCaretBTime = pWin->pCaretInfo->uTime; + return 0; + + case MSG_CARET_DESTROY: + sg_hCaretWnd = 0; + return 0; + + case MSG_ENABLEMAINWIN: + dskEnableWindow (pWin, lParam); + break; + + case MSG_ISENABLED: + return !(pWin->dwStyle & WS_DISABLED); + + case MSG_SETWINCURSOR: + { + HCURSOR old = pWin->hCursor; + + pWin->hCursor = (HCURSOR)lParam; + return (LRESULT)old; + } + + case MSG_GETNEXTMAINWIN: + return (LRESULT)dskGetNextMainWindow (pWin); + + case MSG_SHOWGLOBALCTRL: + { + dskMoveGlobalControl (pWin, (RECT*)&(pWin->left)); + dskMoveToTopMost (pWin, RCTM_SHOWCTRL, 0); + dskSetPrimitiveChildren (pWin, TRUE); break; + } - case MSG_CARET_CREATE: - sg_hCaretWnd = (HWND)pWin; - sg_uCaretBTime = pWin->pCaretInfo->uTime; - return 0; + case MSG_HIDEGLOBALCTRL: + dskHideMainWindow (pWin); + dskSetPrimitiveChildren (pWin, FALSE); + break; - case MSG_CARET_DESTROY: - sg_hCaretWnd = 0; - return 0; + case MSG_STARTDRAGWIN: + return dskStartDragWindow (pWin, (DRAGINFO*)lParam); - case MSG_ENABLEMAINWIN: - dskEnableWindow (pWin, lParam); - break; + case MSG_CANCELDRAGWIN: + return dskCancelDragWindow (pWin); - case MSG_ISENABLED: - return !(pWin->dwStyle & WS_DISABLED); + case MSG_CHANGECAPTION: + return dskChangeCaption (pWin); - case MSG_SETWINCURSOR: - { - HCURSOR old = pWin->hCursor; + /* Since 4.2.0 */ + case MSG_SETALWAYSTOP: + return dskSetMainWinAlwaysTop (pWin, (BOOL)lParam); - pWin->hCursor = (HCURSOR)lParam; - return (LRESULT)old; - } - - case MSG_GETNEXTMAINWIN: - return (LRESULT)dskGetNextMainWindow (pWin); - - case MSG_SHOWGLOBALCTRL: - { - dskMoveGlobalControl (pWin, (RECT*)&(pWin->left)); - dskMoveToTopMost (pWin, RCTM_SHOWCTRL, 0); - dskSetPrimitiveChildren (pWin, TRUE); - break; - } - - case MSG_HIDEGLOBALCTRL: - dskHideMainWindow (pWin); - dskSetPrimitiveChildren (pWin, FALSE); - break; - - case MSG_STARTDRAGWIN: - return dskStartDragWindow (pWin, (DRAGINFO*)lParam); - - case MSG_CANCELDRAGWIN: - return dskCancelDragWindow (pWin); - - case MSG_CHANGECAPTION: - return dskChangeCaption (pWin); - - /* Since 4.2.0 */ - case MSG_SETALWAYSTOP: - return dskSetMainWinAlwaysTop (pWin, (BOOL)lParam); + /* Since 4.2.0 */ + case MSG_SETWINDOWMASK: + return dskSetWindowMask (pWin, (WINMASKINFO*)lParam); #ifdef _MGSCHEMA_COMPOSITING - /* Since 4.2.0 */ - case MSG_SETCOMPOSITING: - return dskSetMainWinCompositing (pWin, (const COMPOSITINGINFO*)lParam); + /* Since 4.2.0 */ + case MSG_SETCOMPOSITING: + return dskSetMainWinCompositing (pWin, (const COMPOSITINGINFO*)lParam); #endif - } return 0; @@ -2900,22 +2908,22 @@ HWND __mg_do_reghook_operation (int cli, const REGHOOKINFO* info) HWND ret = HWND_NULL; switch (info->id_op) { - case ID_REG_KEY: - ret = keyhook.hwnd; - keyhook.cli = cli; - keyhook.hwnd = info->hwnd; - keyhook.flag = info->flag; - break; + case ID_REG_KEY: + ret = keyhook.hwnd; + keyhook.cli = cli; + keyhook.hwnd = info->hwnd; + keyhook.flag = info->flag; + break; - case ID_REG_MOUSE: - ret = mousehook.hwnd; - mousehook.cli = cli; - mousehook.hwnd = info->hwnd; - mousehook.flag = info->flag; - break; + case ID_REG_MOUSE: + ret = mousehook.hwnd; + mousehook.cli = cli; + mousehook.hwnd = info->hwnd; + mousehook.flag = info->flag; + break; - default: - break; + default: + break; } return ret; } @@ -3213,27 +3221,27 @@ static int check_capture (int message) && mgs_captured_main_win != NULL) { switch (message) { - case MSG_LBUTTONDOWN: - case MSG_RBUTTONDOWN: - case MSG_MBUTTONDOWN: - if (mgs_captured_by != message) - return 1; - break; + case MSG_LBUTTONDOWN: + case MSG_RBUTTONDOWN: + case MSG_MBUTTONDOWN: + if (mgs_captured_by != message) + return 1; + break; - case MSG_LBUTTONUP: - if (mgs_captured_by != MSG_LBUTTONDOWN) - return 1; - break; + case MSG_LBUTTONUP: + if (mgs_captured_by != MSG_LBUTTONDOWN) + return 1; + break; - case MSG_RBUTTONUP: - if (mgs_captured_by != MSG_RBUTTONDOWN) - return 1; - break; + case MSG_RBUTTONUP: + if (mgs_captured_by != MSG_RBUTTONDOWN) + return 1; + break; - case MSG_MBUTTONUP: - if (mgs_captured_by != MSG_MBUTTONDOWN) - return 1; - break; + case MSG_MBUTTONUP: + if (mgs_captured_by != MSG_MBUTTONDOWN) + return 1; + break; } } @@ -3281,157 +3289,157 @@ static int dskMouseMessageHandler (int message, WPARAM flags, int x, int y) } switch (message) { - case MSG_MOUSEMOVE: - if (mgs_captured_main_win != (void *)HWND_INVALID) { - if (mgs_captured_main_win) - PostMessage((HWND)mgs_captured_main_win, MSG_NCMOUSEMOVE, - CapHitCode, MAKELONG (x, y)); - else - PostMessage(HWND_DESKTOP, MSG_DT_MOUSEMOVE, - pUnderPointer == NULL, MAKELONG (x, y)); - break; - } + case MSG_MOUSEMOVE: + if (mgs_captured_main_win != (void *)HWND_INVALID) { + if (mgs_captured_main_win) + PostMessage((HWND)mgs_captured_main_win, MSG_NCMOUSEMOVE, + CapHitCode, MAKELONG (x, y)); + else + PostMessage(HWND_DESKTOP, MSG_DT_MOUSEMOVE, + pUnderPointer == NULL, MAKELONG (x, y)); + break; + } - if (pUnderPointer) { - HCURSOR def_cursor = GetDefaultCursor (); - if (UndHitCode == HT_CLIENT) { - if (def_cursor) - SetCursor (def_cursor); - PostMessage ((HWND)pUnderPointer, MSG_SETCURSOR, - UndHitCode, MAKELONG (cx, cy)); - PostMessage((HWND)pUnderPointer, MSG_NCMOUSEMOVE, - UndHitCode, MAKELONG (x, y)); - PostMessage((HWND)pUnderPointer, MSG_MOUSEMOVE, - flags, MAKELONG (cx, cy)); - } - else { - if (def_cursor) - SetCursor (def_cursor); - PostMessage ((HWND)pUnderPointer, MSG_NCSETCURSOR, - UndHitCode, MAKELONG (x, y)); - PostMessage((HWND)pUnderPointer, MSG_NCMOUSEMOVE, - UndHitCode, MAKELONG (x, y)); - } + if (pUnderPointer) { + HCURSOR def_cursor = GetDefaultCursor (); + if (UndHitCode == HT_CLIENT) { + if (def_cursor) + SetCursor (def_cursor); + PostMessage ((HWND)pUnderPointer, MSG_SETCURSOR, + UndHitCode, MAKELONG (cx, cy)); + PostMessage((HWND)pUnderPointer, MSG_NCMOUSEMOVE, + UndHitCode, MAKELONG (x, y)); + PostMessage((HWND)pUnderPointer, MSG_MOUSEMOVE, + flags, MAKELONG (cx, cy)); } + else { + if (def_cursor) + SetCursor (def_cursor); + PostMessage ((HWND)pUnderPointer, MSG_NCSETCURSOR, + UndHitCode, MAKELONG (x, y)); + PostMessage((HWND)pUnderPointer, MSG_NCMOUSEMOVE, + UndHitCode, MAKELONG (x, y)); + } + } break; - case MSG_LBUTTONDOWN: - case MSG_RBUTTONDOWN: - case MSG_MBUTTONDOWN: - if (check_capture (message)) /* ignore the event */ - break; + case MSG_LBUTTONDOWN: + case MSG_RBUTTONDOWN: + case MSG_MBUTTONDOWN: + if (check_capture (message)) /* ignore the event */ + break; - if (pUnderPointer) { + if (pUnderPointer) { #ifdef _MGHAVE_MENU - dskForceCloseMenu (); + dskForceCloseMenu (); #endif - if (pUnderPointer->dwStyle & WS_DISABLED) { - Ping (); - break; + if (pUnderPointer->dwStyle & WS_DISABLED) { + Ping (); + break; + } + + if (pCtrlPtrIn == NULL) { + if (!dskIsTopMost (pUnderPointer)) { + dskMoveToTopMost (pUnderPointer, + RCTM_CLICK, MAKELONG (x, y)); } - if (pCtrlPtrIn == NULL) { - if (!dskIsTopMost (pUnderPointer)) { - dskMoveToTopMost (pUnderPointer, - RCTM_CLICK, MAKELONG (x, y)); - } + if (pUnderPointer != + (PMAINWIN)dskSetActiveWindow (pUnderPointer)) + PostMessage ((HWND) pUnderPointer, + MSG_MOUSEACTIVE, UndHitCode, 0); + } - if (pUnderPointer != - (PMAINWIN)dskSetActiveWindow (pUnderPointer)) - PostMessage ((HWND) pUnderPointer, - MSG_MOUSEACTIVE, UndHitCode, 0); + if (UndHitCode != HT_CLIENT) { + if (UndHitCode & HT_NEEDCAPTURE) { + mgs_captured_main_win = pUnderPointer; + mgs_captured_by = message; } - - if (UndHitCode != HT_CLIENT) { - if (UndHitCode & HT_NEEDCAPTURE) { - mgs_captured_main_win = pUnderPointer; - mgs_captured_by = message; - } - else - mgs_captured_main_win = (void*)HWND_INVALID; - - PostMessage ((HWND)pUnderPointer, message + MSG_NCMOUSEOFF, - UndHitCode, MAKELONG (x, y)); - } - else { - PostMessage((HWND)pUnderPointer, message, - flags, MAKELONG(cx, cy)); + else mgs_captured_main_win = (void*)HWND_INVALID; - } - } - else { - dskSetActiveWindow (NULL); - mgs_captured_main_win = NULL; - PostMessage (HWND_DESKTOP, message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - } - break; - case MSG_LBUTTONUP: - case MSG_RBUTTONUP: - case MSG_MBUTTONUP: - if (check_capture (message)) /* ignore the event */ - break; - - if (mgs_captured_main_win != (void*)HWND_INVALID) { - if (mgs_captured_main_win) - PostMessage ((HWND)mgs_captured_main_win, - message + MSG_NCMOUSEOFF, - CapHitCode, MAKELONG (x, y)); - else if (!pUnderPointer) - PostMessage (HWND_DESKTOP, message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - - // mgs_captured_main_win = NULL; - mgs_captured_main_win = (void*)HWND_INVALID; - break; - } - else { - if (pUnderPointer) { - if (pUnderPointer->dwStyle & WS_DISABLED) { - break; - } - - if (UndHitCode == HT_CLIENT) { - PostMessage((HWND)pUnderPointer, message, - flags, MAKELONG (cx, cy)); - } - else { - PostMessage((HWND)pUnderPointer, - message + MSG_NCMOUSEOFF, - UndHitCode, MAKELONG (x, y)); - } - } - else - PostMessage (HWND_DESKTOP, message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); - } - break; - - case MSG_LBUTTONDBLCLK: - case MSG_RBUTTONDBLCLK: - case MSG_MBUTTONDBLCLK: - if (pUnderPointer) - { - if (pUnderPointer->dwStyle & WS_DISABLED) { - Ping (); - break; - } - - if(UndHitCode == HT_CLIENT) - PostMessage((HWND)pUnderPointer, message, - flags, MAKELONG(cx, cy)); - else - PostMessage((HWND)pUnderPointer, message + MSG_NCMOUSEOFF, + PostMessage ((HWND)pUnderPointer, message + MSG_NCMOUSEOFF, UndHitCode, MAKELONG (x, y)); } else { - PostMessage(HWND_DESKTOP, message + MSG_DT_MOUSEOFF, - flags, MAKELONG (x, y)); + PostMessage((HWND)pUnderPointer, message, + flags, MAKELONG(cx, cy)); + mgs_captured_main_win = (void*)HWND_INVALID; } + } + else { + dskSetActiveWindow (NULL); + mgs_captured_main_win = NULL; + PostMessage (HWND_DESKTOP, message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + } break; + case MSG_LBUTTONUP: + case MSG_RBUTTONUP: + case MSG_MBUTTONUP: + if (check_capture (message)) /* ignore the event */ + break; + + if (mgs_captured_main_win != (void*)HWND_INVALID) { + if (mgs_captured_main_win) + PostMessage ((HWND)mgs_captured_main_win, + message + MSG_NCMOUSEOFF, + CapHitCode, MAKELONG (x, y)); + else if (!pUnderPointer) + PostMessage (HWND_DESKTOP, message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + + // mgs_captured_main_win = NULL; + mgs_captured_main_win = (void*)HWND_INVALID; + break; + } + else { + if (pUnderPointer) { + if (pUnderPointer->dwStyle & WS_DISABLED) { + break; + } + + if (UndHitCode == HT_CLIENT) { + PostMessage((HWND)pUnderPointer, message, + flags, MAKELONG (cx, cy)); + } + else { + PostMessage((HWND)pUnderPointer, + message + MSG_NCMOUSEOFF, + UndHitCode, MAKELONG (x, y)); + } + } + else + PostMessage (HWND_DESKTOP, message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + } + break; + + case MSG_LBUTTONDBLCLK: + case MSG_RBUTTONDBLCLK: + case MSG_MBUTTONDBLCLK: + if (pUnderPointer) + { + if (pUnderPointer->dwStyle & WS_DISABLED) { + Ping (); + break; + } + + if(UndHitCode == HT_CLIENT) + PostMessage((HWND)pUnderPointer, message, + flags, MAKELONG(cx, cy)); + else + PostMessage((HWND)pUnderPointer, message + MSG_NCMOUSEOFF, + UndHitCode, MAKELONG (x, y)); + } + else { + PostMessage(HWND_DESKTOP, message + MSG_DT_MOUSEOFF, + flags, MAKELONG (x, y)); + } + + break; } return 0; @@ -3821,40 +3829,40 @@ static int znodes_of_this_client (void) static int cliSesseionMessageHandler (int message, WPARAM wParam, LPARAM lParam) { switch (message) { - case MSG_STARTSESSION: + case MSG_STARTSESSION: + __mg_init_local_sys_text (); + break; + + case MSG_REINITSESSION: + if (wParam) __mg_init_local_sys_text (); - break; + break; - case MSG_REINITSESSION: - if (wParam) - __mg_init_local_sys_text (); - break; + case MSG_ENDSESSION: + if (CLIENT_HAS_NO_MAINWINDOW()) { + PostQuitMessage (HWND_DESKTOP); + return 1; + } + break; - case MSG_ENDSESSION: - if (CLIENT_HAS_NO_MAINWINDOW()) { - PostQuitMessage (HWND_DESKTOP); - return 1; - } - break; - - default: - break; + default: + break; #if 0 - case MSG_ERASEDESKTOP: - case MSG_DT_KEYDOWN: - case MSG_DT_CHAR: - case MSG_DT_KEYUP: - case MSG_DT_SYSKEYDOWN: - case MSG_DT_SYSCHAR: - case MSG_DT_SYSKEYUP: - case MSG_DT_LBUTTONDOWN: - case MSG_DT_LBUTTONUP: - case MSG_DT_LBUTTONDBLCLK: - case MSG_DT_MOUSEMOVE: - case MSG_DT_RBUTTONDOWN: - case MSG_DT_RBUTTONDBLCLK: - case MSG_DT_RBUTTONUP: - break; + case MSG_ERASEDESKTOP: + case MSG_DT_KEYDOWN: + case MSG_DT_CHAR: + case MSG_DT_KEYUP: + case MSG_DT_SYSKEYDOWN: + case MSG_DT_SYSCHAR: + case MSG_DT_SYSKEYUP: + case MSG_DT_LBUTTONDOWN: + case MSG_DT_LBUTTONUP: + case MSG_DT_LBUTTONDBLCLK: + case MSG_DT_MOUSEMOVE: + case MSG_DT_RBUTTONDOWN: + case MSG_DT_RBUTTONDBLCLK: + case MSG_DT_RBUTTONUP: + break; #endif } @@ -4119,93 +4127,94 @@ static int srvSesseionMessageHandler (int message, WPARAM wParam, LPARAM lParam) static HDC hDesktopDC; switch (message) { - case MSG_STARTSESSION: + case MSG_STARTSESSION: + __mg_init_local_sys_text (); + hDesktopDC = GetDC (HWND_DESKTOP); + + if(dsk_ops->init) + dt_context = dsk_ops->init(); +#ifdef _MGHAVE_MENU + sg_DesktopMenu = srvCreateDesktopMenu (); +#endif + break; + + case MSG_REINITSESSION: + if (wParam) __mg_init_local_sys_text (); - hDesktopDC = GetDC (HWND_DESKTOP); - - if(dsk_ops->init) - dt_context = dsk_ops->init(); -#ifdef _MGHAVE_MENU - sg_DesktopMenu = srvCreateDesktopMenu (); -#endif - break; - - case MSG_REINITSESSION: - if (wParam) - __mg_init_local_sys_text (); #ifdef _MGHAVE_MENU - sg_DesktopMenu = srvCreateDesktopMenu (); + sg_DesktopMenu = srvCreateDesktopMenu (); #endif - SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, 0); - break; + SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0, 0); + break; - case MSG_ENDSESSION: - if (SERVER_HAS_NO_MAINWINDOW()) { - __mg_screensaver_destroy(); + case MSG_ENDSESSION: + if (SERVER_HAS_NO_MAINWINDOW()) { + __mg_screensaver_destroy(); - if (hDesktopDC) { - ReleaseDC (hDesktopDC); - hDesktopDC = 0; - } - -#ifdef _MGHAVE_MENU - if (sg_DesktopMenu) { - DestroyMenu (sg_DesktopMenu); - sg_DesktopMenu = 0; - } -#endif - - if(dsk_ops->deinit) { - dsk_ops->deinit(dt_context); - } - - PostQuitMessage (HWND_DESKTOP); - return 1; + if (hDesktopDC) { + ReleaseDC (hDesktopDC); + hDesktopDC = 0; } - break; - - case MSG_ERASEDESKTOP: - - if(dsk_ops->paint_desktop) - dsk_ops->paint_desktop(dt_context, hDesktopDC, (PRECT)lParam); - - break; - - case MSG_DT_KEYLONGPRESS: - case MSG_DT_KEYALWAYSPRESS: - case MSG_DT_KEYDOWN: - case MSG_DT_CHAR: - case MSG_DT_KEYUP: - case MSG_DT_SYSKEYDOWN: - case MSG_DT_SYSCHAR: - case MSG_DT_SYSKEYUP: - if(dsk_ops->keyboard_handler) - dsk_ops->keyboard_handler(dt_context, message, wParam, lParam); - break; #ifdef _MGHAVE_MENU - case MSG_DT_RBUTTONUP: - srvUpdateDesktopMenu (); + if (sg_DesktopMenu) { + DestroyMenu (sg_DesktopMenu); + sg_DesktopMenu = 0; + } #endif - case MSG_DT_LBUTTONDOWN: - case MSG_DT_LBUTTONUP: - case MSG_DT_LBUTTONDBLCLK: - case MSG_DT_MOUSEMOVE: - case MSG_DT_RBUTTONDOWN: - case MSG_DT_RBUTTONDBLCLK: - case MSG_DT_MBUTTONDOWN: - case MSG_DT_MBUTTONUP: - case MSG_DT_MBUTTONDBLCLK: - if(dsk_ops->mouse_handler) - dsk_ops->mouse_handler(dt_context, message, wParam, lParam); + + if(dsk_ops->deinit) { + dsk_ops->deinit(dt_context); + } + + PostQuitMessage (HWND_DESKTOP); + return 1; + } + break; + + case MSG_ERASEDESKTOP: + + if(dsk_ops->paint_desktop) + dsk_ops->paint_desktop(dt_context, hDesktopDC, (PRECT)lParam); + + break; + + case MSG_DT_KEYLONGPRESS: + case MSG_DT_KEYALWAYSPRESS: + case MSG_DT_KEYDOWN: + case MSG_DT_CHAR: + case MSG_DT_KEYUP: + case MSG_DT_SYSKEYDOWN: + case MSG_DT_SYSCHAR: + case MSG_DT_SYSKEYUP: + if(dsk_ops->keyboard_handler) + dsk_ops->keyboard_handler(dt_context, message, wParam, lParam); + break; + +#ifdef _MGHAVE_MENU + case MSG_DT_RBUTTONUP: + srvUpdateDesktopMenu (); +#endif + case MSG_DT_LBUTTONDOWN: + case MSG_DT_LBUTTONUP: + case MSG_DT_LBUTTONDBLCLK: + case MSG_DT_MOUSEMOVE: + case MSG_DT_RBUTTONDOWN: + case MSG_DT_RBUTTONDBLCLK: + case MSG_DT_MBUTTONDOWN: + case MSG_DT_MBUTTONUP: + case MSG_DT_MBUTTONDBLCLK: + if(dsk_ops->mouse_handler) + dsk_ops->mouse_handler(dt_context, message, wParam, lParam); break; } return 0; } -static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +static LRESULT DesktopWinProc (HWND hWnd, UINT message, + WPARAM wParam, LPARAM lParam) { int flags, x, y; @@ -4213,7 +4222,8 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP return dskWindowMessageHandler (message, (PMAINWIN)wParam, lParam); } // VW: Since 4.0.0 for extra input messages. - else if (message >= MSG_FIRSTEXTRAINPUTMSG && message <= MSG_LASTEXTRAINPUTMSG) { + else if (message >= MSG_FIRSTEXTRAINPUTMSG && + message <= MSG_LASTEXTRAINPUTMSG) { if (mgIsServer && __mg_zorder_info->active_win) { __mg_post_msg_by_znode (__mg_zorder_info, __mg_zorder_info->active_win, message, @@ -4224,7 +4234,7 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP if (mgIsServer) { if (wParam == SCANCODE_PRINTSCREEN && message == MSG_KEYDOWN) { #ifdef _MGMISC_SAVESCREEN - srvSaveScreen (lParam & KS_CTRL); + srvSaveScreen (lParam & KS_CTRL); #endif } #ifdef _MGHAVE_MENU @@ -4236,9 +4246,7 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP #endif if (__mg_zorder_info->cli_trackmenu > 0) { - MSG msg = {0, message, wParam, lParam, __mg_timer_counter}; - __mg_send2client (&msg, mgClients + __mg_zorder_info->cli_trackmenu); } @@ -4290,13 +4298,11 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP return 0; } else if (message == MSG_COMMAND) { - if (wParam <= MAXID_RESERVED && wParam >= MINID_RESERVED) - { + if (wParam <= MAXID_RESERVED && wParam >= MINID_RESERVED) { return srvDesktopCommand ((int)wParam); } - else - { - if(dsk_ops->desktop_menucmd_handler) + else { + if (dsk_ops->desktop_menucmd_handler) dsk_ops->desktop_menucmd_handler(dt_context, (int)wParam); return 0; } @@ -4396,17 +4402,21 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP case MSG_TIMER: if (__mg_quiting_stage < 0) { - if (__mg_quiting_stage > _MG_QUITING_STAGE_FORCE && __mg_quiting_stage <= _MG_QUITING_STAGE_START) { - -- __mg_quiting_stage; + if (__mg_quiting_stage > _MG_QUITING_STAGE_FORCE && + __mg_quiting_stage <= _MG_QUITING_STAGE_START) { + __mg_quiting_stage--; /* printf("try to quit %d\n", __mg_quiting_stage); */ - }else if (__mg_quiting_stage <= _MG_QUITING_STAGE_FORCE) { + } + else if (__mg_quiting_stage <= _MG_QUITING_STAGE_FORCE) { /* printf("force to quit !!!\n"); */ } if (__mg_quiting_stage > _MG_QUITING_STAGE_DESKTOP - && (mgIsServer ? SERVER_HAS_NO_MAINWINDOW() : CLIENT_HAS_NO_MAINWINDOW())) { + && (mgIsServer ? SERVER_HAS_NO_MAINWINDOW() : + CLIENT_HAS_NO_MAINWINDOW())) { __mg_quiting_stage = _MG_QUITING_STAGE_DESKTOP; - }else if (__mg_quiting_stage <= _MG_QUITING_STAGE_DESKTOP) { + } + else if (__mg_quiting_stage <= _MG_QUITING_STAGE_DESKTOP) { PostMessage (HWND_DESKTOP, MSG_ENDSESSION, 0, 0); } } diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index f637c163..e29033dd 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -773,7 +773,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) //ReleaseDC (hdc); //BUGFIXED: we must update the secondaryDC to clientDC, to ensure //the secondaryDC and clientDC are same (dongjunjie 2010/07/08) - if(pWin->pMainWin->secondaryDC) { + if (pWin->pMainWin->secondaryDC) { HDC real_dc = GetClientDC((HWND)pWin->pMainWin); __mg_update_secondary_dc(pWin, hdc, real_dc, pswi->rc1, HT_CLIENT); ReleaseDC (real_dc); diff --git a/src/newgal/surface.c b/src/newgal/surface.c index 82bd9985..e18f3db6 100644 --- a/src/newgal/surface.c +++ b/src/newgal/surface.c @@ -140,7 +140,7 @@ GAL_Surface * GAL_CreateRGBSurface (Uint32 flags, surface->format_version = 0; #if IS_COMPOSITING_SCHEMA surface->shared_header = NULL; - surface->dirty_info = calloc (sizeof (GAL_DirtyInfo), 1); + surface->dirty_info = calloc (1, sizeof (GAL_DirtyInfo)); if (surface->dirty_info == NULL) { GAL_FreeSurface(surface); GAL_OutOfMemory();