diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index 7bfab6cf5..c53656ee1 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef USEWINSDK #include @@ -393,14 +394,17 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r } } break; case WM_NCHITTEST: { + const LONG border_width = 8; // in pixels + RECT winrect; + GetWindowRect(HWND(winId()), &winrect); + + long x = GET_X_LPARAM(msg->lParam); + long y = GET_Y_LPARAM(msg->lParam); + + QPoint point(x - winrect.left, y - winrect.top); + if (this->hasCustomWindowFrame()) { *result = 0; - const LONG border_width = 8; // in pixels - RECT winrect; - GetWindowRect(HWND(winId()), &winrect); - - long x = GET_X_LPARAM(msg->lParam); - long y = GET_Y_LPARAM(msg->lParam); bool resizeWidth = minimumWidth() != maximumWidth(); bool resizeHeight = minimumHeight() != maximumHeight(); @@ -451,7 +455,6 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r if (*result == 0) { bool client = false; - QPoint point(x - winrect.left, y - winrect.top); for (QWidget *widget : this->ui_.buttons) { if (widget->geometry().contains(point)) { client = true; @@ -469,6 +472,36 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r } } + return true; + } else if (this->flags_ & FramelessDraggable) { + *result = 0; + bool client = false; + + if (auto widget = this->childAt(point)) { + std::function recursiveCheckMouseTracking; + recursiveCheckMouseTracking = [&](QWidget *widget) { + if (widget == nullptr) { + return false; + } + + if (widget->hasMouseTracking()) { + return true; + } + + return recursiveCheckMouseTracking(widget->parentWidget()); + }; + + if (recursiveCheckMouseTracking(widget)) { + client = true; + } + } + + if (client) { + *result = HTCLIENT; + } else { + *result = HTCAPTION; + } + return true; } else { return QWidget::nativeEvent(eventType, message, result); diff --git a/src/widgets/basewindow.hpp b/src/widgets/basewindow.hpp index 0839385d7..409d63dc8 100644 --- a/src/widgets/basewindow.hpp +++ b/src/widgets/basewindow.hpp @@ -27,6 +27,7 @@ public: TopMost = 4, DeleteOnFocusOut = 8, DisableCustomScaling = 16, + FramelessDraggable = 32, }; explicit BaseWindow(QWidget *parent = nullptr, Flags flags_ = None); diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp index 8c3897131..28d97e392 100644 --- a/src/widgets/helper/splitheader.cpp +++ b/src/widgets/helper/splitheader.cpp @@ -129,8 +129,8 @@ void SplitHeader::addDropdownItems(RippleEffectButton *) this->dropdownMenu.addSeparator(); this->dropdownMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes())); this->dropdownMenu.addAction("Manual reconnect", this, SLOT(menuManualReconnect())); - this->dropdownMenu.addSeparator(); - this->dropdownMenu.addAction("Show changelog", this, SLOT(menuShowChangelog())); +// this->dropdownMenu.addSeparator(); +// this->dropdownMenu.addAction("Show changelog", this, SLOT(menuShowChangelog())); // clang-format on } diff --git a/src/widgets/userinfopopup.cpp b/src/widgets/userinfopopup.cpp index 42910dad9..d43f47c14 100644 --- a/src/widgets/userinfopopup.cpp +++ b/src/widgets/userinfopopup.cpp @@ -22,7 +22,8 @@ namespace chatterino { namespace widgets { UserInfoPopup::UserInfoPopup() - : BaseWindow(nullptr, BaseWindow::Flags(BaseWindow::Frameless | BaseWindow::DeleteOnFocusOut)) + : BaseWindow(nullptr, BaseWindow::Flags(BaseWindow::Frameless | BaseWindow::DeleteOnFocusOut | + BaseWindow::FramelessDraggable)) , hack_(new bool) { this->setStayInScreenRect(true); @@ -376,21 +377,16 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget() addTimeouts("sec", {{"1", 1}}); addTimeouts("min", { - {"1", 1 * 60}, - {"5", 5 * 60}, - {"10", 10 * 60}, + {"1", 1 * 60}, {"5", 5 * 60}, {"10", 10 * 60}, }); addTimeouts("hour", { - {"1", 1 * 60 * 60}, - {"4", 4 * 60 * 60}, + {"1", 1 * 60 * 60}, {"4", 4 * 60 * 60}, }); addTimeouts("days", { - {"1", 1 * 60 * 60 * 24}, - {"3", 3 * 60 * 60 * 24}, + {"1", 1 * 60 * 60 * 24}, {"3", 3 * 60 * 60 * 24}, }); addTimeouts("weeks", { - {"1", 1 * 60 * 60 * 24 * 7}, - {"2", 2 * 60 * 60 * 24 * 7}, + {"1", 1 * 60 * 60 * 24 * 7}, {"2", 2 * 60 * 60 * 24 * 7}, }); addButton(Ban, "ban", getApp()->resources->buttons.ban);