utils: New geometry spaces local/global
This commit is contained in:
parent
c38a236ffa
commit
42aaafe586
18 changed files with 516 additions and 300 deletions
|
|
@ -82,15 +82,21 @@ impl MoveGrabState {
|
|||
|
||||
let mut window_geo = self.window.geometry();
|
||||
window_geo.loc += cursor_at.to_i32_round() + self.window_offset;
|
||||
if !output.geometry().intersection(window_geo).is_some() {
|
||||
if !output
|
||||
.geometry()
|
||||
.as_logical()
|
||||
.intersection(window_geo)
|
||||
.is_some()
|
||||
{
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let output_scale: Scale<f64> = output.current_scale().fractional_scale().into();
|
||||
let scaling_offset =
|
||||
self.window_offset - self.window_offset.to_f64().upscale(scale).to_i32_round();
|
||||
let render_location =
|
||||
cursor_at.to_i32_round() - output.geometry().loc + self.window_offset - scaling_offset;
|
||||
let render_location = cursor_at.to_i32_round() - output.geometry().loc.as_logical()
|
||||
+ self.window_offset
|
||||
- scaling_offset;
|
||||
|
||||
let focus_element = if self.indicator_thickness > 0 {
|
||||
Some(
|
||||
|
|
@ -105,7 +111,8 @@ impl MoveGrabState {
|
|||
.to_f64()
|
||||
.upscale(scale)
|
||||
.to_i32_round(),
|
||||
),
|
||||
)
|
||||
.as_local(),
|
||||
self.indicator_thickness,
|
||||
output_scale.x,
|
||||
1.0,
|
||||
|
|
@ -208,6 +215,7 @@ impl PointerGrab<State> for MoveGrab {
|
|||
.find(|output| {
|
||||
output
|
||||
.geometry()
|
||||
.as_logical()
|
||||
.contains(handle.current_location().to_i32_round())
|
||||
})
|
||||
.cloned()
|
||||
|
|
@ -233,8 +241,8 @@ impl PointerGrab<State> for MoveGrab {
|
|||
if let Some(grab_state) = borrow.as_mut().and_then(|s| s.as_mut()) {
|
||||
let mut window_geo = self.window.geometry();
|
||||
window_geo.loc += event.location.to_i32_round() + grab_state.window_offset;
|
||||
for output in &state.common.shell.outputs {
|
||||
if let Some(overlap) = output.geometry().intersection(window_geo) {
|
||||
for output in state.common.shell.outputs() {
|
||||
if let Some(overlap) = output.geometry().as_logical().intersection(window_geo) {
|
||||
if self.window_outputs.insert(output.clone()) {
|
||||
self.window.output_enter(output, overlap);
|
||||
if let Some(indicator) =
|
||||
|
|
@ -261,11 +269,20 @@ impl PointerGrab<State> for MoveGrab {
|
|||
|
||||
if indicator_location.is_some() != grab_state.stacking_indicator.is_some() {
|
||||
grab_state.stacking_indicator = indicator_location.map(|geo| {
|
||||
let element = stack_hover(state.common.event_loop_handle.clone(), geo.size);
|
||||
let element = stack_hover(
|
||||
state.common.event_loop_handle.clone(),
|
||||
geo.size.as_logical(),
|
||||
);
|
||||
for output in &self.window_outputs {
|
||||
element.output_enter(output, output.geometry());
|
||||
element.output_enter(
|
||||
output,
|
||||
Rectangle::from_loc_and_size(
|
||||
(0, 0),
|
||||
output.geometry().size.as_logical(),
|
||||
),
|
||||
);
|
||||
}
|
||||
(element, geo.loc)
|
||||
(element, geo.loc.as_logical())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -397,8 +414,8 @@ impl MoveGrab {
|
|||
start_data: PointerGrabStartData<State>,
|
||||
window: CosmicMapped,
|
||||
seat: &Seat<State>,
|
||||
initial_cursor_location: Point<f64, Logical>,
|
||||
initial_window_location: Point<i32, Logical>,
|
||||
initial_cursor_location: Point<f64, Global>,
|
||||
initial_window_location: Point<i32, Global>,
|
||||
indicator_thickness: u8,
|
||||
was_tiled: bool,
|
||||
) -> MoveGrab {
|
||||
|
|
@ -409,7 +426,8 @@ impl MoveGrab {
|
|||
|
||||
let grab_state = MoveGrabState {
|
||||
window: window.clone(),
|
||||
window_offset: initial_window_location - initial_cursor_location.to_i32_round(),
|
||||
window_offset: (initial_window_location - initial_cursor_location.to_i32_round())
|
||||
.as_logical(),
|
||||
indicator_thickness,
|
||||
start: Instant::now(),
|
||||
stacking_indicator: None,
|
||||
|
|
@ -451,16 +469,16 @@ impl MoveGrab {
|
|||
// No more buttons are pressed, release the grab.
|
||||
let output = self.seat.active_output();
|
||||
|
||||
let position = if let Some(grab_state) = self
|
||||
let position: Option<(CosmicMapped, Point<i32, Global>)> = if let Some(grab_state) = self
|
||||
.seat
|
||||
.user_data()
|
||||
.get::<SeatMoveGrabState>()
|
||||
.and_then(|s| s.borrow_mut().take())
|
||||
{
|
||||
if grab_state.window.alive() {
|
||||
let window_location = handle.current_location().to_i32_round()
|
||||
- output.geometry().loc
|
||||
+ grab_state.window_offset;
|
||||
let window_location = (handle.current_location().to_i32_round()
|
||||
+ grab_state.window_offset)
|
||||
.as_global();
|
||||
|
||||
let workspace_handle = state.common.shell.active_space(&output).handle;
|
||||
for old_output in self.window_outputs.iter().filter(|o| *o != &output) {
|
||||
|
|
@ -480,41 +498,26 @@ impl MoveGrab {
|
|||
}
|
||||
|
||||
if self.tiling {
|
||||
Some(
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.active_space_mut(&output)
|
||||
.tiling_layer
|
||||
.drop_window(grab_state.window, &output, handle.current_location()),
|
||||
)
|
||||
} else {
|
||||
let offset = state
|
||||
.common
|
||||
.shell
|
||||
.active_space(&output)
|
||||
.floating_layer
|
||||
.space
|
||||
.output_geometry(&output)
|
||||
.unwrap()
|
||||
.loc;
|
||||
grab_state.window.set_geometry(Rectangle::from_loc_and_size(
|
||||
window_location + offset,
|
||||
grab_state.window.geometry().size,
|
||||
));
|
||||
state
|
||||
let (window, location) = state
|
||||
.common
|
||||
.shell
|
||||
.active_space_mut(&output)
|
||||
.floating_layer
|
||||
.map_internal(grab_state.window, &output, Some(window_location + offset));
|
||||
.tiling_layer
|
||||
.drop_window(grab_state.window);
|
||||
Some((window, location.to_global(&output)))
|
||||
} else {
|
||||
grab_state.window.set_geometry(Rectangle::from_loc_and_size(
|
||||
window_location,
|
||||
grab_state.window.geometry().size.as_global(),
|
||||
));
|
||||
let workspace = state.common.shell.active_space_mut(&output);
|
||||
workspace.floating_layer.map_internal(
|
||||
grab_state.window,
|
||||
Some(window_location.to_local(&workspace.output)),
|
||||
None,
|
||||
);
|
||||
|
||||
let pointer_pos = handle.current_location();
|
||||
let relative_pos = state.common.shell.map_global_to_space(pointer_pos, &output);
|
||||
Some((
|
||||
self.window.clone(),
|
||||
window_location + offset + (pointer_pos - relative_pos).to_i32_round(),
|
||||
))
|
||||
Some((self.window.clone(), window_location))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
|
@ -535,7 +538,7 @@ impl MoveGrab {
|
|||
state,
|
||||
Some((
|
||||
PointerFocusTarget::from(mapped.clone()),
|
||||
position - self.window.geometry().loc,
|
||||
position.as_logical() - self.window.geometry().loc,
|
||||
)),
|
||||
&MotionEvent {
|
||||
location: handle.current_location(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue