changeset 358:59b1ef1b0a89

fix ilter single display (HiDPI)
author oc
date Tue, 03 Mar 2015 17:58:41 +0900
parents 7c763b2a01a5
children 62a6c779fd7f
files src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java
diffstat 2 files changed, 75 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java	Tue Feb 24 18:28:48 2015 +0900
+++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java	Tue Mar 03 17:58:41 2015 +0900
@@ -70,6 +70,13 @@
     private long checkCounter = 0;
     public int numberOfRectangles = 0;
     private Timer timer = null;
+    private int singleWidth;
+    private int singleHeight;
+    private int nextWidth;
+    private int nextHeight;
+    private boolean isHiDPI = false;
+    private int hiDPIWidth;
+    private int hiDPIHeight;
 
     public ReceiverTask(Reader reader,
                         IRepaintController repaintController, ClipboardController clipboardController,
@@ -114,9 +121,16 @@
                     }
                 }, 0, 100);
             }
+            if(rfb.filterSingleDisplay) {
+                singleWidth = rfb.getSingleWidth();
+                nextWidth = rfb.getNextWidth();
+                isHiDPI = rfb.setHiDPI(singleWidth, singleHeight, nextWidth);
+            }
         }
     }
 
+
+
     @Override
     public void run() {
         isRunning = true;
@@ -239,7 +253,17 @@
                     try {
                         decoder.decode(reader, renderer, rect);  // TreeVNC processing here
                         if (rfb.getCuiVersion()) continue;
-                        if (rfb.filterSingleDisplay && rect.x >= rfb.getSingleWidth()) continue;
+                        if (rfb.filterSingleDisplay) {
+                            if (!isHiDPI) {
+                                if (rect.x >= rfb.getSingleWidth()) {
+                                    continue;
+                                }
+                            } else {
+                                if (rect.x >= rfb.getHiDPIWidth()) {
+                                    continue;
+                                }
+                            }
+                        }
                         repaintController.repaintBitmap(rect);
                     } catch (Exception e) {
                         throw e;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java	Tue Feb 24 18:28:48 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeRFBProto.java	Tue Mar 03 17:58:41 2015 +0900
@@ -74,12 +74,15 @@
     private int singleWidth = 0;
     private int singleHeight = 0;
 
+    private int hiDPIWidth = 0;
+    private int hiDPIHeight = 0;
+
     private DatagramSocket socket = null;
 
     private byte[] originalInitData = null;
     private boolean childrenMulticast = true;
-    public int nextSingleWidth;
-    public int nextSingleHeight;
+    private int nextSingleWidth;
+    private int nextSingleHeight;
 
     public TreeRFBProto(boolean isTreeManager, ViewerInterface viewer) {
         rThread = new RequestScreenThread(this);
@@ -739,6 +742,22 @@
                     bufs.addFirst(blen);
                     bufs.addFirst(header);
                     addSerialNumber(bufs);
+
+                    if (filterSingleDisplay) {
+                        if (setHiDPI(singleWidth, singleHeight, nextSingleWidth)) {
+                            if (rect.x <= hiDPIWidth) {
+                                multicastqueue.put(bufs);
+                            }
+                        } else {
+                            if (rect.x <= getSingleWidth()) {
+                                multicastqueue.put(bufs);
+                            }
+                        }
+                    } else {
+                        multicastqueue.put(bufs);
+                    }
+
+                    /*
                     if (filterSingleDisplay) {
                         if (rect.x < singleWidth) {
                             multicastqueue.put(bufs);
@@ -746,6 +765,8 @@
                     } else {
                         multicastqueue.put(bufs);
                     }
+                    */
+
                 } catch (IOException e) {
                     throw new TransportException(e);
                 } catch (DataFormatException e) {
@@ -936,6 +957,25 @@
         this.nextSingleHeight = singleHeight;
     }
 
+    public void setHiDPISize(int hiDPIWidth, int hiDPIHeight) {
+        this.hiDPIWidth = hiDPIWidth;
+        this.hiDPIHeight = hiDPIHeight;
+    }
+
+    public int getHiDPIWidth() {
+        return hiDPIWidth;
+    }
+
+    public boolean setHiDPI(int singleWidth, int singleHeight, int nextWidth) {
+        int fbWidth = context.getFbWidth();
+        if(fbWidth - nextWidth == singleWidth * 2) {
+            setHiDPISize(singleWidth * 2, singleHeight * 2);
+            return true;
+        }
+        return false;
+    }
+
+
     public int getSingleWidth() {
         return singleWidth;
     }
@@ -944,6 +984,14 @@
         return singleHeight;
     }
 
+    public int getNextWidth() {
+        return nextSingleWidth;
+    }
+
+    public int getNextHeight() {
+        return nextSingleHeight;
+    }
+
     public boolean hasParent() {
         return id != -1;
     }