diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a18cc9d9..bac7c28d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Bugfix: Fixed "smiley" emotes being unable to be "Tabbed" with autocompletion, introduced in v2.3.3. (#3010) - Bugfix: Copy buttons in usercard now show properly in light mode (#3057) - Bugfix: Fixed comma appended to username completion when not at the beginning of the message. (#3060) +- Bugfix: Fixed bug misplacing chat when zooming on Chrome with Chatterino Native Host extension (#1936) - Dev: Ubuntu packages are now available (#2936) - Dev: Disabled update checker on Flatpak. (#3051) - Dev: Add logging for HTTP requests (#2991) diff --git a/src/singletons/NativeMessaging.cpp b/src/singletons/NativeMessaging.cpp index e0fdff803..d647fd0d9 100644 --- a/src/singletons/NativeMessaging.cpp +++ b/src/singletons/NativeMessaging.cpp @@ -191,7 +191,6 @@ void NativeMessagingServer::ReceiverThread::handleMessage( const QJsonObject &root) { auto app = getApp(); - QString action = root.value("action").toString(); if (action.isNull()) @@ -211,13 +210,20 @@ void NativeMessagingServer::ReceiverThread::handleMessage( AttachedWindow::GetArgs args; args.winId = root.value("winId").toString(); args.yOffset = root.value("yOffset").toInt(-1); - args.x = root.value("size").toObject().value("x").toInt(-1); - args.width = root.value("size").toObject().value("width").toInt(-1); - args.height = root.value("size").toObject().value("height").toInt(-1); + + { + const auto sizeObject = root.value("size").toObject(); + args.x = sizeObject.value("x").toDouble(-1.0); + args.pixelRatio = sizeObject.value("pixelRatio").toDouble(-1.0); + args.width = sizeObject.value("width").toInt(-1); + args.height = sizeObject.value("height").toInt(-1); + } + args.fullscreen = attachFullscreen; qCDebug(chatterinoNativeMessage) - << args.x << args.width << args.height << args.winId; + << args.x << args.pixelRatio << args.width << args.height + << args.winId; if (_type.isNull() || args.winId.isNull()) { diff --git a/src/widgets/AttachedWindow.cpp b/src/widgets/AttachedWindow.cpp index 15c1f6dc9..05392b2d2 100644 --- a/src/widgets/AttachedWindow.cpp +++ b/src/widgets/AttachedWindow.cpp @@ -93,6 +93,7 @@ AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args) window->fullscreen_ = args.fullscreen; window->x_ = args.x; + window->pixelRatio_ = args.pixelRatio; if (args.height != -1) { @@ -276,7 +277,16 @@ void AttachedWindow::updateWindowRect(void *_attachedPtr) // offset int o = this->fullscreen_ ? 0 : 8; - if (this->x_ != -1) + if (this->pixelRatio_ != -1.0) + { + ::MoveWindow( + hwnd, + int(rect.left + this->x_ * scale * this->pixelRatio_ + o - 2), + int(rect.bottom - this->height_ * scale - o), + int(this->width_ * scale), int(this->height_ * scale), true); + } + //support for old extension version 1.3 + else if (this->x_ != -1.0) { ::MoveWindow(hwnd, int(rect.left + this->x_ * scale + o), int(rect.bottom - this->height_ * scale - o), diff --git a/src/widgets/AttachedWindow.hpp b/src/widgets/AttachedWindow.hpp index 4ecefa11c..186d310fd 100644 --- a/src/widgets/AttachedWindow.hpp +++ b/src/widgets/AttachedWindow.hpp @@ -17,7 +17,8 @@ public: struct GetArgs { QString winId; int yOffset = -1; - int x = -1; + double x = -1; + double pixelRatio = -1; int width = -1; int height = -1; bool fullscreen = false; @@ -54,7 +55,8 @@ private: void *target_; int yOffset_; int currentYOffset_; - int x_ = -1; + double x_ = -1; + double pixelRatio_ = -1; int width_ = 360; int height_ = -1; bool fullscreen_ = false;