Skip to content

Truly independent web browser

UI/Qt: Keep the window's right edge resizable over the close button

Andreas Kling7a75ec883bf2
diff --git a/UI/Qt/BrowserWindow.cpp b/UI/Qt/BrowserWindow.cpp
index 5e52ad6ff9b..e5f4b592271 100644
--- a/UI/Qt/BrowserWindow.cpp
+++ b/UI/Qt/BrowserWindow.cpp
@@ -1650,7 +1650,24 @@ bool BrowserWindow::eventFilter(QObject* object, QEvent* event)
return true;
}
- auto const is_button = qobject_cast<QAbstractButton*>(object) != nullptr;
+ auto is_button = qobject_cast<QAbstractButton*>(object) != nullptr;
+
+ // The window controls run to the window's right edge. While the window can be resized, that edge still resizes it.
+ if (is_button && uses_client_side_decorations() && !isMaximized() && !isFullScreen()) {
+ auto is_press = event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick;
+ auto is_mouse_event = is_press || event->type() == QEvent::MouseMove;
+ auto position = is_mouse_event ? widget->mapTo(this, static_cast<QMouseEvent*>(event)->position().toPoint()) : mapFromGlobal(QCursor::pos());
+ if (auto edges = resize_edges_for_position(position); edges.testFlag(Qt::RightEdge)) {
+ // NB: Even if the resize does not start, a press here must not reach the button and close the window.
+ if (is_press) {
+ auto* handle = windowHandle();
+ if (handle && event->type() == QEvent::MouseButtonPress && static_cast<QMouseEvent*>(event)->button() == Qt::LeftButton)
+ handle->startSystemResize(edges);
+ return true;
+ }
+ is_button = false;
+ }
+ }
if (is_button && (event->type() == QEvent::Enter || event->type() == QEvent::MouseMove || event->type() == QEvent::Leave)) {
clear_resize_cursor();
diff --git a/UI/Qt/WindowControlButton.cpp b/UI/Qt/WindowControlButton.cpp
index c53cbda9498..f6ca6f202fa 100644
--- a/UI/Qt/WindowControlButton.cpp
+++ b/UI/Qt/WindowControlButton.cpp
@@ -61,6 +61,8 @@ WindowControlButton::WindowControlButton(WindowControlButtonType type, QString c
setIconSize(icon_size);
setFixedSize(button_size);
setFocusPolicy(Qt::NoFocus);
+ // NB: The window follows the pointer across a button to show its resize cursor over the edge of the window.
+ setMouseTracking(true);
setProperty(pressed_outside_property, false);
}