FreeRDP
Loading...
Searching...
No Matches
com.freerdp.freerdpcore.presentation.SessionView Class Reference
Inheritance diagram for com.freerdp.freerdpcore.presentation.SessionView:
Collaboration diagram for com.freerdp.freerdpcore.presentation.SessionView:

Data Structures

interface  SessionViewListener
 

Public Member Functions

 SessionView (Context context)
 
 SessionView (Context context, AttributeSet attrs)
 
 SessionView (Context context, AttributeSet attrs, int defStyle)
 
boolean onHoverEvent (MotionEvent event)
 
void setScaleGestureDetector (ScaleGestureDetector scaleGestureDetector)
 
void setSessionViewListener (SessionViewListener sessionViewListener)
 
void addInvalidRegion (Rect invalidRegion)
 
void invalidateRegion ()
 
void onSurfaceChange (SessionState session)
 
float getZoom ()
 
void setZoom (float factor)
 
boolean isAtMaxZoom ()
 
boolean isAtMinZoom ()
 
boolean zoomIn (float factor)
 
boolean zoomOut (float factor)
 
void setTouchPointerPadding (int width, int height)
 
int getTouchPointerPaddingWidth ()
 
int getTouchPointerPaddingHeight ()
 
void onMeasure (int widthMeasureSpec, int heightMeasureSpec)
 
void onDraw (@NonNull Canvas canvas)
 
boolean onTouchEvent (MotionEvent event)
 
boolean onGenericMotionEvent (MotionEvent event)
 
InputConnection onCreateInputConnection (EditorInfo outAttrs)
 

Static Public Attributes

static final float MAX_SCALE_FACTOR = 3.0f
 
static final float MIN_SCALE_FACTOR = 1.0f
 

Detailed Description

Definition at line 43 of file SessionView.java.

Constructor & Destructor Documentation

◆ SessionView() [1/3]

com.freerdp.freerdpcore.presentation.SessionView.SessionView ( Context  context)
inline

Definition at line 67 of file SessionView.java.

68 {
69 super(context);
70 initSessionView(context);
71 }

◆ SessionView() [2/3]

com.freerdp.freerdpcore.presentation.SessionView.SessionView ( Context  context,
AttributeSet  attrs 
)
inline

Definition at line 73 of file SessionView.java.

74 {
75 super(context, attrs);
76 initSessionView(context);
77 }

◆ SessionView() [3/3]

com.freerdp.freerdpcore.presentation.SessionView.SessionView ( Context  context,
AttributeSet  attrs,
int  defStyle 
)
inline

Definition at line 79 of file SessionView.java.

80 {
81 super(context, attrs, defStyle);
82 initSessionView(context);
83 }

Member Function Documentation

◆ addInvalidRegion()

void com.freerdp.freerdpcore.presentation.SessionView.addInvalidRegion ( Rect  invalidRegion)
inline

Definition at line 130 of file SessionView.java.

131 {
132 // correctly transform invalid region depending on current scaling
133 invalidRegionF.set(invalidRegion);
134 scaleMatrix.mapRect(invalidRegionF);
135 invalidRegionF.roundOut(invalidRegion);
136
137 invalidRegions.add(invalidRegion);
138 }

◆ getTouchPointerPaddingHeight()

int com.freerdp.freerdpcore.presentation.SessionView.getTouchPointerPaddingHeight ( )
inline

Definition at line 225 of file SessionView.java.

226 {
227 return touchPointerPaddingHeight;
228 }

◆ getTouchPointerPaddingWidth()

int com.freerdp.freerdpcore.presentation.SessionView.getTouchPointerPaddingWidth ( )
inline

Definition at line 220 of file SessionView.java.

221 {
222 return touchPointerPaddingWidth;
223 }

◆ getZoom()

float com.freerdp.freerdpcore.presentation.SessionView.getZoom ( )
inline

Definition at line 160 of file SessionView.java.

161 {
162 return scaleFactor;
163 }

◆ invalidateRegion()

void com.freerdp.freerdpcore.presentation.SessionView.invalidateRegion ( )
inline

Definition at line 140 of file SessionView.java.

141 {
142 invalidate(invalidRegions.pop());
143 }

◆ isAtMaxZoom()

boolean com.freerdp.freerdpcore.presentation.SessionView.isAtMaxZoom ( )
inline

Definition at line 177 of file SessionView.java.

