mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-07-29 12:18:39 +00:00
fix: group control framesize bug
This commit is contained in:
parent
3487fb7d2b
commit
3fd95bf9ee
6 changed files with 79 additions and 8 deletions
|
@ -91,6 +91,15 @@ const QString &Device::getSerial()
|
||||||
return m_params.serial;
|
return m_params.serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QSize Device::frameSize()
|
||||||
|
{
|
||||||
|
QSize size;
|
||||||
|
if (!m_videoForm) {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
return m_videoForm->frameSize();
|
||||||
|
}
|
||||||
|
|
||||||
void Device::updateScript(QString script)
|
void Device::updateScript(QString script)
|
||||||
{
|
{
|
||||||
if(m_controller){
|
if(m_controller){
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
VideoForm *getVideoForm();
|
VideoForm *getVideoForm();
|
||||||
Server *getServer();
|
Server *getServer();
|
||||||
const QString &getSerial();
|
const QString &getSerial();
|
||||||
|
const QSize frameSize();
|
||||||
|
|
||||||
void updateScript(QString script);
|
void updateScript(QString script);
|
||||||
Device::GroupControlState controlState();
|
Device::GroupControlState controlState();
|
||||||
|
|
|
@ -92,6 +92,11 @@ QRect VideoForm::getGrabCursorRect()
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QSize &VideoForm::frameSize()
|
||||||
|
{
|
||||||
|
return m_frameSize;
|
||||||
|
}
|
||||||
|
|
||||||
void VideoForm::updateRender(const AVFrame *frame)
|
void VideoForm::updateRender(const AVFrame *frame)
|
||||||
{
|
{
|
||||||
if (m_videoWidget->isHidden()) {
|
if (m_videoWidget->isHidden()) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
void updateRender(const AVFrame *frame);
|
void updateRender(const AVFrame *frame);
|
||||||
void setDevice(Device *device);
|
void setDevice(Device *device);
|
||||||
QRect getGrabCursorRect();
|
QRect getGrabCursorRect();
|
||||||
|
const QSize &frameSize();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onSwitchFullScreen();
|
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::clipboardPaste, client, &Device::clipboardPaste);
|
||||||
connect(host, &Device::pushFileRequest, client, &Device::pushFileRequest);
|
connect(host, &Device::pushFileRequest, client, &Device::pushFileRequest);
|
||||||
connect(host, &Device::installApkRequest, client, &Device::installApkRequest);
|
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::screenshot, client, &Device::screenshot);
|
||||||
connect(host, &Device::showTouch, client, &Device::showTouch);
|
connect(host, &Device::showTouch, client, &Device::showTouch);
|
||||||
// dont connect requestDeviceClipboard
|
// 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::clipboardPaste, client, &Device::clipboardPaste);
|
||||||
disconnect(host, &Device::pushFileRequest, client, &Device::pushFileRequest);
|
disconnect(host, &Device::pushFileRequest, client, &Device::pushFileRequest);
|
||||||
disconnect(host, &Device::installApkRequest, client, &Device::installApkRequest);
|
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::screenshot, client, &Device::screenshot);
|
||||||
disconnect(host, &Device::showTouch, client, &Device::showTouch);
|
disconnect(host, &Device::showTouch, client, &Device::showTouch);
|
||||||
}
|
}
|
||||||
|
@ -201,19 +195,75 @@ void DeviceManage::onControlStateChange(Device *device, Device::GroupControlStat
|
||||||
// free to host
|
// free to host
|
||||||
if (oldState == Device::GroupControlState::GCS_FREE
|
if (oldState == Device::GroupControlState::GCS_FREE
|
||||||
&& newState == Device::GroupControlState::GCS_HOST) {
|
&& newState == Device::GroupControlState::GCS_HOST) {
|
||||||
// install control signals
|
// install direct control signals
|
||||||
setGroupControlHost(device, true);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// host to free
|
// host to free
|
||||||
if (oldState == Device::GroupControlState::GCS_HOST
|
if (oldState == Device::GroupControlState::GCS_HOST
|
||||||
&& newState == Device::GroupControlState::GCS_FREE) {
|
&& newState == Device::GroupControlState::GCS_FREE) {
|
||||||
// uninstall control signals
|
// uninstall direct control signals
|
||||||
setGroupControlHost(device, false);
|
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;
|
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 DeviceManage::getFreePort()
|
||||||
{
|
{
|
||||||
quint16 port = m_localPortStart;
|
quint16 port = m_localPortStart;
|
||||||
|
|
|
@ -28,6 +28,11 @@ protected slots:
|
||||||
void onDeviceDisconnect(QString serial);
|
void onDeviceDisconnect(QString serial);
|
||||||
void onControlStateChange(Device* device, Device::GroupControlState oldState, Device::GroupControlState newState);
|
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:
|
private:
|
||||||
quint16 getFreePort();
|
quint16 getFreePort();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue