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 44 of file SessionView.java.

Constructor & Destructor Documentation

◆ SessionView() [1/3]

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

Definition at line 82 of file SessionView.java.

83 {
84 super(context);
85 initSessionView(context);
86 }

◆ SessionView() [2/3]

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

Definition at line 88 of file SessionView.java.

89 {
90 super(context, attrs);
91 initSessionView(context);
92 }

◆ SessionView() [3/3]

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

Definition at line 94 of file SessionView.java.

95 {
96 super(context, attrs, defStyle);
97 initSessionView(context);
98 }

Member Function Documentation

◆ addInvalidRegion()

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

Definition at line 150 of file SessionView.java.

151 {
152 // correctly transform invalid region depending on current scaling
153 invalidRegionF.set(invalidRegion);
154 scaleMatrix.mapRect(invalidRegionF);
155 invalidRegionF.roundOut(invalidRegion);
156
157 invalidRegions.add(invalidRegion);
158 }

◆ getTouchPointerPaddingHeight()

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

Definition at line 266 of file SessionView.java.

267 {
268 return touchPointerPaddingHeight;
269 }

◆ getTouchPointerPaddingWidth()

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

Definition at line 261 of file SessionView.java.

262 {
263 return touchPointerPaddingWidth;
264 }

◆ getZoom()

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

Definition at line 180 of file SessionView.java.

181 {
182 return scaleFactor;
183 }

◆ invalidateRegion()

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

Definition at line 160 of file SessionView.java.

161 {
162 invalidate(invalidRegions.pop());
163 }

◆ isAtMaxZoom()

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

Definition at line 218 of file SessionView.java.

219 {
220 return (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA));
221 }

◆ isAtMinZoom()

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

Definition at line 223 of file SessionView.java.

224 {
225 return (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA));
226 }

◆ onCreateInputConnection()

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

Definition at line 620 of file SessionView.java.

621 {
622 outAttrs.actionLabel = null;
623 outAttrs.inputType = InputType.TYPE_NULL;
624 outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI |
625 EditorInfo.IME_FLAG_NO_FULLSCREEN;
626 return new BaseInputConnection(this, false);
627 }

◆ onDraw()

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

Definition at line 278 of file SessionView.java.

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

◆ onGenericMotionEvent()

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

Definition at line 382 of file SessionView.java.

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

◆ onHoverEvent()

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

Definition at line 123 of file SessionView.java.

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

◆ onMeasure()

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

Definition at line 271 of file SessionView.java.

272 {
273 Log.v(TAG, width + "x" + height);
274 this.setMeasuredDimension((int)(width * scaleFactor) + touchPointerPaddingWidth,
275 (int)(height * scaleFactor) + touchPointerPaddingHeight);
276 }
#define TAG

◆ onSurfaceChange()

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

Definition at line 165 of file SessionView.java.

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

◆ onTouchEvent()

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

Definition at line 313 of file SessionView.java.

314 {
315 // Physical mouse events: bypass gesture detector entirely.
316 // Buttons are handled in onGenericMotionEvent; hover moves in onHoverEvent.
317 // Only ACTION_MOVE with a button held (drag) needs handling here.
318 if (event.isFromSource(InputDevice.SOURCE_MOUSE))
319 {
320 int action = event.getActionMasked();
321 // Some ROMs (e.g. HarmonyOS) deliver the wheel as a touch event.
322 if (action == MotionEvent.ACTION_SCROLL)
323 return onGenericMotionEvent(event);
324 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
325 event.getClassification() == MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE)
326 {
327 handleTouchpadScroll(event);
328 return true;
329 }
330 if (action == MotionEvent.ACTION_MOVE && event.getButtonState() != 0)
331 {
332 MotionEvent mapped = mapTouchEvent(event);
333 sessionViewListener.onSessionViewMouseMove((int)mapped.getX(), (int)mapped.getY());
334 mapped.recycle();
335 return true;
336 }
337 return true;
338 }
339
340 boolean res = gestureDetector.onTouchEvent(event);
341 res |= doubleGestureDetector.onTouchEvent(event);
342 return res;
343 }

◆ setDefaultCursor()

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

Definition at line 485 of file SessionView.java.

486 {
487 setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_ARROW));
488 }

◆ setOnZoomChangedListener()

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

Definition at line 198 of file SessionView.java.

199 {
200 zoomChangedListener = l;
201 }

◆ setRailMode()

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

Definition at line 185 of file SessionView.java.

186 {
187 if (railMode == rail)
188 return;
189 railMode = rail;
190 invalidate();
191 }

◆ setRemoteCursor()

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

Definition at line 457 of file SessionView.java.

458 {
459 if (pixels == null || width == 0 || height == 0)
460 {
461 cursorPixels = null;
462 setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_NULL));
463 return;
464 }
465 cursorPixels = pixels;
466 cursorWidth = width;
467 cursorHeight = height;
468 cursorHotX = hotX;
469 cursorHotY = hotY;
470 applyScaledCursor();
471 }

◆ setScaleGestureDetector()

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

Definition at line 140 of file SessionView.java.

141 {
142 doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector);
143 }

◆ setSessionViewListener()

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

Definition at line 145 of file SessionView.java.

146 {
147 this.sessionViewListener = sessionViewListener;
148 }

◆ setTouchPointerPadding()

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

Definition at line 254 of file SessionView.java.

255 {
256 touchPointerPaddingWidth = width;
257 touchPointerPaddingHeight = height;
258 requestLayout();
259 }

◆ setZoom()

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

Definition at line 203 of file SessionView.java.

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

◆ zoomIn()

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

Definition at line 228 of file SessionView.java.

229 {
230 boolean res = true;
231 scaleFactor += factor;
232 if (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA))
233 {
234 scaleFactor = MAX_SCALE_FACTOR;
235 res = false;
236 }
237 setZoom(scaleFactor);
238 return res;
239 }

◆ zoomOut()

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

Definition at line 241 of file SessionView.java.

242 {
243 boolean res = true;
244 scaleFactor -= factor;
245 if (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA))
246 {
247 scaleFactor = MIN_SCALE_FACTOR;
248 res = false;
249 }
250 setZoom(scaleFactor);
251 return res;
252 }

Field Documentation

◆ MAX_SCALE_FACTOR

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

Definition at line 46 of file SessionView.java.

◆ MIN_SCALE_FACTOR

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

Definition at line 47 of file SessionView.java.


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