178 {
179 return (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA));
180 }

◆ isAtMinZoom()

boolean com.freerdp.freerdpcore.presentation.SessionView.isAtMinZoom ( )
inline

Definition at line 182 of file SessionView.java.

183 {
184 return (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA));
185 }

◆ onCreateInputConnection()

InputConnection com.freerdp.freerdpcore.presentation.SessionView.onCreateInputConnection ( EditorInfo  outAttrs)
inline

Definition at line 499 of file SessionView.java.

500 {
501 outAttrs.actionLabel = null;
502 outAttrs.inputType = InputType.TYPE_NULL;
503 outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI |
504 EditorInfo.IME_FLAG_NO_FULLSCREEN;
505 return new BaseInputConnection(this, false);
506 }

◆ onDraw()

void com.freerdp.freerdpcore.presentation.SessionView.onDraw ( @NonNull Canvas  canvas)
inline

Definition at line 237 of file SessionView.java.

238 {
239 super.onDraw(canvas);
240
241 canvas.save();
242 canvas.concat(scaleMatrix);
243 canvas.drawColor(Color.BLACK);
244 if (surface != null)
245 {
246 surface.draw(canvas);
247 }
248 canvas.restore();
249 }

◆ onGenericMotionEvent()

boolean com.freerdp.freerdpcore.presentation.SessionView.onGenericMotionEvent ( MotionEvent  event)
inline

Definition at line 296 of file SessionView.java.

297 {
298 if (!event.isFromSource(InputDevice.SOURCE_MOUSE))
299 return false;
300
301 int action = event.getActionMasked();
302
303 if (action == MotionEvent.ACTION_BUTTON_PRESS ||
304 action == MotionEvent.ACTION_BUTTON_RELEASE)
305 {
306 boolean down = action == MotionEvent.ACTION_BUTTON_PRESS;
307 MotionEvent mapped = mapTouchEvent(event);
308 int x = (int)mapped.getX();
309 int y = (int)mapped.getY();
310 mapped.recycle();
311
312 switch (event.getActionButton())
313 {
314 case MotionEvent.BUTTON_PRIMARY:
315 if (down)
316 sessionViewListener.onSessionViewBeginTouch();
317 sessionViewListener.onSessionViewLeftTouch(x, y, down);
318 if (!down)
319 sessionViewListener.onSessionViewEndTouch();
320 return true;
321 case MotionEvent.BUTTON_SECONDARY:
322 if (down)
323 sessionViewListener.onSessionViewBeginTouch();
324 sessionViewListener.onSessionViewRightTouch(x, y, down);
325 return true;
326 case MotionEvent.BUTTON_TERTIARY:
327 sessionViewListener.onSessionViewMiddleTouch(x, y, down);
328 return true;
329 default:
330 return true; // consume unknown buttons silently
331 }
332 }
333
334 if (action == MotionEvent.ACTION_SCROLL)
335 {
336 float vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
337 float hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
338 if (vScroll != 0)
339 sessionViewListener.onSessionViewScroll(vScroll > 0);
340 if (hScroll != 0)
341 sessionViewListener.onSessionViewHScroll(hScroll > 0);
342 return true;
343 }
344
345 return false;
346 }

◆ onHoverEvent()

boolean com.freerdp.freerdpcore.presentation.SessionView.onHoverEvent ( MotionEvent  event)
inline

Definition at line 103 of file SessionView.java.

104 {
105 if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE)
106 {
107 // Handle hover move event
108 float x = event.getX();
109 float y = event.getY();
110 // Perform actions based on the hover position (x, y)
111 MotionEvent mappedEvent = mapTouchEvent(event);
112 sessionViewListener.onSessionViewMouseMove((int)mappedEvent.getX(),
113 (int)mappedEvent.getY());
114 mappedEvent.recycle();
115 }
116 // Return true to indicate that you've handled the event
117 return true;
118 }

◆ onMeasure()

void com.freerdp.freerdpcore.presentation.SessionView.onMeasure ( int  widthMeasureSpec,
int  heightMeasureSpec 
)
inline

Definition at line 230 of file SessionView.java.

231 {
232 Log.v(TAG, width + "x" + height);
233 this.setMeasuredDimension((int)(width * scaleFactor) + touchPointerPaddingWidth,
234 (int)(height * scaleFactor) + touchPointerPaddingHeight);
235 }

◆ onSurfaceChange()

