Permalink
Browse files

Added dragWindow feature

Changed Drag to DragWindow and updated style issues and comments
  • Loading branch information...
clintberry authored and gruehle committed Apr 17, 2013
1 parent 8b46288 commit 5e52d8647444d20838a2b01bfff92f463109f014
@@ -580,7 +580,11 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
responseArgs->SetString(2, parentId);
responseArgs->SetInt(3, index);
}
} else {
} else if (message_name == "DragWindow") {
// Parameters: none
DragWindow(browser);
}
else {
fprintf(stderr, "Native function not implemented yet: %s\n", message_name.c_str());
return false;
}
@@ -687,6 +687,16 @@ if (!appshell.app) {
appshell.app.showExtensionsFolder = function (appURL, callback) {
appshell.app.showOSFolder(GetApplicationSupportDirectory() + "/extensions", callback);
};
/**
* Drag the main window
*
* @return None. This is an asynchronous call that sends all return information to the callback.
*/
native function DragWindow();
appshell.app.dragWindow = function () {
DragWindow();
};
// Alias the appshell object to brackets. This is temporary and should be removed.
brackets = appshell;
@@ -1001,3 +1001,24 @@ int32 RemoveMenuItem(CefRefPtr<CefBrowser> browser, const ExtensionString& comma
return NO_ERROR;
}
void DragWindow(CefRefPtr<CefBrowser> browser)
{
NSWindow* win = [browser->GetHost()->GetWindowHandle() window];
NSPoint origin = [win frame].origin;
NSPoint current = [NSEvent mouseLocation];
NSPoint offset;
origin.x -= current.x;
origin.y -= current.y;
while (YES) {
NSEvent* event = [win nextEventMatchingMask:(NSLeftMouseDraggedMask | NSLeftMouseUpMask)];
if ([event type] == NSLeftMouseUp) break;
current = [win convertBaseToScreen:[event locationInWindow]];
offset = origin;
offset.x += current.x;
offset.y += current.y;
[win setFrameOrigin:offset];
[win displayIfNeeded];
}
}
@@ -124,3 +124,5 @@ int32 GetMenuTitle(CefRefPtr<CefBrowser> browser, ExtensionString commandId, Ext
int32 SetMenuItemShortcut(CefRefPtr<CefBrowser> browser, ExtensionString commandId, ExtensionString shortcut, ExtensionString displayStr);
int32 GetMenuPosition(CefRefPtr<CefBrowser> browser, const ExtensionString& commandId, ExtensionString& parentId, int& index);
void DragWindow(CefRefPtr<CefBrowser> browser);
@@ -1581,4 +1581,11 @@ int32 RemoveMenuItem(CefRefPtr<CefBrowser> browser, const ExtensionString& comma
return NO_ERROR;
}
void DragWindow(CefRefPtr<CefBrowser> browser) {
ReleaseCapture();
HWND browserHwnd = (HWND)getMenuParent(browser);
SendMessage(browserHwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}

0 comments on commit 5e52d86

Please sign in to comment.