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  OnZoomChangedListener
 
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 setRailMode (boolean rail)
 
void setOnZoomChangedListener (OnZoomChangedListener l)
 
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)
 
void setRemoteCursor (int[] pixels, int width, int height, int hotX, int hotY)
 
void setDefaultCursor ()
 
InputConnection onCreateInputConnection (EditorInfo outAttrs)
 

Static Public Attributes

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

Detailed Description

Definition at line 42 of file SessionView.java.

Constructor & Destructor Documentation

◆ SessionView() [1/3]

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

Definition at line 80 of file SessionView.java.

81 {
82 super(context);
83 initSessionView(context);
84 }

◆ SessionView() [2/3]

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

Definition at line 86 of file SessionView.java.

87 {
88 super(context, attrs);
89 initSessionView(context);
90 }

◆ SessionView() [3/3]

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

Definition at line 92 of file SessionView.java.

93 {
94 super(context, attrs, defStyle);
95 initSessionView(context);
96 }

Member Function Documentation

◆ addInvalidRegion()

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

Definition at line 146 of file SessionView.java.

147 {
148 // correctly transform invalid region depending on current scaling
149 invalidRegionF.set(invalidRegion);
150 scaleMatrix.mapRect(invalidRegionF);
151 invalidRegionF.roundOut(invalidRegion);
152
153 invalidRegions.add(invalidRegion);
154 }

◆ getTouchPointerPaddingHeight()

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

Definition at line 262 of file SessionView.java.

263 {
264 return touchPointerPaddingHeight;
265 }

◆ getTouchPointerPaddingWidth()

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

Definition at line 257 of file SessionView.java.

258 {
259 return touchPointerPaddingWidth;
260 }

◆ getZoom()

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

Definition at line 176 of file SessionView.java.

177 {
178 return scaleFactor;
179 }

◆ invalidateRegion()

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

Definition at line 156 of file SessionView.java.

157 {
158 invalidate(invalidRegions.pop());
159 }

◆ isAtMaxZoom()

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

Definition at line 214 of file SessionView.java.

215 {
216 return (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA));
217 }

◆ isAtMinZoom()

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

Definition at line 219 of file SessionView.java.

220 {
221 return (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA));
222 }

◆ onCreateInputConnection()

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

Definition at line 612 of file SessionView.java.

613 {
614 outAttrs.actionLabel = null;
615 outAttrs.inputType = InputType.TYPE_NULL;
616 outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI |
617 EditorInfo.IME_FLAG_NO_FULLSCREEN;
618 return new BaseInputConnection(this, false);
619 }

◆ onDraw()

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

Definition at line 274 of file SessionView.java.

275 {
276 super.onDraw(canvas);
277
278 canvas.save();
279 canvas.concat(scaleMatrix);
280 canvas.drawColor(Color.BLACK);
281 if (!railMode && surface != null)
282 {
283 surface.draw(canvas);
284 }
285 canvas.restore();
286 }

◆ onGenericMotionEvent()

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

Definition at line 374 of file SessionView.java.

375 {
376 final boolean isPointer = event.isFromSource(InputDevice.SOURCE_CLASS_POINTER);
377 if (!isPointer)
378 return false;
379
380 final boolean isMouse = event.isFromSource(InputDevice.SOURCE_MOUSE);
381 int action = event.getActionMasked();
382
383 if (isMouse && (action == MotionEvent.ACTION_BUTTON_PRESS ||
384 action == MotionEvent.ACTION_BUTTON_RELEASE))
385 {
386 boolean down = action == MotionEvent.ACTION_BUTTON_PRESS;
387 MotionEvent mapped = mapTouchEvent(event);
388 int x = (int)mapped.getX();
389 int y = (int)mapped.getY();
390 mapped.recycle();
391
392 switch (event.getActionButton())
393 {
394 case MotionEvent.BUTTON_PRIMARY:
395 if (down)
396 sessionViewListener.onSessionViewBeginTouch();
397 sessionViewListener.onSessionViewLeftTouch(x, y, down);
398 if (!down)
399 sessionViewListener.onSessionViewEndTouch();
400 return true;
401 case MotionEvent.BUTTON_SECONDARY:
402 if (down)
403 sessionViewListener.onSessionViewBeginTouch();
404 sessionViewListener.onSessionViewRightTouch(x, y, down);
405 return true;
406 case MotionEvent.BUTTON_TERTIARY:
407 sessionViewListener.onSessionViewMiddleTouch(x, y, down);
408 return true;
409 default:
410 return true; // consume unknown buttons silently
411 }
412 }
413
414 if (action == MotionEvent.ACTION_SCROLL)
415 {
416 float vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
417 float hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
418 if (vScroll != 0)
419 sessionViewListener.onSessionViewScroll(vScroll > 0);
420 if (hScroll != 0)
421 sessionViewListener.onSessionViewHScroll(hScroll > 0);
422 return true;
423 }
424
425 return false;
426 }

◆ onHoverEvent()

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

Definition at line 119 of file SessionView.java.

120 {
121 if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE)
122 {
123 // Handle hover move event
124 float x = event.getX();
125 float y = event.getY();
126 // Perform actions based on the hover position (x, y)
127 MotionEvent mappedEvent = mapTouchEvent(event);
128 sessionViewListener.onSessionViewMouseMove((int)mappedEvent.getX(),
129 (int)mappedEvent.getY());
130 mappedEvent.recycle();
131 }
132 // Return true to indicate that you've handled the event
133 return true;
134 }

