Permalink
Browse files

Merge pull request #345 from adobe/jeff/dark-shell-fixes

Allow brackets to be dragged by the caption bar alot easier
  • Loading branch information...
redmunds committed Oct 3, 2013
2 parents 95f4e46 + f42cfa1 commit 85501c60d527ed10fe2fadc8a0be083f1181ff98
Showing with 32 additions and 2 deletions.
  1. +30 −1 appshell/cef_dark_window.cpp
  2. +2 −1 appshell/cef_dark_window.h
@@ -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;
+ if (::UnionRect(&dest, &rect, &itemRect)) {
+ ::CopyRect(&rect, &dest);
+ }
+ }
+ }
+}
+
// Computes the Rect where the menu bar is drawn in window coordinates
void cef_dark_window::ComputeMenuBarRect(RECT& rect)
{
@@ -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
@@ -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();

0 comments on commit 85501c6

Please sign in to comment.