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

Constructor & Destructor Documentation

◆ SessionView() [1/3]

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

Definition at line 73 of file SessionView.java.

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

◆ SessionView() [2/3]

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

Definition at line 79 of file SessionView.java.

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

◆ SessionView() [3/3]

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

Definition at line 85 of file SessionView.java.

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

Member Function Documentation

◆ addInvalidRegion()

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

Definition at line 136 of file SessionView.java.

137 {
138 // correctly transform invalid region depending on current scaling
139 invalidRegionF.set(invalidRegion);
140 scaleMatrix.mapRect(invalidRegionF);
141 invalidRegionF.roundOut(invalidRegion);
142
143 invalidRegions.add(invalidRegion);
144 }

◆ getTouchPointerPaddingHeight()

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

Definition at line 252 of file SessionView.java.

253 {
254 return touchPointerPaddingHeight;
255 }

◆ getTouchPointerPaddingWidth()

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

Definition at line 247 of file SessionView.java.

248 {
249 return touchPointerPaddingWidth;
250 }

◆ getZoom()

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

Definition at line 166 of file SessionView.java.

167 {
168 return scaleFactor;
169 }

◆ invalidateRegion()

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

Definition at line 146 of file SessionView.java.

147 {
148 invalidate(invalidRegions.pop());
149 }

◆ isAtMaxZoom()

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

Definition at line 204 of file SessionView.java.

205 {
206 return (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA));
207 }

◆ isAtMinZoom()

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

Definition at line 209 of file SessionView.java.

210 {
211 return (scaleFactor < (MIN_SCALE_FACTOR + SCALE_FACTOR_DELTA));
212 }

◆ onCreateInputConnection()

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

Definition at line 561 of file SessionView.java.

562 {
563 outAttrs.actionLabel = null;
564 outAttrs.inputType = InputType.TYPE_NULL;
565 outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI |
566 EditorInfo.IME_FLAG_NO_FULLSCREEN;
567 return new BaseInputConnection(this, false);
568 }

◆ onDraw()

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

Definition at line 264 of file SessionView.java.

265 {
266 super.onDraw(canvas);
267
268 canvas.save();
269 canvas.concat(scaleMatrix);
270 canvas.drawColor(Color.BLACK);
271 if (!railMode && surface != null)
272 {
273 surface.draw(canvas);
274 }
275 canvas.restore();
276 }

◆ onGenericMotionEvent()

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

Definition at line 323 of file SessionView.java.

324 {
325 final boolean isPointer = event.isFromSource(InputDevice.SOURCE_CLASS_POINTER);
326 if (!isPointer)
327 return false;
328
329 final boolean isMouse = event.isFromSource(InputDevice.SOURCE_MOUSE);
330 int action = event.getActionMasked();
331
332 if (isMouse && (action == MotionEvent.ACTION_BUTTON_PRESS ||
333 action == MotionEvent.ACTION_BUTTON_RELEASE))
334 {
335 boolean down = action == MotionEvent.ACTION_BUTTON_PRESS;
336 MotionEvent mapped = mapTouchEvent(event);
337 int x = (int)mapped.getX();
338 int y = (int)mapped.getY();
339 mapped.recycle();
340
341 switch (event.getActionButton())
342 {
343 case MotionEvent.BUTTON_PRIMARY:
344 if (down)
345 sessionViewListener.onSessionViewBeginTouch();
346 sessionViewListener.onSessionViewLeftTouch(x, y, down);
347 if (!down)
348 sessionViewListener.onSessionViewEndTouch();
349 return true;
350 case MotionEvent.BUTTON_SECONDARY:
351 if (down)
352 sessionViewListener.onSessionViewBeginTouch();
353 sessionViewListener.onSessionViewRightTouch(x, y, down);
354 return true;
355 case MotionEvent.BUTTON_TERTIARY:
356 sessionViewListener.onSessionViewMiddleTouch(x, y, down);
357 return true;
358 default:
359 return true; // consume unknown buttons silently
360 }
361 }
362
363 if (action == MotionEvent.ACTION_SCROLL)
364 {
365 float vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
366 float hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
367 if (vScroll != 0)
368 sessionViewListener.onSessionViewScroll(vScroll > 0);
369 if (hScroll != 0)
370 sessionViewListener.onSessionViewHScroll(hScroll > 0);
371 return true;
372 }
373
374 return false;
375 }

◆ onHoverEvent()

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

Definition at line 109 of file SessionView.java.

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

