Merge pull request #2630 from Kingtous/master
fix: keeps mouse region grab key on linux
This commit is contained in:
		
						commit
						38e11ea60a
					
				| @ -128,21 +128,31 @@ class _RemotePageState extends State<RemotePage> | |||||||
|   @override |   @override | ||||||
|   void onWindowBlur() { |   void onWindowBlur() { | ||||||
|     super.onWindowBlur(); |     super.onWindowBlur(); | ||||||
|  |     // On windows, we use `focus` way to handle keyboard better. | ||||||
|  |     // Now on Linux, there's some rdev issues which will break the input. | ||||||
|  |     // We disable the `focus` way for non-Windows temporarily. | ||||||
|  |     if (Platform.isWindows) { | ||||||
|       _isWindowBlur = true; |       _isWindowBlur = true; | ||||||
|     // unfocus the key focus when the whole window is lost focus, |       // unfocus the primary-focus when the whole window is lost focus, | ||||||
|       // and let OS to handle events instead. |       // and let OS to handle events instead. | ||||||
|       _rawKeyFocusNode.unfocus(); |       _rawKeyFocusNode.unfocus(); | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   void onWindowFocus() { |   void onWindowFocus() { | ||||||
|     super.onWindowFocus(); |     super.onWindowFocus(); | ||||||
|  |     // See [onWindowBlur]. | ||||||
|  |     if (Platform.isWindows) { | ||||||
|       _isWindowBlur = false; |       _isWindowBlur = false; | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   void dispose() { |   void dispose() { | ||||||
|     debugPrint("REMOTE PAGE dispose ${widget.id}"); |     debugPrint("REMOTE PAGE dispose ${widget.id}"); | ||||||
|  |     // ensure we leave this session, this is a double check | ||||||
|  |     bind.sessionEnterOrLeave(id: widget.id, enter: false); | ||||||
|     DesktopMultiWindow.removeListener(this); |     DesktopMultiWindow.removeListener(this); | ||||||
|     _ffi.dialogManager.hideMobileActionsOverlay(); |     _ffi.dialogManager.hideMobileActionsOverlay(); | ||||||
|     _ffi.recordingModel.onClose(); |     _ffi.recordingModel.onClose(); | ||||||
| @ -175,6 +185,8 @@ class _RemotePageState extends State<RemotePage> | |||||||
|                       onFocusChange: (bool imageFocused) { |                       onFocusChange: (bool imageFocused) { | ||||||
|                         debugPrint( |                         debugPrint( | ||||||
|                             "onFocusChange(window active:${!_isWindowBlur}) $imageFocused"); |                             "onFocusChange(window active:${!_isWindowBlur}) $imageFocused"); | ||||||
|  |                         // See [onWindowBlur]. | ||||||
|  |                         if (Platform.isWindows) { | ||||||
|                           if (_isWindowBlur) { |                           if (_isWindowBlur) { | ||||||
|                             imageFocused = false; |                             imageFocused = false; | ||||||
|                             Future.delayed(Duration.zero, () { |                             Future.delayed(Duration.zero, () { | ||||||
| @ -186,6 +198,7 @@ class _RemotePageState extends State<RemotePage> | |||||||
|                           } else { |                           } else { | ||||||
|                             _ffi.inputModel.enterOrLeave(false); |                             _ffi.inputModel.enterOrLeave(false); | ||||||
|                           } |                           } | ||||||
|  |                         } | ||||||
|                       }, |                       }, | ||||||
|                       inputModel: _ffi.inputModel, |                       inputModel: _ffi.inputModel, | ||||||
|                       child: getBodyForDesktop(context))); |                       child: getBodyForDesktop(context))); | ||||||
| @ -221,6 +234,13 @@ class _RemotePageState extends State<RemotePage> | |||||||
|         // |         // | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |     // See [onWindowBlur]. | ||||||
|  |     if (!Platform.isWindows) { | ||||||
|  |       if (!_rawKeyFocusNode.hasFocus) { | ||||||
|  |         _rawKeyFocusNode.requestFocus(); | ||||||
|  |       } | ||||||
|  |       bind.sessionEnterOrLeave(id: widget.id, enter: true); | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   void leaveView(PointerExitEvent evt) { |   void leaveView(PointerExitEvent evt) { | ||||||
| @ -233,6 +253,10 @@ class _RemotePageState extends State<RemotePage> | |||||||
|         // |         // | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |     // See [onWindowBlur]. | ||||||
|  |     if (!Platform.isWindows) { | ||||||
|  |       bind.sessionEnterOrLeave(id: widget.id, enter: false); | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   Widget getBodyForDesktop(BuildContext context) { |   Widget getBodyForDesktop(BuildContext context) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user