Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Allow brackets to be dragged by the caption bar alot easier #345

Merged
merged 2 commits into from
Oct 3, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion appshell/cef_dark_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,27 @@ void cef_dark_window::ComputeCloseButtonRect(RECT& rect)
rect.bottom = rect.top + mSysCloseButton->GetHeight();
}


void cef_dark_window::ComputeRequiredMenuRect(RECT& rect)
{
HMENU menu = GetMenu();
int items = ::GetMenuItemCount(menu);

::SetRectEmpty(&rect);

for (int i = 0; i < items; i++) {
RECT itemRect;
::SetRectEmpty(&itemRect);
if (::GetMenuItemRect(mWnd, menu, (UINT)i, &itemRect)) {
ScreenToNonClient(&itemRect);
RECT dest;
::CopyRect(&dest, &rect);
::UnionRect(&dest, &rect, &itemRect);
::CopyRect(&rect, &dest);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the first ::CopyRect is necessary. It copies rect to dest, then ::UnionRect overwites the value you just put in dest. I think you can safely remove that line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@redmunds I was error-ing on the side of caution here but I think you're right. Removed.

}
}

// Computes the Rect where the menu bar is drawn in window coordinates
void cef_dark_window::ComputeMenuBarRect(RECT& rect)
{
Expand Down Expand Up @@ -782,7 +803,15 @@ int cef_dark_window::HandleNcHitTest(LPPOINT ptHit)
if (ptHit->y >= rectWindow.bottom - ::GetSystemMetrics (SM_CYFRAME))
return HTBOTTOM;

return HTMENU;
// If it's not in the menu, it's in the caption
RECT rectMenu;
ComputeRequiredMenuRect(rectMenu);
NonClientToScreen(&rectMenu);

if (::PtInRect(&rectMenu, *ptHit))
return HTMENU;

return HTCAPTION;
}

// Like UpdateNonClientArea, but sets up a clipping region to just update the system buttons
Expand Down
3 changes: 2 additions & 1 deletion appshell/cef_dark_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class cef_dark_window : public cef_window
virtual void ComputeMaximizeButtonRect(RECT& rect);
virtual void ComputeCloseButtonRect(RECT& rect);
virtual void ComputeMenuBarRect(RECT& rect);

virtual void ComputeRequiredMenuRect(RECT& rect);


// Drawing Initializers
void InitDrawingResources();
Expand Down