Improve Chatterino extension positioning (#1825)

This adds support for left-side chat
This commit is contained in:
Matthew Marlow 2020-08-01 06:42:56 -07:00 committed by GitHub
parent 214afc8fc2
commit e5f3bc9f3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View file

@ -198,11 +198,12 @@ 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);
args.fullscreen = attachFullscreen;
qDebug() << args.width << args.height << args.winId;
qDebug() << args.x << args.width << args.height << args.winId;
if (_type.isNull() || args.winId.isNull())
{

View file

@ -91,6 +91,8 @@ AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args)
window->fullscreen_ = args.fullscreen;
window->x_ = args.x;
if (args.height != -1)
{
if (args.height == 0)
@ -269,11 +271,22 @@ void AttachedWindow::updateWindowRect(void *_attachedPtr)
// offset
int o = this->fullscreen_ ? 0 : 8;
if (this->x_ != -1)
{
::MoveWindow(hwnd, int(rect.left + this->x_ * scale + o),
int(rect.bottom - this->height_ * scale - o),
int(this->width_ * scale), int(this->height_ * scale),
true);
}
//support for old extension version 1.2
else
{
::MoveWindow(hwnd, int(rect.right - this->width_ * scale - o),
int(rect.bottom - this->height_ * scale - o),
int(this->width_ * scale), int(this->height_ * scale),
true);
}
}
// if (this->fullscreen_)
// {

View file

@ -17,6 +17,7 @@ public:
struct GetArgs {
QString winId;
int yOffset = -1;
int x = -1;
int width = -1;
int height = -1;
bool fullscreen = false;
@ -53,6 +54,7 @@ private:
void *target_;
int yOffset_;
int currentYOffset_;
int x_ = -1;
int width_ = 360;
int height_ = -1;
bool fullscreen_ = false;