Improve mismatching event size warning

Include both the event size and the current size in the warning message.

PR #5455 <https://github.com/Genymobile/scrcpy/pull/5455>
This commit is contained in:
Romain Vimont 2024-11-15 18:41:04 +01:00
parent b2481626c1
commit 23caa16fd4
3 changed files with 12 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import com.genymobile.scrcpy.device.Device;
import com.genymobile.scrcpy.device.DeviceApp;
import com.genymobile.scrcpy.device.Point;
import com.genymobile.scrcpy.device.Position;
import com.genymobile.scrcpy.device.Size;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.util.LogUtils;
import com.genymobile.scrcpy.video.SurfaceCapture;
@ -359,7 +360,9 @@ public class Controller implements AsyncProcessor, VirtualDisplayListener {
Point point = displayData.positionMapper.map(position);
if (point == null) {
Ln.w("Ignore touch event, it was generated for a different device size");
Size eventSize = position.getScreenSize();
Size currentSize = displayData.positionMapper.getVideoSize();
Ln.w("Ignore touch event generated for size " + eventSize + " (current size is " + currentSize + ")");
return false;
}
@ -473,7 +476,9 @@ public class Controller implements AsyncProcessor, VirtualDisplayListener {
Point point = displayData.positionMapper.map(position);
if (point == null) {
Ln.w("Ignore scroll event, it was generated for a different device size");
Size eventSize = position.getScreenSize();
Size currentSize = displayData.positionMapper.getVideoSize();
Ln.w("Ignore scroll event generated for size " + eventSize + " (current size is " + currentSize + ")");
return false;
}

View File

@ -27,6 +27,10 @@ public final class PositionMapper {
return new PositionMapper(videoSize, transform);
}
public Size getVideoSize() {
return videoSize;
}
public Point map(Position position) {
Size clientVideoSize = position.getScreenSize();
if (!videoSize.equals(clientVideoSize)) {

View File

@ -103,6 +103,6 @@ public final class Size {
@Override
public String toString() {
return "Size{" + width + 'x' + height + '}';
return width + "x" + height;
}
}