void com.freerdp.freerdpcore.presentation.SessionView.onSurfaceChange ( SessionState  session)
inline

Definition at line 145 of file SessionView.java.

146 {
147 surface = session.getSurface();
148 Bitmap bitmap = surface.getBitmap();
149 width = bitmap.getWidth();
150 height = bitmap.getHeight();
151 surface.setBounds(0, 0, width, height);
152
153 setMinimumWidth(width);
154 setMinimumHeight(height);
155
156 requestLayout();
157 currentSession = session;
158 }

◆ onTouchEvent()

boolean com.freerdp.freerdpcore.presentation.SessionView.onTouchEvent ( MotionEvent  event)
inline

Definition at line 272 of file SessionView.java.

273 {
274 // Physical mouse events: bypass gesture detector entirely.
275 // Buttons are handled in onGenericMotionEvent; hover moves in onHoverEvent.
276 // Only ACTION_MOVE with a button held (drag) needs handling here.
277 if (event.isFromSource(InputDevice.SOURCE_MOUSE))
278 {
279 int action = event.getActionMasked();
280 if (action == MotionEvent.ACTION_MOVE && event.getButtonState() != 0)
281 {
282 MotionEvent mapped = mapTouchEvent(event);
283 sessionViewListener.onSessionViewMouseMove((int)mapped.getX(), (int)mapped.getY());
284 mapped.recycle();
285 return true;
286 }
287 return true;
288 }
289
290 boolean res = gestureDetector.onTouchEvent(event);
291 res |= doubleGestureDetector.onTouchEvent(event);
292 return res;
293 }

◆ setScaleGestureDetector()

void com.freerdp.freerdpcore.presentation.SessionView.setScaleGestureDetector ( ScaleGestureDetector  scaleGestureDetector)
inline

Definition at line 120 of file SessionView.java.

121 {
122 doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector);
123 }

◆ setSessionViewListener()

void com.freerdp.freerdpcore.presentation.SessionView.setSessionViewListener ( SessionViewListener  sessionViewListener)
inline

Definition at line 125 of file SessionView.java.

126 {
127 this.sessionViewListener = sessionViewListener;
128 }

◆ setTouchPointerPadding()

void com.freerdp.freerdpcore.presentation.SessionView.setTouchPointerPadding ( int  width,
int  height 
)
inline

Definition at line 213 of file SessionView.java.

214 {
215 touchPointerPaddingWidth = width;
216 touchPointerPaddingHeight = height;
217 requestLayout();
218 }

◆ setZoom()

void com.freerdp.freerdpcore.presentation.SessionView.setZoom ( float  factor)
inline

Definition at line 165 of file SessionView.java.

166 {
167 // calc scale matrix and inverse scale matrix (to correctly transform the view and moues
168 // coordinates)
169 scaleFactor = factor;
170 scaleMatrix.setScale(scaleFactor, scaleFactor);
171 invScaleMatrix.setScale(1.0f / scaleFactor, 1.0f / scaleFactor);
172
173 // update layout
174 requestLayout();
175 }

◆ zoomIn()

boolean com.freerdp.freerdpcore.presentation.SessionView.zoomIn ( float  factor)
inline

Definition at line 187 of file SessionView.java.

188 {
189 boolean res = true;
190 scaleFactor += factor;
191 if (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA))
192 {
193 scaleFactor = MAX_SCALE_FACTOR;
194 res = false;
195 }
196 setZoom(scaleFactor);
197 return res;
198 }

◆ zoomOut()

boolean com.freerdp.freerdpcore.presentation.SessionView.zoomOut ( float  factor)
inline

Definition at line 200 of file SessionView.java.

201 {
202 boolean res = true;
203 scaleFactor -= factor;
204 if (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA))
205 {
206 scaleFactor = MIN_SCALE_FACTOR;
207 res = false;
208 }
209 setZoom(scaleFactor);
210 return res;
211 }

Field Documentation

◆ MAX_SCALE_FACTOR

final float com.freerdp.freerdpcore.presentation.SessionView.MAX_SCALE_FACTOR = 3.0f
static

Definition at line 45 of file SessionView.java.

◆ MIN_SCALE_FACTOR

final float com.freerdp.freerdpcore.presentation.SessionView.MIN_SCALE_FACTOR = 1.0f
static

Definition at line 46 of file SessionView.java.


The documentation for this class was generated from the following file: