Fixed zooming bug in native-host-ext [Chrome] (#1936)

Co-authored-by: alazymeme <jkeasley@icloud.com>
Co-authored-by: 23rd <23rd@vivaldi.net>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Matthew Marlow 2021-07-25 08:13:21 -05:00 committed by GitHub
parent 700e092bf6
commit 6052a0ede6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 8 deletions

View file

@ -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)

View file

@ -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())
{

View file

@ -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),

View file

@ -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;