mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 03:25:02 +00:00
fix: group control framesize bug
This commit is contained in:
parent
f979b0cd32
commit
cbd0061c5f
6 changed files with 79 additions and 8 deletions
|
@ -91,6 +91,15 @@ const QString &Device::getSerial()
|
|||
return m_params.serial;
|
||||
}
|
||||
|
||||
const QSize Device::frameSize()
|
||||
{
|
||||
QSize size;
|
||||
if (!m_videoForm) {
|
||||
return size;
|
||||
}
|
||||
return m_videoForm->frameSize();
|
||||
}
|
||||
|
||||
void Device::updateScript(QString script)
|
||||
{
|
||||
if(m_controller){
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
VideoForm *getVideoForm();
|
||||
Server *getServer();
|
||||
const QString &getSerial();
|
||||
const QSize frameSize();
|
||||
|
||||
void updateScript(QString script);
|
||||
Device::GroupControlState controlState();
|
||||
|
|
|
@ -92,6 +92,11 @@ QRect VideoForm::getGrabCursorRect()
|
|||
return rc;
|
||||
}
|
||||
|
||||
const QSize &VideoForm::frameSize()
|
||||
{
|
||||
return m_frameSize;
|
||||
}
|
||||
|
||||
void VideoForm::updateRender(const AVFrame *frame)
|
||||
{
|
||||
if (m_videoWidget->isHidden()) {
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
void updateRender(const AVFrame *frame);
|
||||
void setDevice(Device *device);
|
||||
QRect getGrabCursorRect();
|
||||
const QSize &frameSize();
|
||||
|
||||
public slots:
|
||||
void onSwitchFullScreen();
|
||||
|
|
|
@ -127,9 +127,6 @@ void DeviceManage::setGroupControlSignals(Device *host, Device *client, bool ins
|
|||
connect(host, &Device::clipboardPaste, client, &Device::clipboardPaste);
|
||||
connect(host, &Device::pushFileRequest, client, &Device::pushFileRequest);
|
||||
connect(host, &Device::installApkRequest, client, &Device::installApkRequest);
|
||||
connect(host, &Device::mouseEvent, client, &Device::mouseEvent);
|
||||
connect(host, &Device::wheelEvent, client, &Device::wheelEvent);
|
||||
connect(host, &Device::keyEvent, client, &Device::keyEvent);
|
||||
connect(host, &Device::screenshot, client, &Device::screenshot);
|
||||
connect(host, &Device::showTouch, client, &Device::showTouch);
|
||||
// dont connect requestDeviceClipboard
|
||||
|
@ -150,9 +147,6 @@ void DeviceManage::setGroupControlSignals(Device *host, Device *client, bool ins
|
|||
disconnect(host, &Device::clipboardPaste, client, &Device::clipboardPaste);
|
||||
disconnect(host, &Device::pushFileRequest, client, &Device::pushFileRequest);
|
||||
disconnect(host, &Device::installApkRequest, client, &Device::installApkRequest);
|
||||
disconnect(host, &Device::mouseEvent, client, &Device::mouseEvent);
|
||||
disconnect(host, &Device::wheelEvent, client, &Device::wheelEvent);
|
||||
disconnect(host, &Device::keyEvent, client, &Device::keyEvent);
|
||||
disconnect(host, &Device::screenshot, client, &Device::screenshot);
|
||||
disconnect(host, &Device::showTouch, client, &Device::showTouch);
|
||||
}
|
||||
|
@ -201,19 +195,75 @@ void DeviceManage::onControlStateChange(Device *device, Device::GroupControlStat
|
|||
// free to host
|
||||
if (oldState == Device::GroupControlState::GCS_FREE
|
||||
&& newState == Device::GroupControlState::GCS_HOST) {
|
||||
// install control signals
|
||||
// install direct control signals
|
||||
setGroupControlHost(device, true);
|
||||
// install convert control signals(frameSize need convert)
|
||||
connect(device, &Device::mouseEvent, this, &DeviceManage::onMouseEvent, Qt::UniqueConnection);
|
||||
connect(device, &Device::wheelEvent, this, &DeviceManage::onWheelEvent, Qt::UniqueConnection);
|
||||
connect(device, &Device::keyEvent, this, &DeviceManage::onKeyEvent, Qt::UniqueConnection);
|
||||
return;
|
||||
}
|
||||
// host to free
|
||||
if (oldState == Device::GroupControlState::GCS_HOST
|
||||
&& newState == Device::GroupControlState::GCS_FREE) {
|
||||
// uninstall control signals
|
||||
// uninstall direct control signals
|
||||
setGroupControlHost(device, false);
|
||||
// uninstall convert control signals(frameSize need convert)
|
||||
disconnect(device, &Device::mouseEvent, this, &DeviceManage::onMouseEvent);
|
||||
disconnect(device, &Device::wheelEvent, this, &DeviceManage::onWheelEvent);
|
||||
disconnect(device, &Device::keyEvent, this, &DeviceManage::onKeyEvent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManage::onMouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize)
|
||||
{
|
||||
QMapIterator<QString, QPointer<Device>> i(m_devices);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (!i.value()) {
|
||||
continue;
|
||||
}
|
||||
if (i.value() == sender()) {
|
||||
continue;
|
||||
}
|
||||
// neend convert frameSize to its frameSize
|
||||
emit i.value()->mouseEvent(from, i.value()->frameSize(), showSize);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManage::onWheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize)
|
||||
{
|
||||
QMapIterator<QString, QPointer<Device>> i(m_devices);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (!i.value()) {
|
||||
continue;
|
||||
}
|
||||
if (i.value() == sender()) {
|
||||
continue;
|
||||
}
|
||||
// neend convert frameSize to its frameSize
|
||||
emit i.value()->wheelEvent(from, i.value()->frameSize(), showSize);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManage::onKeyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize)
|
||||
{
|
||||
QMapIterator<QString, QPointer<Device>> i(m_devices);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (!i.value()) {
|
||||
continue;
|
||||
}
|
||||
if (i.value() == sender()) {
|
||||
continue;
|
||||
}
|
||||
// neend convert frameSize to its frameSize
|
||||
emit i.value()->keyEvent(from, i.value()->frameSize(), showSize);
|
||||
}
|
||||
}
|
||||
|
||||
quint16 DeviceManage::getFreePort()
|
||||
{
|
||||
quint16 port = m_localPortStart;
|
||||
|
|
|
@ -28,6 +28,11 @@ protected slots:
|
|||
void onDeviceDisconnect(QString serial);
|
||||
void onControlStateChange(Device* device, Device::GroupControlState oldState, Device::GroupControlState newState);
|
||||
|
||||
// neend convert frameSize to its frameSize
|
||||
void onMouseEvent(const QMouseEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
void onWheelEvent(const QWheelEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
void onKeyEvent(const QKeyEvent* from, const QSize& frameSize, const QSize& showSize);
|
||||
|
||||
private:
|
||||
quint16 getFreePort();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue