Browse Source

fix: resizing borders in nondraggable regions (#37037)

* fix: resizing borders in nondraggable regions

Co-authored-by: Shelley Vohr <[email protected]>

* chore: remove frame handling from ShouldDescendIntoChildForEventHandling

Co-authored-by: Shelley Vohr <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
trop[bot] 2 years ago
parent
commit
e69270a600
2 changed files with 16 additions and 13 deletions
  1. 15 0
      shell/browser/native_window.cc
  2. 1 13
      shell/browser/native_window_views.cc

+ 15 - 0
shell/browser/native_window.cc

@@ -24,6 +24,10 @@
 #include "ui/base/hit_test.h"
 #include "ui/views/widget/widget.h"
 
+#if !BUILDFLAG(IS_MAC)
+#include "shell/browser/ui/views/frameless_view.h"
+#endif
+
 #if BUILDFLAG(IS_WIN)
 #include "ui/base/win/shell.h"
 #include "ui/display/win/screen_win.h"
@@ -691,6 +695,17 @@ void NativeWindow::NotifyWindowMessage(UINT message,
 #endif
 
 int NativeWindow::NonClientHitTest(const gfx::Point& point) {
+#if !BUILDFLAG(IS_MAC)
+  // We need to ensure we account for resizing borders on Windows and Linux.
+  if ((!has_frame() || has_client_frame()) && IsResizable()) {
+    auto* frame =
+        static_cast<FramelessView*>(widget()->non_client_view()->frame_view());
+    int border_hit = frame->ResizingBorderHitTest(point);
+    if (border_hit != HTNOWHERE)
+      return border_hit;
+  }
+#endif
+
   for (auto* provider : draggable_region_providers_) {
     int hit = provider->NonClientHitTest(point);
     if (hit != HTNOWHERE)

+ 1 - 13
shell/browser/native_window_views.cc

@@ -1592,19 +1592,7 @@ views::View* NativeWindowViews::GetContentsView() {
 bool NativeWindowViews::ShouldDescendIntoChildForEventHandling(
     gfx::NativeView child,
     const gfx::Point& location) {
-  // App window should claim mouse events that fall within any BrowserViews'
-  // draggable region.
-  if (NonClientHitTest(location) != HTNOWHERE)
-    return false;
-
-  // And the events on border for dragging resizable frameless window.
-  if ((!has_frame() || has_client_frame()) && resizable_) {
-    auto* frame =
-        static_cast<FramelessView*>(widget()->non_client_view()->frame_view());
-    return frame->ResizingBorderHitTest(location) == HTNOWHERE;
-  }
-
-  return true;
+  return NonClientHitTest(location) == HTNOWHERE;
 }
 
 views::ClientView* NativeWindowViews::CreateClientView(views::Widget* widget) {