2022-12-27 21:26:32 +01:00
|
|
|
#include "widgets/FramelessEmbedWindow.hpp"
|
2021-04-17 16:15:23 +02:00
|
|
|
|
|
|
|
#include "Application.hpp"
|
2022-12-27 21:26:32 +01:00
|
|
|
#include "common/Args.hpp"
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
#include "providers/twitch/TwitchIrcServer.hpp"
|
2022-12-27 21:26:32 +01:00
|
|
|
#include "widgets/splits/Split.hpp"
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
2022-12-27 21:26:32 +01:00
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QMessageBox>
|
2021-04-17 16:15:23 +02:00
|
|
|
|
|
|
|
#ifdef USEWINSDK
|
|
|
|
# include "Windows.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
FramelessEmbedWindow::FramelessEmbedWindow()
|
2022-12-03 11:50:22 +01:00
|
|
|
: BaseWindow({BaseWindow::Frameless, BaseWindow::DisableLayoutSave})
|
2021-04-17 16:15:23 +02:00
|
|
|
{
|
|
|
|
this->split_ = new Split((QWidget *)nullptr);
|
|
|
|
auto layout = new QHBoxLayout;
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
layout->addWidget(this->split_);
|
|
|
|
|
|
|
|
this->getLayoutContainer()->setLayout(layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USEWINSDK
|
2023-02-13 21:45:58 +01:00
|
|
|
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
bool FramelessEmbedWindow::nativeEvent(const QByteArray &eventType,
|
|
|
|
void *message, qintptr *result)
|
|
|
|
# else
|
2021-04-17 16:15:23 +02:00
|
|
|
bool FramelessEmbedWindow::nativeEvent(const QByteArray &eventType,
|
|
|
|
void *message, long *result)
|
2023-02-13 21:45:58 +01:00
|
|
|
# endif
|
2021-04-17 16:15:23 +02:00
|
|
|
{
|
|
|
|
MSG *msg = reinterpret_cast<MSG *>(message);
|
|
|
|
|
|
|
|
if (msg->message == WM_COPYDATA)
|
|
|
|
{
|
|
|
|
auto data = reinterpret_cast<COPYDATASTRUCT *>(msg->lParam);
|
|
|
|
|
|
|
|
// no idea why I have to read it to a string and then encode it back to utf-8
|
|
|
|
auto str = QString::fromUtf8(reinterpret_cast<char *>(data->lpData),
|
|
|
|
int(data->cbData));
|
|
|
|
auto doc = QJsonDocument::fromJson(str.toUtf8());
|
|
|
|
|
|
|
|
auto root = doc.object();
|
|
|
|
if (root.value("type").toString() == "set-channel")
|
|
|
|
{
|
|
|
|
if (root.value("provider").toString() == "twitch")
|
|
|
|
{
|
|
|
|
auto channelName = root.value("channel-name").toString();
|
|
|
|
|
|
|
|
this->split_->setChannel(
|
2022-03-19 12:02:29 +01:00
|
|
|
getApp()->twitch->getOrAddChannel(channelName));
|
2021-04-17 16:15:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return BaseWidget::nativeEvent(eventType, message, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FramelessEmbedWindow::showEvent(QShowEvent *)
|
|
|
|
{
|
|
|
|
if (!getArgs().parentWindowId)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto parentHwnd =
|
2023-10-08 18:50:48 +02:00
|
|
|
reinterpret_cast<HWND>(getArgs().parentWindowId.value()))
|
2021-04-17 16:15:23 +02:00
|
|
|
{
|
|
|
|
auto handle = reinterpret_cast<HWND>(this->winId());
|
|
|
|
if (!::SetParent(handle, parentHwnd))
|
|
|
|
{
|
|
|
|
qApp->exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
QJsonDocument doc;
|
|
|
|
QJsonObject root;
|
|
|
|
root.insert("type", "created-window");
|
|
|
|
root.insert(
|
|
|
|
"window-id",
|
|
|
|
QString::number(reinterpret_cast<unsigned long long>(handle)));
|
|
|
|
doc.setObject(root);
|
|
|
|
auto json = doc.toJson();
|
|
|
|
json.append('\0');
|
|
|
|
|
|
|
|
COPYDATASTRUCT cds;
|
|
|
|
cds.cbData = static_cast<DWORD>(json.size());
|
|
|
|
cds.lpData = json.data();
|
|
|
|
|
|
|
|
::SendMessage(parentHwnd, WM_COPYDATA, reinterpret_cast<WPARAM>(handle),
|
|
|
|
reinterpret_cast<LPARAM>(&cds));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace chatterino
|