From 0d31eda795a5bbfd62f070b54f2409761a0eb87f Mon Sep 17 00:00:00 2001
From: SineStriker <trueful@163.com>
Date: 周五, 01 12月 2023 18:22:00 +0800
Subject: [PATCH] Add small implementations

---
 src/core/handler/qtwindowcontext.cpp |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/src/core/handler/qtwindowcontext.cpp b/src/core/handler/qtwindowcontext.cpp
index 0dfd7a1..1716fb2 100644
--- a/src/core/handler/qtwindowcontext.cpp
+++ b/src/core/handler/qtwindowcontext.cpp
@@ -2,6 +2,44 @@
 
 namespace QWK {
 
+    static constexpr const int kDefaultResizeBorderThickness = 8;
+
+    static Qt::CursorShape calculateCursorShape(const QWindow *window, const QPoint &pos) {
+#ifdef Q_OS_MACOS
+        Q_UNUSED(window);
+        Q_UNUSED(pos);
+        return Qt::ArrowCursor;
+#else
+        Q_ASSERT(window);
+        if (!window) {
+            return Qt::ArrowCursor;
+        }
+        if (window->visibility() != QWindow::Windowed) {
+            return Qt::ArrowCursor;
+        }
+        const int x = pos.x();
+        const int y = pos.y();
+        const int w = window->width();
+        const int h = window->height();
+        if (((x < kDefaultResizeBorderThickness) && (y < kDefaultResizeBorderThickness)) ||
+            ((x >= (w - kDefaultResizeBorderThickness)) &&
+             (y >= (h - kDefaultResizeBorderThickness)))) {
+            return Qt::SizeFDiagCursor;
+        }
+        if (((x >= (w - kDefaultResizeBorderThickness)) && (y < kDefaultResizeBorderThickness)) ||
+            ((x < kDefaultResizeBorderThickness) && (y >= (h - kDefaultResizeBorderThickness)))) {
+            return Qt::SizeBDiagCursor;
+        }
+        if ((x < kDefaultResizeBorderThickness) || (x >= (w - kDefaultResizeBorderThickness))) {
+            return Qt::SizeHorCursor;
+        }
+        if ((y < kDefaultResizeBorderThickness) || (y >= (h - kDefaultResizeBorderThickness))) {
+            return Qt::SizeVerCursor;
+        }
+        return Qt::ArrowCursor;
+#endif
+    }
+
     QtWindowContext::QtWindowContext(QWindow *window, WindowItemDelegate *delegate)
         : AbstractWindowContext(window, delegate) {
     }
@@ -9,4 +47,8 @@
     QtWindowContext::~QtWindowContext() {
     }
 
+    bool QtWindowContext::eventFilter(QObject *obj, QEvent *event) {
+        return AbstractWindowContext::eventFilter(obj, event);
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.1