diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-09 17:53:15 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-09 17:53:15 +0000 |
commit | cee90240b1301ad373e98fe874a924fcdbb83447 (patch) | |
tree | 2a289365c84efbfd0c27eca4663294b04737d2f1 /plugins/Clist_modern | |
parent | 132e74c3f3f5a31558b6b50be7be70e7bc283804 (diff) |
- fix for button states errors in Clist Modern;
- fix for message handling duplicates;
- fix for naming toolbar icons;
- removed duplicate icon entry in dbeditor++
git-svn-id: http://svn.miranda-ng.org/main/trunk@884 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern')
-rw-r--r-- | plugins/Clist_modern/hdr/modern_commonprototypes.h | 1 | ||||
-rw-r--r-- | plugins/Clist_modern/hdr/modern_static_clui.h | 2 | ||||
-rw-r--r-- | plugins/Clist_modern/init.cpp | 1 | ||||
-rw-r--r-- | plugins/Clist_modern/modern_clistmod.cpp | 19 | ||||
-rw-r--r-- | plugins/Clist_modern/modern_sync.cpp | 77 | ||||
-rw-r--r-- | plugins/Clist_modern/modern_tbbutton.cpp | 65 | ||||
-rw-r--r-- | plugins/Clist_modern/modern_toolbar.cpp | 34 |
7 files changed, 100 insertions, 99 deletions
diff --git a/plugins/Clist_modern/hdr/modern_commonprototypes.h b/plugins/Clist_modern/hdr/modern_commonprototypes.h index 2d0c7b5eb3..d8cb8d33e9 100644 --- a/plugins/Clist_modern/hdr/modern_commonprototypes.h +++ b/plugins/Clist_modern/hdr/modern_commonprototypes.h @@ -68,7 +68,6 @@ extern BOOL g_bTransparentFlag; extern HINSTANCE g_hInst;
extern HIMAGELIST hCListImages;
extern BOOL g_mutex_bChangingMode;
-extern HANDLE g_hMainThread;
extern DWORD g_dwMainThreadID;
extern DWORD g_dwAwayMsgThreadID;
extern DWORD g_dwGetTextAsyncThreadID;
diff --git a/plugins/Clist_modern/hdr/modern_static_clui.h b/plugins/Clist_modern/hdr/modern_static_clui.h index f54fae26c4..11e492e211 100644 --- a/plugins/Clist_modern/hdr/modern_static_clui.h +++ b/plugins/Clist_modern/hdr/modern_static_clui.h @@ -108,8 +108,6 @@ int UnhookAll(); /* Global variables */ -HANDLE g_hMainThread=NULL; - DWORD g_dwMainThreadID=0, g_dwAwayMsgThreadID=0, g_dwGetTextAsyncThreadID=0, diff --git a/plugins/Clist_modern/init.cpp b/plugins/Clist_modern/init.cpp index c1a55fc300..9a20924a46 100644 --- a/plugins/Clist_modern/init.cpp +++ b/plugins/Clist_modern/init.cpp @@ -102,7 +102,6 @@ PLUGININTERFACE int CListInitialise() fnGetAncestor = MyGetAncestor;
g_dwMainThreadID = GetCurrentThreadId();
- DuplicateHandle(GetCurrentProcess(),GetCurrentThread(),GetCurrentProcess(),&g_hMainThread,0,FALSE,DUPLICATE_SAME_ACCESS);
mir_getTMI(&tmi);
mir_getLP( &pluginInfo );
diff --git a/plugins/Clist_modern/modern_clistmod.cpp b/plugins/Clist_modern/modern_clistmod.cpp index 2b3b584e11..535ebc3737 100644 --- a/plugins/Clist_modern/modern_clistmod.cpp +++ b/plugins/Clist_modern/modern_clistmod.cpp @@ -54,8 +54,9 @@ int EventsProcessContactDoubleClick(HANDLE hContact); INT_PTR TrayIconPauseAutoHide(WPARAM wParam,LPARAM lParam);
INT_PTR ContactChangeGroup(WPARAM wParam,LPARAM lParam);
-void InitTrayMenus(void);
+void InitTrayMenus(void);
+void UninitTrayMenu();
HIMAGELIST hCListImages = NULL;
@@ -195,22 +196,20 @@ INT_PTR GetContactIcon(WPARAM wParam,LPARAM lParam) status = ID_STATUS_OFFLINE;
else
status = db_get_w((HANDLE) wParam, szProto, "Status", ID_STATUS_OFFLINE);
- res = ExtIconFromStatusMode((HANDLE)wParam,szProto,szProto == NULL?ID_STATUS_OFFLINE:status); //by FYR
- if (lParam == 0 && res != -1) res &= 0xFFFF;
- return res;
+ res = ExtIconFromStatusMode((HANDLE)wParam,szProto,szProto == NULL?ID_STATUS_OFFLINE:status); //by FYR
+ if (lParam == 0 && res != -1) res &= 0xFFFF;
+ return res;
}
-void UninitTrayMenu();
+
void UnLoadContactListModule() //unhooks noncritical events
{
- UninitTrayMenu();
- UninitCustomMenus();
+ UninitTrayMenu();
+ UninitCustomMenus();
}
int CListMod_ContactListShutdownProc(WPARAM wParam,LPARAM lParam)
{
- FreeDisplayNameCache();
- if (g_hMainThread) CloseHandle(g_hMainThread);
- g_hMainThread = NULL;
+ FreeDisplayNameCache();
return 0;
}
diff --git a/plugins/Clist_modern/modern_sync.cpp b/plugins/Clist_modern/modern_sync.cpp index 829c86c670..df3572766e 100644 --- a/plugins/Clist_modern/modern_sync.cpp +++ b/plugins/Clist_modern/modern_sync.cpp @@ -1,20 +1,22 @@ #include "hdr/modern_commonheaders.h"
#include "hdr/modern_sync.h"
-typedef struct tagSYNCCALLITEM
+struct SYNCCALLITEM
{
WPARAM wParam;
LPARAM lParam;
int nResult;
HANDLE hDoneEvent;
PSYNCCALLBACKPROC pfnProc;
-} SYNCCALLITEM;
-static void CALLBACK _SyncCallerUserAPCProc(ULONG_PTR dwParam)
+};
+
+static void CALLBACK _SyncCallerUserAPCProc(void* param)
{
- SYNCCALLITEM* item = (SYNCCALLITEM*) dwParam;
+ SYNCCALLITEM* item = (SYNCCALLITEM*)param;
item->nResult = item->pfnProc(item->wParam, item->lParam);
SetEvent(item->hDoneEvent);
}
+
static INT_PTR SyncCaller(WPARAM proc, LPARAM lParam)
{
typedef int (*P0PARAMFUNC)();
@@ -25,38 +27,25 @@ static INT_PTR SyncCaller(WPARAM proc, LPARAM lParam) LPARAM * params = (LPARAM *)lParam;
int count = params[0];
- switch (count)
- {
- case 0:
- {
- P0PARAMFUNC pfnProc = (P0PARAMFUNC)proc;
- return pfnProc();
- }
+ switch (count) {
+ case 0:
+ return ((P0PARAMFUNC)proc)();
+
case 1:
- {
- P1PARAMFUNC pfnProc = (P1PARAMFUNC)proc;
- return pfnProc((WPARAM)params[1]);
- }
+ return ((P1PARAMFUNC)proc)((WPARAM)params[1]);
+
case 2:
- {
- P2PARAMFUNC pfnProc = (P2PARAMFUNC)proc;
- return pfnProc((WPARAM)params[1],(LPARAM)params[2]);
- }
+ return ((P2PARAMFUNC)proc)((WPARAM)params[1],(LPARAM)params[2]);
+
case 3:
- {
- P3PARAMFUNC pfnProc = (P3PARAMFUNC)proc;
- return pfnProc((WPARAM)params[1],(LPARAM)params[2], (LPARAM)params[3]);
- }
+ return ((P3PARAMFUNC)proc)((WPARAM)params[1],(LPARAM)params[2], (LPARAM)params[3]);
+
case 4:
- {
- P4PARAMFUNC pfnProc = (P4PARAMFUNC)proc;
- return pfnProc((WPARAM)params[1],(LPARAM)params[2], (LPARAM)params[3], (LPARAM)params[4]);
- }
+ return ((P4PARAMFUNC)proc)((WPARAM)params[1],(LPARAM)params[2], (LPARAM)params[3], (LPARAM)params[4]);
}
return 0;
}
-
int SyncCall(void * vproc, int count, ... )
{
LPARAM params[5];
@@ -65,9 +54,8 @@ int SyncCall(void * vproc, int count, ... ) params[0] = (LPARAM)count;
va_start(va, count);
for (i=0; i < count && i < SIZEOF(params)-1; i++)
- {
params[i+1] = va_arg(va,LPARAM);
- }
+
va_end(va);
return SyncCallProxy(SyncCaller, (WPARAM)vproc, (LPARAM) params);
}
@@ -78,24 +66,20 @@ int SyncCallProxy(PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM lParam, CRITI int nReturn = 0;
- if ( cs != NULL )
- {
- if ( !fnTryEnterCriticalSection ) // for poor OSes like Win98
- {
+ if ( cs != NULL ) {
+ if ( !fnTryEnterCriticalSection ) { // for poor OSes like Win98
EnterCriticalSection( cs );
int result = pfnProc( wParam, lParam );
LeaveCriticalSection( cs );
return result;
}
- if ( fnTryEnterCriticalSection( cs ))
- { //simple call (Fastest)
+ if ( fnTryEnterCriticalSection( cs )) { //simple call (Fastest)
int result = pfnProc(wParam,lParam);
LeaveCriticalSection( cs );
return result;
}
- else
- { //Window SendMessage Call(Middle)
+ else { //Window SendMessage Call(Middle)
if ( SyncCallWinProcProxy( pfnProc, wParam, lParam, nReturn ) == S_OK)
return nReturn;
}
@@ -117,7 +101,6 @@ HRESULT SyncCallWinProcProxy( PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM l item.lParam = lParam;
item.pfnProc = pfnProc;
nReturn = SendMessage(pcli->hwndContactList, UM_SYNCCALL, (WPARAM)&item,0);
-
return S_OK;
}
@@ -125,20 +108,17 @@ HRESULT SyncCallAPCProxy( PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM lPara {
hReturn = 0;
- if (g_hMainThread == NULL || pfnProc == NULL)
+ if (pfnProc == NULL)
return E_FAIL;
- SYNCCALLITEM item = {0};
-
- if (GetCurrentThreadId() != g_dwMainThreadID)
- {
+ if (GetCurrentThreadId() != g_dwMainThreadID) {
+ SYNCCALLITEM item = {0};
item.wParam = wParam;
item.lParam = lParam;
item.pfnProc = pfnProc;
item.hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- QueueUserAPC(_SyncCallerUserAPCProc, g_hMainThread, (ULONG_PTR) &item);
- PostMessage(pcli->hwndContactList,WM_NULL,0,0); // let this get processed in its own time
+ CallFunctionAsync(_SyncCallerUserAPCProc, &item);
WaitForSingleObject(item.hDoneEvent, INFINITE);
CloseHandle(item.hDoneEvent);
@@ -153,10 +133,6 @@ HRESULT SyncCallAPCProxy( PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM lPara return S_OK;
}
-
-
-
-
LRESULT SyncOnWndProcCall( WPARAM wParam )
{
SYNCCALLITEM *psci = (SYNCCALLITEM *)wParam;
@@ -169,4 +145,3 @@ int DoCall( PSYNCCALLBACKPROC pfnProc, WPARAM wParam, LPARAM lParam ) {
return SyncCallProxy( pfnProc, 0, lParam );
}
-
diff --git a/plugins/Clist_modern/modern_tbbutton.cpp b/plugins/Clist_modern/modern_tbbutton.cpp index d9d95e7969..ca34872e89 100644 --- a/plugins/Clist_modern/modern_tbbutton.cpp +++ b/plugins/Clist_modern/modern_tbbutton.cpp @@ -312,28 +312,27 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam if ( !PtInRect( &rcClient, ptMouse )) {
lpSBData->fHotMark = FALSE;
ReleaseCapture();
- break;
}
-
- if (lpSBData->stateId != PBS_DISABLED && lpSBData->stateId != PBS_PRESSED) {
- lpSBData->stateId = PBS_PRESSED;
- lpSBData->fHotMark = TRUE;
- InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
- if (lpSBData->fSendOnDown) {
- SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
- lpSBData->stateId = PBS_NORMAL;
+ else {
+ if (lpSBData->stateId != PBS_DISABLED && lpSBData->stateId != PBS_PRESSED) {
+ lpSBData->stateId = PBS_PRESSED;
+ lpSBData->fHotMark = TRUE;
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
+ if (lpSBData->fSendOnDown) {
+ SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
+ lpSBData->stateId = PBS_NORMAL;
+ InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
+ }
}
+ SetCapture( lpSBData->hwnd );
}
- SetCapture( lpSBData->hwnd );
- break;
}
+ lpSBData->lResult = 0;
+ return 1;
case WM_LBUTTONUP:
if ( GetCapture() == lpSBData->hwnd ) {
- int xPos = ( ( int )( short ) LOWORD( lParam ));
- int yPos = ( ( int )( short ) HIWORD( lParam ));
- POINT ptMouse = { xPos, yPos };
+ POINT ptMouse = { LOWORD(lParam), HIWORD(lParam) };
RECT rcClient;
GetClientRect( lpSBData->hwnd, &rcClient );
@@ -344,12 +343,8 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam break;
}
- if (lpSBData->bIsPushBtn) {
- if (lpSBData->bIsPushed)
- lpSBData->bIsPushed = FALSE;
- else
- lpSBData->bIsPushed = TRUE;
- }
+ if (lpSBData->bIsPushBtn)
+ lpSBData->bIsPushed = !lpSBData->bIsPushed;
if (lpSBData->stateId != PBS_DISABLED) {
// don't change states if disabled
@@ -359,11 +354,13 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam lpSBData->stateId = PBS_NORMAL;
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
}
- if ( !lpSBData->fSendOnDown && lpSBData->fHotMark)
+ if ( !lpSBData->fSendOnDown)
SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg);
- lpSBData->fHotMark = FALSE;
- break;
}
+ lpSBData->fHotMark = FALSE;
+ lpSBData->lResult = 0;
+ return 1;
+
case WM_MOUSEMOVE:
{
RECT rc;
@@ -397,14 +394,17 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam ReleaseCapture();
}
}
- break;
+ lpSBData->lResult = 0;
+ return 1;
case WM_NCHITTEST:
{
LRESULT lr = SendMessage(GetParent(hwndDlg), WM_NCHITTEST, wParam, lParam);
if (lr == HTLEFT || lr == HTRIGHT || lr == HTBOTTOM || lr == HTTOP || lr == HTTOPLEFT || lr == HTTOPRIGHT
- || lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT)
- return HTTRANSPARENT;
+ || lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT) {
+ lpSBData->lResult = HTTRANSPARENT;
+ return 1;
+ }
}
break;
@@ -447,11 +447,13 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam RedrawWindow(hwndDlg,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW);
}
}
- return 0;
+ return 1;
case BM_GETIMAGE:
- if (wParam == IMAGE_ICON)
- return (LRESULT)(lpSBData->hIconPrivate ? lpSBData->hIconPrivate : lpSBData->hIcon);
+ if (wParam == IMAGE_ICON) {
+ lpSBData->lResult = (LRESULT)(lpSBData->hIconPrivate ? lpSBData->hIconPrivate : lpSBData->hIcon);
+ return 1;
+ }
break;
case BM_SETIMAGE:
@@ -486,14 +488,15 @@ static LRESULT CALLBACK ToolbarButtonProc(HWND hwndDlg, UINT msg, WPARAM wParam DeleteObject(ii.hbmMask);
DeleteObject(ii.hbmColor);
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
+ lpSBData->lResult = 0;
+ return 1;
}
- else if (wParam == IMAGE_BITMAP)
+ if (wParam == IMAGE_BITMAP)
{
if (lpSBData->hIconPrivate)
DestroyIcon(lpSBData->hIconPrivate);
lpSBData->hIcon = lpSBData->hIconPrivate = NULL;
InvalidateParentRect(lpSBData->hwnd, NULL, TRUE);
- return 0; // not supported
}
break;
}
diff --git a/plugins/Clist_modern/modern_toolbar.cpp b/plugins/Clist_modern/modern_toolbar.cpp index bd604e0464..5a5b0395f2 100644 --- a/plugins/Clist_modern/modern_toolbar.cpp +++ b/plugins/Clist_modern/modern_toolbar.cpp @@ -65,12 +65,15 @@ static int Modern_InitButtons(WPARAM, LPARAM) char buf[255];
mir_snprintf(buf,SIZEOF(buf),"%s%s%s", TTB_OPTDIR, BTNS[i].pszButtonID, "_dn");
- tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", BTNS[i].pszButtonName , _T("icons\\toolbar_icons.dll"),-BTNS[i].icoDefIdx, g_hInst, BTNS[i].defResource );
+ tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "Toolbar", BTNS[i].pszTooltipUp, _T("icons\\toolbar_icons.dll"),-BTNS[i].icoDefIdx, g_hInst, BTNS[i].defResource );
if (BTNS[i].pszTooltipDn) {
+ tbb.dwFlags |= TTBBF_ASPUSHBUTTON;
+
mir_snprintf(buf,SIZEOF(buf),"%s%s%s", TTB_OPTDIR, BTNS[i].pszButtonID, "_up");
- tbb.hIconHandleUp = RegisterIcolibIconHandle( buf, "ToolBar", BTNS[i].pszTooltipDn , _T("icons\\toolbar_icons.dll"),-(BTNS[i].icoDefIdx+1), g_hInst, BTNS[i].defResource2 );
+ tbb.hIconHandleDn = RegisterIcolibIconHandle( buf, "Toolbar", BTNS[i].pszTooltipDn, _T("icons\\toolbar_icons.dll"),-(BTNS[i].icoDefIdx+1), g_hInst, BTNS[i].defResource2 );
}
+ else tbb.hIconHandleDn = NULL;
}
else tbb.dwFlags |= TTBBF_ISSEPARATOR;
@@ -114,6 +117,26 @@ static tbdat = { 0 }; COLORREF sttGetColor(char * module, char * color, COLORREF defColor);
+static int ehhToolBarSettingsChanged(WPARAM wParam, LPARAM lParam)
+{
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
+ if ((HANDLE)wParam != NULL)
+ return 0;
+
+ if (!mir_strcmp(cws->szModule,"CList")) {
+ if (!mir_strcmp(cws->szSetting,"HideOffline"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[3].hButton, cws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED);
+ else if (!mir_strcmp(cws->szSetting,"UseGroups"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[6].hButton, cws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED);
+ }
+ else if (!mir_strcmp(cws->szModule,"Skin")) {
+ if (!mir_strcmp(cws->szSetting,"UseSound"))
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[7].hButton, cws->value.bVal ? TTBST_PUSHED : TTBST_RELEASED);
+ }
+
+ return 0;
+}
+
static int ehhToolBarBackgroundSettingsChanged(WPARAM wParam, LPARAM lParam)
{
if ( tbdat.mtb_hBmpBackground) {
@@ -240,8 +263,12 @@ static LRESULT CALLBACK toolbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA Offset.y = childRect.top - MyRect.top;
SendMessage(mtbi->hWindow, BUTTONDRAWINPARENT, (WPARAM)hDC, (LPARAM)&Offset);
}
- return 1;
}
+ pMTBInfo->lResult = 0;
+ return 1;
+
+ case WM_DESTROY:
+ xpt_FreeThemeForWindow(hwnd);
}
return 0;
@@ -267,6 +294,7 @@ void CustomizeToolbar(HWND hwnd) static int Toolbar_ModulesLoaded(WPARAM, LPARAM)
{
CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)"ToolBar Background/ToolBar",0);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ehhToolBarSettingsChanged);
HookEvent(ME_BACKGROUNDCONFIG_CHANGED, ehhToolBarBackgroundSettingsChanged);
HookEvent(ME_TTB_INITBUTTONS, Modern_InitButtons);
return 0;
|