◆ onMeasure()

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

Definition at line 267 of file SessionView.java.

268 {
269 Log.v(TAG, width + "x" + height);
270 this.setMeasuredDimension((int)(width * scaleFactor) + touchPointerPaddingWidth,
271 (int)(height * scaleFactor) + touchPointerPaddingHeight);
272 }

◆ onSurfaceChange()

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

Definition at line 161 of file SessionView.java.

162 {
163 surface = session.getSurface();
164 Bitmap bitmap = surface.getBitmap();
165 width = bitmap.getWidth();
166 height = bitmap.getHeight();
167 surface.setBounds(0, 0, width, height);
168
169 setMinimumWidth(width);
170 setMinimumHeight(height);
171
172 requestLayout();
173 currentSession = session;
174 }

◆ onTouchEvent()

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

Definition at line 309 of file SessionView.java.

310 {
311 // Physical mouse events: bypass gesture detector entirely.
312 // Buttons are handled in onGenericMotionEvent; hover moves in onHoverEvent.
313 // Only ACTION_MOVE with a button held (drag) needs handling here.
314 if (event.isFromSource(InputDevice.SOURCE_MOUSE))
315 {
316 int action = event.getActionMasked();
317 if (event.getClassification() == MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE)
318 {
319 handleTouchpadScroll(event);
320 return true;
321 }
322 if (action == MotionEvent.ACTION_MOVE && event.getButtonState() != 0)
323 {
324 MotionEvent mapped = mapTouchEvent(event);
325 sessionViewListener.onSessionViewMouseMove((int)mapped.getX(), (int)mapped.getY());
326 mapped.recycle();
327 return true;
328 }
329 return true;
330 }
331
332 boolean res = gestureDetector.onTouchEvent(event);
333 res |= doubleGestureDetector.onTouchEvent(event);
334 return res;
335 }

◆ setDefaultCursor()

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

Definition at line 477 of file SessionView.java.

478 {
479 setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_ARROW));
480 }

◆ setOnZoomChangedListener()

void com.freerdp.freerdpcore.presentation.SessionView.setOnZoomChangedListener ( OnZoomChangedListener  l)
inline

Definition at line 194 of file SessionView.java.

195 {
196 zoomChangedListener = l;
197 }

◆ setRailMode()

void com.freerdp.freerdpcore.presentation.SessionView.setRailMode ( boolean  rail)
inline

Definition at line 181 of file SessionView.java.

182 {
183 if (railMode == rail)
184 return;
185 railMode = rail;
186 invalidate();
187 }

◆ setRemoteCursor()

void com.freerdp.freerdpcore.presentation.SessionView.setRemoteCursor ( int[]  pixels,
int  width,
int  height,
int  hotX,
int  hotY 
)
inline

Definition at line 449 of file SessionView.java.

450 {
451 if (pixels == null || width == 0 || height == 0)
452 {
453 cursorPixels = null;
454 setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_NULL));
455 return;
456 }
457 cursorPixels = pixels;
458 cursorWidth = width;
459 cursorHeight = height;
460 cursorHotX = hotX;
461 cursorHotY = hotY;
462 applyScaledCursor();
463 }

◆ setScaleGestureDetector()

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

Definition at line 136 of file SessionView.java.

137 {
138 doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector);
139 }

◆ setSessionViewListener()

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

Definition at line 141 of file SessionView.java.

142 {
143 this.sessionViewListener = sessionViewListener;
144 }

◆ setTouchPointerPadding()

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

Definition at line 250 of file SessionView.java.

251 {
252 touchPointerPaddingWidth = width;
253 touchPointerPaddingHeight = height;
254 requestLayout();
255 }

◆ setZoom()

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

Definition at line 199 of file SessionView.java.

200 {
201 scaleFactor = factor;
202 scaleMatrix.setScale(scaleFactor, scaleFactor);
203 invScaleMatrix.setScale(1.0f / scaleFactor, 1.0f / scaleFactor);
204
205 if (cursorPixels != null)
206 applyScaledCursor();
207
208 if (zoomChangedListener != null)
209 zoomChangedListener.onZoomChanged(scaleFactor);
210
211 requestLayout();
212 }

◆ zoomIn()

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

Definition at line 224 of file SessionView.java.

225 {
226 boolean res = true;
227 scaleFactor += factor;
228 if (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA))
229 {
230 scaleFactor = MAX_SCALE_FACTOR;
231 res = false;
232 }
233 setZoom(scaleFactor);
234 return res;
235 }

◆ zoomOut()

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

Definition at line 237 of file SessionView.java.

238 {
239 boolean res = true;
240 scaleFactor -= factor;
241 if (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA))
242 {
243 scaleFactor = MIN_SCALE_FACTOR;
244 res = false;
245 }
246 setZoom(scaleFactor);
247 return res;
248 }

Field Documentation

◆ MAX_SCALE_FACTOR

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

Definition at line 44 of file SessionView.java.

◆ MIN_SCALE_FACTOR

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

Definition at line 45 of file SessionView.java.


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