◆ onMeasure()

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

Definition at line 257 of file SessionView.java.

258 {
259 Log.v(TAG, width + "x" + height);
260 this.setMeasuredDimension((int)(width * scaleFactor) + touchPointerPaddingWidth,
261 (int)(height * scaleFactor) + touchPointerPaddingHeight);
262 }

◆ onSurfaceChange()

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

Definition at line 151 of file SessionView.java.

152 {
153 surface = session.getSurface();
154 Bitmap bitmap = surface.getBitmap();
155 width = bitmap.getWidth();
156 height = bitmap.getHeight();
157 surface.setBounds(0, 0, width, height);
158
159 setMinimumWidth(width);
160 setMinimumHeight(height);
161
162 requestLayout();
163 currentSession = session;
164 }

◆ onTouchEvent()

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

Definition at line 299 of file SessionView.java.

300 {
301 // Physical mouse events: bypass gesture detector entirely.
302 // Buttons are handled in onGenericMotionEvent; hover moves in onHoverEvent.
303 // Only ACTION_MOVE with a button held (drag) needs handling here.
304 if (event.isFromSource(InputDevice.SOURCE_MOUSE))
305 {
306 int action = event.getActionMasked();
307 if (action == MotionEvent.ACTION_MOVE && event.getButtonState() != 0)
308 {
309 MotionEvent mapped = mapTouchEvent(event);
310 sessionViewListener.onSessionViewMouseMove((int)mapped.getX(), (int)mapped.getY());
311 mapped.recycle();
312 return true;
313 }
314 return true;
315 }
316
317 boolean res = gestureDetector.onTouchEvent(event);
318 res |= doubleGestureDetector.onTouchEvent(event);
319 return res;
320 }

◆ setDefaultCursor()

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

Definition at line 426 of file SessionView.java.

427 {
428 setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_ARROW));
429 }

◆ setOnZoomChangedListener()

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

Definition at line 184 of file SessionView.java.

185 {
186 zoomChangedListener = l;
187 }

◆ setRailMode()

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

Definition at line 171 of file SessionView.java.

172 {
173 if (railMode == rail)
174 return;
175 railMode = rail;
176 invalidate();
177 }

◆ setRemoteCursor()

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

Definition at line 398 of file SessionView.java.

399 {
400 if (pixels == null || width == 0 || height == 0)
401 {
402 cursorPixels = null;
403 setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_NULL));
404 return;
405 }
406 cursorPixels = pixels;
407 cursorWidth = width;
408 cursorHeight = height;
409 cursorHotX = hotX;
410 cursorHotY = hotY;
411 applyScaledCursor();
412 }

◆ setScaleGestureDetector()

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

Definition at line 126 of file SessionView.java.

127 {
128 doubleGestureDetector.setScaleGestureDetector(scaleGestureDetector);
129 }

◆ setSessionViewListener()

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

Definition at line 131 of file SessionView.java.

132 {
133 this.sessionViewListener = sessionViewListener;
134 }

◆ setTouchPointerPadding()

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

Definition at line 240 of file SessionView.java.

241 {
242 touchPointerPaddingWidth = width;
243 touchPointerPaddingHeight = height;
244 requestLayout();
245 }

◆ setZoom()

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

Definition at line 189 of file SessionView.java.

190 {
191 scaleFactor = factor;
192 scaleMatrix.setScale(scaleFactor, scaleFactor);
193 invScaleMatrix.setScale(1.0f / scaleFactor, 1.0f / scaleFactor);
194
195 if (cursorPixels != null)
196 applyScaledCursor();
197
198 if (zoomChangedListener != null)
199 zoomChangedListener.onZoomChanged(scaleFactor);
200
201 requestLayout();
202 }

◆ zoomIn()

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

Definition at line 214 of file SessionView.java.

215 {
216 boolean res = true;
217 scaleFactor += factor;
218 if (scaleFactor > (MAX_SCALE_FACTOR - SCALE_FACTOR_DELTA))
219 {
220 scaleFactor = MAX_SCALE_FACTOR;
221 res = false;
222 }
223 setZoom(scaleFactor);
224 return res;
225 }

◆ zoomOut()

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

Definition at line 227 of file SessionView.java.

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

Field Documentation

◆ MAX_SCALE_FACTOR

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

Definition at line 43 of file SessionView.java.

◆ MIN_SCALE_FACTOR

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

Definition at line 44 of file SessionView.java.


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