feat: include resize edge with will-resize event (#29199)
* feat: emit resize edge with will-resize event fix: wparam type fix: private member usage on mac docs: will-resize event edge option refactor: 'info' -> 'details' for better type gen * Update docs/api/browser-window.md Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com> * Update docs/api/browser-window.md Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
This commit is contained in:
parent
750a762bf0
commit
f9d2a7077e
11 changed files with 104 additions and 4 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <Quartz/Quartz.h>
|
||||
|
||||
#include "components/remote_cocoa/app_shim/views_nswindow_delegate.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
namespace electron {
|
||||
class NativeWindowMac;
|
||||
|
@ -20,6 +21,11 @@ class NativeWindowMac;
|
|||
bool is_zooming_;
|
||||
int level_;
|
||||
bool is_resizable_;
|
||||
|
||||
// Only valid during a live resize.
|
||||
// Used to keep track of whether a resize is happening horizontally or
|
||||
// vertically, even if physically the user is resizing in both directions.
|
||||
absl::optional<bool> resizingHorizontally_;
|
||||
}
|
||||
- (id)initWithShell:(electron::NativeWindowMac*)shell;
|
||||
@end
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "shell/browser/native_window_mac.h"
|
||||
#include "shell/browser/ui/cocoa/electron_preview_item.h"
|
||||
#include "shell/browser/ui/cocoa/electron_touch_bar.h"
|
||||
#include "ui/gfx/geometry/resize_utils.h"
|
||||
#include "ui/gfx/mac/coordinate_conversion.h"
|
||||
#include "ui/views/cocoa/native_widget_mac_ns_window_host.h"
|
||||
#include "ui/views/widget/native_widget_mac.h"
|
||||
|
@ -140,11 +141,21 @@ using FullScreenTransitionState =
|
|||
extraHeightPlusFrame);
|
||||
}
|
||||
|
||||
if (!resizingHorizontally_) {
|
||||
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
|
||||
const auto widthDelta = frameSize.width - [window frame].size.width;
|
||||
const auto heightDelta = frameSize.height - [window frame].size.height;
|
||||
resizingHorizontally_ = std::abs(widthDelta) > std::abs(heightDelta);
|
||||
}
|
||||
|
||||
{
|
||||
bool prevent_default = false;
|
||||
NSRect new_bounds = NSMakeRect(sender.frame.origin.x, sender.frame.origin.y,
|
||||
newSize.width, newSize.height);
|
||||
shell_->NotifyWindowWillResize(gfx::ScreenRectFromNSRect(new_bounds),
|
||||
*resizingHorizontally_
|
||||
? gfx::ResizeEdge::kRight
|
||||
: gfx::ResizeEdge::kBottom,
|
||||
&prevent_default);
|
||||
if (prevent_default) {
|
||||
return sender.frame.size;
|
||||
|
@ -204,6 +215,7 @@ using FullScreenTransitionState =
|
|||
}
|
||||
|
||||
- (void)windowDidEndLiveResize:(NSNotification*)notification {
|
||||
resizingHorizontally_.reset();
|
||||
shell_->NotifyWindowResized();
|
||||
if (is_zooming_) {
|
||||
if (shell_->IsMaximized())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue