Mercurial > hg > Applications > TreeVNC
annotate src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java @ 432:a80d190a9fc1
trying to fix fitScreen
author | Nozomi |
---|---|
date | Wed, 08 Jun 2016 21:18:38 +0900 |
parents | 7eaa95ca7e45 |
children | ff7fa81f3616 |
rev | line source |
---|---|
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC. |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 // All rights reserved. |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 //------------------------------------------------------------------------- |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is part of the TightVNC software. Please visit our Web site: |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 // http://www.tightvnc.com/ |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 // |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 // This program is free software; you can redistribute it and/or modify |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 // it under the terms of the GNU General Public License as published by |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 // the Free Software Foundation; either version 2 of the License, or |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 // (at your option) any later version. |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 // |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 // This program is distributed in the hope that it will be useful, |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 // GNU General Public License for more details. |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 // |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 // You should have received a copy of the GNU General Public License along |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 // with this program; if not, write to the Free Software Foundation, Inc., |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 //------------------------------------------------------------------------- |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 // |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 package com.glavsoft.viewer.swing; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 import com.glavsoft.core.SettingsChangedEvent; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 import com.glavsoft.rfb.IChangeSettingsListener; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 import com.glavsoft.rfb.client.KeyEventMessage; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 import com.glavsoft.rfb.protocol.Protocol; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 import com.glavsoft.rfb.protocol.ProtocolContext; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 import com.glavsoft.rfb.protocol.ProtocolSettings; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 import com.glavsoft.utils.Keymap; |
407
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
34 import com.glavsoft.viewer.*; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 import com.glavsoft.viewer.swing.gui.OptionsDialog; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 import javax.swing.*; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 import javax.swing.border.BevelBorder; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 import javax.swing.border.Border; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 import javax.swing.border.EmptyBorder; |
109 | 41 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 import java.awt.*; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 import java.awt.event.*; |
410 | 44 import java.lang.reflect.Field; |
407
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
45 import java.net.Socket; |
274 | 46 import java.util.ArrayList; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 import java.util.LinkedList; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 import java.util.List; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 import java.util.concurrent.Executors; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 import java.util.concurrent.ScheduledExecutorService; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 import java.util.concurrent.ScheduledFuture; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 import java.util.concurrent.TimeUnit; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 import java.util.logging.Logger; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 |
290
c10e0dee7bbb
add READY_SHARE_SOUND msg, add function of receive READY_SHARE_SOUND msg, add sendSound thread.
oc
parents:
289
diff
changeset
|
55 import jp.ac.u_ryukyu.treevnc.*; |
113
bce2ef0a2e79
use ProtocolContext.sendMessage for upward command
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
56 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 public class SwingViewerWindow implements IChangeSettingsListener { |
314 | 58 public static final int FS_SCROLLING_ACTIVE_BORDER = 20; |
59 private JToggleButton zoomFitButton; | |
60 private JToggleButton zoomFullScreenButton; | |
61 private JButton zoomInButton; | |
62 private JButton zoomOutButton; | |
63 private JButton zoomAsIsButton; | |
64 private JPanel outerPanel; | |
65 private JScrollPane scroller; | |
66 private JFrame frame; | |
67 private boolean forceResizable = true; | |
68 private ButtonsBar buttonsBar; | |
69 private Surface surface; | |
70 private boolean isSeparateFrame; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71 private final boolean isApplet; |
153 | 72 private ViewerInterface viewer; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 private String connectionString; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 private ConnectionPresenter presenter; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 private Rectangle oldContainerBounds; |
314 | 76 private volatile boolean isFullScreen; |
77 private Border oldScrollerBorder; | |
78 private JLayeredPane lpane; | |
79 private EmptyButtonsBarMouseAdapter buttonsBarMouseAdapter; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
80 private String remoteDesktopName; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
81 private ProtocolSettings rfbSettings; |
392 | 82 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 private UiSettings uiSettings; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 private Protocol workingProtocol; |
225 | 85 public int width; |
86 public int height; | |
257 | 87 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 private boolean isZoomToFitSelected; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 private List<JComponent> kbdButtons; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 public SwingViewerWindow(Protocol workingProtocol, ProtocolSettings rfbSettings, UiSettings uiSettings, Surface surface, |
314 | 92 boolean isSeparateFrame, boolean isApplet, ViewerInterface viewer, String connectionString, |
93 ConnectionPresenter presenter, int w, int h) { | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 this.workingProtocol = workingProtocol; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 this.rfbSettings = rfbSettings; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 this.uiSettings = uiSettings; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 this.surface = surface; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 this.isSeparateFrame = isSeparateFrame; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99 this.isApplet = isApplet; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
100 this.viewer = viewer; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 this.connectionString = connectionString; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 this.presenter = presenter; |
225 | 103 this.width = w; |
104 this.height = h; | |
301 | 105 |
65 | 106 if(viewer instanceof Viewer) |
314 | 107 createContainer(surface, isApplet, (Viewer)viewer); |
108 | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
110 if (uiSettings.showControls) { |
314 | 111 if(viewer instanceof Viewer) |
112 createButtonsPanel(workingProtocol, isSeparateFrame? frame: (Viewer)viewer); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 if (isSeparateFrame) registerResizeListener(frame); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 updateZoomButtonsState(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
115 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 if (uiSettings.isFullScreen()) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 switchOnFullscreenMode(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119 setSurfaceToHandleKbdFocus(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 if (isSeparateFrame) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
121 new Thread(new Runnable() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
122 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
123 public void run() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
124 try { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125 Thread.sleep(1000); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 } catch (InterruptedException e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127 // nop |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 SwingUtilities.invokeLater(new Runnable() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
131 public void run() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132 frame.toFront(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 }); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 }).start(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 } |
314 | 138 } |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 |
314 | 140 private void createContainer(final Surface surface, boolean isApplet, JApplet appletWindow) { |
141 outerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)) { | |
142 /** | |
83 | 143 * |
144 */ | |
145 private static final long serialVersionUID = 1L; | |
146 @Override | |
314 | 147 public Dimension getSize() { |
148 return surface.getPreferredSize(); | |
149 } | |
150 @Override | |
151 public Dimension getPreferredSize() { | |
152 return surface.getPreferredSize(); | |
153 } | |
154 }; | |
247
dd154ffe1a53
fix lostparent, in case of death last node.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
225
diff
changeset
|
155 Dimension outerPanelSize = outerPanel.getSize(); |
257 | 156 double width = outerPanelSize.getWidth(); |
247
dd154ffe1a53
fix lostparent, in case of death last node.
one@firefly.cr.ie.u-ryukyu.ac.jp
parents:
225
diff
changeset
|
157 double height = outerPanelSize.getHeight(); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 outerPanel.setBackground(Color.DARK_GRAY); |
314 | 159 lpane = new JLayeredPane() { |
160 /** | |
83 | 161 * |
162 */ | |
163 private static final long serialVersionUID = 1L; | |
164 @Override | |
314 | 165 public Dimension getSize() { |
166 return surface.getPreferredSize(); | |
167 } | |
168 @Override | |
169 public Dimension getPreferredSize() { | |
170 return surface.getPreferredSize(); | |
171 } | |
172 }; | |
173 lpane.setPreferredSize(surface.getPreferredSize()); | |
174 lpane.add(surface, JLayeredPane.DEFAULT_LAYER, 0); | |
175 outerPanel.add(lpane); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 |
314 | 177 scroller = new JScrollPane(outerPanel); |
178 if (isSeparateFrame) { | |
179 frame = new JFrame(); | |
180 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | |
181 if ( ! isApplet) { | |
182 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | |
183 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184 frame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE); |
314 | 185 Utils.setApplicationIconsForWindow(frame); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 frame.setLayout(new BorderLayout(0, 0)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 frame.add(scroller, BorderLayout.CENTER); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 |
314 | 189 // frame.pack(); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
190 outerPanel.setSize(surface.getPreferredSize()); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
191 internalPack(null); |
204
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
191
diff
changeset
|
192 if(viewer.getRfb().isTreeManager() || viewer.getCuiVersion()) { |
314 | 193 frame.setVisible(false); |
194 viewer.setCuiVersion(false); | |
68 | 195 } else |
314 | 196 frame.setVisible(true); |
61
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
57
diff
changeset
|
197 //frame.setVisible(false); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
198 frame.validate(); |
314 | 199 } else { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
200 appletWindow.setLayout(new BorderLayout(0, 0)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201 appletWindow.add(scroller, BorderLayout.CENTER); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
202 appletWindow.validate(); |
314 | 203 } |
204 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 |
314 | 206 public void pack() { |
207 final Dimension outerPanelOldSize = outerPanel.getSize(); | |
208 outerPanel.setSize(surface.getPreferredSize()); | |
209 if (isSeparateFrame && ! isZoomToFitSelected()) { | |
210 internalPack(outerPanelOldSize); | |
211 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 if (buttonsBar != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
213 updateZoomButtonsState(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215 updateWindowTitle(); |
314 | 216 } |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
218 public boolean isZoomToFitSelected() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 return isZoomToFitSelected; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
221 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222 public void setZoomToFitSelected(boolean zoomToFitSelected) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
223 isZoomToFitSelected = zoomToFitSelected; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
224 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
225 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
226 public void setRemoteDesktopName(String name) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
227 remoteDesktopName = name; |
207 | 228 TreeRFBProto rfb = viewer.getRfb(); |
167 | 229 if (rfb!=null) { |
314 | 230 int port = rfb.getAcceptPort(); |
231 remoteDesktopName += ":" + port; | |
167 | 232 } |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
233 updateWindowTitle(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
234 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
235 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
236 private void updateWindowTitle() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
237 if (isSeparateFrame) { |
314 | 238 frame.setTitle(remoteDesktopName + " [zoom: " + uiSettings.getScalePercentFormatted() + "%]"); |
239 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
240 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
241 |
314 | 242 private void internalPack(Dimension outerPanelOldSize) { |
243 final Rectangle workareaRectangle = getWorkareaRectangle(); | |
244 if (workareaRectangle.equals(frame.getBounds())) { | |
245 forceResizable = true; | |
246 } | |
247 final boolean isHScrollBar = scroller.getHorizontalScrollBar().isShowing() && ! forceResizable; | |
248 final boolean isVScrollBar = scroller.getVerticalScrollBar().isShowing() && ! forceResizable; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
249 |
314 | 250 boolean isWidthChangeable = true; |
251 boolean isHeightChangeable = true; | |
252 if (outerPanelOldSize != null && surface.oldSize != null) { | |
253 isWidthChangeable = forceResizable || | |
254 (outerPanelOldSize.width == surface.oldSize.width && ! isHScrollBar); | |
255 isHeightChangeable = forceResizable || | |
256 (outerPanelOldSize.height == surface.oldSize.height && ! isVScrollBar); | |
257 } | |
258 forceResizable = false; | |
259 frame.validate(); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
260 |
314 | 261 final Insets containerInsets = frame.getInsets(); |
262 Dimension preferredSize = frame.getPreferredSize(); | |
263 Rectangle preferredRectangle = new Rectangle(frame.getLocation(), preferredSize); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
264 |
314 | 265 if (null == outerPanelOldSize && workareaRectangle.contains(preferredRectangle)) { |
266 frame.pack(); | |
267 } else { | |
268 Dimension minDimension = new Dimension( | |
269 containerInsets.left + containerInsets.right, containerInsets.top + containerInsets.bottom); | |
270 if (buttonsBar != null && buttonsBar.isVisible) { | |
271 minDimension.width += buttonsBar.getWidth(); | |
272 minDimension.height += buttonsBar.getHeight(); | |
273 } | |
274 Dimension dim = new Dimension(preferredSize); | |
275 Point location = frame.getLocation(); | |
276 if ( ! isWidthChangeable) { | |
277 dim.width = frame.getWidth(); | |
278 } else { | |
301 | 279 // このあたり、scalepercentを計算するのに使えそう |
314 | 280 if (isVScrollBar) dim.width += scroller.getVerticalScrollBar().getWidth(); |
281 if (dim.width < minDimension.width) dim.width = minDimension.width; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
282 |
314 | 283 int dx = location.x - workareaRectangle.x; |
284 if (dx < 0) { | |
285 dx = 0; | |
286 location.x = workareaRectangle.x; | |
287 } | |
288 int w = workareaRectangle.width - dx; | |
289 if (w < dim.width) { | |
290 int dw = dim.width - w; | |
291 if (dw < dx) { | |
292 location.x -= dw; | |
293 } else { | |
294 dim.width = workareaRectangle.width; | |
295 location.x = workareaRectangle.x; | |
296 } | |
297 } | |
298 } | |
299 if ( ! isHeightChangeable) { | |
300 dim.height = frame.getHeight(); | |
301 } else { | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
302 |
314 | 303 if (isHScrollBar) dim.height += scroller.getHorizontalScrollBar().getHeight(); |
304 if (dim.height < minDimension.height) dim.height = minDimension.height; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
305 |
314 | 306 int dy = location.y - workareaRectangle.y; |
307 if (dy < 0) { | |
308 dy = 0; | |
309 location.y = workareaRectangle.y; | |
310 } | |
311 int h = workareaRectangle.height - dy; | |
312 if (h < dim.height) { | |
313 int dh = dim.height - h; | |
314 if (dh < dy) { | |
315 location.y -= dh; | |
316 } else { | |
317 dim.height = workareaRectangle.height; | |
318 location.y = workareaRectangle.y; | |
319 } | |
320 } | |
321 } | |
412 | 322 // canet full size |
309 | 323 /* |
300 | 324 dim.width = workareaRectangle.width; |
325 dim.height = workareaRectangle.height; | |
314 | 326 */ |
327 if ( ! location.equals(frame.getLocation())) { | |
328 frame.setLocation(location); | |
329 } | |
330 if ( ! isFullScreen ) { | |
331 frame.setSize(dim); | |
332 } | |
333 } | |
334 scroller.revalidate(); | |
335 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
336 |
314 | 337 private Rectangle getWorkareaRectangle() { |
338 final GraphicsConfiguration graphicsConfiguration = frame.getGraphicsConfiguration(); | |
339 final Rectangle screenBounds = graphicsConfiguration.getBounds(); | |
340 final Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfiguration); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
341 |
314 | 342 screenBounds.x += screenInsets.left; |
343 screenBounds.y += screenInsets.top; | |
344 if (width != 0) { | |
345 screenBounds.width = width; | |
346 screenBounds.height = height; | |
347 } else { | |
348 screenBounds.width -= screenInsets.left + screenInsets.right; | |
349 screenBounds.height -= screenInsets.top + screenInsets.bottom; | |
225 | 350 } |
351 | |
314 | 352 return screenBounds; |
353 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
354 |
314 | 355 void addZoomButtons() { |
356 buttonsBar.createStrut(); | |
357 zoomOutButton = buttonsBar.createButton("zoom-out", "Zoom Out", new ActionListener() { | |
358 @Override | |
359 public void actionPerformed(ActionEvent e) { | |
360 zoomFitButton.setSelected(false); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
361 uiSettings.zoomOut(); |
314 | 362 } |
363 }); | |
364 zoomInButton = buttonsBar.createButton("zoom-in", "Zoom In", new ActionListener() { | |
365 @Override | |
366 public void actionPerformed(ActionEvent e) { | |
367 zoomFitButton.setSelected(false); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
368 uiSettings.zoomIn(); |
314 | 369 } |
370 }); | |
371 zoomAsIsButton = buttonsBar.createButton("zoom-100", "Zoom 100%", new ActionListener() { | |
372 @Override | |
373 public void actionPerformed(ActionEvent e) { | |
374 zoomFitButton.setSelected(false); | |
375 forceResizable = false; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
376 uiSettings.zoomAsIs(); |
314 | 377 } |
378 }); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
379 |
314 | 380 zoomFitButton = buttonsBar.createToggleButton("zoom-fit", "Zoom to Fit Window", |
381 new ItemListener() { | |
382 @Override | |
383 public void itemStateChanged(ItemEvent e) { | |
384 if (e.getStateChange() == ItemEvent.SELECTED) { | |
385 setZoomToFitSelected(true); | |
386 forceResizable = true; | |
387 zoomToFit(); | |
388 updateZoomButtonsState(); | |
389 } else { | |
390 setZoomToFitSelected(false); | |
391 } | |
392 setSurfaceToHandleKbdFocus(); | |
393 } | |
394 }); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
395 |
314 | 396 zoomFullScreenButton = buttonsBar.createToggleButton("zoom-fullscreen", "Full Screen", |
397 new ItemListener() { | |
398 @Override | |
399 public void itemStateChanged(ItemEvent e) { | |
400 updateZoomButtonsState(); | |
401 if (e.getStateChange() == ItemEvent.SELECTED) { | |
402 uiSettings.setFullScreen(switchOnFullscreenMode()); | |
403 } else { | |
404 switchOffFullscreenMode(); | |
405 uiSettings.setFullScreen(false); | |
406 } | |
407 setSurfaceToHandleKbdFocus(); | |
408 } | |
409 }); | |
410 if ( ! isSeparateFrame) { | |
411 zoomFullScreenButton.setEnabled(false); | |
412 zoomFitButton.setEnabled(false); | |
413 } | |
414 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
415 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
416 protected void setSurfaceToHandleKbdFocus() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
417 if (surface != null && ! surface.requestFocusInWindow()) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
418 surface.requestFocus(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
419 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
420 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
421 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
422 boolean switchOnFullscreenMode() { |
314 | 423 zoomFullScreenButton.setSelected(true); |
424 oldContainerBounds = frame.getBounds(); | |
425 setButtonsBarVisible(false); | |
426 forceResizable = true; | |
427 frame.dispose(); | |
428 frame.setUndecorated(true); | |
429 frame.setResizable(false); | |
430 frame.setVisible(true); | |
431 try { | |
432 frame.getGraphicsConfiguration().getDevice().setFullScreenWindow(frame); | |
433 isFullScreen = true; | |
434 scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); | |
435 scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); | |
436 oldScrollerBorder = scroller.getBorder(); | |
437 scroller.setBorder(new EmptyBorder(0, 0, 0, 0)); | |
438 new FullscreenBorderDetectionThread(frame).start(); | |
439 } catch (Exception ex) { | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
440 Logger.getLogger(this.getClass().getName()).info("Cannot switch into FullScreen mode: " + ex.getMessage()); |
314 | 441 return false; |
442 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
443 return true; |
314 | 444 } |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
445 |
314 | 446 private void switchOffFullscreenMode() { |
447 if (isFullScreen) { | |
448 zoomFullScreenButton.setSelected(false); | |
449 isFullScreen = false; | |
450 setButtonsBarVisible(true); | |
451 try { | |
452 frame.dispose(); | |
453 frame.setUndecorated(false); | |
454 frame.setResizable(true); | |
455 frame.getGraphicsConfiguration().getDevice().setFullScreenWindow(null); | |
456 } catch (Exception e) { | |
457 // nop | |
458 } | |
459 scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); | |
460 scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); | |
461 scroller.setBorder(oldScrollerBorder); | |
462 this.frame.setBounds(oldContainerBounds); | |
463 frame.setVisible(true); | |
464 pack(); | |
465 } | |
466 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
467 |
371 | 468 public void zoomToFit() { |
314 | 469 Dimension scrollerSize = scroller.getSize(); |
470 Insets scrollerInsets = scroller.getInsets(); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
471 uiSettings.zoomToFit(scrollerSize.width - scrollerInsets.left - scrollerInsets.right, |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
472 scrollerSize.height - scrollerInsets.top - scrollerInsets.bottom + |
314 | 473 (isFullScreen ? buttonsBar.getHeight() : 0), |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
474 workingProtocol.getFbWidth(), workingProtocol.getFbHeight()); |
314 | 475 } |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
476 |
314 | 477 void registerResizeListener(Container container) { |
478 container.addComponentListener(new ComponentAdapter() { | |
479 @Override | |
480 public void componentResized(ComponentEvent e) { | |
481 if (isZoomToFitSelected()) { | |
482 zoomToFit(); | |
483 updateZoomButtonsState(); | |
484 updateWindowTitle(); | |
485 setSurfaceToHandleKbdFocus(); | |
486 } | |
487 } | |
488 }); | |
489 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
490 |
314 | 491 void updateZoomButtonsState() { |
492 zoomOutButton.setEnabled(uiSettings.getScalePercent() > UiSettings.MIN_SCALE_PERCENT); | |
493 zoomInButton.setEnabled(uiSettings.getScalePercent() < UiSettings.MAX_SCALE_PERCENT); | |
494 zoomAsIsButton.setEnabled(uiSettings.getScalePercent() != 100); | |
495 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
496 |
314 | 497 public ButtonsBar createButtonsBar() { |
498 buttonsBar = new ButtonsBar(); | |
499 return buttonsBar; | |
500 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
501 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
502 public void setButtonsBarVisible(boolean isVisible) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
503 setButtonsBarVisible(isVisible, frame); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
504 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
505 |
314 | 506 private void setButtonsBarVisible(boolean isVisible, Container container) { |
507 buttonsBar.setVisible(isVisible); | |
508 if (isVisible) { | |
509 buttonsBar.borderOff(); | |
510 container.add(buttonsBar.bar, BorderLayout.NORTH); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
511 container.validate(); |
314 | 512 } else { |
513 container.remove(buttonsBar.bar); | |
514 buttonsBar.borderOn(); | |
515 } | |
516 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
517 |
314 | 518 public void setButtonsBarVisibleFS(boolean isVisible) { |
519 if (isVisible) { | |
520 if ( ! buttonsBar.isVisible) { | |
521 lpane.add(buttonsBar.bar, JLayeredPane.POPUP_LAYER, 0); | |
522 final int bbWidth = buttonsBar.bar.getPreferredSize().width; | |
523 buttonsBar.bar.setBounds( | |
524 scroller.getViewport().getViewPosition().x + (scroller.getWidth() - bbWidth)/2, 0, | |
525 bbWidth, buttonsBar.bar.getPreferredSize().height); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
526 |
314 | 527 // prevent mouse events to through down to Surface |
528 if (null == buttonsBarMouseAdapter) buttonsBarMouseAdapter = new EmptyButtonsBarMouseAdapter(); | |
529 buttonsBar.bar.addMouseListener(buttonsBarMouseAdapter); | |
530 } | |
531 } else { | |
532 buttonsBar.bar.removeMouseListener(buttonsBarMouseAdapter); | |
533 lpane.remove(buttonsBar.bar); | |
534 lpane.repaint(buttonsBar.bar.getBounds()); | |
535 } | |
536 buttonsBar.setVisible(isVisible); | |
537 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
538 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
539 public Surface getSurface() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
540 return surface; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
541 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
542 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
543 void close() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
544 if (isSeparateFrame && frame != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
545 frame.setVisible(false); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
546 frame.dispose(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
547 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
548 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
549 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
550 public static class ButtonsBar { |
314 | 551 private static final Insets BUTTONS_MARGIN = new Insets(2, 2, 2, 2); |
552 private JPanel bar; | |
553 private boolean isVisible; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
554 |
314 | 555 public ButtonsBar() { |
556 bar = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 1)); | |
557 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
558 |
314 | 559 public JButton createButton(String iconId, String tooltipText, ActionListener actionListener) { |
560 JButton button = new JButton(Utils.getButtonIcon(iconId)); | |
561 button.setToolTipText(tooltipText); | |
562 button.setMargin(BUTTONS_MARGIN); | |
563 bar.add(button); | |
564 button.addActionListener(actionListener); | |
565 return button; | |
566 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
567 |
314 | 568 public void createStrut() { |
569 bar.add(Box.createHorizontalStrut(10)); | |
570 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
571 |
314 | 572 public JToggleButton createToggleButton(String iconId, String tooltipText, ItemListener itemListener) { |
573 JToggleButton button = new JToggleButton(Utils.getButtonIcon(iconId)); | |
574 button.setToolTipText(tooltipText); | |
575 button.setMargin(BUTTONS_MARGIN); | |
576 bar.add(button); | |
577 button.addItemListener(itemListener); | |
578 return button; | |
579 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
580 |
314 | 581 public void setVisible(boolean isVisible) { |
582 this.isVisible = isVisible; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
583 if (isVisible) bar.revalidate(); |
314 | 584 } |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
585 |
314 | 586 public int getWidth() { |
587 return bar.getMinimumSize().width; | |
588 } | |
589 public int getHeight() { | |
590 return bar.getMinimumSize().height; | |
591 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
592 |
314 | 593 public void borderOn() { |
594 bar.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); | |
595 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
596 |
314 | 597 public void borderOff() { |
598 bar.setBorder(BorderFactory.createEmptyBorder()); | |
599 } | |
600 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
601 |
314 | 602 private static class EmptyButtonsBarMouseAdapter extends MouseAdapter { |
603 // empty | |
604 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
605 |
314 | 606 private class FullscreenBorderDetectionThread extends Thread { |
607 public static final int SHOW_HIDE_BUTTONS_BAR_DELAY_IN_MILLS = 700; | |
608 private final JFrame frame; | |
609 private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); | |
610 private ScheduledFuture<?> futureForShow; | |
611 private ScheduledFuture<?> futureForHide; | |
612 private Point mousePoint, oldMousePoint; | |
613 private Point viewPosition; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
614 |
314 | 615 public FullscreenBorderDetectionThread(JFrame frame) { |
616 super("FS border detector"); | |
617 this.frame = frame; | |
618 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
619 |
314 | 620 public void run() { |
621 setPriority(Thread.MIN_PRIORITY); | |
622 while(isFullScreen) { | |
623 mousePoint = MouseInfo.getPointerInfo().getLocation(); | |
624 if (null == oldMousePoint) oldMousePoint = mousePoint; | |
625 SwingUtilities.convertPointFromScreen(mousePoint, frame); | |
626 viewPosition = scroller.getViewport().getViewPosition(); | |
627 processButtonsBarVisibility(); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
628 |
314 | 629 boolean needScrolling = processVScroll() || processHScroll(); |
630 oldMousePoint = mousePoint; | |
631 if (needScrolling) { | |
632 cancelShowExecutor(); | |
633 setButtonsBarVisibleFS(false); | |
634 makeScrolling(viewPosition); | |
635 } | |
636 try { | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
637 Thread.sleep(100); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
638 } catch (Exception e) { |
314 | 639 // nop |
640 } | |
641 } | |
642 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
643 |
314 | 644 private boolean processHScroll() { |
645 if (mousePoint.x < FS_SCROLLING_ACTIVE_BORDER) { | |
646 if (viewPosition.x > 0) { | |
647 int delta = FS_SCROLLING_ACTIVE_BORDER - mousePoint.x; | |
648 if (mousePoint.y != oldMousePoint.y) delta *= 2; // speedify scrolling on mouse moving | |
649 viewPosition.x -= delta; | |
650 if (viewPosition.x < 0) viewPosition.x = 0; | |
651 return true; | |
652 } | |
653 } else if (mousePoint.x > (frame.getWidth() - FS_SCROLLING_ACTIVE_BORDER)) { | |
654 final Rectangle viewRect = scroller.getViewport().getViewRect(); | |
655 final int right = viewRect.width + viewRect.x; | |
656 if (right < outerPanel.getSize().width) { | |
657 int delta = FS_SCROLLING_ACTIVE_BORDER - (frame.getWidth() - mousePoint.x); | |
658 if (mousePoint.y != oldMousePoint.y) delta *= 2; // speedify scrolling on mouse moving | |
659 viewPosition.x += delta; | |
660 if (viewPosition.x + viewRect.width > outerPanel.getSize().width) viewPosition.x = | |
661 outerPanel.getSize().width - viewRect.width; | |
662 return true; | |
663 } | |
664 } | |
665 return false; | |
666 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
667 |
314 | 668 private boolean processVScroll() { |
669 if (mousePoint.y < FS_SCROLLING_ACTIVE_BORDER) { | |
670 if (viewPosition.y > 0) { | |
671 int delta = FS_SCROLLING_ACTIVE_BORDER - mousePoint.y; | |
672 if (mousePoint.x != oldMousePoint.x) delta *= 2; // speedify scrolling on mouse moving | |
673 viewPosition.y -= delta; | |
674 if (viewPosition.y < 0) viewPosition.y = 0; | |
675 return true; | |
676 } | |
677 } else if (mousePoint.y > (frame.getHeight() - FS_SCROLLING_ACTIVE_BORDER)) { | |
678 final Rectangle viewRect = scroller.getViewport().getViewRect(); | |
679 final int bottom = viewRect.height + viewRect.y; | |
680 if (bottom < outerPanel.getSize().height) { | |
681 int delta = FS_SCROLLING_ACTIVE_BORDER - (frame.getHeight() - mousePoint.y); | |
682 if (mousePoint.x != oldMousePoint.x) delta *= 2; // speedify scrolling on mouse moving | |
683 viewPosition.y += delta; | |
684 if (viewPosition.y + viewRect.height > outerPanel.getSize().height) viewPosition.y = | |
685 outerPanel.getSize().height - viewRect.height; | |
686 return true; | |
687 } | |
688 } | |
689 return false; | |
690 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
691 |
314 | 692 private void processButtonsBarVisibility() { |
693 if (mousePoint.y < 1) { | |
694 cancelHideExecutor(); | |
695 // show buttons bar after delay | |
696 if (! buttonsBar.isVisible && (null == futureForShow || futureForShow.isDone())) { | |
697 futureForShow = scheduler.schedule(new Runnable() { | |
698 @Override | |
699 public void run() { | |
700 showButtonsBar(); | |
701 } | |
702 }, SHOW_HIDE_BUTTONS_BAR_DELAY_IN_MILLS, TimeUnit.MILLISECONDS); | |
703 } | |
704 } else { | |
705 cancelShowExecutor(); | |
706 } | |
707 if (buttonsBar.isVisible && mousePoint.y <= buttonsBar.getHeight()) { | |
708 cancelHideExecutor(); | |
709 } | |
710 if (buttonsBar.isVisible && mousePoint.y > buttonsBar.getHeight()) { | |
711 // hide buttons bar after delay | |
712 if (null == futureForHide || futureForHide.isDone()) { | |
713 futureForHide = scheduler.schedule(new Runnable() { | |
714 @Override | |
715 public void run() { | |
716 SwingUtilities.invokeLater(new Runnable() { | |
717 @Override | |
718 public void run() { | |
719 setButtonsBarVisibleFS(false); | |
720 SwingViewerWindow.this.frame.validate(); | |
721 } | |
722 }); | |
723 } | |
724 }, SHOW_HIDE_BUTTONS_BAR_DELAY_IN_MILLS, TimeUnit.MILLISECONDS); | |
725 } | |
726 } | |
727 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
728 |
314 | 729 private void cancelHideExecutor() { |
730 cancelExecutor(futureForHide); | |
731 } | |
732 private void cancelShowExecutor() { | |
733 cancelExecutor(futureForShow); | |
734 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
735 |
314 | 736 private void cancelExecutor(ScheduledFuture<?> future) { |
737 if (future != null && ! future.isDone()) { | |
738 future.cancel(true); | |
739 } | |
740 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
741 |
314 | 742 private void makeScrolling(final Point viewPosition) { |
743 SwingUtilities.invokeLater(new Runnable() { | |
744 @Override | |
745 public void run() { | |
746 scroller.getViewport().setViewPosition(viewPosition); | |
747 final Point mousePosition = surface.getMousePosition(); | |
748 if (mousePosition != null) { | |
749 final MouseEvent mouseEvent = new MouseEvent(frame, 0, 0, 0, | |
750 mousePosition.x, mousePosition.y, 0, false); | |
751 for (MouseMotionListener mml : surface.getMouseMotionListeners()) { | |
752 mml.mouseMoved(mouseEvent); | |
753 } | |
754 } | |
755 } | |
756 }); | |
757 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
758 |
314 | 759 private void showButtonsBar() { |
760 SwingUtilities.invokeLater(new Runnable() { | |
761 @Override | |
762 public void run() { | |
763 setButtonsBarVisibleFS(true); | |
764 } | |
765 }); | |
766 } | |
767 } | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
768 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
769 protected void createButtonsPanel(final ProtocolContext context, Container container) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
770 final SwingViewerWindow.ButtonsBar buttonsBar = createButtonsBar(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
771 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
772 buttonsBar.createButton("options", "Set Options", new ActionListener() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
773 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
774 public void actionPerformed(ActionEvent e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
775 showOptionsDialog(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
776 setSurfaceToHandleKbdFocus(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
777 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
778 }); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
779 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
780 buttonsBar.createButton("info", "Show connection info", new ActionListener() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
781 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
782 public void actionPerformed(ActionEvent e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
783 showConnectionInfoMessage(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
784 setSurfaceToHandleKbdFocus(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
785 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
786 }); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
787 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
788 buttonsBar.createStrut(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
789 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
790 buttonsBar.createButton("refresh", "Refresh screen", new ActionListener() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
791 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
792 public void actionPerformed(ActionEvent e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
793 context.sendRefreshMessage(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
794 setSurfaceToHandleKbdFocus(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
795 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
796 }); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
797 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
798 addZoomButtons(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
799 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
800 kbdButtons = new LinkedList<JComponent>(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
801 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
802 buttonsBar.createStrut(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
803 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
804 JButton ctrlAltDelButton = buttonsBar.createButton("ctrl-alt-del", "Send 'Ctrl-Alt-Del'", new ActionListener() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
805 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
806 public void actionPerformed(ActionEvent e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
807 sendCtrlAltDel(context); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
808 setSurfaceToHandleKbdFocus(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
809 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
810 }); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
811 kbdButtons.add(ctrlAltDelButton); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
812 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
813 JButton winButton = buttonsBar.createButton("win", "Send 'Win' key as 'Ctrl-Esc'", new ActionListener() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
814 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
815 public void actionPerformed(ActionEvent e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
816 sendWinKey(context); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
817 setSurfaceToHandleKbdFocus(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
818 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
819 }); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
820 kbdButtons.add(winButton); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
821 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
822 JToggleButton ctrlButton = buttonsBar.createToggleButton("ctrl", "Ctrl Lock", |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
823 new ItemListener() { |
314 | 824 @Override |
825 public void itemStateChanged(ItemEvent e) { | |
826 if (e.getStateChange() == ItemEvent.SELECTED) { | |
827 context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, true)); | |
828 } else { | |
829 context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, false)); | |
830 } | |
831 setSurfaceToHandleKbdFocus(); | |
832 } | |
833 }); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
834 kbdButtons.add(ctrlButton); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
835 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
836 JToggleButton altButton = buttonsBar.createToggleButton("alt", "Alt Lock", |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
837 new ItemListener() { |
314 | 838 @Override |
839 public void itemStateChanged(ItemEvent e) { | |
840 if (e.getStateChange() == ItemEvent.SELECTED) { | |
841 context.sendMessage(new KeyEventMessage(Keymap.K_ALT_LEFT, true)); | |
842 } else { | |
843 context.sendMessage(new KeyEventMessage(Keymap.K_ALT_LEFT, false)); | |
844 } | |
845 setSurfaceToHandleKbdFocus(); | |
846 } | |
847 }); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
848 kbdButtons.add(altButton); |
107 | 849 |
406
0eea469c6349
Add ScreenChangeSelectionPanel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
850 final SwingViewerWindow viewerWindow = this; |
72 | 851 JButton screenButton = buttonsBar.createButton("share", "Share my screen", new ActionListener() { |
314 | 852 @Override |
853 public void actionPerformed(ActionEvent e) { | |
301 | 854 ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); |
408
bbd844c15ab1
Disable screenChangeSelectionPanel if single display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
407
diff
changeset
|
855 if (rectangles.size() == 1) { // single display |
bbd844c15ab1
Disable screenChangeSelectionPanel if single display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
407
diff
changeset
|
856 screenChangeRequest(context, 0); |
bbd844c15ab1
Disable screenChangeSelectionPanel if single display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
407
diff
changeset
|
857 } else if (rectangles.size() == 2){ // dual display |
bbd844c15ab1
Disable screenChangeSelectionPanel if single display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
407
diff
changeset
|
858 ScreenChangeSelectionPanel selectionPanel = new ScreenChangeSelectionPanel(viewerWindow, context); |
420
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
859 for (int i = 0; i < rectangles.size(); i++) { |
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
860 Rectangle rectangle = rectangles.get(i); |
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
861 int screenWidth = rectangle.width * retinaScale(i); |
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
862 int screenHeight = rectangle.height * retinaScale(i); |
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
863 selectionPanel.checkBox(screenWidth+" X "+screenHeight); |
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
864 } |
408
bbd844c15ab1
Disable screenChangeSelectionPanel if single display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
407
diff
changeset
|
865 selectionPanel.setButton(); |
bbd844c15ab1
Disable screenChangeSelectionPanel if single display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
407
diff
changeset
|
866 selectionPanel.visible(); |
351 | 867 } |
284 | 868 } |
61
d9cf08c6415c
During implementation change screen.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
57
diff
changeset
|
869 }); |
107 | 870 |
288 | 871 final JButton adjustHdSizeButton = buttonsBar.createButton("adjust-hd", "Adjust Hd Size", new ActionListener() { |
280
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
279
diff
changeset
|
872 @Override |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
279
diff
changeset
|
873 public void actionPerformed(ActionEvent e) { |
314 | 874 // adjustHdSizeButton.setSelected(false); |
306 | 875 int singleWidth = viewer.getRfb().getSingleWidth(); |
876 uiSettings.adjustHdSize(singleWidth); | |
280
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
279
diff
changeset
|
877 } |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
279
diff
changeset
|
878 }); |
9c5874d0f37e
fix adjustHdSizeButton button, this button send REQUEST_SINGLE_DISPLAY_WIDTH
oc
parents:
279
diff
changeset
|
879 |
309 | 880 final JButton fitScreenButton = buttonsBar.createButton("fit-screen", "Fit Screen", new ActionListener() { |
881 @Override | |
882 public void actionPerformed(ActionEvent e) { | |
371 | 883 fitScreen(); |
432 | 884 /* |
310 | 885 if (!viewer.getRfb().isTreeManager()) { |
320 | 886 context.sendMessage(new RequestSingleDisplaySize()); |
309 | 887 } |
432 | 888 */ |
309 | 889 } |
890 }); | |
891 | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
892 ModifierButtonEventListener modifierButtonListener = new ModifierButtonEventListener(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
893 modifierButtonListener.addButton(KeyEvent.VK_CONTROL, ctrlButton); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
894 modifierButtonListener.addButton(KeyEvent.VK_ALT, altButton); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
895 surface.addModifierListener(modifierButtonListener); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
896 |
314 | 897 // JButton fileTransferButton = new JButton(Utils.getButtonIcon("file-transfer")); |
898 // fileTransferButton.setMargin(buttonsMargin); | |
899 // buttonBar.add(fileTransferButton); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
900 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
901 buttonsBar.createStrut(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
902 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
903 buttonsBar.createButton("close", isApplet ? "Disconnect" : "Close", new ActionListener() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
904 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
905 public void actionPerformed(ActionEvent e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
906 if (frame != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
907 frame.setVisible(false); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
908 frame.dispose(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
909 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
910 presenter.setNeedReconnection(false); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
911 presenter.cancelConnection(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
912 viewer.closeApp(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
913 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
914 }).setAlignmentX(JComponent.RIGHT_ALIGNMENT); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
915 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
916 setButtonsBarVisible(true, container); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
917 } |
346 | 918 |
406
0eea469c6349
Add ScreenChangeSelectionPanel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
919 public void screenChangeRequest(ProtocolContext context, int shareScreenNumber) { |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
920 ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
921 int singleWidth = (int) (rectangles.get(shareScreenNumber).getWidth()); |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
922 int singleHeight = (int) (rectangles.get(shareScreenNumber).getHeight()); |
406
0eea469c6349
Add ScreenChangeSelectionPanel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
923 viewer.getRfb().setSingleDisplaySize(singleWidth, singleHeight); |
431 | 924 int x = (int) (rectangles.get(shareScreenNumber).getX()); // convert double to int |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
925 int y = (int) (rectangles.get(shareScreenNumber).getY()); |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
926 |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
927 // Fix invalid x, y position. |
421
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
928 if (x == 0 && y == 0) { |
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
929 for (int i = 0; i < rectangles.size(); i++) { |
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
930 Rectangle rectangle = rectangles.get(i); |
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
931 int scale = retinaScale(i); |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
932 if (rectangle.getX() < 0) { |
421
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
933 x = Math.abs((int) rectangle.getX()) * scale; |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
934 } |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
935 if (rectangle.getY() < 0) { |
421
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
936 y = Math.abs((int) rectangle.getY()) * scale; |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
937 } |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
938 } |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
939 } else { |
421
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
940 for (int i = 0; i < rectangles.size(); i++) { |
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
941 if(i != shareScreenNumber) { |
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
942 x = x * retinaScale(i); |
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
943 y = y * retinaScale(i); |
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
944 } |
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
945 } |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
946 } |
421
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
947 x = x < 0 ? 0 : x; |
cafbff8d5b09
Fix invalid x y Display position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
420
diff
changeset
|
948 y = y < 0 ? 0 : y; |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
949 |
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
950 int scale = retinaScale(shareScreenNumber); |
420
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
951 |
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
952 if (viewer.getRfb().isTreeManager()) { |
427
ed15f0bd8dfa
Remove shareScrrenNumber for ScreenChangeRequest Message
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
425
diff
changeset
|
953 changeVncServer(viewer, x, y, singleWidth, singleHeight, scale, viewer.getRfb().getId()); |
420
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
954 return; |
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
955 } |
0ad52aac3bc3
Send repeat FramebufferUpdateRequest from Timer class
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
417
diff
changeset
|
956 |
406
0eea469c6349
Add ScreenChangeSelectionPanel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
957 if (viewer.getRfb().hasParent()) { |
0eea469c6349
Add ScreenChangeSelectionPanel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
958 String adr = viewer.getRfb().getMyAddress(); |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
959 if (scanPort(adr, ConnectionParams.DEFAULT_RFB_PORT)) { |
407
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
960 // -1 means request to reverse direct connection socket |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
961 short id = viewer.getRfb().isTreeManager()? (short)-1 : viewer.getRfb().getId(); |
427
ed15f0bd8dfa
Remove shareScrrenNumber for ScreenChangeRequest Message
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
425
diff
changeset
|
962 context.sendMessage(new ScreenChangeRequest(adr, ConnectionParams.DEFAULT_VNC_ROOT, id, x, y, singleWidth, singleHeight, scale)); |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
963 } |
406
0eea469c6349
Add ScreenChangeSelectionPanel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
964 } |
0eea469c6349
Add ScreenChangeSelectionPanel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
965 } |
0eea469c6349
Add ScreenChangeSelectionPanel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
405
diff
changeset
|
966 |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
967 private int retinaScale(int shareScreenNumber) { |
410 | 968 int scale = 1; |
969 GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
970 final GraphicsDevice[] devices = env.getScreenDevices(); |
410 | 971 |
972 try { | |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
973 Field field = devices[shareScreenNumber].getClass().getDeclaredField("scale"); |
410 | 974 |
975 if (field != null) { | |
976 field.setAccessible(true); | |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
412
diff
changeset
|
977 Object retinaScale = field.get(devices[shareScreenNumber]); |
410 | 978 |
979 if (retinaScale instanceof Integer) { | |
431 | 980 scale = (Integer) retinaScale; |
410 | 981 return scale; |
982 } | |
983 } | |
984 } catch (Exception ignore) {} | |
985 //... | |
986 return scale; | |
987 } | |
988 | |
408
bbd844c15ab1
Disable screenChangeSelectionPanel if single display
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
407
diff
changeset
|
989 private boolean scanPort(String adr, int port) { |
407
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
990 try { |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
991 Socket socket = new Socket(adr, port); |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
992 socket.close(); |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
993 return true; |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
994 } catch (Exception e) { |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
995 String message = "Please screen sharing settings"; |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
996 // show error panel |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
997 presenter.showPortErrorDialog(message); |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
998 presenter.clearMessage(); |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
999 return false; |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
1000 } |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
1001 } |
7cd416d6a152
Show port Error dialog to server change client
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
406
diff
changeset
|
1002 |
431 | 1003 /** |
1004 * change screen viewer scale to fit the server screen size | |
1005 */ | |
317 | 1006 public void fitScreen() { |
1007 ArrayList<Rectangle> rectangles = viewer.getScreenRectangles(); | |
1008 int leftScreenNumber = 0; | |
411 | 1009 int thisScreenWidth = (int) rectangles.get(leftScreenNumber).getWidth(); |
1010 int thisScreenHeight = (int) rectangles.get(leftScreenNumber).getHeight(); | |
317 | 1011 |
431 | 1012 |
1013 int thatScreenX = (int) presenter.getX(); | |
1014 int thatScreenY = (int) presenter.getY(); | |
1015 | |
411 | 1016 int singleWidth = viewer.getRfb().getSingleWidth() * viewer.getRfb().getRetinaScale(); |
1017 int singleHeight = viewer.getRfb().getSingleHeight() * viewer.getRfb().getRetinaScale(); | |
317 | 1018 frame.setSize(thisScreenWidth, thisScreenHeight); |
1019 uiSettings.fitScreen(thisScreenWidth, thisScreenHeight, singleWidth, singleHeight); | |
432 | 1020 final Rectangle visible = new Rectangle(thatScreenX,thatScreenY,thisScreenWidth,thisScreenHeight); |
1021 SwingUtilities.invokeLater(new Runnable(){ | |
1022 public void run() { | |
1023 scroller.scrollRectToVisible(visible); | |
1024 } | |
1025 }); | |
317 | 1026 } |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1027 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1028 private void sendCtrlAltDel(ProtocolContext context) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1029 context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, true)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1030 context.sendMessage(new KeyEventMessage(Keymap.K_ALT_LEFT, true)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1031 context.sendMessage(new KeyEventMessage(Keymap.K_DELETE, true)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1032 context.sendMessage(new KeyEventMessage(Keymap.K_DELETE, false)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1033 context.sendMessage(new KeyEventMessage(Keymap.K_ALT_LEFT, false)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1034 context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, false)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1035 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1036 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1037 private void sendWinKey(ProtocolContext context) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1038 context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, true)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1039 context.sendMessage(new KeyEventMessage(Keymap.K_ESCAPE, true)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1040 context.sendMessage(new KeyEventMessage(Keymap.K_ESCAPE, false)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1041 context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, false)); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1042 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1043 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1044 @Override |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1045 public void settingsChanged(SettingsChangedEvent e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1046 if (ProtocolSettings.isRfbSettingsChangedFired(e)) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1047 ProtocolSettings settings = (ProtocolSettings) e.getSource(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1048 setEnabledKbdButtons( ! settings.isViewOnly()); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1049 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1050 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1051 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1052 private void setEnabledKbdButtons(boolean enabled) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1053 if (kbdButtons != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1054 for (JComponent b : kbdButtons) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1055 b.setEnabled(enabled); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1056 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1057 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1058 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1059 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1060 private void showOptionsDialog() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1061 OptionsDialog optionsDialog = new OptionsDialog(frame); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1062 optionsDialog.initControlsFromSettings(rfbSettings, uiSettings, false); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1063 optionsDialog.setVisible(true); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1064 presenter.saveHistory(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1065 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1066 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1067 private void showConnectionInfoMessage() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1068 StringBuilder message = new StringBuilder(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1069 message.append("TightVNC Viewer v.").append(Viewer.ver()).append("\n\n"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1070 message.append("Connected to: ").append(remoteDesktopName).append("\n"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1071 message.append("Host: ").append(connectionString).append("\n\n"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1072 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1073 message.append("Desktop geometry: ") |
314 | 1074 .append(String.valueOf(surface.getWidth())) |
1075 .append(" \u00D7 ") // multiplication sign | |
1076 .append(String.valueOf(surface.getHeight())).append("\n"); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1077 message.append("Color format: ") |
314 | 1078 .append(String.valueOf(Math.round(Math.pow(2, workingProtocol.getPixelFormat().depth)))) |
1079 .append(" colors (") | |
1080 .append(String.valueOf(workingProtocol.getPixelFormat().depth)) | |
1081 .append(" bits)\n"); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1082 message.append("Current protocol version: ") |
314 | 1083 .append(workingProtocol.getProtocolVersion()); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1084 if (workingProtocol.isTight()) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1085 message.append("tight"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1086 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1087 message.append("\n"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1088 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1089 JOptionPane infoPane = new JOptionPane(message.toString(), JOptionPane.INFORMATION_MESSAGE); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1090 final JDialog infoDialog = infoPane.createDialog(frame, "VNC connection info"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1091 infoDialog.setModalityType(Dialog.ModalityType.MODELESS); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1092 infoDialog.setVisible(true); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1093 } |
169 | 1094 |
314 | 1095 public void setVisible(boolean b) { |
1096 frame.setVisible(b); | |
1097 } | |
292 | 1098 |
427
ed15f0bd8dfa
Remove shareScrrenNumber for ScreenChangeRequest Message
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
425
diff
changeset
|
1099 private void changeVncServer(ViewerInterface viewer, int x, int y, int width, int height, int scale, short id) { |
351 | 1100 String localhost = "127.0.0.1"; // InetAddress.getLocalHost().getHostName() |
292 | 1101 try { |
427
ed15f0bd8dfa
Remove shareScrrenNumber for ScreenChangeRequest Message
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
425
diff
changeset
|
1102 viewer.getRfb().changeVNCServer(viewer, localhost, ConnectionParams.DEFAULT_RFB_PORT, x, y, width, height, scale, id, null, null); |
292 | 1103 } catch (Exception e1) { |
1104 System.out.println("can't change server :" + e1.getMessage()); | |
1105 } | |
1106 } | |
1107 | |
392 | 1108 public UiSettings getUiSettings() { |
1109 return uiSettings; | |
1110 } | |
313 | 1111 } |