Merge pull request #6591 from fufesou/fix/6453
Fix. Do not update cursor pos when switching display on toolbar when "Show monitors on toolbar"
This commit is contained in:
		
						commit
						b6f870ac5f
					
				| @ -2698,7 +2698,7 @@ Future<List<Rect>> getScreenRectList() async { | |||||||
|       : await getScreenListNotWayland(); |       : await getScreenListNotWayland(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi) { | openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi, {bool updateCursorPos = true}) { | ||||||
|   final displays = i == kAllDisplayValue |   final displays = i == kAllDisplayValue | ||||||
|       ? List.generate(pi.displays.length, (index) => index) |       ? List.generate(pi.displays.length, (index) => index) | ||||||
|       : [i]; |       : [i]; | ||||||
| @ -2707,7 +2707,7 @@ openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi) { | |||||||
|     sessionId: ffi.sessionId, |     sessionId: ffi.sessionId, | ||||||
|     value: Int32List.fromList(displays), |     value: Int32List.fromList(displays), | ||||||
|   ); |   ); | ||||||
|   ffi.ffiModel.switchToNewDisplay(i, ffi.sessionId, ffi.id); |   ffi.ffiModel.switchToNewDisplay(i, ffi.sessionId, ffi.id, updateCursorPos: updateCursorPos); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Open new tab or window to show this monitor. | // Open new tab or window to show this monitor. | ||||||
|  | |||||||
| @ -730,7 +730,7 @@ class _MonitorMenu extends StatelessWidget { | |||||||
|                       ], |                       ], | ||||||
|                     ), |                     ), | ||||||
|                   ), |                   ), | ||||||
|             onPressed: () => onPressed(i, pi), |             onPressed: () => onPressed(i, pi, isMulti), | ||||||
|           ); |           ); | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
| @ -810,14 +810,17 @@ class _MonitorMenu extends StatelessWidget { | |||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   onPressed(int i, PeerInfo pi) { |   onPressed(int i, PeerInfo pi, bool isMulti) { | ||||||
|  |     if (!isMulti) { | ||||||
|  |       // If show monitors in toolbar(`buildMultiMonitorMenu()`), then the menu will dismiss automatically. | ||||||
|       _menuDismissCallback(ffi); |       _menuDismissCallback(ffi); | ||||||
|  |     } | ||||||
|     RxInt display = CurrentDisplayState.find(id); |     RxInt display = CurrentDisplayState.find(id); | ||||||
|     if (display.value != i) { |     if (display.value != i) { | ||||||
|       if (isChooseDisplayToOpenInNewWindow(pi, ffi.sessionId)) { |       if (isChooseDisplayToOpenInNewWindow(pi, ffi.sessionId)) { | ||||||
|         openMonitorInNewTabOrWindow(i, ffi.id, pi); |         openMonitorInNewTabOrWindow(i, ffi.id, pi); | ||||||
|       } else { |       } else { | ||||||
|         openMonitorInTheSameTab(i, ffi, pi); |         openMonitorInTheSameTab(i, ffi, pi, updateCursorPos: !isMulti); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -415,18 +415,21 @@ class FfiModel with ChangeNotifier { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   updateCurDisplay(SessionID sessionId) { |   updateCurDisplay(SessionID sessionId, {updateCursorPos = true}) { | ||||||
|     final newRect = displaysRect(); |     final newRect = displaysRect(); | ||||||
|     if (newRect == null) { |     if (newRect == null) { | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|     if (newRect != _rect) { |     if (newRect != _rect) { | ||||||
|  |       if (updateCursorPos) { | ||||||
|         if (newRect.left != _rect?.left || newRect.top != _rect?.top) { |         if (newRect.left != _rect?.left || newRect.top != _rect?.top) { | ||||||
|           parent.target?.cursorModel |           parent.target?.cursorModel | ||||||
|               .updateDisplayOrigin(newRect.left, newRect.top); |               .updateDisplayOrigin(newRect.left, newRect.top); | ||||||
|         } |         } | ||||||
|  |       } | ||||||
|       _rect = newRect; |       _rect = newRect; | ||||||
|       parent.target?.canvasModel.updateViewStyle(); |       parent.target?.canvasModel | ||||||
|  |           .updateViewStyle(refreshMousePos: updateCursorPos); | ||||||
|       _updateSessionWidthHeight(sessionId); |       _updateSessionWidthHeight(sessionId); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| @ -952,12 +955,13 @@ class FfiModel with ChangeNotifier { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // Directly switch to the new display without waiting for the response. |   // Directly switch to the new display without waiting for the response. | ||||||
|   switchToNewDisplay(int display, SessionID sessionId, String peerId) { |   switchToNewDisplay(int display, SessionID sessionId, String peerId, | ||||||
|  |       {bool updateCursorPos = true}) { | ||||||
|     // VideoHandler creation is upon when video frames are received, so either caching commands(don't know next width/height) or stopping recording when switching displays. |     // VideoHandler creation is upon when video frames are received, so either caching commands(don't know next width/height) or stopping recording when switching displays. | ||||||
|     parent.target?.recordingModel.onClose(); |     parent.target?.recordingModel.onClose(); | ||||||
|     // no need to wait for the response |     // no need to wait for the response | ||||||
|     pi.currentDisplay = display; |     pi.currentDisplay = display; | ||||||
|     updateCurDisplay(sessionId); |     updateCurDisplay(sessionId, updateCursorPos: updateCursorPos); | ||||||
|     try { |     try { | ||||||
|       CurrentDisplayState.find(peerId).value = display; |       CurrentDisplayState.find(peerId).value = display; | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
| @ -1242,7 +1246,7 @@ class CanvasModel with ChangeNotifier { | |||||||
|       ? windowBorderWidth + kDragToResizeAreaPadding.bottom |       ? windowBorderWidth + kDragToResizeAreaPadding.bottom | ||||||
|       : 0; |       : 0; | ||||||
| 
 | 
 | ||||||
|   updateViewStyle() async { |   updateViewStyle({refreshMousePos = true}) async { | ||||||
|     Size getSize() { |     Size getSize() { | ||||||
|       final size = MediaQueryData.fromWindow(ui.window).size; |       final size = MediaQueryData.fromWindow(ui.window).size; | ||||||
|       // If minimized, w or h may be negative here. |       // If minimized, w or h may be negative here. | ||||||
| @ -1283,8 +1287,10 @@ class CanvasModel with ChangeNotifier { | |||||||
|     _y = (size.height - displayHeight * _scale) / 2; |     _y = (size.height - displayHeight * _scale) / 2; | ||||||
|     _imageOverflow.value = _x < 0 || y < 0; |     _imageOverflow.value = _x < 0 || y < 0; | ||||||
|     notifyListeners(); |     notifyListeners(); | ||||||
|  |     if (refreshMousePos) { | ||||||
|       parent.target?.inputModel.refreshMousePos(); |       parent.target?.inputModel.refreshMousePos(); | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   updateScrollStyle() async { |   updateScrollStyle() async { | ||||||
|     final style = await bind.sessionGetScrollStyle(sessionId: sessionId); |     final style = await bind.sessionGetScrollStyle(sessionId: sessionId); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user