summaryrefslogtreecommitdiff
path: root/tipper/message_pump.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tipper/message_pump.cpp')
-rw-r--r--tipper/message_pump.cpp93
1 files changed, 48 insertions, 45 deletions
diff --git a/tipper/message_pump.cpp b/tipper/message_pump.cpp
index baed871..be7fa92 100644
--- a/tipper/message_pump.cpp
+++ b/tipper/message_pump.cpp
@@ -15,47 +15,47 @@ unsigned int CALLBACK MessagePumpThread(void *param)
HWND hwndTip = 0;
MSG hwndMsg = {0};
- while(GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated()) {
- if(!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) {
- switch(hwndMsg.message) {
+ while (GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated())
+ {
+ if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg))
+ {
+ switch(hwndMsg.message)
+ {
case MUM_CREATEPOPUP:
- {
- if(hwndTip) DestroyWindow(hwndTip);
- // if child of clist, zorder is right, but it steals the first click on a contact :(
+ if(hwndTip) DestroyWindow(hwndTip);
+ // if child of clist, zorder is right, but it steals the first click on a contact :(
- // copy topmost exstyle from clist, since we'll put clist under tip in WM_CREATE message
- //LONG clist_exstyle = GetWindowLong((HWND)CallService(MS_CLUI_GETHWND, 0, 0), GWL_EXSTYLE);
- //hwndTip = CreateWindowEx((clist_exstyle & WS_EX_TOPMOST), POP_WIN_CLASS, _T("TipperPopup"), WS_POPUP, 0, 0, 0, 0, 0/*(HWND)CallService(MS_CLUI_GETHWND, 0, 0)*/, 0, hInst, (LPVOID)hwndMsg.lParam);
+ // copy topmost exstyle from clist, since we'll put clist under tip in WM_CREATE message
+ //LONG clist_exstyle = GetWindowLong((HWND)CallService(MS_CLUI_GETHWND, 0, 0), GWL_EXSTYLE);
+ //hwndTip = CreateWindowEx((clist_exstyle & WS_EX_TOPMOST), POP_WIN_CLASS, _T("TipperPopup"), WS_POPUP, 0, 0, 0, 0, 0/*(HWND)CallService(MS_CLUI_GETHWND, 0, 0)*/, 0, hInst, (LPVOID)hwndMsg.lParam);
- hwndTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("TipperPopup"), WS_POPUP, 0, 0, 0, 0, 0/*(HWND)CallService(MS_CLUI_GETHWND, 0, 0)*/, 0, hInst, (LPVOID)hwndMsg.lParam);
- if(hwndMsg.lParam) free((LPVOID)hwndMsg.lParam);
- }
+ hwndTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("TipperPopup"), WS_POPUP, 0, 0, 0, 0, 0/*(HWND)CallService(MS_CLUI_GETHWND, 0, 0)*/, 0, hInst, (LPVOID)hwndMsg.lParam);
+ if(hwndMsg.lParam) free((LPVOID)hwndMsg.lParam);
break;
case MUM_DELETEPOPUP:
- {
- if(hwndTip) {
- DestroyWindow(hwndTip);
- hwndTip = 0;
- }
+ if(hwndTip) {
+ DestroyWindow(hwndTip);
+ hwndTip = NULL;
}
break;
+
case MUM_GOTSTATUS:
- {
- if(hwndTip) SendMessage(hwndTip, PUM_SETSTATUSTEXT, hwndMsg.wParam, hwndMsg.lParam);
- else if(hwndMsg.lParam) free((void *)hwndMsg.lParam);
- }
+ if(hwndTip) SendMessage(hwndTip, PUM_SETSTATUSTEXT, hwndMsg.wParam, hwndMsg.lParam);
+ else if(hwndMsg.lParam) free((void *)hwndMsg.lParam);
break;
+
+ case MUM_REDRAW:
+ if(hwndTip) SendMessage(hwndTip, PUM_REFRESH_VALUES, hwndMsg.wParam, hwndMsg.lParam);
+ break;
+
case MUM_GOTAVATAR:
- {
- if(hwndTip) SendMessage(hwndTip, PUM_SETAVATAR, hwndMsg.wParam, hwndMsg.lParam);
- }
+ if(hwndTip) SendMessage(hwndTip, PUM_SETAVATAR, hwndMsg.wParam, hwndMsg.lParam);
break;
+
default:
- {
- TranslateMessage(&hwndMsg);
- DispatchMessage(&hwndMsg);
- }
+ TranslateMessage(&hwndMsg);
+ DispatchMessage(&hwndMsg);
break;
}
}
@@ -68,12 +68,6 @@ void PostMPMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
PostThreadMessage(message_pump_thread_id, msg, wParam, lParam);
}
-// given a popup data pointer, and a handle to an event, this function
-// will post a message to the message queue which will set the hwnd value
-// and then set the event...so create an event, call this function and then wait on the event
-// when the event is signalled, the hwnd will be valid
-void FindWindow(POPUPDATAW *pd, HANDLE hEvent, HWND *hwnd);
-
void InitMessagePump() {
WNDCLASS popup_win_class = {0};
popup_win_class.style = 0;
@@ -127,6 +121,7 @@ int ShowTipHook(WPARAM wParam, LPARAM lParam) {
return 0;
}
+#ifdef _UNICODE
INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam) {
CLCINFOTIP *clcit = (CLCINFOTIP *)lParam;
if(clcit->isGroup) return 0; // no group tips (since they're pretty useless)
@@ -146,6 +141,7 @@ INT_PTR ShowTipW(WPARAM wParam, LPARAM lParam) {
PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)clcit2);
return 1;
}
+#endif
INT_PTR HideTip(WPARAM wParam, LPARAM lParam) {
//CLCINFOTIP *clcit = (CLCINFOTIP *)lParam;
@@ -160,24 +156,31 @@ int HideTipHook(WPARAM wParam, LPARAM lParam) {
int ProtoAck(WPARAM wParam, LPARAM lParam) {
ACKDATA *ack = (ACKDATA *)lParam;
- char *szMsg = (char *)ack->lParam;
- if(ack->type == ACKTYPE_AWAYMSG && ack->result == ACKRESULT_SUCCESS)
+ if (ack->type == ACKTYPE_AWAYMSG && ack->result == ACKRESULT_SUCCESS)
{
#ifdef _UNICODE
DBVARIANT dbv;
- bool unicode = !DBGetContactSetting(ack->hContact, "CList", "StatusMsg", &dbv) &&
- (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR);
- DBFreeVariant(&dbv);
- if (unicode) {
- DBGetContactSettingWString(ack->hContact, "CList", "StatusMsg", &dbv);
- PostMPMessage(MUM_GOTSTATUS, (WPARAM)ack->hContact, (LPARAM)_wcsdup(dbv.pwszVal));
+ if (!DBGetContactSetting(ack->hContact, "CList", "StatusMsg", &dbv))
+ {
+ bool unicode = (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR);
DBFreeVariant(&dbv);
+ if (unicode) {
+ DBGetContactSettingTString(ack->hContact, "CList", "StatusMsg", &dbv);
+ PostMPMessage(MUM_GOTSTATUS, (WPARAM)ack->hContact, (LPARAM)_tcsdup(dbv.ptszVal));
+ DBFreeVariant(&dbv);
+ return 0;
+ }
}
- else
#endif
- if (szMsg && szMsg[0])
- PostMPMessage(MUM_GOTSTATUS, (WPARAM)ack->hContact, (LPARAM)a2t(szMsg));
+ char *szMsg = (char *)ack->lParam;
+ if (szMsg && szMsg[0])
+ PostMPMessage(MUM_GOTSTATUS, (WPARAM)ack->hContact, (LPARAM)a2t(szMsg));
+ }
+ else if (ack->type == ACKTYPE_GETINFO && ack->result == ACKRESULT_SUCCESS)
+ {
+ PostMPMessage(MUM_REDRAW, (WPARAM)ack->hContact, 0);
}
+
return 0;
}