fix: make draggable regions work when devtools is opened on macOS (#26361)
* fix: make draggable region work when devtools is open * fix: update draggable regions when resizing
This commit is contained in:
parent
f21a21f172
commit
02a8c0a640
8 changed files with 78 additions and 20 deletions
|
@ -63,6 +63,9 @@ class BrowserWindow : public BaseWindow,
|
|||
void OnActivateContents() override;
|
||||
void OnPageTitleUpdated(const base::string16& title,
|
||||
bool explicit_set) override;
|
||||
#if defined(OS_MAC)
|
||||
void OnDevToolsResized() override;
|
||||
#endif
|
||||
|
||||
// NativeWindowObserver:
|
||||
void RequestPreferredWidth(int* width) override;
|
||||
|
|
|
@ -12,27 +12,9 @@
|
|||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "shell/browser/native_browser_view.h"
|
||||
#include "shell/browser/native_window_mac.h"
|
||||
#include "shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h"
|
||||
#include "shell/browser/ui/inspectable_web_contents_view.h"
|
||||
|
||||
@interface NSView (WebContentsView)
|
||||
- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
|
||||
@end
|
||||
|
||||
@interface ControlRegionView : NSView
|
||||
@end
|
||||
|
||||
@implementation ControlRegionView
|
||||
|
||||
- (BOOL)mouseDownCanMoveWindow {
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSView*)hitTest:(NSPoint)aPoint {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
@ -54,6 +36,10 @@ void BrowserWindow::OverrideNSWindowContentView(InspectableWebContents* iwc) {
|
|||
[contentView viewDidMoveToWindow];
|
||||
}
|
||||
|
||||
void BrowserWindow::OnDevToolsResized() {
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
}
|
||||
|
||||
void BrowserWindow::UpdateDraggableRegions(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||
if (window_->has_frame())
|
||||
|
|
|
@ -1481,6 +1481,11 @@ void WebContents::DevToolsClosed() {
|
|||
Emit("devtools-closed");
|
||||
}
|
||||
|
||||
void WebContents::DevToolsResized() {
|
||||
for (ExtendedWebContentsObserver& observer : observers_)
|
||||
observer.OnDevToolsResized();
|
||||
}
|
||||
|
||||
bool WebContents::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
|
||||
|
|
|
@ -590,6 +590,7 @@ class WebContents : public gin::Wrappable<WebContents>,
|
|||
void DevToolsFocused() override;
|
||||
void DevToolsOpened() override;
|
||||
void DevToolsClosed() override;
|
||||
void DevToolsResized() override;
|
||||
|
||||
private:
|
||||
ElectronBrowserContext* GetBrowserContext() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue