fix: setMovable only on macos (#8261)
* fix: setMovable only on macos Signed-off-by: fufesou <linlong1266@gmail.com> * Refact and comments Signed-off-by: fufesou <linlong1266@gmail.com> * comments Signed-off-by: fufesou <linlong1266@gmail.com> * Refact comments Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
		
							parent
							
								
									ce1dac3b86
								
							
						
					
					
						commit
						a84b9bd2c8
					
				| @ -1008,7 +1008,8 @@ class CustomAlertDialog extends StatelessWidget { | ||||
|           return KeyEventResult.handled; // avoid TextField exception on escape | ||||
|         } else if (!tabTapped && | ||||
|             onSubmit != null && | ||||
|             (key.logicalKey == LogicalKeyboardKey.enter || key.logicalKey == LogicalKeyboardKey.numpadEnter)) { | ||||
|             (key.logicalKey == LogicalKeyboardKey.enter || | ||||
|                 key.logicalKey == LogicalKeyboardKey.numpadEnter)) { | ||||
|           if (key is RawKeyDownEvent) onSubmit?.call(); | ||||
|           return KeyEventResult.handled; | ||||
|         } else if (key.logicalKey == LogicalKeyboardKey.tab) { | ||||
| @ -3372,3 +3373,27 @@ get defaultOptionNo => isCustomClient ? 'N' : ''; | ||||
| get defaultOptionWhitelist => isCustomClient ? ',' : ''; | ||||
| get defaultOptionAccessMode => isCustomClient ? 'custom' : ''; | ||||
| get defaultOptionApproveMode => isCustomClient ? 'password-click' : ''; | ||||
| 
 | ||||
| // `setMovable()` is only supported on macOS. | ||||
| // | ||||
| // On macOS, the window can be dragged by the tab bar by default. | ||||
| // We need to disable the movable feature to prevent the window from being dragged by the tabs in the tab bar. | ||||
| // | ||||
| // When we drag the blank tab bar (not the tab), the window will be dragged normally by adding the `onPanStart` handle. | ||||
| // | ||||
| // See the following code for more details: | ||||
| // https://github.com/rustdesk/rustdesk/blob/ce1dac3b8613596b4d8ae981275f9335489eb935/flutter/lib/desktop/widgets/tabbar_widget.dart#L385 | ||||
| // https://github.com/rustdesk/rustdesk/blob/ce1dac3b8613596b4d8ae981275f9335489eb935/flutter/lib/desktop/widgets/tabbar_widget.dart#L399 | ||||
| // | ||||
| // @platforms macos | ||||
| disableWindowMovable(int? windowId) { | ||||
|   if (!isMacOS) { | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   if (windowId == null) { | ||||
|     windowManager.setMovable(false); | ||||
|   } else { | ||||
|     WindowController.fromWindowId(windowId).setMovable(false); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -397,6 +397,8 @@ class DesktopTab extends StatelessWidget { | ||||
|                     : null, | ||||
|                 onPanStart: (_) => startDragging(isMainWindow), | ||||
|                 onPanCancel: () { | ||||
|                   // We want to disable dragging of the tab area in the tab bar. | ||||
|                   // Disable dragging is needed because macOS handles dragging by default. | ||||
|                   if (isMacOS) { | ||||
|                     setMovable(isMainWindow, false); | ||||
|                   } | ||||
|  | ||||
| @ -95,7 +95,9 @@ Future<void> main(List<String> args) async { | ||||
|     desktopType = DesktopType.main; | ||||
|     await windowManager.ensureInitialized(); | ||||
|     windowManager.setPreventClose(true); | ||||
|     windowManager.setMovable(false); | ||||
|     if (isMacOS) { | ||||
|       disableWindowMovable(kWindowId); | ||||
|     } | ||||
|     runMainApp(true); | ||||
|   } | ||||
| } | ||||
| @ -168,7 +170,9 @@ void runMultiWindow( | ||||
|   final title = getWindowName(); | ||||
|   // set prevent close to true, we handle close event manually | ||||
|   WindowController.fromWindowId(kWindowId!).setPreventClose(true); | ||||
|   WindowController.fromWindowId(kWindowId!).setMovable(false); | ||||
|   if (isMacOS) { | ||||
|     disableWindowMovable(kWindowId); | ||||
|   } | ||||
|   late Widget widget; | ||||
|   switch (appType) { | ||||
|     case kAppTypeDesktopRemote: | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user