summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-17 12:24:04 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-17 12:24:04 +0000
commit800d1885d036ef2f7f1bc6f52f8855c03fb64705 (patch)
tree8803cfad08bad536c2a2eb21bd6a423e7a00e114
parentebcd54e2b17388d93eb7ec9949f6571f002af259 (diff)
- manual critical section control replaced with mir_cslock;
- unused variables removed; git-svn-id: http://svn.miranda-ng.org/main/trunk@9838 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Clist_modern/src/hdr/modern_commonprototypes.h1
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp200
-rw-r--r--plugins/Clist_modern/src/modern_tbbutton.cpp11
-rw-r--r--plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp1740
-rw-r--r--plugins/Clist_nicer/src/Include/Version.h2
5 files changed, 915 insertions, 1039 deletions
diff --git a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h
index aadbddc498..b0dc2bc203 100644
--- a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h
+++ b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h
@@ -61,7 +61,6 @@ extern BOOL g_mutex_bChangingMode;
extern UINT g_dwMainThreadID;
extern HANDLE g_hAwayMsgThread, g_hGetTextAsyncThread, g_hSmoothAnimationThread;
extern HWND g_hwndViewModeFrame;
-extern HANDLE hSmileyAddOptionsChangedHook,hAvatarChanged,hIconChangedHook;
extern BYTE gl_TrimText;
/************************************************************************/
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index 27d53a83cf..7416691b35 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -48,8 +48,6 @@ static BOOL fMouseUpped;
static BYTE IsDragToScrollMode = 0;
static int StartDragPos = 0;
static int StartScrollPos = 0;
-HANDLE hSmileyAddOptionsChangedHook = NULL;
-HANDLE hIconChangedHook = NULL;
HANDLE hAckHook = NULL;
HANDLE hAvatarChanged = NULL;
static BOOL g_bSortTimerIsSet = FALSE;
@@ -115,19 +113,18 @@ static int clcHookModulesLoaded(WPARAM wParam, LPARAM lParam)
clcHookIconsChanged(0, 0);
- hIconChangedHook = HookEvent(ME_SKIN2_ICONSCHANGED, clcHookIconsChanged);
+ HookEvent(ME_SKIN2_ICONSCHANGED, clcHookIconsChanged);
// Register smiley category
if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY)) {
SMADD_REGCAT rc;
-
rc.cbSize = sizeof(rc);
rc.name = "clist";
rc.dispname = Translate("Contact list smileys");
CallService(MS_SMILEYADD_REGISTERCATEGORY, 0, (LPARAM)&rc);
- hSmileyAddOptionsChangedHook = HookEvent(ME_SMILEYADD_OPTIONSCHANGED, clcHookSmileyAddOptionsChanged);
+ HookEvent(ME_SMILEYADD_OPTIONSCHANGED, clcHookSmileyAddOptionsChanged);
}
CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)(LPGEN("List background")"/CLC"), 0);
@@ -425,7 +422,7 @@ static LRESULT clcOnCommand(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LP
ClcContact *contact;
int hit = pcli->pfnGetRowByIndex(dat, dat->selection, &contact, NULL);
if (hit == -1) return 0;
- if (contact->type == CLCIT_CONTACT && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)contact->hContact)) return 0;
+ if (contact->type == CLCIT_CONTACT && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), contact->hContact)) return 0;
switch (LOWORD(wParam)) {
case POPUP_NEWSUBGROUP:
@@ -1212,7 +1209,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam,
CLUI_SafeSetTimer(hwnd, TIMERID_RENAME, GetDoubleClickTime(), NULL);
else if ((dat->dragStage & DRAGSTAGEM_STAGE) == DRAGSTAGE_ACTIVE) {
TCHAR Wording[500];
- int res = 0;
+ ClcContact *contDest, *contSour;
POINT pt = UNPACK_POINT(lParam);
int target = GetDropTargetInformation(hwnd, dat, pt);
switch (target) {
@@ -1220,40 +1217,36 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam,
break;
case DROPTARGET_ONCONTACT:
- if (ServiceExists(MS_MC_ADDTOMETA)) {
- ClcContact *contDest, *contSour;
- int res;
- MCONTACT handle, hcontact;
+ cliGetRowByIndex(dat, dat->iDragItem, &contSour, NULL);
+ cliGetRowByIndex(dat, dat->selection, &contDest, NULL);
+ if (contSour->type == CLCIT_CONTACT) {
+ MCONTACT hcontact = contSour->hContact;
+ if (mir_strcmp(contSour->proto, META_PROTO)) {
+ if (!contSour->isSubcontact) {
+ MCONTACT hDest = contDest->hContact;
+ mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it?"), contDest->szText, contSour->szText);
+ int res = MessageBox(hwnd, Wording, TranslateT("Converting to metacontact"), MB_OKCANCEL | MB_ICONQUESTION);
+ if (res == 1) {
+ MCONTACT handle = CallService(MS_MC_CONVERTTOMETA, hDest, 0);
+ if (!handle)
+ return 0;
- cliGetRowByIndex(dat, dat->iDragItem, &contSour, NULL);
- cliGetRowByIndex(dat, dat->selection, &contDest, NULL);
- hcontact = contSour->hContact;
- if (contSour->type == CLCIT_CONTACT) {
- if (mir_strcmp(contSour->proto, META_PROTO)) {
- if (!contSour->isSubcontact) {
- MCONTACT hDest = contDest->hContact;
- mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it?"), contDest->szText, contSour->szText);
- res = MessageBox(hwnd, Wording, TranslateT("Converting to metacontact"), MB_OKCANCEL | MB_ICONQUESTION);
- if (res == 1) {
- handle = (MCONTACT)CallService(MS_MC_CONVERTTOMETA, (WPARAM)hDest, 0);
- if (!handle) return 0;
- CallService(MS_MC_ADDTOMETA, (WPARAM)hcontact, (LPARAM)handle);
- }
+ CallService(MS_MC_ADDTOMETA, hcontact, handle);
}
- else {
- hcontact = contSour->hContact;
- MCONTACT hfrom = contSour->subcontacts->hContact;
- MCONTACT hdest = contDest->hContact;
- mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it (remove it from '%s')?"), contDest->szText, contSour->szText, contSour->subcontacts->szText);
- res = MessageBox(hwnd, Wording, TranslateT("Converting to metacontact (moving)"), MB_OKCANCEL | MB_ICONQUESTION);
- if (res == 1) {
- MCONTACT handle = (MCONTACT)CallService(MS_MC_CONVERTTOMETA, (WPARAM)hdest, 0);
- if (!handle)
- return 0;
-
- CallService(MS_MC_REMOVEFROMMETA, 0, (LPARAM)hcontact);
- CallService(MS_MC_ADDTOMETA, (WPARAM)hcontact, (LPARAM)handle);
- }
+ }
+ else {
+ hcontact = contSour->hContact;
+ MCONTACT hfrom = contSour->subcontacts->hContact;
+ MCONTACT hdest = contDest->hContact;
+ mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be converted to metacontact and '%s' be added to it (remove it from '%s')?"), contDest->szText, contSour->szText, contSour->subcontacts->szText);
+ int res = MessageBox(hwnd, Wording, TranslateT("Converting to metacontact (moving)"), MB_OKCANCEL | MB_ICONQUESTION);
+ if (res == 1) {
+ MCONTACT handle = (MCONTACT)CallService(MS_MC_CONVERTTOMETA, (WPARAM)hdest, 0);
+ if (!handle)
+ return 0;
+
+ CallService(MS_MC_REMOVEFROMMETA, 0, hcontact);
+ CallService(MS_MC_ADDTOMETA, hcontact, handle);
}
}
}
@@ -1261,79 +1254,76 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam,
break;
case DROPTARGET_ONMETACONTACT:
- {
- ClcContact *contDest, *contSour;
- cliGetRowByIndex(dat, dat->iDragItem, &contSour, NULL);
- cliGetRowByIndex(dat, dat->selection, &contDest, NULL);
- if (contSour->type == CLCIT_CONTACT) {
- if (!strcmp(contSour->proto, META_PROTO))
- break;
- if (!contSour->isSubcontact) {
- MCONTACT hcontact = contSour->hContact;
- MCONTACT handle = contDest->hContact;
- mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->szText);
- int res = MessageBox(hwnd, Wording, TranslateT("Adding contact to metacontact"), MB_OKCANCEL | MB_ICONQUESTION);
- if (res == 1) {
- if (!handle) return 0;
- CallService(MS_MC_ADDTOMETA, (WPARAM)hcontact, (LPARAM)handle);
- }
+ cliGetRowByIndex(dat, dat->iDragItem, &contSour, NULL);
+ cliGetRowByIndex(dat, dat->selection, &contDest, NULL);
+ if (contSour->type == CLCIT_CONTACT) {
+ if (!strcmp(contSour->proto, META_PROTO))
+ break;
+ if (!contSour->isSubcontact) {
+ MCONTACT hcontact = contSour->hContact;
+ MCONTACT handle = contDest->hContact;
+ mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->szText);
+ int res = MessageBox(hwnd, Wording, TranslateT("Adding contact to metacontact"), MB_OKCANCEL | MB_ICONQUESTION);
+ if (res == 1) {
+ if (!handle)
+ return 0;
+ CallService(MS_MC_ADDTOMETA, hcontact, handle);
}
- else {
- if (contSour->subcontacts == contDest) {
- MCONTACT hsour = contSour->hContact;
- mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be default?"), contSour->szText);
- int res = MessageBox(hwnd, Wording, TranslateT("Set default contact"), MB_OKCANCEL | MB_ICONQUESTION);
- if (res == 1)
- db_mc_setDefault(contDest->hContact, hsour, true);
- }
- else {
- MCONTACT hcontact = contSour->hContact;
- MCONTACT hfrom = contSour->subcontacts->hContact;
- MCONTACT handle = contDest->hContact;
- mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be removed from metacontact '%s' and added to '%s'?"), contSour->szText, contSour->subcontacts->szText, contDest->szText);
- int res = MessageBox(hwnd, Wording, TranslateT("Changing metacontacts (moving)"), MB_OKCANCEL | MB_ICONQUESTION);
- if (res == 1) {
- if (!handle) return 0;
-
- CallService(MS_MC_REMOVEFROMMETA, 0, (LPARAM)hcontact);
- CallService(MS_MC_ADDTOMETA, (WPARAM)hcontact, (LPARAM)handle);
- }
- }
+ }
+ else if (contSour->subcontacts == contDest) {
+ MCONTACT hsour = contSour->hContact;
+ mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be default?"), contSour->szText);
+ int res = MessageBox(hwnd, Wording, TranslateT("Set default contact"), MB_OKCANCEL | MB_ICONQUESTION);
+ if (res == 1)
+ db_mc_setDefault(contDest->hContact, hsour, true);
+ }
+ else {
+ MCONTACT hcontact = contSour->hContact;
+ MCONTACT hfrom = contSour->subcontacts->hContact;
+ MCONTACT handle = contDest->hContact;
+ mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be removed from metacontact '%s' and added to '%s'?"), contSour->szText, contSour->subcontacts->szText, contDest->szText);
+ int res = MessageBox(hwnd, Wording, TranslateT("Changing metacontacts (moving)"), MB_OKCANCEL | MB_ICONQUESTION);
+ if (res == 1) {
+ if (!handle)
+ return 0;
+
+ CallService(MS_MC_REMOVEFROMMETA, 0, hcontact);
+ CallService(MS_MC_ADDTOMETA, hcontact, handle);
}
}
}
break;
case DROPTARGET_ONSUBCONTACT:
- {
- ClcContact *contDest, *contSour;
- cliGetRowByIndex(dat, dat->iDragItem, &contSour, NULL);
- cliGetRowByIndex(dat, dat->selection, &contDest, NULL);
- if (contSour->type == CLCIT_CONTACT) {
- if (!strcmp(contSour->proto, META_PROTO))
- break;
- if (!contSour->isSubcontact) {
- MCONTACT hcontact = contSour->hContact;
- MCONTACT handle = contDest->subcontacts->hContact;
- mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->subcontacts->szText);
- int res = MessageBox(hwnd, Wording, TranslateT("Changing metacontacts (moving)"), MB_OKCANCEL | MB_ICONQUESTION);
- if (res == 1) {
- if (!handle) return 0;
- CallService(MS_MC_ADDTOMETA, (WPARAM)hcontact, (LPARAM)handle);
- }
+ cliGetRowByIndex(dat, dat->iDragItem, &contSour, NULL);
+ cliGetRowByIndex(dat, dat->selection, &contDest, NULL);
+ if (contSour->type == CLCIT_CONTACT) {
+ if (!strcmp(contSour->proto, META_PROTO))
+ break;
+ if (!contSour->isSubcontact) {
+ MCONTACT hcontact = contSour->hContact;
+ MCONTACT handle = contDest->subcontacts->hContact;
+ mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be added to metacontact '%s'?"), contSour->szText, contDest->subcontacts->szText);
+ int res = MessageBox(hwnd, Wording, TranslateT("Changing metacontacts (moving)"), MB_OKCANCEL | MB_ICONQUESTION);
+ if (res == 1) {
+ if (!handle)
+ return 0;
+
+ CallService(MS_MC_ADDTOMETA, hcontact, handle);
}
- else if (contSour->subcontacts != contDest->subcontacts) {
- MCONTACT hcontact = contSour->hContact;
- MCONTACT hfrom = contSour->subcontacts->hContact;
- MCONTACT handle = contDest->subcontacts->hContact;
- mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be removed from metacontact '%s' and added to '%s'?"), contSour->szText, contSour->subcontacts->szText, contDest->subcontacts->szText);
- int res = MessageBox(hwnd, Wording, TranslateT("Changing metacontacts (moving)"), MB_OKCANCEL | MB_ICONQUESTION);
- if (res == 1) {
- if (!handle) return 0;
-
- CallService(MS_MC_REMOVEFROMMETA, 0, (LPARAM)hcontact);
- CallService(MS_MC_ADDTOMETA, (WPARAM)hcontact, (LPARAM)handle);
- }
+ }
+ else if (contSour->subcontacts != contDest->subcontacts) {
+ MCONTACT hcontact = contSour->hContact;
+ MCONTACT hfrom = contSour->subcontacts->hContact;
+ MCONTACT handle = contDest->subcontacts->hContact;
+ mir_sntprintf(Wording, SIZEOF(Wording), TranslateT("Do you want contact '%s' to be removed from metacontact '%s' and added to '%s'?"), contSour->szText, contSour->subcontacts->szText, contDest->subcontacts->szText);
+ int res = MessageBox(hwnd, Wording, TranslateT("Changing metacontacts (moving)"), MB_OKCANCEL | MB_ICONQUESTION);
+ if (res == 1) {
+ if (!handle)
+ return 0;
+
+ CallService(MS_MC_REMOVEFROMMETA, 0, hcontact);
+ CallService(MS_MC_ADDTOMETA, hcontact, handle);
}
}
}
@@ -1455,7 +1445,7 @@ static LRESULT clcOnIntmGroupChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM w
nm.hdr.idFrom = GetDlgCtrlID(hwnd);
nm.flags = 0;
nm.hItem = (HANDLE)wParam;
- SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)& nm);
+ SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm);
dat->needsResort = 1;
}
SetTimer(hwnd, TIMERID_REBUILDAFTER, 1, NULL);
diff --git a/plugins/Clist_modern/src/modern_tbbutton.cpp b/plugins/Clist_modern/src/modern_tbbutton.cpp
index 4274347583..ee5d5c521d 100644
--- a/plugins/Clist_modern/src/modern_tbbutton.cpp
+++ b/plugins/Clist_modern/src/modern_tbbutton.cpp
@@ -35,7 +35,6 @@ static HWND hwndToolTips = NULL;
static BOOL bThemed = FALSE;
static HANDLE hButtonWindowList = NULL;
-static HANDLE hBkgChangedHook = NULL;
static int OnIconLibIconChanged(WPARAM wParam, LPARAM lParam)
{
@@ -250,11 +249,11 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam
break;
case BUTTONSETMARGINS:
- if (lParam) bct->rcMargins = *(RECT*)lParam;
- else {
- RECT nillRect = {0};
+ if (!lParam) {
+ RECT nillRect = { 0 };
bct->rcMargins = nillRect;
}
+ else bct->rcMargins = *(RECT*)lParam;
break;
case BUTTONSETID:
@@ -495,8 +494,8 @@ int Buttons_OnSkinModeSettingsChanged(WPARAM wParam, LPARAM lParam)
HRESULT ToolbarButtonLoadModule()
{
hButtonWindowList = WindowList_Create();
- hIconChangedHook = HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged);
- hBkgChangedHook = HookEvent(ME_BACKGROUNDCONFIG_CHANGED,Buttons_OnSkinModeSettingsChanged);
+ HookEvent(ME_SKIN2_ICONSCHANGED, OnIconLibIconChanged);
+ HookEvent(ME_BACKGROUNDCONFIG_CHANGED, Buttons_OnSkinModeSettingsChanged);
return S_OK;
}
diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp
index 0a3bf1a58b..90d294c582 100644
--- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp
+++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp
@@ -106,7 +106,7 @@ static int LastStoreTick = 0;
static int lbypos = -1;
static int oldframeheight = -1;
static int curdragbar = -1;
-static CRITICAL_SECTION csFrameHook;
+static mir_cs csFrameHook;
static BOOLEAN CLUIFramesFitInSize(void);
HWND hWndExplorerToolBar;
@@ -138,30 +138,17 @@ int __forceinline btoint(BOOLEAN b)
return (b ? 1 : 0);
}
-void __forceinline lockfrm()
-{
- if (FramesSysNotStarted == FALSE)
- EnterCriticalSection(&csFrameHook);
-}
-
-void __forceinline ulockfrm()
-{
- LeaveCriticalSection(&csFrameHook);
-}
-
static FRAMEWND *FindFrameByWnd(HWND hwnd)
{
- BOOL bFound = FALSE;
- int i;
-
if (hwnd == NULL)
- return (NULL);
+ return NULL;
- for (i = 0; i < nFramescount; i++) {
+ BOOL bFound = FALSE;
+ for (int i = 0; i < nFramescount; i++)
if ((Frames[i].floating) && (Frames[i].ContainerWnd == hwnd))
return (&Frames[i]);
- }
- return(NULL);
+
+ return NULL;
}
static void DockThumbs(FRAMEWND *pThumbLeft, FRAMEWND *pThumbRight, BOOL bMoveLeft)
@@ -555,10 +542,9 @@ int CLUIFramesStoreAllFrames()
if (cfg::shutDown)
return -1;
- lockfrm();
+ mir_cslock lck(csFrameHook);
for (i = 0;i < nFramescount;i++)
CLUIFramesStoreFrameSettings(i);
- ulockfrm();
return 0;
}
@@ -786,9 +772,8 @@ static int CLUIFramesModifyContextMenuForFrame(WPARAM wParam, LPARAM lParam)
if (FramesSysNotStarted)
return -1;
- lockfrm();
+ mir_cslock lck(csFrameHook);
int pos = id2pos((INT_PTR)wParam);
-
if (pos >= 0 && pos < nFramescount) {
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_NAME | CMIF_CHILDPOPUP | CMIF_TCHAR;
@@ -837,7 +822,6 @@ static int CLUIFramesModifyContextMenuForFrame(WPARAM wParam, LPARAM lParam)
if ((!Frames[pos].visible) || (Frames[pos].Locked) || (pos == CLUIFramesGetalClientFrame())) mi.flags |= CMIF_GRAYED;
ModifyMItem((WPARAM)contMIColl, (LPARAM)&mi);
}
- ulockfrm();
return 0;
}
@@ -846,7 +830,7 @@ INT_PTR CLUIFramesModifyMainMenuItems(WPARAM wParam, LPARAM lParam)
if (FramesSysNotStarted)
return -1;
- lockfrm();
+ mir_cslock lck(csFrameHook);
int pos = id2pos((INT_PTR)wParam);
if (pos >= 0 && pos < nFramescount) {
@@ -896,76 +880,59 @@ INT_PTR CLUIFramesModifyMainMenuItems(WPARAM wParam, LPARAM lParam)
if ((!Frames[pos].visible) || Frames[pos].Locked || (pos == CLUIFramesGetalClientFrame())) mi.flags |= CMIF_GRAYED;
Menu_ModifyItem(Frames[pos].MenuHandles.MIColl, &mi);
}
- ulockfrm();
return 0;
}
INT_PTR CLUIFramesGetFrameOptions(WPARAM wParam, LPARAM lParam)
{
- int pos;
- INT_PTR retval;
-
if (FramesSysNotStarted) return -1;
- lockfrm();
- pos = id2pos(HIWORD(wParam));
- if (pos < 0 || pos >= nFramescount) {
- ulockfrm();
+ mir_cslock lck(csFrameHook);
+ int pos = id2pos(HIWORD(wParam));
+ if (pos < 0 || pos >= nFramescount)
return -1;
- }
switch (LOWORD(wParam)) {
- case FO_FLAGS:
- retval = 0;
- if (Frames[pos].visible) retval |= F_VISIBLE;
- if ( !Frames[pos].collapsed) retval |= F_UNCOLLAPSED;
- if (Frames[pos].Locked) retval |= F_LOCKED;
- if (Frames[pos].TitleBar.ShowTitleBar) retval |= F_SHOWTB;
- if (Frames[pos].TitleBar.ShowTitleBarTip) retval |= F_SHOWTBTIP;
- if (Frames[pos].Skinned) retval |= F_SKINNED;
- if ( !(GetWindowLongPtr(Frames[pos].hWnd, GWL_STYLE)&WS_BORDER)) retval |= F_NOBORDER;
- break;
+ case FO_NAME:
+ return (INT_PTR)Frames[pos].name;
- case FO_NAME:
- retval = (INT_PTR)Frames[pos].name;
- break;
+ case FO_TBNAME:
+ return (INT_PTR)Frames[pos].TitleBar.tbname;
- case FO_TBNAME:
- retval = (INT_PTR)Frames[pos].TitleBar.tbname;
- break;
+ case FO_TBTIPNAME:
+ return (INT_PTR)Frames[pos].TitleBar.tooltip;
- case FO_TBTIPNAME:
- retval = (INT_PTR)Frames[pos].TitleBar.tooltip;
- break;
+ case FO_TBSTYLE:
+ return GetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE);
- case FO_TBSTYLE:
- retval = GetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE);
- break;
+ case FO_TBEXSTYLE:
+ return GetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_EXSTYLE);
- case FO_TBEXSTYLE:
- retval = GetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_EXSTYLE);
- break;
+ case FO_ICON:
+ return (INT_PTR)Frames[pos].TitleBar.hicon;
- case FO_ICON:
- retval = (INT_PTR)Frames[pos].TitleBar.hicon;
- break;
+ case FO_HEIGHT:
+ return (INT_PTR)Frames[pos].height;
- case FO_HEIGHT:
- retval = (INT_PTR)Frames[pos].height;
- break;
+ case FO_ALIGN:
+ return (INT_PTR)Frames[pos].align;
- case FO_ALIGN:
- retval = (INT_PTR)Frames[pos].align;
- break;
- case FO_FLOATING:
- retval = (int)Frames[pos].floating;
- break;
- default:
- retval = -1;
- break;
+ case FO_FLOATING:
+ return (int)Frames[pos].floating;
+
+ case FO_FLAGS:
+ INT_PTR dwFlags = 0;
+ if (Frames[pos].visible) dwFlags |= F_VISIBLE;
+ if (!Frames[pos].collapsed) dwFlags |= F_UNCOLLAPSED;
+ if (Frames[pos].Locked) dwFlags |= F_LOCKED;
+ if (Frames[pos].TitleBar.ShowTitleBar) dwFlags |= F_SHOWTB;
+ if (Frames[pos].TitleBar.ShowTitleBarTip) dwFlags |= F_SHOWTBTIP;
+ if (Frames[pos].Skinned) dwFlags |= F_SKINNED;
+ if (!(GetWindowLongPtr(Frames[pos].hWnd, GWL_STYLE)&WS_BORDER)) dwFlags |= F_NOBORDER;
+ return dwFlags;
}
- ulockfrm();
- return retval;
+
+ return -1;
}
INT_PTR CLUIFramesSetFrameOptions(WPARAM wParam, LPARAM lParam)
@@ -975,12 +942,10 @@ INT_PTR CLUIFramesSetFrameOptions(WPARAM wParam, LPARAM lParam)
if (FramesSysNotStarted)
return -1;
- lockfrm();
+ mir_cslockfull lck(csFrameHook);
int pos = id2pos(HIWORD(wParam));
- if (pos < 0 || pos >= nFramescount) {
- ulockfrm();
+ if (pos < 0 || pos >= nFramescount)
return -1;
- }
switch (LOWORD(wParam) & ~FO_UNICODETEXT) {
case FO_FLAGS:
@@ -1025,66 +990,58 @@ INT_PTR CLUIFramesSetFrameOptions(WPARAM wParam, LPARAM lParam)
SetWindowLongPtr(Frames[pos].hWnd, GWL_STYLE, (LONG_PTR)style);
SetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE, (LONG_PTR)style & ~(WS_VSCROLL | WS_HSCROLL));
+ lck.unlock();
- ulockfrm();
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
SetWindowPos(Frames[pos].TitleBar.hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
}
return 0;
case FO_NAME:
- if (lParam == 0) {
- ulockfrm();
+ if (lParam == 0)
return -1;
- }
+
mir_free(Frames[pos].name);
Frames[pos].name = (wParam & FO_UNICODETEXT) ? mir_u2t((LPWSTR)lParam) : mir_a2t((LPSTR)lParam);
- ulockfrm();
return 0;
case FO_TBNAME:
- if (lParam == 0) {
- ulockfrm();
+ if (lParam == 0)
return -1;
- }
+
mir_free(Frames[pos].TitleBar.tbname);
Frames[pos].TitleBar.tbname = (wParam & FO_UNICODETEXT) ? mir_u2t((LPWSTR)lParam) : mir_a2t((LPSTR)lParam);
- ulockfrm();
+ lck.unlock();
+
if (Frames[pos].floating && (Frames[pos].TitleBar.tbname != NULL))
SetWindowText(Frames[pos].ContainerWnd, Frames[pos].TitleBar.tbname);
return 0;
case FO_TBTIPNAME:
- if (lParam == 0) {
- ulockfrm();
+ if (lParam == 0)
return -1;
- }
+
mir_free(Frames[pos].TitleBar.tooltip);
Frames[pos].TitleBar.tooltip = (wParam & FO_UNICODETEXT) ? mir_u2t((LPWSTR)lParam) : mir_a2t((LPSTR)lParam);
UpdateTBToolTip(pos);
- ulockfrm();
return 0;
case FO_TBSTYLE:
SetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_STYLE, lParam);
- ulockfrm();
return 0;
case FO_TBEXSTYLE:
SetWindowLongPtr(Frames[pos].TitleBar.hwnd, GWL_EXSTYLE, lParam);
- ulockfrm();
return 0;
case FO_ICON:
Frames[pos].TitleBar.hicon = (HICON)lParam;
- ulockfrm();
return 0;
case FO_HEIGHT:
- if (lParam < 0) {
- ulockfrm();
+ if (lParam < 0)
return -1;
- }
+
if (Frames[pos].Skinned) {
int uID = (Frames[pos].TitleBar.ShowTitleBar ? ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE : ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE);
lParam += (arStatusItems[uID]->MARGIN_BOTTOM + arStatusItems[uID]->MARGIN_TOP);
@@ -1110,61 +1067,55 @@ INT_PTR CLUIFramesSetFrameOptions(WPARAM wParam, LPARAM lParam)
Frames[pos].HeightWhenCollapsed = retval;
retval = Frames[pos].HeightWhenCollapsed;
}
- ulockfrm();
return retval;
case FO_FLOATING:
- if (lParam < 0) {
- ulockfrm();
+ if (lParam < 0)
return -1;
- }
else {
int id = Frames[pos].id;
Frames[pos].floating = !(lParam);
- ulockfrm();
+ lck.unlock();
CLUIFrameSetFloat(id, 1);//lparam=1 use stored width and height
}
return wParam;
case FO_ALIGN:
- if ( !(lParam&alTop || lParam&alBottom || lParam&alClient)) {
- ulockfrm();
+ if ( !(lParam&alTop || lParam&alBottom || lParam&alClient))
return -1;
- }
+
if ((lParam&alClient) && (CLUIFramesGetalClientFrame() >= 0)) { //only one alClient frame possible
alclientFrame = -1;//recalc it
- ulockfrm();
return -1;
}
Frames[pos].align = lParam;
- ulockfrm();
return 0;
}
- ulockfrm();
+ lck.unlock();
+
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
return -1;
}
static INT_PTR CLUIFramesShowAll(WPARAM wParam, LPARAM lParam)
{
- int i;
-
- if (FramesSysNotStarted) return -1;
+ if (FramesSysNotStarted)
+ return -1;
- for (i = 0;i < nFramescount;i++)
+ for (int i = 0;i < nFramescount;i++)
Frames[i].visible = TRUE;
+
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
return 0;
}
INT_PTR CLUIFramesShowAllTitleBars(WPARAM wParam, LPARAM lParam)
{
- int i;
-
- if (FramesSysNotStarted) return -1;
+ if (FramesSysNotStarted)
+ return -1;
- for (i = 0;i < nFramescount;i++) {
+ for (int i = 0;i < nFramescount;i++) {
Frames[i].TitleBar.ShowTitleBar = TRUE;
SetWindowPos(Frames[i].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
}
@@ -1176,11 +1127,10 @@ INT_PTR CLUIFramesShowAllTitleBars(WPARAM wParam, LPARAM lParam)
//wparam=lparam=0
INT_PTR CLUIFramesHideAllTitleBars(WPARAM wParam, LPARAM lParam)
{
- int i;
-
- if (FramesSysNotStarted) return -1;
+ if (FramesSysNotStarted)
+ return -1;
- for (i = 0;i < nFramescount;i++) {
+ for (int i = 0;i < nFramescount;i++) {
Frames[i].TitleBar.ShowTitleBar = FALSE;
SetWindowPos(Frames[i].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
}
@@ -1192,23 +1142,24 @@ INT_PTR CLUIFramesHideAllTitleBars(WPARAM wParam, LPARAM lParam)
//wparam=frameid
INT_PTR CLUIFramesShowHideFrame(WPARAM wParam, LPARAM lParam)
{
- int pos;
-
if (FramesSysNotStarted)
return -1;
- lockfrm();
- pos = id2pos((INT_PTR)wParam);
- if (pos >= 0 && !lstrcmp(Frames[pos].name, _T("My contacts")))
- Frames[pos].visible = 1;
- else {
- if (pos >= 0 && (int)pos < nFramescount)
- Frames[pos].visible = !Frames[pos].visible;
- if (Frames[pos].floating)
- CLUIFrameResizeFloatingFrame(pos);
+ int pos;
+ {
+ mir_cslock lck(csFrameHook);
+ pos = id2pos((INT_PTR)wParam);
+ if (pos >= 0 && !lstrcmp(Frames[pos].name, _T("My contacts")))
+ Frames[pos].visible = 1;
+ else {
+ if (pos >= 0 && (int)pos < nFramescount)
+ Frames[pos].visible = !Frames[pos].visible;
+ if (Frames[pos].floating)
+ CLUIFrameResizeFloatingFrame(pos);
+ }
}
- ulockfrm();
- if ( !Frames[pos].floating)
+
+ if (!Frames[pos].floating)
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN);
return 0;
@@ -1217,18 +1168,18 @@ INT_PTR CLUIFramesShowHideFrame(WPARAM wParam, LPARAM lParam)
//wparam=frameid
INT_PTR CLUIFramesShowHideFrameTitleBar(WPARAM wParam, LPARAM lParam)
{
- int pos;
-
if (FramesSysNotStarted)
return -1;
- lockfrm();
- pos = id2pos((INT_PTR)wParam);
- if (pos >= 0 && (int)pos < nFramescount) {
- Frames[pos].TitleBar.ShowTitleBar = !Frames[pos].TitleBar.ShowTitleBar;
- SetWindowPos(Frames[pos].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
+ {
+ mir_cslock lck(csFrameHook);
+ int pos = id2pos((INT_PTR)wParam);
+ if (pos >= 0 && (int)pos < nFramescount) {
+ Frames[pos].TitleBar.ShowTitleBar = !Frames[pos].TitleBar.ShowTitleBar;
+ SetWindowPos(Frames[pos].hWnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
+ }
}
- ulockfrm();
+
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN);
return 0;
@@ -1239,54 +1190,54 @@ INT_PTR CLUIFramesShowHideFrameTitleBar(WPARAM wParam, LPARAM lParam)
//lparam=-1 up ,1 down
INT_PTR CLUIFramesMoveUpDown(WPARAM wParam, LPARAM lParam)
{
- int pos, i, curpos, curalign, v, tmpval;
+ int i, tmpval;
if (FramesSysNotStarted)
return -1;
- lockfrm();
- pos = id2pos((INT_PTR)wParam);
- if (pos >= 0 && (int)pos < nFramescount) {
- curpos = Frames[pos].order;
- curalign = Frames[pos].align;
- v = 0;
- memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES);
- for (i = 0;i < nFramescount;i++) {
- if (Frames[i].floating || (!Frames[i].visible) || (Frames[i].align != curalign))
- continue;
- g_sd[v].order = Frames[i].order;
- g_sd[v].realpos = i;
- v++;
- }
- if (v == 0) {
- ulockfrm();
- return 0;
- }
- qsort(g_sd, v, sizeof(SortData), sortfunc);
- for (i = 0;i < v;i++) {
- if (g_sd[i].realpos == pos) {
- if (lParam == -1) {
- if (i < 1) break;
- tmpval = Frames[g_sd[i-1].realpos].order;
- Frames[g_sd[i-1].realpos].order = Frames[pos].order;
- Frames[pos].order = tmpval;
- break;
- }
- if (lParam == 1) {
- if (i > v - 1) break;
- tmpval = Frames[g_sd[i+1].realpos].order;
- Frames[g_sd[i+1].realpos].order = Frames[pos].order;
- Frames[pos].order = tmpval;
- break;
- }
+ mir_cslockfull lck(csFrameHook);
+ int pos = id2pos((INT_PTR)wParam);
+ if (pos < 0 || pos >= nFramescount)
+ return 0;
+
+ int curpos = Frames[pos].order;
+ int curalign = Frames[pos].align;
+ int v = 0;
+ memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES);
+ for (i = 0;i < nFramescount;i++) {
+ if (Frames[i].floating || (!Frames[i].visible) || (Frames[i].align != curalign))
+ continue;
+ g_sd[v].order = Frames[i].order;
+ g_sd[v].realpos = i;
+ v++;
+ }
+ if (v == 0)
+ return 0;
+
+ qsort(g_sd, v, sizeof(SortData), sortfunc);
+ for (i = 0;i < v;i++) {
+ if (g_sd[i].realpos == pos) {
+ if (lParam == -1) {
+ if (i < 1) break;
+ tmpval = Frames[g_sd[i-1].realpos].order;
+ Frames[g_sd[i-1].realpos].order = Frames[pos].order;
+ Frames[pos].order = tmpval;
+ break;
+ }
+ if (lParam == 1) {
+ if (i > v - 1) break;
+ tmpval = Frames[g_sd[i+1].realpos].order;
+ Frames[g_sd[i+1].realpos].order = Frames[pos].order;
+ Frames[pos].order = tmpval;
+ break;
}
}
- ulockfrm();
- CLUIFramesReSort();
- //CLUIFramesStoreAllFrames();
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
- PostMessage(pcli->hwndContactList, CLUIINTM_REDRAW, 0, 0);
}
+ lck.unlock();
+
+ CLUIFramesReSort();
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
+ PostMessage(pcli->hwndContactList, CLUIINTM_REDRAW, 0, 0);
return 0;
}
@@ -1335,48 +1286,41 @@ INT_PTR CLUIFramesSetAlignalClient(WPARAM wParam, LPARAM lParam)
//wparam=frameid
INT_PTR CLUIFramesLockUnlockFrame(WPARAM wParam, LPARAM lParam)
{
- int pos;
-
if (FramesSysNotStarted)
return -1;
- lockfrm();
- pos = id2pos((INT_PTR)wParam);
+ mir_cslock lck(csFrameHook);
+ int pos = id2pos((INT_PTR)wParam);
if (pos >= 0 && (int)pos < nFramescount) {
Frames[pos].Locked = !Frames[pos].Locked;
CLUIFramesStoreFrameSettings(pos);
}
- ulockfrm();
return 0;
}
//wparam=frameid
INT_PTR CLUIFramesSetUnSetBorder(WPARAM wParam, LPARAM lParam)
{
- RECT rc;
- int FrameId, oldflags;
- HWND hw;
- boolean flt;
-
if (FramesSysNotStarted)
return -1;
- lockfrm();
- FrameId = id2pos((INT_PTR)wParam);
- if (FrameId == -1) {
- ulockfrm();
- return -1;
- }
- flt = oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), 0);
+ HWND hw;
+ int FrameId, oldflags;
+ {
+ mir_cslock lck(csFrameHook);
+ FrameId = id2pos((INT_PTR)wParam);
+ if (FrameId == -1)
+ return -1;
- if (oldflags&F_NOBORDER)
- oldflags &= (~F_NOBORDER);
- else
- oldflags |= F_NOBORDER;
+ oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), 0);
+ if (oldflags & F_NOBORDER)
+ oldflags &= (~F_NOBORDER);
+ else
+ oldflags |= F_NOBORDER;
+
+ hw = Frames[FrameId].hWnd;
+ }
- hw = Frames[FrameId].hWnd;
- GetWindowRect(hw, &rc);
- ulockfrm();
CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), oldflags);
SetWindowPos(hw, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_DRAWFRAME | SWP_NOZORDER);
return 0;
@@ -1385,30 +1329,26 @@ INT_PTR CLUIFramesSetUnSetBorder(WPARAM wParam, LPARAM lParam)
//wparam=frameid
INT_PTR CLUIFramesSetUnSetSkinned(WPARAM wParam, LPARAM lParam)
{
- RECT rc;
- int FrameId, oldflags;
- HWND hw;
- boolean flt;
-
if (FramesSysNotStarted)
return -1;
- lockfrm();
- FrameId = id2pos((INT_PTR)wParam);
- if (FrameId == -1) {
- ulockfrm();
- return -1;
- }
- flt = oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), 0);
+ HWND hw;
+ int FrameId, oldflags;
+ {
+ mir_cslock lck(csFrameHook);
+ FrameId = id2pos((INT_PTR)wParam);
+ if (FrameId == -1)
+ return -1;
- if (oldflags & F_SKINNED)
- oldflags &= ~F_SKINNED;
- else
- oldflags |= F_SKINNED;
+ oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), 0);
+ if (oldflags & F_SKINNED)
+ oldflags &= ~F_SKINNED;
+ else
+ oldflags |= F_SKINNED;
+
+ hw = Frames[FrameId].hWnd;
+ }
- hw = Frames[FrameId].hWnd;
- GetWindowRect(hw, &rc);
- ulockfrm();
CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, wParam), oldflags);
SetWindowPos(hw, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_DRAWFRAME | SWP_NOZORDER);
return 0;
@@ -1417,122 +1357,113 @@ INT_PTR CLUIFramesSetUnSetSkinned(WPARAM wParam, LPARAM lParam)
//wparam=frameid
INT_PTR CLUIFramesCollapseUnCollapseFrame(WPARAM wParam, LPARAM lParam)
{
- int FrameId;
-
if (FramesSysNotStarted)
return -1;
TitleBarH = cfg::dat.titleBarHeight;
- lockfrm();
- FrameId = id2pos((INT_PTR)wParam);
- if (FrameId >= 0 && FrameId < nFramescount) {
- int oldHeight;
-
- // do not collapse/uncollapse client/locked/invisible frames
- if (Frames[FrameId].align == alClient && !(Frames[FrameId].Locked || (!Frames[FrameId].visible) || Frames[FrameId].floating)) {
- RECT rc;
- if (CallService(MS_CLIST_DOCKINGISDOCKED, 0, 0)) {
- ulockfrm();
- return 0;
- }
- if (cfg::getByte("CLUI", "AutoSize", 0)) {
- ulockfrm();
- return 0;
- }
- GetWindowRect(pcli->hwndContactList, &rc);
-
- if (Frames[FrameId].collapsed == TRUE) {
- rc.bottom -= rc.top;
- rc.bottom -= Frames[FrameId].height;
- Frames[FrameId].HeightWhenCollapsed = Frames[FrameId].height;
- Frames[FrameId].collapsed = FALSE;
- } else {
- rc.bottom -= rc.top;
- rc.bottom += Frames[FrameId].HeightWhenCollapsed;
- Frames[FrameId].collapsed = TRUE;
- }
- SetWindowPos(pcli->hwndContactList, NULL, 0, 0, rc.right - rc.left, rc.bottom, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
+ mir_cslockfull lck(csFrameHook);
+ int FrameId = id2pos((INT_PTR)wParam);
+ if (FrameId < 0 || FrameId >= nFramescount)
+ return -1;
+
+ int oldHeight;
- CLUIFramesStoreAllFrames();
- ulockfrm();
- RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN);
+ // do not collapse/uncollapse client/locked/invisible frames
+ if (Frames[FrameId].align == alClient && !(Frames[FrameId].Locked || (!Frames[FrameId].visible) || Frames[FrameId].floating)) {
+ RECT rc;
+ if (CallService(MS_CLIST_DOCKINGISDOCKED, 0, 0))
return 0;
- }
- if (Frames[FrameId].Locked || (!Frames[FrameId].visible)) {
- ulockfrm();
+ if (cfg::getByte("CLUI", "AutoSize", 0))
return 0;
- }
- oldHeight = Frames[FrameId].height;
+ GetWindowRect(pcli->hwndContactList, &rc);
- // if collapsed, uncollapse
if (Frames[FrameId].collapsed == TRUE) {
+ rc.bottom -= rc.top;
+ rc.bottom -= Frames[FrameId].height;
Frames[FrameId].HeightWhenCollapsed = Frames[FrameId].height;
- Frames[FrameId].height = UNCOLLAPSED_FRAME_SIZE;
Frames[FrameId].collapsed = FALSE;
}
- // if uncollapsed, collapse
else {
- Frames[FrameId].height = Frames[FrameId].HeightWhenCollapsed;
+ rc.bottom -= rc.top;
+ rc.bottom += Frames[FrameId].HeightWhenCollapsed;
Frames[FrameId].collapsed = TRUE;
}
- if ( !Frames[FrameId].floating) {
+ SetWindowPos(pcli->hwndContactList, NULL, 0, 0, rc.right - rc.left, rc.bottom, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
+
+ CLUIFramesStoreAllFrames();
+ lck.unlock();
+ RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN);
+ return 0;
+
+ }
+ if (Frames[FrameId].Locked || (!Frames[FrameId].visible))
+ return 0;
- if ( !CLUIFramesFitInSize()) {
- //cant collapse,we can resize only for height<alclient frame height
- int alfrm = CLUIFramesGetalClientFrame();
+ oldHeight = Frames[FrameId].height;
- if (alfrm != -1) {
- Frames[FrameId].collapsed = FALSE;
- if (Frames[alfrm].height > 2*UNCOLLAPSED_FRAME_SIZE) {
- oldHeight = Frames[alfrm].height - UNCOLLAPSED_FRAME_SIZE;
- Frames[FrameId].collapsed = TRUE;
- }
- } else {
- int i, sumheight = 0;
-
- for (i = 0;i < nFramescount;i++) {
- if ((Frames[i].align != alClient) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) {
- sumheight += (Frames[i].height) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 2;
- ulockfrm();
- return FALSE;
- }
- if (sumheight > ContactListHeight - 0 - 2)
- Frames[FrameId].height = (ContactListHeight - 0 - 2) - sumheight;
- }
+ // if collapsed, uncollapse
+ if (Frames[FrameId].collapsed == TRUE) {
+ Frames[FrameId].HeightWhenCollapsed = Frames[FrameId].height;
+ Frames[FrameId].height = UNCOLLAPSED_FRAME_SIZE;
+ Frames[FrameId].collapsed = FALSE;
+ }
+ // if uncollapsed, collapse
+ else {
+ Frames[FrameId].height = Frames[FrameId].HeightWhenCollapsed;
+ Frames[FrameId].collapsed = TRUE;
+ }
+
+ if (!Frames[FrameId].floating) {
+
+ if (!CLUIFramesFitInSize()) {
+ //cant collapse,we can resize only for height<alclient frame height
+ int alfrm = CLUIFramesGetalClientFrame();
+
+ if (alfrm != -1) {
+ Frames[FrameId].collapsed = FALSE;
+ if (Frames[alfrm].height > 2 * UNCOLLAPSED_FRAME_SIZE) {
+ oldHeight = Frames[alfrm].height - UNCOLLAPSED_FRAME_SIZE;
+ Frames[FrameId].collapsed = TRUE;
}
- Frames[FrameId].height = oldHeight;
- if (Frames[FrameId].collapsed == FALSE) {
- if (Frames[FrameId].floating)
- SetWindowPos(Frames[FrameId].ContainerWnd, HWND_TOP, 0, 0, Frames[FrameId].wndSize.right - Frames[FrameId].wndSize.left + 6, Frames[FrameId].height + DEFAULT_TITLEBAR_HEIGHT + 4, SWP_SHOWWINDOW | SWP_NOMOVE);
- ulockfrm();
- return -1;
+ }
+ else {
+ int i, sumheight = 0;
+
+ for (i = 0; i < nFramescount; i++) {
+ if ((Frames[i].align != alClient) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) {
+ sumheight += (Frames[i].height) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 2;
+ return FALSE;
+ }
+ if (sumheight > ContactListHeight - 0 - 2)
+ Frames[FrameId].height = (ContactListHeight - 0 - 2) - sumheight;
}
}
+ Frames[FrameId].height = oldHeight;
+ if (Frames[FrameId].collapsed == FALSE) {
+ if (Frames[FrameId].floating)
+ SetWindowPos(Frames[FrameId].ContainerWnd, HWND_TOP, 0, 0, Frames[FrameId].wndSize.right - Frames[FrameId].wndSize.left + 6, Frames[FrameId].height + DEFAULT_TITLEBAR_HEIGHT + 4, SWP_SHOWWINDOW | SWP_NOMOVE);
+ return -1;
+ }
}
- ulockfrm();
- if ( !Frames[FrameId].floating)
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
- else {
- RECT contwnd;
- GetWindowRect(Frames[FrameId].ContainerWnd, &contwnd);
- contwnd.top = contwnd.bottom - contwnd.top;//height
- contwnd.left = contwnd.right - contwnd.left;//width
+ }
+ lck.unlock();
+ if (!Frames[FrameId].floating)
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
+ else {
+ RECT contwnd;
+ GetWindowRect(Frames[FrameId].ContainerWnd, &contwnd);
+ contwnd.top = contwnd.bottom - contwnd.top;//height
+ contwnd.left = contwnd.right - contwnd.left;//width
- contwnd.top -= (oldHeight - Frames[FrameId].height);//newheight
- SetWindowPos(Frames[FrameId].ContainerWnd, HWND_TOP, 0, 0, contwnd.left, contwnd.top, SWP_SHOWWINDOW | SWP_NOMOVE);
- }
- RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN);
- CLUIFramesStoreAllFrames();
- return 0;
- } else {
- ulockfrm();
- return -1;
+ contwnd.top -= (oldHeight - Frames[FrameId].height);//newheight
+ SetWindowPos(Frames[FrameId].ContainerWnd, HWND_TOP, 0, 0, contwnd.left, contwnd.top, SWP_SHOWWINDOW | SWP_NOMOVE);
}
- ulockfrm();
+ RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN);
+ CLUIFramesStoreAllFrames();
return 0;
}
@@ -1541,9 +1472,9 @@ static int CLUIFramesLoadMainMenu()
if (FramesSysNotStarted)
return -1;
- if (MainMIRoot != (HANDLE)- 1) {
+ if (MainMIRoot != (HANDLE)-1) {
CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)MainMIRoot, 0);
- MainMIRoot = (HGENMENU) - 1;
+ MainMIRoot = (HGENMENU)-1;
}
// create root menu
@@ -1551,14 +1482,14 @@ static int CLUIFramesLoadMainMenu()
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_FRAME);
mi.flags = CMIF_ROOTHANDLE;
mi.position = 3000090000;
- mi.pszPopupName = (char*) - 1;
+ mi.pszPopupName = (char*)-1;
mi.pszName = LPGEN("Frames");
mi.pszService = 0;
MainMIRoot = Menu_AddMainMenuItem(&mi);
// create frames menu
int separator = (int)3000200000;
- for (int i=0; i < nFramescount; i++) {
+ for (int i = 0; i < nFramescount; i++) {
mi.hIcon = Frames[i].TitleBar.hicon;
mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
mi.position = separator;
@@ -1624,7 +1555,7 @@ static int UpdateTBToolTip(int framepos)
ti.cbSize = sizeof(ti);
ti.lpszText = Frames[framepos].TitleBar.tooltip;
ti.hinst = g_hInst;
- ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS ;
+ ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
ti.uId = (UINT_PTR)Frames[framepos].TitleBar.hwnd;
return SendMessage(Frames[framepos].TitleBar.hwndTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
@@ -1644,7 +1575,7 @@ int FrameNCPaint(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BO
if (pcli && pcli->hwndContactList && GetParent(hwnd) == pcli->hwndContactList) {
if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SKINNEDFRAME) {
- StatusItems_t *item = (arStatusItems.getCount() != 0) ? (hasTitleBar ? arStatusItems[ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE] : arStatusItems[ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE]) : 0;
+ StatusItems_t *item = (arStatusItems.getCount() != 0) ? (hasTitleBar ? arStatusItems[ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE] : arStatusItems[ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE]) : 0;
if (item == 0)
return 0;
@@ -1678,7 +1609,7 @@ int FrameNCPaint(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BO
return 0;
}
- if ( GetWindowLongPtr(hwnd, GWL_STYLE) & WS_BORDER) {
+ if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_BORDER) {
hdc = GetWindowDC(hwnd);
HPEN hPenOld = reinterpret_cast<HPEN>(SelectObject(hdc, g_hPenCLUIFrames));
GetWindowRect(hwnd, &rcWindow);
@@ -1698,7 +1629,7 @@ int FrameNCPaint(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BO
int FrameNCCalcSize(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam, BOOL hasTitleBar)
{
- StatusItems_t *item = (arStatusItems.getCount() != 0) ? (hasTitleBar ? arStatusItems[ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE] : arStatusItems[ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE]) : 0;
+ StatusItems_t *item = (arStatusItems.getCount() != 0) ? (hasTitleBar ? arStatusItems[ID_EXTBKOWNEDFRAMEBORDERTB - ID_STATUS_OFFLINE] : arStatusItems[ID_EXTBKOWNEDFRAMEBORDER - ID_STATUS_OFFLINE]) : 0;
LRESULT orig = oldWndProc ? CallWindowProc(oldWndProc, hwnd, WM_NCCALCSIZE, wParam, lParam) : 0;
NCCALCSIZE_PARAMS *nccp = (NCCALCSIZE_PARAMS *)lParam;
DWORD dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
@@ -1730,17 +1661,16 @@ static LRESULT CALLBACK FramesSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, L
}
}
switch (msg) {
- case WM_NCPAINT: {
- return FrameNCPaint(hwnd, oldWndProc ? oldWndProc : DefWindowProc, wParam, lParam, hasTitleBar);
- }
- case WM_NCCALCSIZE: {
- return FrameNCCalcSize(hwnd, oldWndProc, wParam, lParam, hasTitleBar);
- }
- case WM_PRINTCLIENT:
- return 0;
- default:
- break;
+ case WM_NCPAINT:
+ return FrameNCPaint(hwnd, oldWndProc ? oldWndProc : DefWindowProc, wParam, lParam, hasTitleBar);
+
+ case WM_NCCALCSIZE:
+ return FrameNCCalcSize(hwnd, oldWndProc, wParam, lParam, hasTitleBar);
+
+ case WM_PRINTCLIENT:
+ return 0;
}
+
if (oldWndProc)
return CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam);
return DefWindowProc(hwnd, msg, wParam, lParam);
@@ -1755,9 +1685,9 @@ static int CLUIFramesReSort()
int v = 0, i;
int order = 1;
- lockfrm();
+ mir_cslock lck(csFrameHook);
memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES);
- for (i = 0;i < nFramescount;i++) {
+ for (i = 0; i < nFramescount; i++) {
if (Frames[i].align != alTop)
continue;
g_sd[v].order = Frames[i].order;
@@ -1772,7 +1702,7 @@ static int CLUIFramesReSort()
memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES);
v = 0;
- for (i = 0;i < nFramescount;i++) {
+ for (i = 0; i < nFramescount; i++) {
if (Frames[i].align != alBottom)
continue;
g_sd[v].order = Frames[i].order;
@@ -1785,14 +1715,13 @@ static int CLUIFramesReSort()
Frames[g_sd[i].realpos].order = order++;
}
CLUIFramesStoreAllFrames();
- ulockfrm();
return 0;
}
//wparam=(CLISTFrame*)clfrm
INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM lParam)
{
- int style, retval;
+ int style;
char * CustomName = NULL;
CLISTFrame *clfrm = (CLISTFrame *)wParam;
@@ -1800,11 +1729,10 @@ INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM lParam)
if (FramesSysNotStarted) return -1;
if (clfrm->cbSize != sizeof(CLISTFrame)) return -1;
- lockfrm();
- if (nFramescount >= MAX_FRAMES) {
- ulockfrm();
+ mir_cslockfull lck(csFrameHook);
+ if (nFramescount >= MAX_FRAMES)
return -1;
- }
+
if (Frames == NULL) {
Frames = (FRAMEWND*)malloc(sizeof(FRAMEWND) * (MAX_FRAMES + 2));
ZeroMemory(Frames, sizeof(FRAMEWND) * (MAX_FRAMES + 2));
@@ -1820,7 +1748,7 @@ INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM lParam)
Frames[nFramescount].floating = FALSE;
if (clfrm->Flags & F_NO_SUBCONTAINER)
- Frames[nFramescount].OwnerWindow = (HWND) - 2;
+ Frames[nFramescount].OwnerWindow = (HWND)-2;
else
Frames[nFramescount].OwnerWindow = pcli->hwndContactList;
@@ -1844,14 +1772,15 @@ INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM lParam)
Frames[nFramescount].dwFlags = clfrm->Flags;
if (clfrm->name == NULL || ((clfrm->Flags&F_UNICODE) ? lstrlenW(clfrm->wname) : lstrlenA(clfrm->name)) == 0) {
- TCHAR ptszClassName[ 256 ];
+ TCHAR ptszClassName[256];
GetClassName(Frames[nFramescount].hWnd, ptszClassName, SIZEOF(ptszClassName));
Frames[nFramescount].name = mir_tstrdup(ptszClassName);
- } else Frames[nFramescount].name = (clfrm->Flags & F_UNICODE) ? mir_u2t(clfrm->wname) : mir_a2t(clfrm->name);
+ }
+ else Frames[nFramescount].name = (clfrm->Flags & F_UNICODE) ? mir_u2t(clfrm->wname) : mir_a2t(clfrm->name);
if (IsBadCodePtr((FARPROC)clfrm->TBname) || clfrm->TBname == NULL
- || ((clfrm->Flags&F_UNICODE) ? lstrlenW(clfrm->TBwname) : lstrlenA(clfrm->TBname)) == 0)
- Frames[nFramescount].TitleBar.tbname = mir_tstrdup(Frames[nFramescount].name);
+ || ((clfrm->Flags&F_UNICODE) ? lstrlenW(clfrm->TBwname) : lstrlenA(clfrm->TBname)) == 0)
+ Frames[nFramescount].TitleBar.tbname = mir_tstrdup(Frames[nFramescount].name);
else
Frames[nFramescount].TitleBar.tbname = (clfrm->Flags & F_UNICODE) ? mir_u2t(clfrm->TBwname) : mir_a2t(clfrm->TBname);
Frames[nFramescount].needhide = FALSE;
@@ -1868,15 +1797,15 @@ INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM lParam)
// create frame
Frames[nFramescount].TitleBar.hwnd =
CreateWindow(CLUIFrameTitleBarClassName, Frames[nFramescount].name,
- (cfg::getByte(CLUIFrameModule, "RemoveAllTitleBarBorders", 1) ? 0 : WS_BORDER)
- | WS_CHILD | WS_CLIPCHILDREN | (Frames[nFramescount].TitleBar.ShowTitleBar ? WS_VISIBLE : 0) |
- WS_CLIPCHILDREN, 0, 0, 0, 0, pcli->hwndContactList, NULL, g_hInst, NULL);
+ (cfg::getByte(CLUIFrameModule, "RemoveAllTitleBarBorders", 1) ? 0 : WS_BORDER)
+ | WS_CHILD | WS_CLIPCHILDREN | (Frames[nFramescount].TitleBar.ShowTitleBar ? WS_VISIBLE : 0) |
+ WS_CLIPCHILDREN, 0, 0, 0, 0, pcli->hwndContactList, NULL, g_hInst, NULL);
SetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd, GWLP_USERDATA, Frames[nFramescount].id);
Frames[nFramescount].TitleBar.hwndTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- pcli->hwndContactList, NULL, g_hInst, NULL);
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ pcli->hwndContactList, NULL, g_hInst, NULL);
SetWindowPos(Frames[nFramescount].TitleBar.hwndTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
{
@@ -1887,42 +1816,40 @@ INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM lParam)
ti.cbSize = sizeof(ti);
ti.lpszText = "";
ti.hinst = g_hInst;
- ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS ;
+ ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
ti.uId = (UINT_PTR)Frames[nFramescount].TitleBar.hwnd;
- res = SendMessageA(Frames[nFramescount].TitleBar.hwndTip, TTM_ADDTOOL, 0, (LPARAM) & ti);
+ res = SendMessageA(Frames[nFramescount].TitleBar.hwndTip, TTM_ADDTOOL, 0, (LPARAM)& ti);
}
SendMessage(Frames[nFramescount].TitleBar.hwndTip, TTM_ACTIVATE, (WPARAM)Frames[nFramescount].TitleBar.ShowTitleBarTip, 0);
Frames[nFramescount].oldstyles = GetWindowLongPtr(Frames[nFramescount].hWnd, GWL_STYLE);
Frames[nFramescount].TitleBar.oldstyles = GetWindowLongPtr(Frames[nFramescount].TitleBar.hwnd, GWL_STYLE);
- //Frames[nFramescount].FloatingPos.x=
- retval = Frames[nFramescount].id;
+ int retval = Frames[nFramescount].id;
Frames[nFramescount].order = nFramescount + 1;
nFramescount++;
CLUIFramesLoadFrameSettings(id2pos(retval));
- style = GetWindowLongPtr(Frames[nFramescount-1].hWnd, GWL_STYLE);
+ style = GetWindowLongPtr(Frames[nFramescount - 1].hWnd, GWL_STYLE);
style &= ~(WS_BORDER);
- style |= ((Frames[nFramescount-1].UseBorder) ? WS_BORDER : 0);
+ style |= ((Frames[nFramescount - 1].UseBorder) ? WS_BORDER : 0);
- style |= Frames[nFramescount-1].Skinned ? CLS_SKINNEDFRAME : 0;
+ style |= Frames[nFramescount - 1].Skinned ? CLS_SKINNEDFRAME : 0;
- SetWindowLongPtr(Frames[nFramescount-1].hWnd, GWL_STYLE, style);
- SetWindowLongPtr(Frames[nFramescount-1].TitleBar.hwnd, GWL_STYLE, style & ~(WS_VSCROLL | WS_HSCROLL));
+ SetWindowLongPtr(Frames[nFramescount - 1].hWnd, GWL_STYLE, style);
+ SetWindowLongPtr(Frames[nFramescount - 1].TitleBar.hwnd, GWL_STYLE, style & ~(WS_VSCROLL | WS_HSCROLL));
- if (Frames[nFramescount-1].order == 0) {
- Frames[nFramescount-1].order = nFramescount;
- }
+ if (Frames[nFramescount - 1].order == 0)
+ Frames[nFramescount - 1].order = nFramescount;
- ulockfrm();
+ lck.unlock();
alclientFrame = -1;//recalc it
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
- if (Frames[nFramescount-1].floating) {
- Frames[nFramescount-1].floating = FALSE;
+ if (Frames[nFramescount - 1].floating) {
+ Frames[nFramescount - 1].floating = FALSE;
CLUIFrameSetFloat(retval, 1);//lparam=1 use stored width and height
}
RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN);
@@ -1931,19 +1858,15 @@ INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM lParam)
static INT_PTR CLUIFramesRemoveFrame(WPARAM wParam, LPARAM lParam)
{
- int pos;
if (FramesSysNotStarted)
return -1;
- lockfrm();
- pos = id2pos((INT_PTR)wParam);
-
- if (pos < 0 || pos > nFramescount) {
- ulockfrm();
- return -1;
- }
-
{
+ mir_cslock lck(csFrameHook);
+ int pos = id2pos((INT_PTR)wParam);
+ if (pos < 0 || pos > nFramescount)
+ return -1;
+
FRAMEWND* F = &Frames[pos];
if (F->hWnd == g_hwndEventArea)
wndFrameEventArea = NULL;
@@ -1957,18 +1880,17 @@ static INT_PTR CLUIFramesRemoveFrame(WPARAM wParam, LPARAM lParam)
mir_free(F->TitleBar.tooltip);
DestroyWindow(F->hWnd);
- F->hWnd = (HWND) - 1;
+ F->hWnd = (HWND)-1;
DestroyWindow(F->TitleBar.hwnd);
- F->TitleBar.hwnd = (HWND) - 1;
+ F->TitleBar.hwnd = (HWND)-1;
DestroyWindow(F->ContainerWnd);
- F->ContainerWnd = (HWND) - 1;
+ F->ContainerWnd = (HWND)-1;
DestroyMenu(F->TitleBar.hmenu);
- }
- RemoveItemFromList(pos, &Frames, &nFramescount);
+ RemoveItemFromList(pos, &Frames, &nFramescount);
+ }
- ulockfrm();
- if ( !cfg::shutDown) {
+ if (!cfg::shutDown) {
InvalidateRect(pcli->hwndContactList, NULL, TRUE);
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN);
@@ -2000,19 +1922,20 @@ int CLUIFrameMoveResize(const FRAMEWND *Frame)
if (Frame->visible && (!Frame->needhide)) {
ShowWindow(Frame->hWnd, SW_SHOW);
ShowWindow(Frame->TitleBar.hwnd, Frame->TitleBar.ShowTitleBar == TRUE ? SW_SHOW : SW_HIDE);
- } else {
+ }
+ else {
ShowWindow(Frame->hWnd, SW_HIDE);
ShowWindow(Frame->TitleBar.hwnd, SW_HIDE);
return 0;
}
SetWindowPos(Frame->hWnd, NULL, Frame->wndSize.left + cfg::dat.bCLeft, Frame->wndSize.top + cfg::dat.topOffset,
- (Frame->wndSize.right - Frame->wndSize.left),
- (Frame->wndSize.bottom - Frame->wndSize.top), SWP_NOZORDER | SWP_NOREDRAW);
+ (Frame->wndSize.right - Frame->wndSize.left),
+ (Frame->wndSize.bottom - Frame->wndSize.top), SWP_NOZORDER | SWP_NOREDRAW);
if (Frame->TitleBar.ShowTitleBar) {
SetWindowPos(Frame->TitleBar.hwnd, NULL, Frame->wndSize.left + cfg::dat.bCLeft, Frame->wndSize.top + cfg::dat.topOffset - TitleBarH,
- (Frame->wndSize.right - Frame->wndSize.left),
- TitleBarH + (Frame->UseBorder ? (!Frame->collapsed ? (Frame->align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER);
+ (Frame->wndSize.right - Frame->wndSize.left),
+ TitleBarH + (Frame->UseBorder ? (!Frame->collapsed ? (Frame->align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER);
}
return 0;
}
@@ -2030,7 +1953,7 @@ BOOLEAN CLUIFramesFitInSize(void)
if (clientfrm != -1)
tbh = TitleBarH * btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
- for (i = 0;i < nFramescount;i++) {
+ for (i = 0; i < nFramescount; i++) {
if ((Frames[i].align != alClient) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) {
sumheight += (Frames[i].height) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 2/*+btoint(Frames[i].UseBorder)*2*/;
if (sumheight > ContactListHeight - tbh - 2)
@@ -2042,45 +1965,43 @@ BOOLEAN CLUIFramesFitInSize(void)
int CLUIFramesGetMinHeight()
{
- int i, tbh, clientfrm, sumheight = 0;
- RECT border;
- int allbord = 0;
-
if (pcli->hwndContactList == NULL)
return 0;
- lockfrm();
-
- TitleBarH = cfg::dat.titleBarHeight;
- // search for alClient frame and get the titlebar's height
- tbh = 0;
- clientfrm = CLUIFramesGetalClientFrame();
- if (clientfrm != -1)
- tbh = TitleBarH * btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
-
- for (i = 0;i < nFramescount;i++) {
- if ((Frames[i].align != alClient) && (Frames[i].visible) && (!Frames[i].needhide) && (!Frames[i].floating)) {
- RECT wsize;
+ int i, tbh, clientfrm, sumheight = 0;
+ RECT border;
+ int allbord = 0;
+ {
+ mir_cslock lck(csFrameHook);
- GetWindowRect(Frames[i].hWnd, &wsize);
- sumheight += (wsize.bottom - wsize.top) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 3;
+ TitleBarH = cfg::dat.titleBarHeight;
+ // search for alClient frame and get the titlebar's height
+ tbh = 0;
+ clientfrm = CLUIFramesGetalClientFrame();
+ if (clientfrm != -1)
+ tbh = TitleBarH * btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
+
+ for (i = 0; i < nFramescount; i++) {
+ if ((Frames[i].align != alClient) && (Frames[i].visible) && (!Frames[i].needhide) && (!Frames[i].floating)) {
+ RECT wsize;
+
+ GetWindowRect(Frames[i].hWnd, &wsize);
+ sumheight += (wsize.bottom - wsize.top) + (TitleBarH * btoint(Frames[i].TitleBar.ShowTitleBar)) + 3;
+ }
}
}
- ulockfrm();
+
GetBorderSize(pcli->hwndContactList, &border);
return(sumheight + border.top + border.bottom + allbord + tbh + 3);
}
int SizeMoveNewSizes()
{
- int i;
- for (i = 0;i < nFramescount;i++) {
-
- if (Frames[i].floating) {
+ for (int i = 0; i < nFramescount; i++) {
+ if (Frames[i].floating)
CLUIFrameResizeFloatingFrame(i);
- } else {
+ else
CLUIFrameMoveResize(&Frames[i]);
- };
}
return 0;
}
@@ -2120,10 +2041,10 @@ int CLUIFramesResize(const RECT newsize)
tbh = 0;
clientfrm = CLUIFramesGetalClientFrame();
if (clientfrm != -1)
- tbh = (TitleBarH) * btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
+ tbh = (TitleBarH)* btoint(Frames[clientfrm].TitleBar.ShowTitleBar);
- for (i = 0;i < nFramescount;i++) {
- if ( !Frames[i].floating) {
+ for (i = 0; i < nFramescount; i++) {
+ if (!Frames[i].floating) {
Frames[i].needhide = FALSE;
Frames[i].wndSize.left = 0;
Frames[i].wndSize.right = newsize.right - newsize.left;
@@ -2132,7 +2053,7 @@ int CLUIFramesResize(const RECT newsize)
{
//sorting stuff
memset(g_sd, 0, sizeof(SortData) * MAX_FRAMES);
- for (i = 0;i < nFramescount;i++) {
+ for (i = 0; i < nFramescount; i++) {
g_sd[i].order = Frames[i].order;
g_sd[i].realpos = i;
}
@@ -2140,13 +2061,13 @@ int CLUIFramesResize(const RECT newsize)
}
drawitems = nFramescount;
- while (sumheight > (newheight - tbh) && drawitems > 0) {
+ while (sumheight >(newheight - tbh) && drawitems > 0) {
sumheight = 0;
drawitems = 0;
- for (i = 0;i < nFramescount;i++) {
+ for (i = 0; i < nFramescount; i++) {
if (((Frames[i].align != alClient)) && (!Frames[i].floating) && (Frames[i].visible) && (!Frames[i].needhide)) {
drawitems++;
- curfrmtbh = (TitleBarH) * btoint(Frames[i].TitleBar.ShowTitleBar);
+ curfrmtbh = (TitleBarH)* btoint(Frames[i].TitleBar.ShowTitleBar);
sumheight += (Frames[i].height) + curfrmtbh + (i > 0 ? sepw : 0) + (Frames[i].UseBorder ? 2 : 0);
if (sumheight > newheight - tbh) {
sumheight -= (Frames[i].height) + curfrmtbh + (i > 0 ? sepw : 0);
@@ -2160,11 +2081,11 @@ int CLUIFramesResize(const RECT newsize)
prevframe = -1;
prevframebottomline = 0;
- for (j = 0;j < nFramescount;j++) {
+ for (j = 0; j < nFramescount; j++) {
//move all alTop frames
i = g_sd[j].realpos;
if ((!Frames[i].needhide) && (!Frames[i].floating) && (Frames[i].visible) && (Frames[i].align == alTop)) {
- curfrmtbh = (TitleBarH) * btoint(Frames[i].TitleBar.ShowTitleBar);
+ curfrmtbh = (TitleBarH)* btoint(Frames[i].TitleBar.ShowTitleBar);
Frames[i].wndSize.top = prevframebottomline + (prevframebottomline > 0 ? sepw : 0) + (curfrmtbh);
Frames[i].wndSize.bottom = Frames[i].height + Frames[i].wndSize.top + (Frames[i].UseBorder ? 2 : 0);
Frames[i].prevvisframe = prevframe;
@@ -2175,7 +2096,7 @@ int CLUIFramesResize(const RECT newsize)
}
if (sumheight < newheight) {
- for (j = 0;j < nFramescount;j++) {
+ for (j = 0; j < nFramescount; j++) {
//move alClient frame
i = g_sd[j].realpos;
if ((!Frames[i].needhide) && (!Frames[i].floating) && (Frames[i].visible) && (Frames[i].align == alClient)) {
@@ -2200,11 +2121,11 @@ int CLUIFramesResize(const RECT newsize)
//newheight
prevframebottomline = last_bottomtop = newheight;
//prevframe=-1;
- for (j = nFramescount - 1;j >= 0;j--) {
+ for (j = nFramescount - 1; j >= 0; j--) {
//move all alBottom frames
i = g_sd[j].realpos;
if ((Frames[i].visible) && (!Frames[i].floating) && (!Frames[i].needhide) && (Frames[i].align == alBottom)) {
- curfrmtbh = (TitleBarH) * btoint(Frames[i].TitleBar.ShowTitleBar);
+ curfrmtbh = (TitleBarH)* btoint(Frames[i].TitleBar.ShowTitleBar);
Frames[i].wndSize.bottom = prevframebottomline - ((prevframebottomline < newheight) ? sepw : 0);
Frames[i].wndSize.top = Frames[i].wndSize.bottom - Frames[i].height - (Frames[i].UseBorder ? 2 : 0);
Frames[i].prevvisframe = prevframe;
@@ -2216,7 +2137,6 @@ int CLUIFramesResize(const RECT newsize)
}
// correct client frame bottom gap if there is no other top frame.
-
if (clientframe != -1) {
Frames[clientframe].wndSize.bottom = last_bottomtop - (last_bottomtop < newheight ? sepw : 0);
Frames[clientframe].height = Frames[clientframe].wndSize.bottom - Frames[clientframe].wndSize.top;
@@ -2229,24 +2149,24 @@ INT_PTR CLUIFramesUpdateFrame(WPARAM wParam, LPARAM lParam)
int pos;
if (FramesSysNotStarted)
return -1;
+
if (wParam == -1) {
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
return 0;
}
- if (lParam&FU_FMPOS)
+
+ if (lParam & FU_FMPOS)
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 1);
- lockfrm();
+ mir_cslock lck(csFrameHook);
pos = id2pos((INT_PTR)wParam);
- if (pos < 0 || pos >= nFramescount) {
- ulockfrm();
+ if (pos < 0 || pos >= nFramescount)
return -1;
- }
- if (lParam&FU_TBREDRAW)
+
+ if (lParam & FU_TBREDRAW)
CLUIFramesForceUpdateTB(&Frames[pos]);
- if (lParam&FU_FMREDRAW)
+ if (lParam & FU_FMREDRAW)
CLUIFramesForceUpdateFrame(&Frames[pos]);
- ulockfrm();
return 0;
}
@@ -2254,12 +2174,11 @@ int dock_prevent_moving = 0;
int CLUIFramesApplyNewSizes(int mode)
{
- int i;
dock_prevent_moving = 0;
- for (i = 0;i < nFramescount;i++) {
- if ((mode == 1 && Frames[i].OwnerWindow != (HWND) - 2 && Frames[i].OwnerWindow) ||
- (mode == 2 && Frames[i].OwnerWindow == (HWND) - 2) ||
- (mode == 3))
+
+ for (int i = 0; i < nFramescount; i++) {
+ if ((mode == 1 && Frames[i].OwnerWindow != (HWND)-2 && Frames[i].OwnerWindow) ||
+ (mode == 2 && Frames[i].OwnerWindow == (HWND)-2) || (mode == 3))
if (Frames[i].floating)
CLUIFrameResizeFloatingFrame(i);
else
@@ -2269,7 +2188,7 @@ int CLUIFramesApplyNewSizes(int mode)
return 0;
}
-RECT old_window_rect = {0}, new_window_rect = {0};
+RECT old_window_rect = { 0 }, new_window_rect = { 0 };
int SizeFramesByWindowRect(RECT *r)
{
@@ -2280,7 +2199,8 @@ int SizeFramesByWindowRect(RECT *r)
return -1;
TitleBarH = cfg::dat.titleBarHeight;
- lockfrm();
+
+ mir_cslock lck(csFrameHook);
GapBetweenFrames = cfg::dat.gapBetweenFrames;
nRect = *r;
@@ -2294,42 +2214,43 @@ int SizeFramesByWindowRect(RECT *r)
CLUIFramesResize(nRect);
{
int i;
- for (i = 0;i < nFramescount;i++) {
+ for (i = 0; i < nFramescount; i++) {
int dx;
int dy;
dx = new_window_rect.left - old_window_rect.left;
dy = new_window_rect.top - old_window_rect.top;
- if ( !Frames[i].floating) {
- if (Frames[i].OwnerWindow && Frames[i].OwnerWindow != (HWND) - 2) {
+ if (!Frames[i].floating) {
+ if (Frames[i].OwnerWindow && Frames[i].OwnerWindow != (HWND)-2) {
/*
if (Frames[i].wndSize.right - Frames[i].wndSize.left == Frames[i].oldWndSize.right - Frames[i].oldWndSize.left &&
- Frames[i].wndSize.bottom - Frames[i].wndSize.top == Frames[i].oldWndSize.bottom - Frames[i].oldWndSize.top)
- noSize = SWP_NOSIZE;
+ Frames[i].wndSize.bottom - Frames[i].wndSize.top == Frames[i].oldWndSize.bottom - Frames[i].oldWndSize.top)
+ noSize = SWP_NOSIZE;
else {
- noSize = 0;
- CopyRect(&Frames[i].oldWndSize, &Frames[i].wndSize);
+ noSize = 0;
+ CopyRect(&Frames[i].oldWndSize, &Frames[i].wndSize);
}*/
SetWindowPos(Frames[i].hWnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset,
- (Frames[i].wndSize.right - Frames[i].wndSize.left),
- (Frames[i].wndSize.bottom - Frames[i].wndSize.top), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS | noSize);
+ (Frames[i].wndSize.right - Frames[i].wndSize.left),
+ (Frames[i].wndSize.bottom - Frames[i].wndSize.top), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS | noSize);
if (Frames[i].TitleBar.ShowTitleBar) {
SetWindowPos(Frames[i].TitleBar.hwnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset - TitleBarH,
- (Frames[i].wndSize.right - Frames[i].wndSize.left),
- TitleBarH + (Frames[i].UseBorder ? (!Frames[i].collapsed ? (Frames[i].align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS);
+ (Frames[i].wndSize.right - Frames[i].wndSize.left),
+ TitleBarH + (Frames[i].UseBorder ? (!Frames[i].collapsed ? (Frames[i].align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS);
}
- } else {
+ }
+ else {
int res = 0;
// set frame position
SetWindowPos(Frames[i].hWnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset,
- (Frames[i].wndSize.right - Frames[i].wndSize.left),
- (Frames[i].wndSize.bottom - Frames[i].wndSize.top), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOCOPYBITS | SWP_NOREDRAW);
+ (Frames[i].wndSize.right - Frames[i].wndSize.left),
+ (Frames[i].wndSize.bottom - Frames[i].wndSize.top), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOCOPYBITS | SWP_NOREDRAW);
// set titlebar position
if (Frames[i].TitleBar.ShowTitleBar) {
SetWindowPos(Frames[i].TitleBar.hwnd, NULL, Frames[i].wndSize.left + cfg::dat.bCLeft, Frames[i].wndSize.top + cfg::dat.topOffset - TitleBarH,
- (Frames[i].wndSize.right - Frames[i].wndSize.left),
- TitleBarH + (Frames[i].UseBorder ? (!Frames[i].collapsed ? (Frames[i].align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW);
+ (Frames[i].wndSize.right - Frames[i].wndSize.left),
+ TitleBarH + (Frames[i].UseBorder ? (!Frames[i].collapsed ? (Frames[i].align == alClient ? 0 : 2) : 1) : 0), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW);
}
//UpdateWindow(Frames[i].hWnd);
if (Frames[i].TitleBar.ShowTitleBar)
@@ -2343,55 +2264,55 @@ int SizeFramesByWindowRect(RECT *r)
LastStoreTick = GetTickCount();
}
}
- ulockfrm();
return 0;
}
int CLUIFramesOnClistResize(WPARAM wParam, LPARAM lParam)
{
- RECT nRect, rcStatus;
- int tick;
GapBetweenFrames = cfg::dat.gapBetweenFrames;
if (FramesSysNotStarted || cfg::shutDown)
return -1;
- lockfrm();
-
- GetClientRect(pcli->hwndContactList, &nRect);
- if (lParam && lParam != 1) {
- RECT oldRect;
- POINT pt;
- RECT * newRect = (RECT *)lParam;
- int dl, dt, dr, db;
- GetWindowRect((HWND)wParam, &oldRect);
- pt.x = nRect.left;
- pt.y = nRect.top;
- ClientToScreen(pcli->hwndContactList, &pt);
- dl = pt.x - oldRect.left;
- dt = pt.y - oldRect.top;
- dr = (oldRect.right - oldRect.left) - (nRect.right - nRect.left) - dl;
- db = (oldRect.bottom - oldRect.top) - (nRect.bottom - nRect.top) - dt;
- nRect.left = newRect->left + dl;
- nRect.top = newRect->top + dt;
- nRect.bottom = newRect->bottom - db;
- nRect.right = newRect->right - dr;
- }
-
- rcStatus.top = rcStatus.bottom = 0;
+ RECT nRect, rcStatus;
+ int tick;
+ {
+ mir_cslock lck(csFrameHook);
- nRect.bottom -= (cfg::dat.statusBarHeight + cfg::dat.bottomOffset);
- nRect.right -= cfg::dat.bCRight;
- nRect.left = cfg::dat.bCLeft;
- nRect.top = cfg::dat.topOffset;
- ContactListHeight = nRect.bottom - nRect.top;
+ GetClientRect(pcli->hwndContactList, &nRect);
+ if (lParam && lParam != 1) {
+ RECT oldRect;
+ POINT pt;
+ RECT * newRect = (RECT *)lParam;
+ int dl, dt, dr, db;
+ GetWindowRect((HWND)wParam, &oldRect);
+ pt.x = nRect.left;
+ pt.y = nRect.top;
+ ClientToScreen(pcli->hwndContactList, &pt);
+ dl = pt.x - oldRect.left;
+ dt = pt.y - oldRect.top;
+ dr = (oldRect.right - oldRect.left) - (nRect.right - nRect.left) - dl;
+ db = (oldRect.bottom - oldRect.top) - (nRect.bottom - nRect.top) - dt;
+ nRect.left = newRect->left + dl;
+ nRect.top = newRect->top + dt;
+ nRect.bottom = newRect->bottom - db;
+ nRect.right = newRect->right - dr;
+ }
- tick = GetTickCount();
+ rcStatus.top = rcStatus.bottom = 0;
- CLUIFramesResize(nRect);
- CLUIFramesApplyNewSizes(3);
+ nRect.bottom -= (cfg::dat.statusBarHeight + cfg::dat.bottomOffset);
+ nRect.right -= cfg::dat.bCRight;
+ nRect.left = cfg::dat.bCLeft;
+ nRect.top = cfg::dat.topOffset;
+ ContactListHeight = nRect.bottom - nRect.top;
+
+ tick = GetTickCount();
+
+ CLUIFramesResize(nRect);
+ CLUIFramesApplyNewSizes(3);
+ }
- ulockfrm();
tick = GetTickCount() - tick;
if (pcli->hwndContactList != 0)
@@ -2427,7 +2348,7 @@ int OnFrameTitleBarBackgroundChange()
hBmpBackground = NULL;
}
if (cfg::getByte("FrameTitleBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) {
- if ( !db_get(NULL, "FrameTitleBar", "BkBitmap", &dbv)) {
+ if (!db_get(NULL, "FrameTitleBar", "BkBitmap", &dbv)) {
hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
mir_free(dbv.pszVal);
}
@@ -2440,10 +2361,6 @@ int OnFrameTitleBarBackgroundChange()
static int DrawTitleBar(HDC dc, RECT rect, int Frameid)
{
- HDC hdcMem;
- HBITMAP hBmpOsb, hoBmp;
- HBRUSH hBack, hoBrush;
- int pos;
StatusItems_t *item = arStatusItems[ID_EXTBKFRAMETITLE - ID_STATUS_OFFLINE];
/*
@@ -2453,67 +2370,70 @@ static int DrawTitleBar(HDC dc, RECT rect, int Frameid)
return 0;
TitleBarH = cfg::dat.titleBarHeight;
- hdcMem = CreateCompatibleDC(dc);
- hBmpOsb = CreateCompatibleBitmap(dc, rect.right, rect.bottom);
- hoBmp = reinterpret_cast<HBITMAP>(SelectObject(hdcMem, hBmpOsb));
+ HDC hdcMem = CreateCompatibleDC(dc);
+ HBITMAP hBmpOsb = CreateCompatibleBitmap(dc, rect.right, rect.bottom);
+ HBITMAP hoBmp = reinterpret_cast<HBITMAP>(SelectObject(hdcMem, hBmpOsb));
SetBkMode(hdcMem, TRANSPARENT);
- hBack = GetSysColorBrush(COLOR_3DFACE);
- hoBrush = reinterpret_cast<HBRUSH>(SelectObject(hdcMem, hBack));
-
- lockfrm();
- pos = id2pos(Frameid);
-
- if (pos >= 0 && pos < nFramescount) {
- HFONT oFont;
- int fHeight, fontTop;
- GetClientRect(Frames[pos].TitleBar.hwnd, &Frames[pos].TitleBar.wndSize);
-
- if (cfg::clcdat) {
- oFont = ChangeToFont(hdcMem, cfg::clcdat, FONTID_FRAMETITLE, &fHeight);
- } else {
- oFont = reinterpret_cast<HFONT>(SelectObject(hdcMem, GetStockObject(DEFAULT_GUI_FONT)));
- fHeight = 10;
- }
- fontTop = (TitleBarH - fHeight) / 2;
-
- if (cfg::dat.bWallpaperMode && !Frames[pos].floating)
- SkinDrawBg(Frames[pos].TitleBar.hwnd, hdcMem);
-
- if ( !item->IGNORED) {
- RECT rc = Frames[pos].TitleBar.wndSize;
- rc.top += item->MARGIN_TOP;
- rc.bottom -= item->MARGIN_BOTTOM;
- rc.left += item->MARGIN_LEFT;
- rc.right -= item->MARGIN_RIGHT;
- DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT,
- item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem);
- SetTextColor(hdcMem, item->TEXTCOLOR);
- } else if (cfg::clcdat) {
- FillRect(hdcMem, &rect, hBack);
- SetTextColor(hdcMem, cfg::clcdat->fontInfo[FONTID_FRAMETITLE].colour);
- } else {
- FillRect(hdcMem, &rect, hBack);
- SetTextColor(hdcMem, GetSysColor(COLOR_BTNTEXT));
- }
+ HBRUSH hBack = GetSysColorBrush(COLOR_3DFACE);
+ HBRUSH hoBrush = reinterpret_cast<HBRUSH>(SelectObject(hdcMem, hBack));
+ {
+ mir_cslock lck(csFrameHook);
+ int pos = id2pos(Frameid);
+ if (pos >= 0 && pos < nFramescount) {
+ HFONT oFont;
+ int fHeight, fontTop;
+ GetClientRect(Frames[pos].TitleBar.hwnd, &Frames[pos].TitleBar.wndSize);
+
+ if (cfg::clcdat) {
+ oFont = ChangeToFont(hdcMem, cfg::clcdat, FONTID_FRAMETITLE, &fHeight);
+ }
+ else {
+ oFont = reinterpret_cast<HFONT>(SelectObject(hdcMem, GetStockObject(DEFAULT_GUI_FONT)));
+ fHeight = 10;
+ }
+ fontTop = (TitleBarH - fHeight) / 2;
+
+ if (cfg::dat.bWallpaperMode && !Frames[pos].floating)
+ SkinDrawBg(Frames[pos].TitleBar.hwnd, hdcMem);
+
+ if (!item->IGNORED) {
+ RECT rc = Frames[pos].TitleBar.wndSize;
+ rc.top += item->MARGIN_TOP;
+ rc.bottom -= item->MARGIN_BOTTOM;
+ rc.left += item->MARGIN_LEFT;
+ rc.right -= item->MARGIN_RIGHT;
+ DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT,
+ item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem);
+ SetTextColor(hdcMem, item->TEXTCOLOR);
+ }
+ else if (cfg::clcdat) {
+ FillRect(hdcMem, &rect, hBack);
+ SetTextColor(hdcMem, cfg::clcdat->fontInfo[FONTID_FRAMETITLE].colour);
+ }
+ else {
+ FillRect(hdcMem, &rect, hBack);
+ SetTextColor(hdcMem, GetSysColor(COLOR_BTNTEXT));
+ }
- if ( !AlignCOLLIconToLeft) {
- if (Frames[pos].TitleBar.hicon != NULL) {
- DrawIconEx(hdcMem, 6 + cfg::dat.bClipBorder, ((TitleBarH >> 1) - 8), Frames[pos].TitleBar.hicon, 16, 16, 0, NULL, DI_NORMAL);
- TextOut(hdcMem, 24 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, lstrlen(Frames[pos].TitleBar.tbname));
+ if (!AlignCOLLIconToLeft) {
+ if (Frames[pos].TitleBar.hicon != NULL) {
+ DrawIconEx(hdcMem, 6 + cfg::dat.bClipBorder, ((TitleBarH >> 1) - 8), Frames[pos].TitleBar.hicon, 16, 16, 0, NULL, DI_NORMAL);
+ TextOut(hdcMem, 24 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, lstrlen(Frames[pos].TitleBar.tbname));
+ }
+ else TextOut(hdcMem, 6 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, lstrlen(Frames[pos].TitleBar.tbname));
}
- else TextOut(hdcMem, 6 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, lstrlen(Frames[pos].TitleBar.tbname));
- }
- else TextOut(hdcMem, 18 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, lstrlen(Frames[pos].TitleBar.tbname));
+ else TextOut(hdcMem, 18 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, lstrlen(Frames[pos].TitleBar.tbname));
- if ( !AlignCOLLIconToLeft)
- DrawIconEx(hdcMem, Frames[pos].TitleBar.wndSize.right - 22, ((TitleBarH >> 1) - 8), Frames[pos].collapsed ? LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN) : LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT), 16, 16, 0, NULL, DI_NORMAL);
- else
- DrawIconEx(hdcMem, 0, ((TitleBarH >> 1) - 8), Frames[pos].collapsed ? LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN) : LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT), 16, 16, 0, NULL, DI_NORMAL);
- SelectObject(hdcMem, oFont);
+ if (!AlignCOLLIconToLeft)
+ DrawIconEx(hdcMem, Frames[pos].TitleBar.wndSize.right - 22, ((TitleBarH >> 1) - 8), Frames[pos].collapsed ? LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN) : LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT), 16, 16, 0, NULL, DI_NORMAL);
+ else
+ DrawIconEx(hdcMem, 0, ((TitleBarH >> 1) - 8), Frames[pos].collapsed ? LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN) : LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT), 16, 16, 0, NULL, DI_NORMAL);
+ SelectObject(hdcMem, oFont);
+ }
}
- ulockfrm();
+
BitBlt(dc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, hdcMem, rect.left, rect.top, SRCCOPY);
SelectObject(hdcMem, hoBmp);
SelectObject(hdcMem, hoBrush);
@@ -2525,8 +2445,8 @@ static int DrawTitleBar(HDC dc, RECT rect, int Frameid)
#define MPCF_CONTEXTFRAMEMENU 3
POINT ptOld;
-short nLeft = 0;
-short nTop = 0;
+short nLeft = 0;
+short nTop = 0;
LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
@@ -2552,7 +2472,7 @@ LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
return 0;
case WM_COMMAND:
- if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), 0), Frameid))
+ if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), 0), Frameid))
break;
if (HIWORD(wParam) == 0) {//mouse events for self created menu
@@ -2586,11 +2506,10 @@ LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
else {
framepos = id2pos(Frameid);
- lockfrm();
- if (framepos == -1) {
- ulockfrm();
+ mir_cslock lck(csFrameHook);
+ if (framepos == -1)
break;
- }
+
hmenu = CreatePopupMenu();
AppendMenu(hmenu, MF_STRING | MF_DISABLED | MF_GRAYED, 15, Frames[framepos].name);
AppendMenu(hmenu, MF_SEPARATOR, 16, _T(""));
@@ -2619,8 +2538,6 @@ LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
AppendMenu(hmenu, MF_STRING | MF_CHECKED, frame_menu_floating, TranslateT("Floating"));
else
AppendMenu(hmenu, MF_STRING, frame_menu_floating, TranslateT("Floating"));
-
- ulockfrm();
}
POINT pt;
GetCursorPos(&pt);
@@ -2653,248 +2570,232 @@ LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
case WM_LBUTTONDOWN:
framepos = id2pos(Frameid);
- lockfrm();
- if (framepos == -1) {
- ulockfrm();
- break;
- }
-
- if (Frames[framepos].floating) {
- POINT pt;
- GetCursorPos(&pt);
- Frames[framepos].TitleBar.oldpos = pt;
- }
+ {
+ mir_cslock lck(csFrameHook);
+ if (framepos == -1)
+ break;
- if ((!(wParam&MK_CONTROL)) && Frames[framepos].Locked && (!(Frames[framepos].floating))) {
- if (cfg::getByte("CLUI", "ClientAreaDrag", 0)) {
+ if (Frames[framepos].floating) {
POINT pt;
GetCursorPos(&pt);
- ulockfrm();
- return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y));
+ Frames[framepos].TitleBar.oldpos = pt;
+ }
+
+ if ((!(wParam&MK_CONTROL)) && Frames[framepos].Locked && (!(Frames[framepos].floating))) {
+ if (cfg::getByte("CLUI", "ClientAreaDrag", 0)) {
+ POINT pt;
+ GetCursorPos(&pt);
+ return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y));
+ }
+ }
+ if (Frames[framepos].floating) {
+ RECT rc;
+ GetCursorPos(&ptOld);
+ GetWindowRect(hwnd, &rc);
+ nLeft = (short)rc.left;
+ nTop = (short)rc.top;
}
}
- if (Frames[framepos].floating) {
- RECT rc;
- GetCursorPos(&ptOld);
- GetWindowRect(hwnd, &rc);
- nLeft = (short)rc.left;
- nTop = (short)rc.top;
- }
- ulockfrm();
SetCapture(hwnd);
break;
case WM_MOUSEMOVE:
{
- POINT pt, pt2;
- RECT wndr;
- int pos;
- {
- char TBcapt[255];
-
- lockfrm();
- pos = id2pos(Frameid);
-
- if (pos != -1) {
- int oldflags;
- mir_snprintf(TBcapt, SIZEOF(TBcapt), "%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d",
- Frames[pos].name, Frames[pos].height, Frames[pos].visible, Frames[pos].floating,
- Frames[pos].FloatingPos.x, Frames[pos].FloatingPos.y,
- Frames[pos].FloatingSize.x, Frames[pos].FloatingSize.y,
- Frames[pos].order
- );
-
- oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, Frames[pos].id), 0);
- if ( !(oldflags&F_SHOWTBTIP))
- oldflags |= F_SHOWTBTIP;
- }
- ulockfrm();
+ char TBcapt[255];
+
+ mir_cslock lck(csFrameHook);
+ int pos = id2pos(Frameid);
+ if (pos != -1) {
+ int oldflags;
+ mir_snprintf(TBcapt, SIZEOF(TBcapt), "%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d",
+ Frames[pos].name, Frames[pos].height, Frames[pos].visible, Frames[pos].floating,
+ Frames[pos].FloatingPos.x, Frames[pos].FloatingPos.y,
+ Frames[pos].FloatingSize.x, Frames[pos].FloatingSize.y,
+ Frames[pos].order
+ );
+
+ oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, Frames[pos].id), 0);
+ if (!(oldflags&F_SHOWTBTIP))
+ oldflags |= F_SHOWTBTIP;
}
- if (wParam & MK_LBUTTON) {
- RECT rcMiranda;
- RECT rcwnd, rcOverlap;
- POINT newpt, ofspt, curpt, newpos;
+ }
+ if (wParam & MK_LBUTTON) {
+ RECT rcMiranda;
+ RECT rcwnd, rcOverlap;
+ POINT newpt, ofspt, curpt, newpos;
+
+ mir_cslockfull lck(csFrameHook);
- lockfrm();
+ int pos = id2pos(Frameid);
+ if (Frames[pos].floating) {
+ GetCursorPos(&curpt);
+ rcwnd.bottom = curpt.y + 5;
+ rcwnd.top = curpt.y;
+ rcwnd.left = curpt.x;
+ rcwnd.right = curpt.x + 5;
+
+ GetWindowRect(pcli->hwndContactList, &rcMiranda);
+ if (IsWindowVisible(pcli->hwndContactList) && IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) {
+ int id = Frames[pos].id;
- pos = id2pos(Frameid);
- if (Frames[pos].floating) {
+ lck.unlock();
+ ofspt.x = 0;
+ ofspt.y = 0;
+ ClientToScreen(Frames[pos].TitleBar.hwnd, &ofspt);
+ ofspt.x = curpt.x - ofspt.x;
+ ofspt.y = curpt.y - ofspt.y;
+
+ CLUIFrameSetFloat(id, 0);
+ newpt.x = 0;
+ newpt.y = 0;
+ ClientToScreen(Frames[pos].TitleBar.hwnd, &newpt);
+ SetCursorPos(newpt.x + ofspt.x, newpt.y + ofspt.y);
GetCursorPos(&curpt);
- rcwnd.bottom = curpt.y + 5;
- rcwnd.top = curpt.y;
- rcwnd.left = curpt.x;
- rcwnd.right = curpt.x + 5;
-
- GetWindowRect(pcli->hwndContactList, &rcMiranda);
- if (IsWindowVisible(pcli->hwndContactList) && IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) {
- int id = Frames[pos].id;
-
- ulockfrm();
- ofspt.x = 0;
- ofspt.y = 0;
- ClientToScreen(Frames[pos].TitleBar.hwnd, &ofspt);
- ofspt.x = curpt.x - ofspt.x;
- ofspt.y = curpt.y - ofspt.y;
-
- CLUIFrameSetFloat(id, 0);
- newpt.x = 0;
- newpt.y = 0;
- ClientToScreen(Frames[pos].TitleBar.hwnd, &newpt);
- SetCursorPos(newpt.x + ofspt.x, newpt.y + ofspt.y);
- GetCursorPos(&curpt);
- lockfrm();
- Frames[pos].TitleBar.oldpos = curpt;
- ulockfrm();
- return 0;
- }
+
+ lck.lock();
+ Frames[pos].TitleBar.oldpos = curpt;
+ return 0;
}
- else {
- int id = Frames[pos].id;
+ }
+ else {
+ int id = Frames[pos].id;
+ GetCursorPos(&curpt);
+ rcwnd.bottom = curpt.y + 5;
+ rcwnd.top = curpt.y;
+ rcwnd.left = curpt.x;
+ rcwnd.right = curpt.x + 5;
+
+ GetWindowRect(pcli->hwndContactList, &rcMiranda);
+
+ if (!IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) {
+ lck.unlock();
GetCursorPos(&curpt);
- rcwnd.bottom = curpt.y + 5;
- rcwnd.top = curpt.y;
- rcwnd.left = curpt.x;
- rcwnd.right = curpt.x + 5;
-
- GetWindowRect(pcli->hwndContactList, &rcMiranda);
-
- if ( !IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) {
- ulockfrm();
- GetCursorPos(&curpt);
- GetWindowRect(Frames[pos].hWnd, &rcwnd);
- rcwnd.left = rcwnd.right - rcwnd.left;
- rcwnd.top = rcwnd.bottom - rcwnd.top;
- newpos.x = curpt.x;
- newpos.y = curpt.y;
- if (curpt.x >= (rcMiranda.right - 1))
- newpos.x = curpt.x + 5;
- if (curpt.x <= (rcMiranda.left + 1))
- newpos.x = curpt.x - (rcwnd.left) - 5;
- if (curpt.y >= (rcMiranda.bottom - 1))
- newpos.y = curpt.y + 5;
- if (curpt.y <= (rcMiranda.top + 1))
- newpos.y = curpt.y - (rcwnd.top) - 5;
-
- ofspt.x = 0;
- ofspt.y = 0;
- GetWindowRect(Frames[pos].TitleBar.hwnd, &rcwnd);
- ofspt.x = curpt.x - ofspt.x;
- ofspt.y = curpt.y - ofspt.y;
- Frames[pos].FloatingPos.x = newpos.x;
- Frames[pos].FloatingPos.y = newpos.y;
- CLUIFrameSetFloat(id, 0);
- lockfrm();
- newpt.x = 0;
- newpt.y = 0;
- ClientToScreen(Frames[pos].TitleBar.hwnd, &newpt);
- GetWindowRect(Frames[pos].hWnd, &rcwnd);
- SetCursorPos(newpt.x + (rcwnd.right - rcwnd.left) / 2, newpt.y + (rcwnd.bottom - rcwnd.top) / 2);
- GetCursorPos(&curpt);
- Frames[pos].TitleBar.oldpos = curpt;
- ulockfrm();
- return 0;
- }
+ GetWindowRect(Frames[pos].hWnd, &rcwnd);
+ rcwnd.left = rcwnd.right - rcwnd.left;
+ rcwnd.top = rcwnd.bottom - rcwnd.top;
+ newpos.x = curpt.x;
+ newpos.y = curpt.y;
+ if (curpt.x >= (rcMiranda.right - 1))
+ newpos.x = curpt.x + 5;
+ if (curpt.x <= (rcMiranda.left + 1))
+ newpos.x = curpt.x - (rcwnd.left) - 5;
+ if (curpt.y >= (rcMiranda.bottom - 1))
+ newpos.y = curpt.y + 5;
+ if (curpt.y <= (rcMiranda.top + 1))
+ newpos.y = curpt.y - (rcwnd.top) - 5;
+
+ ofspt.x = 0;
+ ofspt.y = 0;
+ GetWindowRect(Frames[pos].TitleBar.hwnd, &rcwnd);
+ ofspt.x = curpt.x - ofspt.x;
+ ofspt.y = curpt.y - ofspt.y;
+ Frames[pos].FloatingPos.x = newpos.x;
+ Frames[pos].FloatingPos.y = newpos.y;
+ CLUIFrameSetFloat(id, 0);
+
+ lck.lock();
+ newpt.x = 0;
+ newpt.y = 0;
+ ClientToScreen(Frames[pos].TitleBar.hwnd, &newpt);
+ GetWindowRect(Frames[pos].hWnd, &rcwnd);
+ SetCursorPos(newpt.x + (rcwnd.right - rcwnd.left) / 2, newpt.y + (rcwnd.bottom - rcwnd.top) / 2);
+ GetCursorPos(&curpt);
+ Frames[pos].TitleBar.oldpos = curpt;
+ return 0;
}
- ulockfrm();
}
- if (wParam & MK_LBUTTON) {
- int newh = -1, prevold;
+ }
+ if (wParam & MK_LBUTTON) {
+ int newh = -1, prevold;
- if (GetCapture() != hwnd)
- break;
+ if (GetCapture() != hwnd)
+ break;
- lockfrm();
- pos = id2pos(Frameid);
+ POINT pt, pt2;
+ mir_cslockfull lck(csFrameHook);
+ int pos = id2pos(Frameid);
- if (Frames[pos].floating) {
- GetCursorPos(&pt);
- if ((Frames[pos].TitleBar.oldpos.x != pt.x) || (Frames[pos].TitleBar.oldpos.y != pt.y)) {
- pt2 = pt;
- ScreenToClient(hwnd, &pt2);
- GetWindowRect(Frames[pos].ContainerWnd, &wndr);
+ if (Frames[pos].floating) {
+ RECT wndr;
+ GetCursorPos(&pt);
+ if ((Frames[pos].TitleBar.oldpos.x != pt.x) || (Frames[pos].TitleBar.oldpos.y != pt.y)) {
+ pt2 = pt;
+ ScreenToClient(hwnd, &pt2);
+ GetWindowRect(Frames[pos].ContainerWnd, &wndr);
- POINT ptNew = pt;
+ POINT ptNew = pt;
- nLeft += (short)ptNew.x - ptOld.x;
- nTop += (short)ptNew.y - ptOld.y;
+ nLeft += (short)ptNew.x - ptOld.x;
+ nTop += (short)ptNew.y - ptOld.y;
- if ( !(wParam & MK_CONTROL))
- PositionThumb(&Frames[pos], nLeft, nTop);
- else
- SetWindowPos(Frames[pos].ContainerWnd, 0, nLeft, nTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+ if (!(wParam & MK_CONTROL))
+ PositionThumb(&Frames[pos], nLeft, nTop);
+ else
+ SetWindowPos(Frames[pos].ContainerWnd, 0, nLeft, nTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
- ptOld = ptNew;
+ ptOld = ptNew;
- pt.x = nLeft;
- pt.y = nTop;
- Frames[pos].TitleBar.oldpos = pt;
- }
- ulockfrm();
- return 0;
+ pt.x = nLeft;
+ pt.y = nTop;
+ Frames[pos].TitleBar.oldpos = pt;
}
- if (Frames[pos].prevvisframe != -1) {
- GetCursorPos(&pt);
-
- if ((Frames[pos].TitleBar.oldpos.x == pt.x) && (Frames[pos].TitleBar.oldpos.y == pt.y)) {
- ulockfrm();
- break;
- }
+ return 0;
+ }
+ if (Frames[pos].prevvisframe != -1) {
+ GetCursorPos(&pt);
- ypos = rect.top + pt.y;
- xpos = rect.left + pt.x;
- Framemod = -1;
+ if ((Frames[pos].TitleBar.oldpos.x == pt.x) && (Frames[pos].TitleBar.oldpos.y == pt.y))
+ break;
- if (Frames[pos].align == alBottom) {
- direction = -1;
- Framemod = pos;
- } else {
- direction = 1;
- Framemod = Frames[pos].prevvisframe;
- }
- if (Frames[Framemod].Locked) {
- ulockfrm();
- break;
- }
- if (curdragbar != -1 && curdragbar != pos) {
- ulockfrm();
- break;
- }
+ ypos = rect.top + pt.y;
+ xpos = rect.left + pt.x;
+ Framemod = -1;
- if (lbypos == -1) {
- curdragbar = pos;
- lbypos = ypos;
- oldframeheight = Frames[Framemod].height;
- SetCapture(hwnd);
- ulockfrm();
- break;
- }
- newh = oldframeheight + direction * (ypos - lbypos);
- if (newh > 0) {
- prevold = Frames[Framemod].height;
- Frames[Framemod].height = newh;
- if ( !CLUIFramesFitInSize()) {
- Frames[Framemod].height = prevold;
- ulockfrm();
- return TRUE;
- }
- Frames[Framemod].height = newh;
- if (newh > 3) Frames[Framemod].collapsed = TRUE;
+ if (Frames[pos].align == alBottom) {
+ direction = -1;
+ Framemod = pos;
+ }
+ else {
+ direction = 1;
+ Framemod = Frames[pos].prevvisframe;
+ }
+ if (Frames[Framemod].Locked)
+ break;
+ if (curdragbar != -1 && curdragbar != pos)
+ break;
- }
- Frames[pos].TitleBar.oldpos = pt;
+ if (lbypos == -1) {
+ curdragbar = pos;
+ lbypos = ypos;
+ oldframeheight = Frames[Framemod].height;
+ SetCapture(hwnd);
+ break;
}
- ulockfrm();
+ newh = oldframeheight + direction * (ypos - lbypos);
if (newh > 0) {
- CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
+ prevold = Frames[Framemod].height;
+ Frames[Framemod].height = newh;
+ if (!CLUIFramesFitInSize()) {
+ Frames[Framemod].height = prevold;
+ return TRUE;
+ }
+ Frames[Framemod].height = newh;
+ if (newh > 3) Frames[Framemod].collapsed = TRUE;
+
}
- break;
+ Frames[pos].TitleBar.oldpos = pt;
}
- curdragbar = -1;
- lbypos = -1;
- oldframeheight = -1;
- ReleaseCapture();
+ lck.unlock();
+
+ if (newh > 0)
+ CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
+ break;
}
+ curdragbar = -1;
+ lbypos = -1;
+ oldframeheight = -1;
+ ReleaseCapture();
break;
case WM_NCPAINT:
@@ -2941,7 +2842,7 @@ LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
int CLUIFrameResizeFloatingFrame(int framepos)
{
- if ( !Frames[framepos].floating)
+ if (!Frames[framepos].floating)
return 0;
if (Frames[framepos].ContainerWnd == 0)
return 0;
@@ -2965,7 +2866,8 @@ int CLUIFrameResizeFloatingFrame(int framepos)
InvalidateRect(Frames[framepos].TitleBar.hwnd, NULL, FALSE);
SetWindowPos(Frames[framepos].hWnd, HWND_TOP, 0, floatingHeight, width, height - floatingHeight, SWP_SHOWWINDOW | SWP_NOACTIVATE);
- } else {
+ }
+ else {
Frames[framepos].height = height;
ShowWindow(Frames[framepos].TitleBar.hwnd, SW_HIDE);
SetWindowPos(Frames[framepos].hWnd, HWND_TOP, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOACTIVATE);
@@ -2996,103 +2898,91 @@ LRESULT CALLBACK CLUIFrameContainerWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
switch (msg) {
case WM_CREATE:
- lockfrm();
- framepos = id2pos(Frameid);
- ulockfrm();
+ {
+ mir_cslockfull lck(csFrameHook);
+ framepos = id2pos(Frameid);
+ }
return 0;
case WM_GETMINMAXINFO:
TitleBarH = cfg::dat.titleBarHeight;
- lockfrm();
+ {
+ mir_cslock lck(csFrameHook);
+ framepos = id2pos(Frameid);
+ if (framepos < 0 || framepos >= nFramescount)
+ break;
- framepos = id2pos(Frameid);
- if (framepos < 0 || framepos >= nFramescount) {
- ulockfrm();
- break;
- }
- if ( !Frames[framepos].minmaxenabled) {
- ulockfrm();
- break;
- }
- if (Frames[framepos].ContainerWnd == 0) {
- ulockfrm();
- break;
- }
- if (Frames[framepos].Locked) {
- RECT rct;
-
- GetWindowRect(hwnd, &rct);
- ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = rct.right - rct.left;
- ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = rct.bottom - rct.top;
- ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = rct.right - rct.left;
- ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = rct.bottom - rct.top;
- }
+ if (!Frames[framepos].minmaxenabled)
+ break;
+
+ if (Frames[framepos].ContainerWnd == 0)
+ break;
+
+ if (Frames[framepos].Locked) {
+ RECT rct;
+ GetWindowRect(hwnd, &rct);
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = rct.right - rct.left;
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = rct.bottom - rct.top;
+ ((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = rct.right - rct.left;
+ ((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = rct.bottom - rct.top;
+ }
+
+ MINMAXINFO minmax;
+ memset(&minmax, 0, sizeof(minmax));
+ if (SendMessage(Frames[framepos].hWnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax) != 0)
+ return DefWindowProc(hwnd, msg, wParam, lParam);
- MINMAXINFO minmax;
- memset(&minmax, 0, sizeof(minmax));
- if (SendMessage(Frames[framepos].hWnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax) == 0) {
RECT border;
int tbh = TitleBarH * btoint(Frames[framepos].TitleBar.ShowTitleBar);
GetBorderSize(hwnd, &border);
if (minmax.ptMaxTrackSize.x != 0 && minmax.ptMaxTrackSize.y != 0) {
-
((LPMINMAXINFO)lParam)->ptMinTrackSize.x = minmax.ptMinTrackSize.x;
((LPMINMAXINFO)lParam)->ptMinTrackSize.y = minmax.ptMinTrackSize.y;
((LPMINMAXINFO)lParam)->ptMaxTrackSize.x = minmax.ptMaxTrackSize.x + border.left + border.right;
((LPMINMAXINFO)lParam)->ptMaxTrackSize.y = minmax.ptMaxTrackSize.y + tbh + border.top + border.bottom;
}
}
- else {
- ulockfrm();
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- ulockfrm();
case WM_MOVE:
- lockfrm();
- framepos = id2pos(Frameid);
+ {
+ mir_cslock lck(csFrameHook);
+ framepos = id2pos(Frameid);
+ if (framepos < 0 || framepos >= nFramescount)
+ break;
- if (framepos < 0 || framepos >= nFramescount) {
- ulockfrm();
- break;
- }
- if (Frames[framepos].ContainerWnd == 0) {
- ulockfrm();
- return 0;
+ if (Frames[framepos].ContainerWnd == 0)
+ return 0;
+
+ GetWindowRect(Frames[framepos].ContainerWnd, &rect);
+ Frames[framepos].FloatingPos.x = rect.left;
+ Frames[framepos].FloatingPos.y = rect.top;
+ Frames[framepos].FloatingSize.x = rect.right - rect.left;
+ Frames[framepos].FloatingSize.y = rect.bottom - rect.top;
+ CLUIFramesStoreFrameSettings(framepos);
}
- GetWindowRect(Frames[framepos].ContainerWnd, &rect);
- Frames[framepos].FloatingPos.x = rect.left;
- Frames[framepos].FloatingPos.y = rect.top;
- Frames[framepos].FloatingSize.x = rect.right - rect.left;
- Frames[framepos].FloatingSize.y = rect.bottom - rect.top;
- CLUIFramesStoreFrameSettings(framepos);
- ulockfrm();
return 0;
case WM_SIZE:
- lockfrm();
- framepos = id2pos(Frameid);
+ {
+ mir_cslock lck(csFrameHook);
+ framepos = id2pos(Frameid);
+ if (framepos < 0 || framepos >= nFramescount)
+ break;
- if (framepos < 0 || framepos >= nFramescount) {
- ulockfrm();
- break;
- }
- if (Frames[framepos].ContainerWnd == 0) {
- ulockfrm();
- return 0;
- }
- CLUIFrameResizeFloatingFrame(framepos);
+ if (Frames[framepos].ContainerWnd == 0)
+ return 0;
- RECT rect;
- GetWindowRect(Frames[framepos].ContainerWnd, &rect);
- Frames[framepos].FloatingPos.x = rect.left;
- Frames[framepos].FloatingPos.y = rect.top;
- Frames[framepos].FloatingSize.x = rect.right - rect.left;
- Frames[framepos].FloatingSize.y = rect.bottom - rect.top;
+ CLUIFrameResizeFloatingFrame(framepos);
- CLUIFramesStoreFrameSettings(framepos);
+ RECT rect;
+ GetWindowRect(Frames[framepos].ContainerWnd, &rect);
+ Frames[framepos].FloatingPos.x = rect.left;
+ Frames[framepos].FloatingPos.y = rect.top;
+ Frames[framepos].FloatingSize.x = rect.right - rect.left;
+ Frames[framepos].FloatingSize.y = rect.bottom - rect.top;
- ulockfrm();
+ CLUIFramesStoreFrameSettings(framepos);
+ }
return 0;
case WM_CLOSE:
@@ -3110,90 +3000,90 @@ static HWND CreateContainerWindow(HWND parent, int x, int y, int width, int heig
return(CreateWindowA("FramesContainer", "aaaa", WS_POPUP | WS_THICKFRAME, x, y, width, height, parent, 0, g_hInst, 0));
}
-
INT_PTR CLUIFrameSetFloat(WPARAM wParam, LPARAM lParam)
{
HWND hwndtmp, hwndtooltiptmp;
+ {
+ mir_cslock lck(csFrameHook);
+ wParam = id2pos((INT_PTR)wParam);
+ if ((int)wParam >= 0 && (int)wParam < nFramescount) {
+ if (Frames[wParam].floating) {
+ SetParent(Frames[wParam].hWnd, pcli->hwndContactList);
+ SetParent(Frames[wParam].TitleBar.hwnd, pcli->hwndContactList);
+ Frames[wParam].floating = FALSE;
+ DestroyWindow(Frames[wParam].ContainerWnd);
+ Frames[wParam].ContainerWnd = 0;
+ }
+ else {
+ RECT recttb, rectw, border;
+ int temp;
+ int neww, newh;
+ BOOLEAN locked;
- lockfrm();
- wParam = id2pos((INT_PTR)wParam);
- if ((int)wParam >= 0 && (int)wParam < nFramescount) {
- if (Frames[wParam].floating) {
- SetParent(Frames[wParam].hWnd, pcli->hwndContactList);
- SetParent(Frames[wParam].TitleBar.hwnd, pcli->hwndContactList);
- Frames[wParam].floating = FALSE;
- DestroyWindow(Frames[wParam].ContainerWnd);
- Frames[wParam].ContainerWnd = 0;
- }
- else {
- RECT recttb, rectw, border;
- int temp;
- int neww, newh;
- BOOLEAN locked;
+ Frames[wParam].oldstyles = GetWindowLongPtr(Frames[wParam].hWnd, GWL_STYLE);
+ Frames[wParam].TitleBar.oldstyles = GetWindowLongPtr(Frames[wParam].TitleBar.hwnd, GWL_STYLE);
+ locked = Frames[wParam].Locked;
+ Frames[wParam].Locked = FALSE;
+ Frames[wParam].minmaxenabled = FALSE;
+
+ GetWindowRect(Frames[wParam].hWnd, &rectw);
+ GetWindowRect(Frames[wParam].TitleBar.hwnd, &recttb);
+ if (!Frames[wParam].TitleBar.ShowTitleBar)
+ recttb.top = recttb.bottom = recttb.left = recttb.right = 0;
- Frames[wParam].oldstyles = GetWindowLongPtr(Frames[wParam].hWnd, GWL_STYLE);
- Frames[wParam].TitleBar.oldstyles = GetWindowLongPtr(Frames[wParam].TitleBar.hwnd, GWL_STYLE);
- locked = Frames[wParam].Locked;
- Frames[wParam].Locked = FALSE;
- Frames[wParam].minmaxenabled = FALSE;
+ Frames[wParam].ContainerWnd = CreateContainerWindow(pcli->hwndContactList, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, 10, 10);
- GetWindowRect(Frames[wParam].hWnd, &rectw);
- GetWindowRect(Frames[wParam].TitleBar.hwnd, &recttb);
- if ( !Frames[wParam].TitleBar.ShowTitleBar)
- recttb.top = recttb.bottom = recttb.left = recttb.right = 0;
+ SetParent(Frames[wParam].hWnd, Frames[wParam].ContainerWnd);
+ SetParent(Frames[wParam].TitleBar.hwnd, Frames[wParam].ContainerWnd);
- Frames[wParam].ContainerWnd = CreateContainerWindow(pcli->hwndContactList, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, 10, 10);
+ GetBorderSize(Frames[wParam].ContainerWnd, &border);
- SetParent(Frames[wParam].hWnd, Frames[wParam].ContainerWnd);
- SetParent(Frames[wParam].TitleBar.hwnd, Frames[wParam].ContainerWnd);
+ SetWindowLongPtr(Frames[wParam].ContainerWnd, GWLP_USERDATA, Frames[wParam].id);
+ if ((lParam == 1)) {
+ if ((Frames[wParam].FloatingPos.x != 0) && (Frames[wParam].FloatingPos.y != 0)) {
+ if (Frames[wParam].FloatingPos.x < 20)
+ Frames[wParam].FloatingPos.x = 40;
- GetBorderSize(Frames[wParam].ContainerWnd, &border);
+ if (Frames[wParam].FloatingPos.y < 20)
+ Frames[wParam].FloatingPos.y = 40;
+
+ SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, Frames[wParam].FloatingSize.x, Frames[wParam].FloatingSize.y, SWP_HIDEWINDOW);
+ }
+ else SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, 120, 120, 140, 140, SWP_HIDEWINDOW);
+ }
+ else {
+ neww = rectw.right - rectw.left + border.left + border.right;
+ newh = (rectw.bottom - rectw.top) + (recttb.bottom - recttb.top) + border.top + border.bottom;
+ if (neww < 20)
+ neww = 40;
+
+ if (newh < 20)
+ newh = 40;
- SetWindowLongPtr(Frames[wParam].ContainerWnd, GWLP_USERDATA, Frames[wParam].id);
- if ((lParam == 1)) {
- if ((Frames[wParam].FloatingPos.x != 0) && (Frames[wParam].FloatingPos.y != 0)) {
if (Frames[wParam].FloatingPos.x < 20)
Frames[wParam].FloatingPos.x = 40;
if (Frames[wParam].FloatingPos.y < 20)
Frames[wParam].FloatingPos.y = 40;
- SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, Frames[wParam].FloatingSize.x, Frames[wParam].FloatingSize.y, SWP_HIDEWINDOW);
+ SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, neww, newh, SWP_HIDEWINDOW);
}
- else SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, 120, 120, 140, 140, SWP_HIDEWINDOW);
+ SetWindowText(Frames[wParam].ContainerWnd, Frames[wParam].TitleBar.tbname);
+ temp = GetWindowLongPtr(Frames[wParam].ContainerWnd, GWL_EXSTYLE);
+ temp |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
+ SetWindowLongPtr(Frames[wParam].ContainerWnd, GWL_EXSTYLE, temp);
+ Frames[wParam].floating = TRUE;
+ Frames[wParam].Locked = locked;
}
- else {
- neww = rectw.right - rectw.left + border.left + border.right;
- newh = (rectw.bottom - rectw.top) + (recttb.bottom - recttb.top) + border.top + border.bottom;
- if (neww < 20)
- neww = 40;
-
- if (newh < 20)
- newh = 40;
-
- if (Frames[wParam].FloatingPos.x < 20)
- Frames[wParam].FloatingPos.x = 40;
+ }
- if (Frames[wParam].FloatingPos.y < 20)
- Frames[wParam].FloatingPos.y = 40;
+ CLUIFramesStoreFrameSettings(wParam);
+ Frames[wParam].minmaxenabled = TRUE;
+ hwndtooltiptmp = Frames[wParam].TitleBar.hwndTip;
- SetWindowPos(Frames[wParam].ContainerWnd, HWND_TOPMOST, Frames[wParam].FloatingPos.x, Frames[wParam].FloatingPos.y, neww, newh, SWP_HIDEWINDOW);
- }
- SetWindowText(Frames[wParam].ContainerWnd, Frames[wParam].TitleBar.tbname);
- temp = GetWindowLongPtr(Frames[wParam].ContainerWnd, GWL_EXSTYLE);
- temp |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST ;
- SetWindowLongPtr(Frames[wParam].ContainerWnd, GWL_EXSTYLE, temp);
- Frames[wParam].floating = TRUE;
- Frames[wParam].Locked = locked;
- }
+ hwndtmp = Frames[wParam].ContainerWnd;
}
- CLUIFramesStoreFrameSettings(wParam);
- Frames[wParam].minmaxenabled = TRUE;
- hwndtooltiptmp = Frames[wParam].TitleBar.hwndTip;
-
- hwndtmp = Frames[wParam].ContainerWnd;
- ulockfrm();
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
SendMessage(hwndtmp, WM_SIZE, 0, 0);
SetWindowPos(hwndtooltiptmp, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
@@ -3246,27 +3136,27 @@ void RegisterCLUIFrameClasses()
WNDCLASS wndclass;
WNDCLASS cntclass;
- wndclass.style = CS_DBLCLKS;//|CS_HREDRAW|CS_VREDRAW ;
- wndclass.lpfnWndProc = CLUIFrameTitleBarProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = g_hInst;
- wndclass.hIcon = NULL;
- wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wndclass.style = CS_DBLCLKS;//|CS_HREDRAW|CS_VREDRAW ;
+ wndclass.lpfnWndProc = CLUIFrameTitleBarProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = g_hInst;
+ wndclass.hIcon = NULL;
+ wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = NULL;
- wndclass.lpszMenuName = NULL;
+ wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = CLUIFrameTitleBarClassName;
RegisterClass(&wndclass);
- cntclass.style = CS_DBLCLKS/*|CS_HREDRAW|CS_VREDRAW*/ | CS_DROPSHADOW;
- cntclass.lpfnWndProc = CLUIFrameContainerWndProc;
- cntclass.cbClsExtra = 0;
- cntclass.cbWndExtra = 0;
- cntclass.hInstance = g_hInst;
- cntclass.hIcon = NULL;
- cntclass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ cntclass.style = CS_DBLCLKS/*|CS_HREDRAW|CS_VREDRAW*/ | CS_DROPSHADOW;
+ cntclass.lpfnWndProc = CLUIFrameContainerWndProc;
+ cntclass.cbClsExtra = 0;
+ cntclass.cbWndExtra = 0;
+ cntclass.hInstance = g_hInst;
+ cntclass.hIcon = NULL;
+ cntclass.hCursor = LoadCursor(NULL, IDC_ARROW);
cntclass.hbrBackground = NULL;
- cntclass.lpszMenuName = NULL;
+ cntclass.lpszMenuName = NULL;
cntclass.lpszClassName = _T("FramesContainer");
RegisterClass(&cntclass);
}
@@ -3276,13 +3166,12 @@ int LoadCLUIFramesModule(void)
GapBetweenFrames = cfg::dat.gapBetweenFrames;
nFramescount = 0;
- InitializeCriticalSection(&csFrameHook);
InitFramesMenus();
HookEvent(ME_SYSTEM_MODULESLOADED, CLUIFrameOnModulesLoad);
HookEvent(ME_CLIST_PREBUILDFRAMEMENU, CLUIFramesModifyContextMenuForFrame);
HookEvent(ME_CLIST_PREBUILDMAINMENU, CLUIFrameOnMainMenuBuild);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, CLUIFrameOnModulesUnload);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, CLUIFrameOnModulesUnload);
CreateServiceFunction(MS_CLIST_FRAMES_ADDFRAME, CLUIFramesAddFrame);
CreateServiceFunction(MS_CLIST_FRAMES_REMOVEFRAME, CLUIFramesRemoveFrame);
@@ -3330,15 +3219,16 @@ int UnLoadCLUIFramesModule(void)
CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0);
CLUIFramesStoreAllFrames();
DeleteObject(g_hPenCLUIFrames);
- EnterCriticalSection(&csFrameHook);
+
+ mir_cslock lck(csFrameHook);
FramesSysNotStarted = TRUE;
- for (int i = 0;i < nFramescount;i++) {
+ for (int i = 0; i < nFramescount; i++) {
DestroyWindow(Frames[i].hWnd);
- Frames[i].hWnd = (HWND) - 1;
+ Frames[i].hWnd = (HWND)-1;
DestroyWindow(Frames[i].TitleBar.hwnd);
- Frames[i].TitleBar.hwnd = (HWND) - 1;
+ Frames[i].TitleBar.hwnd = (HWND)-1;
DestroyWindow(Frames[i].ContainerWnd);
- Frames[i].ContainerWnd = (HWND) - 1;
+ Frames[i].ContainerWnd = (HWND)-1;
DestroyMenu(Frames[i].TitleBar.hmenu);
if (Frames[i].name != NULL)
@@ -3350,7 +3240,5 @@ int UnLoadCLUIFramesModule(void)
Frames = NULL;
nFramescount = 0;
UnregisterClass(CLUIFrameTitleBarClassName, g_hInst);
- LeaveCriticalSection(&csFrameHook);
- DeleteCriticalSection(&csFrameHook);
return 0;
}
diff --git a/plugins/Clist_nicer/src/Include/Version.h b/plugins/Clist_nicer/src/Include/Version.h
index 74cce7462a..babd66c1bc 100644
--- a/plugins/Clist_nicer/src/Include/Version.h
+++ b/plugins/Clist_nicer/src/Include/Version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 9
#define __RELEASE_NUM 2
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>