Android: Fix cursor position when setting from popup#11003
Android: Fix cursor position when setting from popup#11003Murmele wants to merge 39 commits intoslint-ui:masterfrom
Conversation
3f88b57 to
5889c9a
Compare
Reason: If not a dedicated window, it does not have its own coordinate system, but all elements must be still relative to the main window. Fixes: slint-ui#10475
849ccad to
85c9db7
Compare
…root index instead of hardcoded 0
66a5a84 to
fa0c5ce
Compare
This reverts commit 068ea52. #Conflicts: # internal/backends/android-activity/javahelper.rs # internal/core/item_tree.rs # internal/core/items/text.rs # internal/core/window.rs
Replace the hardcoded `ROOT_ITEM_INDEX` constant with a new `ItemRc::new_root` method and `is_root` check
…opup' #Conflicts: # internal/core/item_tree.rs
…ant logic Remove redundant code that calculates `parent_window_adapter` and `position` for popup placement, as this is already handled in the mapping function. The logic was duplicated and unnecessary, reducing code complexity and improving readability. This change aligns with the existing mapping logic that already determines the correct window adapter and position for popups.
Reason: Otherwise it might be that for TopLevel Windows the position is incorrect
|
I am wondering where the logic for the mouse position is ... |
ogoffart
left a comment
There was a problem hiding this comment.
This change the behavior of map_to_window to no longer stop at the PopupWindow but return the value of the actual Window.
This will indeed solve the bug. I wonder if it won't have unintended side effect. (Like will it change the behavior of the absolute-position property?)
Just a comment for next time:
The drive-by refactoring of ItemRc is great, but makes the change harder to review because that is most of the content of the change, and the commit history is not clean enough to allow per-commit review. In that case, it is helpful to rebase -i the change to keep a clean commit history, or put it in a separate PR.
internal/core/item_tree.rs
Outdated
| use crate::slice::Slice; | ||
| use crate::window::WindowAdapterRc; | ||
| use alloc::vec::Vec; | ||
| use core::borrow::Borrow; |
There was a problem hiding this comment.
In my experience, this gets added by rust_analyzer sometimes when trying to borrow something that is not a RefCell. Are you sure you really mean to add this?
| .is_none_or(|adapter| adapter.renderer().supports_transformations()); | ||
| while let Some(parent) = current.parent_item(ParentItemTraversalMode::StopAtPopups) { | ||
| if stop_condition(&parent) { | ||
| break; |
There was a problem hiding this comment.
| return result; |
I believe we don't want to add the popup position when we are called from the map_to_item_tree function.
(Alternative would be to move the added code directly in map_to_window)
There was a problem hiding this comment.
reverted because not required because of 4450eda
#Conflicts: # internal/backends/winit/accesskit.rs # internal/core/window.rs
|
One thing I don't understand yet is why in the test is_root_item_of() does not consider dynamic elements |
Reason: because map_to_window is used for logical mapping to the window but sometimes we really need the screen value if the popup is only virtual
internal/core/item_tree.rs
Outdated
| &self, | ||
| p: LogicalPoint, | ||
| stop_condition: impl Fn(&Self) -> bool, | ||
| consider_popup: bool, |
There was a problem hiding this comment.
Inside of passing a boolean there that is only true in map_to_screen, just move the code that consider the popup in the map_to_screen function.
internal/core/item_tree.rs
Outdated
| /// Similar to `map_to_window` but considers also the popup location if the popup | ||
| /// is not a dedicated window but of type ChildWindow | ||
| /// Use this function if you wanna have the real absolute position | ||
| pub fn map_to_screen(&self, p: LogicalPoint) -> LogicalPoint { |
There was a problem hiding this comment.
map_to_screen here is not the right name, because this is not the case when the top level window is not full screen (eg, on desktop)
A better name would perhaps be map_to_native_window
…ap_to_native_window function
Was unintentionally
Under Android the popup is not a dedicated window with own coordinate system, but only a ChildWindow of the main window. Because of that the position of the popup must be considered as well, because everything is relative to the main window
Fixes: #10475
The testcase
popupwindow_nested.slintchecks if the changes are correct