summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern/modern_docking.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-06 20:23:55 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-06 20:23:55 +0000
commit2799d3c1c54f5b4681b45b76cfdacb081312ae88 (patch)
tree7c3fcf6b8bb40fd3226e1c76ba0f70e53fa923a1 /plugins/Clist_modern/modern_docking.cpp
parentfd2115f98aca6fa093498cf7a24216a12b05a885 (diff)
- crash fix in Clist Modern cache
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@800 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern/modern_docking.cpp')
-rw-r--r--plugins/Clist_modern/modern_docking.cpp184
1 files changed, 92 insertions, 92 deletions
diff --git a/plugins/Clist_modern/modern_docking.cpp b/plugins/Clist_modern/modern_docking.cpp
index d9d4c717da..ad5a719c43 100644
--- a/plugins/Clist_modern/modern_docking.cpp
+++ b/plugins/Clist_modern/modern_docking.cpp
@@ -35,10 +35,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DOCKED_LEFT 1
#define DOCKED_RIGHT 2
-BOOL LockSubframeMoving=0;
-static int TempDock=0;
-static int dock_drag_dx=0;
-static int dock_drag_dy=0;
+BOOL LockSubframeMoving = 0;
+static int TempDock = 0;
+static int dock_drag_dx = 0;
+static int dock_drag_dy = 0;
static void Docking_GetMonitorRectFromPoint(POINT pt,RECT *rc)
{
@@ -78,23 +78,23 @@ static void Docking_AdjustPosition(HWND hwnd,RECT *rcDisplay,RECT *rc)
APPBARDATA abd;
ZeroMemory(&abd,sizeof(abd));
- abd.cbSize=sizeof(abd);
- abd.hWnd=hwnd;
- abd.uEdge=g_CluiData.fDocked==DOCKED_LEFT?ABE_LEFT:ABE_RIGHT;
- abd.rc=*rc;
- abd.rc.top=rcDisplay->top;
- abd.rc.bottom=rcDisplay->bottom;
- if(g_CluiData.fDocked==DOCKED_LEFT) {
- abd.rc.right=rcDisplay->left+abd.rc.right-abd.rc.left;
- abd.rc.left=rcDisplay->left;
+ abd.cbSize = sizeof(abd);
+ abd.hWnd = hwnd;
+ abd.uEdge = g_CluiData.fDocked == DOCKED_LEFT?ABE_LEFT:ABE_RIGHT;
+ abd.rc = *rc;
+ abd.rc.top = rcDisplay->top;
+ abd.rc.bottom = rcDisplay->bottom;
+ if (g_CluiData.fDocked == DOCKED_LEFT) {
+ abd.rc.right = rcDisplay->left+abd.rc.right-abd.rc.left;
+ abd.rc.left = rcDisplay->left;
}
else {
- abd.rc.left=rcDisplay->right-(abd.rc.right-abd.rc.left);
- abd.rc.right=rcDisplay->right;
+ abd.rc.left = rcDisplay->right-(abd.rc.right-abd.rc.left);
+ abd.rc.right = rcDisplay->right;
}
SHAppBarMessage(ABM_SETPOS,&abd);
- *rc=abd.rc;
+ *rc = abd.rc;
}
int Docking_IsDocked(WPARAM wParam,LPARAM lParam)
@@ -106,40 +106,40 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
{
APPBARDATA abd;
static int draggingTitle;
- MSG *msg=(MSG*)wParam;
+ MSG *msg = (MSG*)wParam;
- if(msg->message==WM_DESTROY)
+ if (msg->message == WM_DESTROY)
db_set_b(NULL,"CList","Docked",(BYTE)g_CluiData.fDocked);
- if (!g_CluiData.fDocked && msg->message!=WM_CREATE && msg->message!=WM_MOVING && msg->message!=WM_CREATEDOCKED && msg->message != WM_MOVE && msg->message != WM_SIZE) return 0;
+ if (!g_CluiData.fDocked && msg->message != WM_CREATE && msg->message != WM_MOVING && msg->message != WM_CREATEDOCKED && msg->message !=WM_MOVE && msg->message !=WM_SIZE) return 0;
switch(msg->message) {
case WM_CREATE:
- //if(GetSystemMetrics(SM_CMONITORS)>1) return 0;
- if(db_get_b(NULL,"CList","Docked",0) && db_get_b(NULL,"CLUI","DockToSides",SETTING_DOCKTOSIDES_DEFAULT))
+ //if (GetSystemMetrics(SM_CMONITORS)>1) return 0;
+ if (db_get_b(NULL,"CList","Docked",0) && db_get_b(NULL,"CLUI","DockToSides",SETTING_DOCKTOSIDES_DEFAULT))
{
PostMessage(msg->hwnd,WM_CREATEDOCKED,0,0);
}
- draggingTitle=0;
+ draggingTitle = 0;
return 0;
case WM_CREATEDOCKED:
//we need to post a message just after creation to let main message function do some work
- g_CluiData.fDocked=(BOOL)db_get_b(NULL,"CList","Docked",0);
- if(IsWindowVisible(msg->hwnd) && !IsIconic(msg->hwnd)) {
+ g_CluiData.fDocked = (BOOL)db_get_b(NULL,"CList","Docked",0);
+ if (IsWindowVisible(msg->hwnd) && !IsIconic(msg->hwnd)) {
RECT rc, rcMonitor;
ZeroMemory(&abd,sizeof(abd));
- abd.cbSize=sizeof(abd);
- abd.hWnd=msg->hwnd;
- abd.lParam=0;
- abd.uCallbackMessage=WM_DOCKCALLBACK;
+ abd.cbSize = sizeof(abd);
+ abd.hWnd = msg->hwnd;
+ abd.lParam = 0;
+ abd.uCallbackMessage = WM_DOCKCALLBACK;
SHAppBarMessage(ABM_NEW,&abd);
GetWindowRect(msg->hwnd,&rc);
Docking_GetMonitorRectFromWindow(msg->hwnd,&rcMonitor);
Docking_AdjustPosition(msg->hwnd,&rcMonitor,&rc);
MoveWindow(msg->hwnd,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,TRUE);
- g_CluiData.mutexPreventDockMoving=0;
+ g_CluiData.mutexPreventDockMoving = 0;
Sync(CLUIFrames_OnMoving,msg->hwnd,&rc);
- g_CluiData.mutexPreventDockMoving=1;
+ g_CluiData.mutexPreventDockMoving = 1;
ModernSkinButton_ReposButtons( msg->hwnd, SBRF_DO_NOT_DRAW, NULL );
}
break;
@@ -148,8 +148,8 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
return 0;
case WM_ACTIVATE:
ZeroMemory(&abd,sizeof(abd));
- abd.cbSize=sizeof(abd);
- abd.hWnd=msg->hwnd;
+ abd.cbSize = sizeof(abd);
+ abd.hWnd = msg->hwnd;
SHAppBarMessage(ABM_ACTIVATE,&abd);
return 0;
case WM_SIZE:
@@ -161,8 +161,8 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
if (g_CluiData.fDocked) ModernSkinButton_ReposButtons( msg->hwnd,SBRF_DO_NOT_DRAW, NULL );
return 0;
ZeroMemory(&abd,sizeof(abd));
- abd.cbSize=sizeof(abd);
- abd.hWnd=msg->hwnd;
+ abd.cbSize = sizeof(abd);
+ abd.hWnd = msg->hwnd;
SHAppBarMessage(ABM_WINDOWPOSCHANGED,&abd);
ModernSkinButton_ReposButtons( msg->hwnd, SBRF_DO_NOT_DRAW, NULL );
return 0;
@@ -172,7 +172,7 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
RECT rcMonitor;
RECT rcWindow;
RECT *rc;
- int dx=0;
+ int dx = 0;
POINT ptCursor;
if (g_CluiData.fDocked) return 0;
// stop early
@@ -181,35 +181,35 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
// GetMessagePos() is no good, position is always unsigned
GetCursorPos(&ptCursor);
GetWindowRect(msg->hwnd,&rcWindow);
- dock_drag_dx=rcWindow.left-ptCursor.x;
- dock_drag_dy=rcWindow.top-ptCursor.y;
+ dock_drag_dx = rcWindow.left-ptCursor.x;
+ dock_drag_dy = rcWindow.top-ptCursor.y;
Docking_GetMonitorRectFromPoint(ptCursor,&rcMonitor);
- if (((ptCursor.x<rcMonitor.left+EDGESENSITIVITY)
- || (ptCursor.x>=rcMonitor.right-EDGESENSITIVITY))
+ if (((ptCursor.x < rcMonitor.left+EDGESENSITIVITY)
+ || (ptCursor.x >= rcMonitor.right-EDGESENSITIVITY))
&& db_get_b(NULL,"CLUI","DockToSides",SETTING_DOCKTOSIDES_DEFAULT))
{
ZeroMemory(&abd,sizeof(abd));
- abd.cbSize=sizeof(abd);
- abd.hWnd=msg->hwnd;
- abd.lParam=0;
- abd.uCallbackMessage=WM_DOCKCALLBACK;
+ abd.cbSize = sizeof(abd);
+ abd.hWnd = msg->hwnd;
+ abd.lParam = 0;
+ abd.uCallbackMessage = WM_DOCKCALLBACK;
SHAppBarMessage(ABM_NEW,&abd);
- if(ptCursor.x<rcMonitor.left+EDGESENSITIVITY) g_CluiData.fDocked=DOCKED_LEFT;
- else g_CluiData.fDocked=DOCKED_RIGHT;
- // TempDock=1;
+ if (ptCursor.x < rcMonitor.left+EDGESENSITIVITY) g_CluiData.fDocked = DOCKED_LEFT;
+ else g_CluiData.fDocked = DOCKED_RIGHT;
+ // TempDock = 1;
GetWindowRect(msg->hwnd,(LPRECT)msg->lParam);
- rc=(RECT*)msg->lParam;
- if (g_CluiData.fDocked==DOCKED_RIGHT)
- dx=(rc->right>rcMonitor.right)?rc->right-rcMonitor.right:0;
+ rc = (RECT*)msg->lParam;
+ if (g_CluiData.fDocked == DOCKED_RIGHT)
+ dx = (rc->right>rcMonitor.right)?rc->right-rcMonitor.right:0;
else
- dx=(rc->left<rcMonitor.left)?rc->left-rcMonitor.left:0;
+ dx = (rc->left < rcMonitor.left)?rc->left-rcMonitor.left:0;
OffsetRect(rc,-dx,0);
Docking_AdjustPosition(msg->hwnd,(LPRECT)&rcMonitor,(LPRECT)msg->lParam);
SendMessage(msg->hwnd,WM_SIZE,0,0);
- g_CluiData.mutexPreventDockMoving=0;
+ g_CluiData.mutexPreventDockMoving = 0;
Sync(CLUIFrames_OnMoving,msg->hwnd,(LPRECT)msg->lParam);
- g_CluiData.mutexPreventDockMoving=1;
+ g_CluiData.mutexPreventDockMoving = 1;
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
db_set_b(NULL,"CList","Docked",(BYTE)g_CluiData.fDocked);
ModernSkinButton_ReposButtons( msg->hwnd, SBRF_DO_NOT_DRAW, NULL );
@@ -221,30 +221,30 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
{
RECT rcMonitor;
RECT rcWindow;
- if (TempDock) TempDock=0;
+ if (TempDock) TempDock = 0;
GetWindowRect(msg->hwnd,&rcWindow);
Docking_GetMonitorRectFromWindow(msg->hwnd,&rcMonitor);
Docking_AdjustPosition(msg->hwnd,&rcMonitor,&rcWindow);
- *((LRESULT*)lParam)=TRUE;
- g_CluiData.mutexPreventDockMoving=0;
+ *((LRESULT*)lParam) = TRUE;
+ g_CluiData.mutexPreventDockMoving = 0;
SetWindowPos(msg->hwnd,0,rcWindow.left,rcWindow.top,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOSENDCHANGING);
Sync(CLUIFrames_OnMoving,msg->hwnd,&rcWindow);
- ModernSkinButton_ReposButtons( msg->hwnd, SBRF_DO_NOT_DRAW, NULL );//-=-=-=
- g_CluiData.mutexPreventDockMoving=1;
+ ModernSkinButton_ReposButtons( msg->hwnd, SBRF_DO_NOT_DRAW, NULL );// -= -= -=
+ g_CluiData.mutexPreventDockMoving = 1;
return 1;
}
case WM_MOVE:
{
- if(g_CluiData.fDocked && 0) {
+ if (g_CluiData.fDocked && 0) {
RECT rc, rcMonitor;
Docking_GetMonitorRectFromWindow(msg->hwnd,&rcMonitor);
GetWindowRect(msg->hwnd,&rc);
Docking_AdjustPosition(msg->hwnd,&rcMonitor,&rc);
MoveWindow(msg->hwnd,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,TRUE);
Sync(CLUIFrames_OnMoving,msg->hwnd,&rc);
- ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, NULL);//-=-=-=
+ ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, NULL);// -= -= -=
return 1;
}
@@ -257,36 +257,36 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
/*RECT rcMonitor;
Docking_GetMonitorRectFromWindow(msg->hwnd,&rcMonitor);
Docking_AdjustPosition(msg->hwnd,&rcMonitor,(LPRECT)msg->lParam);
- *((LRESULT*)lParam)=TRUE;
+ *((LRESULT*)lParam) = TRUE;
*/
RECT rc;
if (g_CluiData.fDocked) ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW,NULL);
return FALSE;
- rc=*(RECT*)(msg->lParam);
- g_CluiData.mutexPreventDockMoving=0;
+ rc = *(RECT*)(msg->lParam);
+ g_CluiData.mutexPreventDockMoving = 0;
Sync(CLUIFrames_OnMoving,msg->hwnd,&rc);
- //-=-=-=
+ // -= -= -=
return TRUE;
}
case WM_SHOWWINDOW:
{
- if(msg->lParam) return 0;
+ if (msg->lParam) return 0;
BOOL toBeDocked = (BOOL) db_get_b(NULL,"CLUI","DockToSides",SETTING_DOCKTOSIDES_DEFAULT);
- if ((msg->wParam && g_CluiData.fDocked<0) || (!msg->wParam && g_CluiData.fDocked>0)) g_CluiData.fDocked=-g_CluiData.fDocked;
+ if ((msg->wParam && g_CluiData.fDocked < 0) || (!msg->wParam && g_CluiData.fDocked>0)) g_CluiData.fDocked = -g_CluiData.fDocked;
ZeroMemory(&abd,sizeof(abd));
- abd.cbSize=sizeof(abd);
- abd.hWnd=msg->hwnd;
- if(msg->wParam) {
+ abd.cbSize = sizeof(abd);
+ abd.hWnd = msg->hwnd;
+ if (msg->wParam) {
RECT rc, rcMonitor;
Docking_GetMonitorRectFromWindow(msg->hwnd,&rcMonitor);
- abd.lParam=0;
- abd.uCallbackMessage=WM_DOCKCALLBACK;
+ abd.lParam = 0;
+ abd.uCallbackMessage = WM_DOCKCALLBACK;
SHAppBarMessage(ABM_NEW,&abd);
GetWindowRect(msg->hwnd,&rc);
Docking_AdjustPosition(msg->hwnd,&rcMonitor,&rc);
MoveWindow(msg->hwnd,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,FALSE);
Sync(CLUIFrames_OnMoving,msg->hwnd,&rc);
- ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW,NULL);//-=-=-=
+ ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW,NULL);// -= -= -=
}
else {
SHAppBarMessage(ABM_REMOVE,&abd);
@@ -295,21 +295,21 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
return 0;
case WM_NCHITTEST:
{ LONG result;
- result=DefWindowProc(msg->hwnd,WM_NCHITTEST,msg->wParam,msg->lParam);
- if(result==HTSIZE || result==HTTOP || result==HTTOPLEFT || result==HTTOPRIGHT ||
- result==HTBOTTOM || result==HTBOTTOMRIGHT || result==HTBOTTOMLEFT) {*((LRESULT*)lParam)=HTCLIENT; return TRUE;}
- if(g_CluiData.fDocked==DOCKED_LEFT && result==HTLEFT) {*((LRESULT*)lParam)=HTCLIENT; return TRUE;}
- if(g_CluiData.fDocked==DOCKED_RIGHT && result==HTRIGHT) {*((LRESULT*)lParam)=HTCLIENT; return TRUE;}
+ result = DefWindowProc(msg->hwnd,WM_NCHITTEST,msg->wParam,msg->lParam);
+ if (result == HTSIZE || result == HTTOP || result == HTTOPLEFT || result == HTTOPRIGHT ||
+ result == HTBOTTOM || result == HTBOTTOMRIGHT || result == HTBOTTOMLEFT) {*((LRESULT*)lParam) = HTCLIENT; return TRUE;}
+ if (g_CluiData.fDocked == DOCKED_LEFT && result == HTLEFT) {*((LRESULT*)lParam) = HTCLIENT; return TRUE;}
+ if (g_CluiData.fDocked == DOCKED_RIGHT && result == HTRIGHT) {*((LRESULT*)lParam) = HTCLIENT; return TRUE;}
return 0;
}
case WM_SYSCOMMAND:
- if ((msg->wParam&0xFFF0)!=SC_MOVE) return 0;
+ if ((msg->wParam&0xFFF0) != SC_MOVE) return 0;
SetActiveWindow(msg->hwnd);
SetCapture(msg->hwnd);
- draggingTitle=1;
- *((LRESULT*)lParam)=0;
+ draggingTitle = 1;
+ *((LRESULT*)lParam) = 0;
return TRUE;
case WM_MOUSEMOVE:
@@ -317,15 +317,15 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
{ RECT rc;
POINT pt;
GetClientRect(msg->hwnd,&rc);
- if (((g_CluiData.fDocked==DOCKED_LEFT || g_CluiData.fDocked==-DOCKED_LEFT) && (short)LOWORD(msg->lParam)>rc.right) ||
- ((g_CluiData.fDocked==DOCKED_RIGHT || g_CluiData.fDocked==-DOCKED_RIGHT) && (short)LOWORD(msg->lParam)<0)) {
+ if (((g_CluiData.fDocked == DOCKED_LEFT || g_CluiData.fDocked == -DOCKED_LEFT) && (short)LOWORD(msg->lParam)>rc.right) ||
+ ((g_CluiData.fDocked == DOCKED_RIGHT || g_CluiData.fDocked == -DOCKED_RIGHT) && (short)LOWORD(msg->lParam) < 0)) {
ReleaseCapture();
- draggingTitle=0;
+ draggingTitle = 0;
ZeroMemory(&abd,sizeof(abd));
- abd.cbSize=sizeof(abd);
- abd.hWnd=msg->hwnd;
+ abd.cbSize = sizeof(abd);
+ abd.hWnd = msg->hwnd;
SHAppBarMessage(ABM_REMOVE,&abd);
- g_CluiData.fDocked=0;
+ g_CluiData.fDocked = 0;
GetCursorPos(&pt);
PostMessage(msg->hwnd,WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(pt.x,pt.y));
SetWindowPos(msg->hwnd,0,pt.x-rc.right/2,pt.y-GetSystemMetrics(SM_CYFRAME)-GetSystemMetrics(SM_CYSMCAPTION)/2,db_get_dw(NULL,"CList","Width",0),db_get_dw(NULL,"CList","Height",0),SWP_NOZORDER);
@@ -335,9 +335,9 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
return 1;
}
case WM_LBUTTONUP:
- if(draggingTitle) {
+ if (draggingTitle) {
ReleaseCapture();
- draggingTitle=0;
+ draggingTitle = 0;
}
return 0;
case WM_DOCKCALLBACK:
@@ -350,19 +350,19 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam)
Docking_GetMonitorRectFromWindow(msg->hwnd,&rcMonitor);
GetWindowRect(msg->hwnd,&rc);
Docking_AdjustPosition(msg->hwnd,&rcMonitor,&rc);
- Sync(CLUIFrames_OnMoving,msg->hwnd,&rc); //-=-=-=
+ Sync(CLUIFrames_OnMoving,msg->hwnd,&rc); // -= -= -=
ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, NULL);
- g_CluiData.mutexPreventDockMoving=1;
+ g_CluiData.mutexPreventDockMoving = 1;
}
break;
}
return TRUE;
case WM_DESTROY:
- if(g_CluiData.fDocked>0) {
+ if (g_CluiData.fDocked>0) {
ZeroMemory(&abd,sizeof(abd));
- abd.cbSize=sizeof(abd);
- abd.hWnd=msg->hwnd;
+ abd.cbSize = sizeof(abd);
+ abd.hWnd = msg->hwnd;
SHAppBarMessage(ABM_REMOVE,&abd);
ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, NULL);
}