utils: New geometry spaces local/global
This commit is contained in:
parent
c38a236ffa
commit
42aaafe586
18 changed files with 516 additions and 300 deletions
|
|
@ -17,7 +17,7 @@ use crate::{
|
||||||
CosmicMapped, CosmicMappedRenderElement, OverviewMode, Trigger, WorkspaceRenderElement,
|
CosmicMapped, CosmicMappedRenderElement, OverviewMode, Trigger, WorkspaceRenderElement,
|
||||||
},
|
},
|
||||||
state::{Common, Fps},
|
state::{Common, Fps},
|
||||||
utils::prelude::{OutputExt, SeatExt},
|
utils::prelude::*,
|
||||||
wayland::{
|
wayland::{
|
||||||
handlers::{
|
handlers::{
|
||||||
data_device::get_dnd_icon,
|
data_device::get_dnd_icon,
|
||||||
|
|
@ -160,7 +160,7 @@ impl IndicatorShader {
|
||||||
pub fn focus_element<R: AsGlowRenderer>(
|
pub fn focus_element<R: AsGlowRenderer>(
|
||||||
renderer: &R,
|
renderer: &R,
|
||||||
key: impl Into<Key>,
|
key: impl Into<Key>,
|
||||||
mut element_geo: Rectangle<i32, Logical>,
|
mut element_geo: Rectangle<i32, Local>,
|
||||||
thickness: u8,
|
thickness: u8,
|
||||||
scale: f64,
|
scale: f64,
|
||||||
alpha: f32,
|
alpha: f32,
|
||||||
|
|
@ -184,7 +184,7 @@ impl IndicatorShader {
|
||||||
pub fn element<R: AsGlowRenderer>(
|
pub fn element<R: AsGlowRenderer>(
|
||||||
renderer: &R,
|
renderer: &R,
|
||||||
key: impl Into<Key>,
|
key: impl Into<Key>,
|
||||||
geo: Rectangle<i32, Logical>,
|
geo: Rectangle<i32, Local>,
|
||||||
thickness: u8,
|
thickness: u8,
|
||||||
radius: u8,
|
radius: u8,
|
||||||
alpha: f32,
|
alpha: f32,
|
||||||
|
|
@ -223,7 +223,7 @@ impl IndicatorShader {
|
||||||
|
|
||||||
let elem = PixelShaderElement::new(
|
let elem = PixelShaderElement::new(
|
||||||
shader,
|
shader,
|
||||||
geo,
|
geo.as_logical(),
|
||||||
None, //TODO
|
None, //TODO
|
||||||
alpha,
|
alpha,
|
||||||
vec![
|
vec![
|
||||||
|
|
@ -240,8 +240,8 @@ impl IndicatorShader {
|
||||||
}
|
}
|
||||||
|
|
||||||
let elem = &mut cache.get_mut(&key).unwrap().1;
|
let elem = &mut cache.get_mut(&key).unwrap().1;
|
||||||
if elem.geometry(1.0.into()).to_logical(1) != geo {
|
if elem.geometry(1.0.into()).to_logical(1) != geo.as_logical() {
|
||||||
elem.resize(geo, None);
|
elem.resize(geo.as_logical(), None);
|
||||||
}
|
}
|
||||||
elem.clone()
|
elem.clone()
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +271,7 @@ impl BackdropShader {
|
||||||
pub fn element<R: AsGlowRenderer>(
|
pub fn element<R: AsGlowRenderer>(
|
||||||
renderer: &R,
|
renderer: &R,
|
||||||
key: impl Into<Key>,
|
key: impl Into<Key>,
|
||||||
geo: Rectangle<i32, Logical>,
|
geo: Rectangle<i32, Local>,
|
||||||
radius: f32,
|
radius: f32,
|
||||||
alpha: f32,
|
alpha: f32,
|
||||||
color: [f32; 3],
|
color: [f32; 3],
|
||||||
|
|
@ -304,7 +304,7 @@ impl BackdropShader {
|
||||||
|
|
||||||
let elem = PixelShaderElement::new(
|
let elem = PixelShaderElement::new(
|
||||||
shader,
|
shader,
|
||||||
geo,
|
geo.as_logical(),
|
||||||
None, // TODO
|
None, // TODO
|
||||||
alpha,
|
alpha,
|
||||||
vec![
|
vec![
|
||||||
|
|
@ -320,8 +320,8 @@ impl BackdropShader {
|
||||||
}
|
}
|
||||||
|
|
||||||
let elem = &mut cache.get_mut(&key).unwrap().1;
|
let elem = &mut cache.get_mut(&key).unwrap().1;
|
||||||
if elem.geometry(1.0.into()).to_logical(1) != geo {
|
if elem.geometry(1.0.into()).to_logical(1) != geo.as_logical() {
|
||||||
elem.resize(geo, None);
|
elem.resize(geo.as_logical(), None);
|
||||||
}
|
}
|
||||||
elem.clone()
|
elem.clone()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
229
src/input/mod.rs
229
src/input/mod.rs
|
|
@ -553,24 +553,18 @@ impl State {
|
||||||
if let Some(seat) = self.common.seat_with_device(&event.device()).cloned() {
|
if let Some(seat) = self.common.seat_with_device(&event.device()).cloned() {
|
||||||
let current_output = seat.active_output();
|
let current_output = seat.active_output();
|
||||||
|
|
||||||
let mut position = seat.get_pointer().unwrap().current_location();
|
let mut position = seat.get_pointer().unwrap().current_location().as_global();
|
||||||
|
|
||||||
let relative_pos = self
|
|
||||||
.common
|
|
||||||
.shell
|
|
||||||
.map_global_to_space(position, ¤t_output);
|
|
||||||
let overview = self.common.shell.overview_mode();
|
let overview = self.common.shell.overview_mode();
|
||||||
let output_geometry = current_output.geometry();
|
|
||||||
let workspace = self.common.shell.workspaces.active_mut(¤t_output);
|
let workspace = self.common.shell.workspaces.active_mut(¤t_output);
|
||||||
let under = State::surface_under(
|
let under = State::surface_under(
|
||||||
position,
|
position,
|
||||||
relative_pos,
|
|
||||||
¤t_output,
|
¤t_output,
|
||||||
output_geometry,
|
|
||||||
&self.common.shell.override_redirect_windows,
|
&self.common.shell.override_redirect_windows,
|
||||||
overview.0.clone(),
|
overview.0.clone(),
|
||||||
workspace,
|
workspace,
|
||||||
);
|
)
|
||||||
|
.map(|(target, pos)| (target, pos.as_logical()));
|
||||||
|
|
||||||
let ptr = seat.get_pointer().unwrap();
|
let ptr = seat.get_pointer().unwrap();
|
||||||
|
|
||||||
|
|
@ -618,7 +612,7 @@ impl State {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
position += event.delta();
|
position += event.delta().as_global();
|
||||||
|
|
||||||
let output = self
|
let output = self
|
||||||
.common
|
.common
|
||||||
|
|
@ -627,18 +621,17 @@ impl State {
|
||||||
.find(|output| output.geometry().to_f64().contains(position))
|
.find(|output| output.geometry().to_f64().contains(position))
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or(current_output.clone());
|
.unwrap_or(current_output.clone());
|
||||||
|
let output_geometry = output.geometry();
|
||||||
|
|
||||||
let workspace = self.common.shell.workspaces.active_mut(&output);
|
let workspace = self.common.shell.workspaces.active_mut(&output);
|
||||||
let output_geometry = output.geometry();
|
|
||||||
let new_under = State::surface_under(
|
let new_under = State::surface_under(
|
||||||
position,
|
position,
|
||||||
relative_pos,
|
|
||||||
&output,
|
&output,
|
||||||
output_geometry,
|
|
||||||
&self.common.shell.override_redirect_windows,
|
&self.common.shell.override_redirect_windows,
|
||||||
overview.0,
|
overview.0,
|
||||||
workspace,
|
workspace,
|
||||||
);
|
)
|
||||||
|
.map(|(target, pos)| (target, pos.as_logical()));
|
||||||
|
|
||||||
position.x = position.x.clamp(
|
position.x = position.x.clamp(
|
||||||
output_geometry.loc.x as f64,
|
output_geometry.loc.x as f64,
|
||||||
|
|
@ -660,13 +653,17 @@ impl State {
|
||||||
}
|
}
|
||||||
if let PointerFocusTarget::Element(element) = surface {
|
if let PointerFocusTarget::Element(element) = surface {
|
||||||
//if !element.is_in_input_region(&(position.to_i32_round() - *surface_loc).to_f64()) {
|
//if !element.is_in_input_region(&(position.to_i32_round() - *surface_loc).to_f64()) {
|
||||||
if !element.is_in_input_region(&(position - surface_loc.to_f64())) {
|
if !element.is_in_input_region(
|
||||||
|
&(position.as_logical() - surface_loc.to_f64()),
|
||||||
|
) {
|
||||||
ptr.frame(self);
|
ptr.frame(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(region) = confine_region {
|
if let Some(region) = confine_region {
|
||||||
if !region.contains(position.to_i32_round() - *surface_loc) {
|
if !region
|
||||||
|
.contains(position.as_logical().to_i32_round() - *surface_loc)
|
||||||
|
{
|
||||||
ptr.frame(self);
|
ptr.frame(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -679,7 +676,7 @@ impl State {
|
||||||
self,
|
self,
|
||||||
under,
|
under,
|
||||||
&MotionEvent {
|
&MotionEvent {
|
||||||
location: position,
|
location: position.as_logical(),
|
||||||
serial,
|
serial,
|
||||||
time: event.time_msec(),
|
time: event.time_msec(),
|
||||||
},
|
},
|
||||||
|
|
@ -720,17 +717,16 @@ impl State {
|
||||||
|
|
||||||
for session in sessions_for_output(&self.common, &output) {
|
for session in sessions_for_output(&self.common, &output) {
|
||||||
if let Some((geometry, offset)) = seat.cursor_geometry(
|
if let Some((geometry, offset)) = seat.cursor_geometry(
|
||||||
position.to_buffer(
|
position.as_logical().to_buffer(
|
||||||
output.current_scale().fractional_scale(),
|
output.current_scale().fractional_scale(),
|
||||||
output.current_transform(),
|
output.current_transform(),
|
||||||
&output.geometry().size.to_f64(),
|
&output_geometry.size.to_f64().as_logical(),
|
||||||
),
|
),
|
||||||
self.common.clock.now(),
|
self.common.clock.now(),
|
||||||
) {
|
) {
|
||||||
session.cursor_info(&seat, InputType::Pointer, geometry, offset);
|
session.cursor_info(&seat, InputType::Pointer, geometry, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
if self.common.seats().position(|x| x == &seat).unwrap() == 0 {
|
if self.common.seats().position(|x| x == &seat).unwrap() == 0 {
|
||||||
let location = if let Some(output) = self.common.shell.outputs.first() {
|
let location = if let Some(output) = self.common.shell.outputs.first() {
|
||||||
|
|
@ -752,28 +748,27 @@ impl State {
|
||||||
let position = geometry.loc.to_f64()
|
let position = geometry.loc.to_f64()
|
||||||
+ smithay::backend::input::AbsolutePositionEvent::position_transformed(
|
+ smithay::backend::input::AbsolutePositionEvent::position_transformed(
|
||||||
&event,
|
&event,
|
||||||
geometry.size,
|
geometry.size.as_logical(),
|
||||||
);
|
)
|
||||||
let relative_pos = self.common.shell.map_global_to_space(position, &output);
|
.as_global();
|
||||||
let overview = self.common.shell.overview_mode();
|
let overview = self.common.shell.overview_mode();
|
||||||
let workspace = self.common.shell.workspaces.active_mut(&output);
|
let workspace = self.common.shell.workspaces.active_mut(&output);
|
||||||
let serial = SERIAL_COUNTER.next_serial();
|
let serial = SERIAL_COUNTER.next_serial();
|
||||||
let under = State::surface_under(
|
let under = State::surface_under(
|
||||||
position,
|
position,
|
||||||
relative_pos,
|
|
||||||
&output,
|
&output,
|
||||||
geometry,
|
|
||||||
&self.common.shell.override_redirect_windows,
|
&self.common.shell.override_redirect_windows,
|
||||||
overview.0,
|
overview.0,
|
||||||
workspace,
|
workspace,
|
||||||
);
|
)
|
||||||
|
.map(|(target, pos)| (target, pos.as_logical()));
|
||||||
|
|
||||||
for session in sessions_for_output(&self.common, &output) {
|
for session in sessions_for_output(&self.common, &output) {
|
||||||
if let Some((geometry, offset)) = seat.cursor_geometry(
|
if let Some((geometry, offset)) = seat.cursor_geometry(
|
||||||
position.to_buffer(
|
position.as_logical().to_buffer(
|
||||||
output.current_scale().fractional_scale(),
|
output.current_scale().fractional_scale(),
|
||||||
output.current_transform(),
|
output.current_transform(),
|
||||||
&output.geometry().size.to_f64(),
|
&geometry.size.to_f64().as_logical(),
|
||||||
),
|
),
|
||||||
self.common.clock.now(),
|
self.common.clock.now(),
|
||||||
) {
|
) {
|
||||||
|
|
@ -785,7 +780,7 @@ impl State {
|
||||||
self,
|
self,
|
||||||
under,
|
under,
|
||||||
&MotionEvent {
|
&MotionEvent {
|
||||||
location: position,
|
location: position.as_logical(),
|
||||||
serial,
|
serial,
|
||||||
time: event.time_msec(),
|
time: event.time_msec(),
|
||||||
},
|
},
|
||||||
|
|
@ -835,22 +830,22 @@ impl State {
|
||||||
&& !seat.get_keyboard().map(|k| k.is_grabbed()).unwrap_or(false)
|
&& !seat.get_keyboard().map(|k| k.is_grabbed()).unwrap_or(false)
|
||||||
{
|
{
|
||||||
let output = seat.active_output();
|
let output = seat.active_output();
|
||||||
let pos = seat.get_pointer().unwrap().current_location();
|
let pos = seat.get_pointer().unwrap().current_location().as_global();
|
||||||
let relative_pos = self.common.shell.map_global_to_space(pos, &output);
|
let relative_pos = pos.to_local(&output);
|
||||||
let overview = self.common.shell.overview_mode();
|
let overview = self.common.shell.overview_mode();
|
||||||
let workspace = self.common.shell.active_space_mut(&output);
|
let workspace = self.common.shell.active_space_mut(&output);
|
||||||
let mut under = None;
|
let mut under = None;
|
||||||
|
|
||||||
if let Some(window) = workspace.get_fullscreen(&output) {
|
if let Some(window) = workspace.get_fullscreen() {
|
||||||
let layers = layer_map_for_output(&output);
|
let layers = layer_map_for_output(&output);
|
||||||
if let Some(layer) =
|
if let Some(layer) =
|
||||||
layers.layer_under(WlrLayer::Overlay, relative_pos)
|
layers.layer_under(WlrLayer::Overlay, relative_pos.as_logical())
|
||||||
{
|
{
|
||||||
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
||||||
if layer.can_receive_keyboard_focus()
|
if layer.can_receive_keyboard_focus()
|
||||||
&& layer
|
&& layer
|
||||||
.surface_under(
|
.surface_under(
|
||||||
relative_pos - layer_loc.to_f64(),
|
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||||
WindowSurfaceType::ALL,
|
WindowSurfaceType::ALL,
|
||||||
)
|
)
|
||||||
.is_some()
|
.is_some()
|
||||||
|
|
@ -864,14 +859,19 @@ impl State {
|
||||||
let done = {
|
let done = {
|
||||||
let layers = layer_map_for_output(&output);
|
let layers = layer_map_for_output(&output);
|
||||||
if let Some(layer) = layers
|
if let Some(layer) = layers
|
||||||
.layer_under(WlrLayer::Overlay, relative_pos)
|
.layer_under(WlrLayer::Overlay, relative_pos.as_logical())
|
||||||
.or_else(|| layers.layer_under(WlrLayer::Top, relative_pos))
|
.or_else(|| {
|
||||||
|
layers.layer_under(
|
||||||
|
WlrLayer::Top,
|
||||||
|
relative_pos.as_logical(),
|
||||||
|
)
|
||||||
|
})
|
||||||
{
|
{
|
||||||
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
||||||
if layer.can_receive_keyboard_focus()
|
if layer.can_receive_keyboard_focus()
|
||||||
&& layer
|
&& layer
|
||||||
.surface_under(
|
.surface_under(
|
||||||
relative_pos - layer_loc.to_f64(),
|
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||||
WindowSurfaceType::ALL,
|
WindowSurfaceType::ALL,
|
||||||
)
|
)
|
||||||
.is_some()
|
.is_some()
|
||||||
|
|
@ -884,35 +884,38 @@ impl State {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if !done {
|
if !done {
|
||||||
if let Some(surface) = workspace.get_maximized(&output) {
|
if let Some((target, _)) =
|
||||||
under = Some(surface.clone().into());
|
workspace.element_under(pos, overview.0)
|
||||||
|
{
|
||||||
|
under = Some(target);
|
||||||
} else {
|
} else {
|
||||||
if let Some((target, _)) =
|
let layers = layer_map_for_output(&output);
|
||||||
workspace.element_under(relative_pos, overview.0)
|
if let Some(layer) = layers
|
||||||
|
.layer_under(
|
||||||
|
WlrLayer::Bottom,
|
||||||
|
relative_pos.as_logical(),
|
||||||
|
)
|
||||||
|
.or_else(|| {
|
||||||
|
layers.layer_under(
|
||||||
|
WlrLayer::Background,
|
||||||
|
relative_pos.as_logical(),
|
||||||
|
)
|
||||||
|
})
|
||||||
{
|
{
|
||||||
under = Some(target);
|
let layer_loc =
|
||||||
} else {
|
layers.layer_geometry(layer).unwrap().loc;
|
||||||
let layers = layer_map_for_output(&output);
|
if layer.can_receive_keyboard_focus()
|
||||||
if let Some(layer) = layers
|
&& layer
|
||||||
.layer_under(WlrLayer::Bottom, pos)
|
.surface_under(
|
||||||
.or_else(|| {
|
relative_pos.as_logical()
|
||||||
layers.layer_under(WlrLayer::Background, pos)
|
- layer_loc.to_f64(),
|
||||||
})
|
WindowSurfaceType::ALL,
|
||||||
|
)
|
||||||
|
.is_some()
|
||||||
{
|
{
|
||||||
let layer_loc =
|
under = Some(layer.clone().into());
|
||||||
layers.layer_geometry(layer).unwrap().loc;
|
}
|
||||||
if layer.can_receive_keyboard_focus()
|
};
|
||||||
&& layer
|
|
||||||
.surface_under(
|
|
||||||
relative_pos - layer_loc.to_f64(),
|
|
||||||
WindowSurfaceType::ALL,
|
|
||||||
)
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
under = Some(layer.clone().into());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1349,7 +1352,7 @@ impl State {
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
&MotionEvent {
|
&MotionEvent {
|
||||||
location: new_pos.to_f64(),
|
location: new_pos.to_f64().as_logical(),
|
||||||
serial,
|
serial,
|
||||||
time,
|
time,
|
||||||
},
|
},
|
||||||
|
|
@ -1386,7 +1389,7 @@ impl State {
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
&MotionEvent {
|
&MotionEvent {
|
||||||
location: new_pos.to_f64(),
|
location: new_pos.to_f64().as_logical(),
|
||||||
serial,
|
serial,
|
||||||
time,
|
time,
|
||||||
},
|
},
|
||||||
|
|
@ -1426,7 +1429,7 @@ impl State {
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
&MotionEvent {
|
&MotionEvent {
|
||||||
location: new_pos.to_f64(),
|
location: new_pos.to_f64().as_logical(),
|
||||||
serial,
|
serial,
|
||||||
time,
|
time,
|
||||||
},
|
},
|
||||||
|
|
@ -1462,7 +1465,7 @@ impl State {
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
&MotionEvent {
|
&MotionEvent {
|
||||||
location: new_pos.to_f64(),
|
location: new_pos.to_f64().as_logical(),
|
||||||
serial,
|
serial,
|
||||||
time,
|
time,
|
||||||
},
|
},
|
||||||
|
|
@ -1705,77 +1708,83 @@ impl State {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn surface_under(
|
pub fn surface_under(
|
||||||
global_pos: Point<f64, Logical>,
|
global_pos: Point<f64, Global>,
|
||||||
relative_pos: Point<f64, Logical>,
|
|
||||||
output: &Output,
|
output: &Output,
|
||||||
output_geo: Rectangle<i32, Logical>,
|
|
||||||
override_redirect_windows: &[X11Surface],
|
override_redirect_windows: &[X11Surface],
|
||||||
overview: OverviewMode,
|
overview: OverviewMode,
|
||||||
workspace: &mut Workspace,
|
workspace: &mut Workspace,
|
||||||
) -> Option<(PointerFocusTarget, Point<i32, Logical>)> {
|
) -> Option<(PointerFocusTarget, Point<i32, Global>)> {
|
||||||
if let Some(window) = workspace.get_fullscreen(output) {
|
let relative_pos = global_pos.to_local(output);
|
||||||
|
let output_geo = output.geometry();
|
||||||
|
|
||||||
|
if let Some(window) = workspace.get_fullscreen() {
|
||||||
let layers = layer_map_for_output(output);
|
let layers = layer_map_for_output(output);
|
||||||
if let Some(layer) = layers.layer_under(WlrLayer::Overlay, relative_pos) {
|
if let Some(layer) = layers.layer_under(WlrLayer::Overlay, relative_pos.as_logical()) {
|
||||||
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
||||||
if layer
|
if layer
|
||||||
.surface_under(relative_pos - layer_loc.to_f64(), WindowSurfaceType::ALL)
|
.surface_under(
|
||||||
|
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||||
|
WindowSurfaceType::ALL,
|
||||||
|
)
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
return Some((layer.clone().into(), output_geo.loc + layer_loc));
|
return Some((layer.clone().into(), output_geo.loc + layer_loc.as_global()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(or) = override_redirect_windows
|
if let Some(or) = override_redirect_windows.iter().find(|or| {
|
||||||
.iter()
|
or.is_in_input_region(&(global_pos.as_logical() - or.geometry().loc.to_f64()))
|
||||||
.find(|or| or.is_in_input_region(&(global_pos - or.geometry().loc.to_f64())))
|
}) {
|
||||||
{
|
return Some((or.clone().into(), or.geometry().loc.as_global()));
|
||||||
return Some((or.clone().into(), or.geometry().loc));
|
|
||||||
}
|
}
|
||||||
Some((window.clone().into(), output_geo.loc))
|
Some((window.clone().into(), output_geo.loc))
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
let layers = layer_map_for_output(output);
|
let layers = layer_map_for_output(output);
|
||||||
if let Some(layer) = layers
|
if let Some(layer) = layers
|
||||||
.layer_under(WlrLayer::Overlay, relative_pos)
|
.layer_under(WlrLayer::Overlay, relative_pos.as_logical())
|
||||||
.or_else(|| layers.layer_under(WlrLayer::Top, relative_pos))
|
.or_else(|| layers.layer_under(WlrLayer::Top, relative_pos.as_logical()))
|
||||||
{
|
{
|
||||||
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
||||||
if layer
|
if layer
|
||||||
.surface_under(relative_pos - layer_loc.to_f64(), WindowSurfaceType::ALL)
|
.surface_under(
|
||||||
|
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||||
|
WindowSurfaceType::ALL,
|
||||||
|
)
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
return Some((layer.clone().into(), output_geo.loc + layer_loc));
|
return Some((
|
||||||
|
layer.clone().into(),
|
||||||
|
output_geo.loc + layer_loc.as_global(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(or) = override_redirect_windows
|
if let Some(or) = override_redirect_windows.iter().find(|or| {
|
||||||
.iter()
|
or.is_in_input_region(&(global_pos.as_logical() - or.geometry().loc.to_f64()))
|
||||||
.find(|or| or.is_in_input_region(&(global_pos - or.geometry().loc.to_f64())))
|
}) {
|
||||||
{
|
return Some((or.clone().into(), or.geometry().loc.as_global()));
|
||||||
return Some((or.clone().into(), or.geometry().loc));
|
|
||||||
}
|
}
|
||||||
if let Some(surface) = workspace.get_maximized(output) {
|
if let Some((target, loc)) = workspace.element_under(global_pos, overview) {
|
||||||
let offset = layer_map_for_output(output).non_exclusive_zone().loc;
|
return Some((target, loc));
|
||||||
return Some((surface.clone().into(), output_geo.loc + offset));
|
}
|
||||||
} else {
|
{
|
||||||
if let Some((target, loc)) = workspace.element_under(relative_pos, overview) {
|
let layers = layer_map_for_output(output);
|
||||||
return Some((target, loc + (global_pos - relative_pos).to_i32_round()));
|
if let Some(layer) = layers
|
||||||
}
|
.layer_under(WlrLayer::Bottom, relative_pos.as_logical())
|
||||||
|
.or_else(|| layers.layer_under(WlrLayer::Background, relative_pos.as_logical()))
|
||||||
{
|
{
|
||||||
let layers = layer_map_for_output(output);
|
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
||||||
if let Some(layer) = layers
|
if layer
|
||||||
.layer_under(WlrLayer::Bottom, relative_pos)
|
.surface_under(
|
||||||
.or_else(|| layers.layer_under(WlrLayer::Background, relative_pos))
|
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||||
|
WindowSurfaceType::ALL,
|
||||||
|
)
|
||||||
|
.is_some()
|
||||||
{
|
{
|
||||||
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
return Some((
|
||||||
if layer
|
layer.clone().into(),
|
||||||
.surface_under(
|
output_geo.loc + layer_loc.as_global(),
|
||||||
relative_pos - layer_loc.to_f64(),
|
));
|
||||||
WindowSurfaceType::ALL,
|
|
||||||
)
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
return Some((layer.clone().into(), output_geo.loc + layer_loc));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
GlMultiError, GlMultiFrame, GlMultiRenderer,
|
GlMultiError, GlMultiFrame, GlMultiRenderer,
|
||||||
},
|
},
|
||||||
state::State,
|
state::State,
|
||||||
utils::prelude::SeatExt,
|
utils::prelude::*,
|
||||||
};
|
};
|
||||||
use calloop::LoopHandle;
|
use calloop::LoopHandle;
|
||||||
use id_tree::NodeId;
|
use id_tree::NodeId;
|
||||||
|
|
@ -94,8 +94,8 @@ pub struct CosmicMapped {
|
||||||
//tiling
|
//tiling
|
||||||
pub tiling_node_id: Arc<Mutex<Option<NodeId>>>,
|
pub tiling_node_id: Arc<Mutex<Option<NodeId>>>,
|
||||||
//floating
|
//floating
|
||||||
pub(super) last_geometry: Arc<Mutex<Option<Rectangle<i32, Logical>>>>,
|
|
||||||
pub(super) resize_state: Arc<Mutex<Option<ResizeState>>>,
|
pub(super) resize_state: Arc<Mutex<Option<ResizeState>>>,
|
||||||
|
pub last_geometry: Arc<Mutex<Option<Rectangle<i32, Local>>>>,
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
debug: Arc<Mutex<Option<smithay_egui::EguiState>>>,
|
debug: Arc<Mutex<Option<smithay_egui::EguiState>>>,
|
||||||
|
|
@ -108,6 +108,7 @@ impl fmt::Debug for CosmicMapped {
|
||||||
.field("last_cursor_position", &self.last_cursor_position)
|
.field("last_cursor_position", &self.last_cursor_position)
|
||||||
.field("tiling_node_id", &self.tiling_node_id)
|
.field("tiling_node_id", &self.tiling_node_id)
|
||||||
.field("resize_state", &self.resize_state)
|
.field("resize_state", &self.resize_state)
|
||||||
|
.field("last_geometry", &self.last_geometry)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -361,7 +362,7 @@ impl CosmicMapped {
|
||||||
window.is_activated(pending)
|
window.is_activated(pending)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
|
||||||
match &self.element {
|
match &self.element {
|
||||||
CosmicMappedInternal::Stack(s) => s.set_geometry(geo),
|
CosmicMappedInternal::Stack(s) => s.set_geometry(geo),
|
||||||
CosmicMappedInternal::Window(w) => w.set_geometry(geo),
|
CosmicMappedInternal::Window(w) => w.set_geometry(geo),
|
||||||
|
|
@ -501,11 +502,9 @@ impl CosmicMapped {
|
||||||
|
|
||||||
let stack = CosmicStack::new(std::iter::once(surface), handle);
|
let stack = CosmicStack::new(std::iter::once(surface), handle);
|
||||||
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
|
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
|
||||||
stack.set_geometry(geo);
|
stack.set_geometry(geo.to_global(&output));
|
||||||
}
|
|
||||||
for (output, overlap) in outputs {
|
|
||||||
stack.output_enter(output, overlap);
|
|
||||||
}
|
}
|
||||||
|
stack.output_enter(output, overlap);
|
||||||
stack.set_activate(activated);
|
stack.set_activate(activated);
|
||||||
stack.active().send_configure();
|
stack.active().send_configure();
|
||||||
stack.refresh();
|
stack.refresh();
|
||||||
|
|
@ -527,11 +526,9 @@ impl CosmicMapped {
|
||||||
let window = CosmicWindow::new(surface, handle);
|
let window = CosmicWindow::new(surface, handle);
|
||||||
|
|
||||||
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
|
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
|
||||||
window.set_geometry(geo);
|
window.set_geometry(geo.to_global(&output));
|
||||||
}
|
|
||||||
for (output, overlap) in outputs {
|
|
||||||
window.output_enter(output, overlap);
|
|
||||||
}
|
}
|
||||||
|
window.output_enter(output, overlap);
|
||||||
window.set_activate(self.is_activated(true));
|
window.set_activate(self.is_activated(true));
|
||||||
window.surface().send_configure();
|
window.surface().send_configure();
|
||||||
window.refresh();
|
window.refresh();
|
||||||
|
|
@ -1068,8 +1065,8 @@ impl From<CosmicWindow> for CosmicMapped {
|
||||||
element: CosmicMappedInternal::Window(w),
|
element: CosmicMappedInternal::Window(w),
|
||||||
last_cursor_position: Arc::new(Mutex::new(HashMap::new())),
|
last_cursor_position: Arc::new(Mutex::new(HashMap::new())),
|
||||||
tiling_node_id: Arc::new(Mutex::new(None)),
|
tiling_node_id: Arc::new(Mutex::new(None)),
|
||||||
last_geometry: Arc::new(Mutex::new(None)),
|
|
||||||
resize_state: Arc::new(Mutex::new(None)),
|
resize_state: Arc::new(Mutex::new(None)),
|
||||||
|
last_geometry: Arc::new(Mutex::new(None)),
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
debug: Arc::new(Mutex::new(None)),
|
debug: Arc::new(Mutex::new(None)),
|
||||||
}
|
}
|
||||||
|
|
@ -1082,8 +1079,8 @@ impl From<CosmicStack> for CosmicMapped {
|
||||||
element: CosmicMappedInternal::Stack(s),
|
element: CosmicMappedInternal::Stack(s),
|
||||||
last_cursor_position: Arc::new(Mutex::new(HashMap::new())),
|
last_cursor_position: Arc::new(Mutex::new(HashMap::new())),
|
||||||
tiling_node_id: Arc::new(Mutex::new(None)),
|
tiling_node_id: Arc::new(Mutex::new(None)),
|
||||||
last_geometry: Arc::new(Mutex::new(None)),
|
|
||||||
resize_state: Arc::new(Mutex::new(None)),
|
resize_state: Arc::new(Mutex::new(None)),
|
||||||
|
last_geometry: Arc::new(Mutex::new(None)),
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
debug: Arc::new(Mutex::new(None)),
|
debug: Arc::new(Mutex::new(None)),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
state::State,
|
state::State,
|
||||||
utils::iced::{IcedElement, Program},
|
utils::iced::{IcedElement, Program},
|
||||||
utils::prelude::SeatExt,
|
utils::prelude::*,
|
||||||
wayland::handlers::screencopy::ScreencopySessions,
|
wayland::handlers::screencopy::ScreencopySessions,
|
||||||
};
|
};
|
||||||
use calloop::LoopHandle;
|
use calloop::LoopHandle;
|
||||||
|
|
@ -91,7 +91,7 @@ pub struct CosmicStackInternal {
|
||||||
override_alive: Arc<AtomicBool>,
|
override_alive: Arc<AtomicBool>,
|
||||||
last_seat: Arc<Mutex<Option<(Seat<State>, Serial)>>>,
|
last_seat: Arc<Mutex<Option<(Seat<State>, Serial)>>>,
|
||||||
last_location: Arc<Mutex<Option<(Point<f64, Logical>, Serial, u32)>>>,
|
last_location: Arc<Mutex<Option<(Point<f64, Logical>, Serial, u32)>>>,
|
||||||
geometry: Arc<Mutex<Option<Rectangle<i32, Logical>>>>,
|
geometry: Arc<Mutex<Option<Rectangle<i32, Global>>>>,
|
||||||
mask: Arc<Mutex<Option<tiny_skia::Mask>>>,
|
mask: Arc<Mutex<Option<tiny_skia::Mask>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -406,7 +406,7 @@ impl CosmicStack {
|
||||||
Point::from((0, TAB_HEIGHT))
|
Point::from((0, TAB_HEIGHT))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
|
||||||
self.0.with_program(|p| {
|
self.0.with_program(|p| {
|
||||||
let loc = (geo.loc.x, geo.loc.y + TAB_HEIGHT);
|
let loc = (geo.loc.x, geo.loc.y + TAB_HEIGHT);
|
||||||
let size = (geo.size.w, geo.size.h - TAB_HEIGHT);
|
let size = (geo.size.w, geo.size.h - TAB_HEIGHT);
|
||||||
|
|
@ -1047,11 +1047,11 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
if let Some(workspace) = data.common.shell.space_for(stack_mapped) {
|
if let Some(workspace) = data.common.shell.space_for(stack_mapped) {
|
||||||
// TODO: Unify this somehow with Shell::move_request/Workspace::move_request
|
// TODO: Unify this somehow with Shell::move_request/Workspace::move_request
|
||||||
let button = 0x110; // BTN_LEFT
|
let button = 0x110; // BTN_LEFT
|
||||||
let pos = event.location;
|
let pos = event.location.as_global();
|
||||||
let start_data = PointerGrabStartData {
|
let start_data = PointerGrabStartData {
|
||||||
focus: None,
|
focus: None,
|
||||||
button,
|
button,
|
||||||
location: pos,
|
location: pos.as_logical(),
|
||||||
};
|
};
|
||||||
let mapped = CosmicMapped::from(CosmicWindow::new(
|
let mapped = CosmicMapped::from(CosmicWindow::new(
|
||||||
surface,
|
surface,
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ use smithay::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
state::{State, SurfaceDmabufFeedback},
|
state::{State, SurfaceDmabufFeedback},
|
||||||
|
utils::prelude::*,
|
||||||
wayland::handlers::decoration::PreferredDecorationMode,
|
wayland::handlers::decoration::PreferredDecorationMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -122,13 +123,13 @@ impl CosmicSurface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
|
||||||
match self {
|
match self {
|
||||||
CosmicSurface::Wayland(window) => window
|
CosmicSurface::Wayland(window) => window
|
||||||
.toplevel()
|
.toplevel()
|
||||||
.with_pending_state(|state| state.size = Some(geo.size)),
|
.with_pending_state(|state| state.size = Some(geo.size.as_logical())),
|
||||||
CosmicSurface::X11(surface) => {
|
CosmicSurface::X11(surface) => {
|
||||||
let _ = surface.configure(geo);
|
let _ = surface.configure(geo.as_logical());
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::{
|
||||||
state::State,
|
state::State,
|
||||||
utils::{
|
utils::{
|
||||||
iced::{IcedElement, Program},
|
iced::{IcedElement, Program},
|
||||||
prelude::SeatExt,
|
prelude::*,
|
||||||
},
|
},
|
||||||
wayland::handlers::screencopy::ScreencopySessions,
|
wayland::handlers::screencopy::ScreencopySessions,
|
||||||
};
|
};
|
||||||
|
|
@ -132,7 +132,7 @@ impl CosmicWindow {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
|
||||||
self.0.with_program(|p| {
|
self.0.with_program(|p| {
|
||||||
let loc = (
|
let loc = (
|
||||||
geo.loc.x,
|
geo.loc.x,
|
||||||
|
|
|
||||||
|
|
@ -82,15 +82,21 @@ impl MoveGrabState {
|
||||||
|
|
||||||
let mut window_geo = self.window.geometry();
|
let mut window_geo = self.window.geometry();
|
||||||
window_geo.loc += cursor_at.to_i32_round() + self.window_offset;
|
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();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
let output_scale: Scale<f64> = output.current_scale().fractional_scale().into();
|
let output_scale: Scale<f64> = output.current_scale().fractional_scale().into();
|
||||||
let scaling_offset =
|
let scaling_offset =
|
||||||
self.window_offset - self.window_offset.to_f64().upscale(scale).to_i32_round();
|
self.window_offset - self.window_offset.to_f64().upscale(scale).to_i32_round();
|
||||||
let render_location =
|
let render_location = cursor_at.to_i32_round() - output.geometry().loc.as_logical()
|
||||||
cursor_at.to_i32_round() - output.geometry().loc + self.window_offset - scaling_offset;
|
+ self.window_offset
|
||||||
|
- scaling_offset;
|
||||||
|
|
||||||
let focus_element = if self.indicator_thickness > 0 {
|
let focus_element = if self.indicator_thickness > 0 {
|
||||||
Some(
|
Some(
|
||||||
|
|
@ -105,7 +111,8 @@ impl MoveGrabState {
|
||||||
.to_f64()
|
.to_f64()
|
||||||
.upscale(scale)
|
.upscale(scale)
|
||||||
.to_i32_round(),
|
.to_i32_round(),
|
||||||
),
|
)
|
||||||
|
.as_local(),
|
||||||
self.indicator_thickness,
|
self.indicator_thickness,
|
||||||
output_scale.x,
|
output_scale.x,
|
||||||
1.0,
|
1.0,
|
||||||
|
|
@ -208,6 +215,7 @@ impl PointerGrab<State> for MoveGrab {
|
||||||
.find(|output| {
|
.find(|output| {
|
||||||
output
|
output
|
||||||
.geometry()
|
.geometry()
|
||||||
|
.as_logical()
|
||||||
.contains(handle.current_location().to_i32_round())
|
.contains(handle.current_location().to_i32_round())
|
||||||
})
|
})
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|
@ -233,8 +241,8 @@ impl PointerGrab<State> for MoveGrab {
|
||||||
if let Some(grab_state) = borrow.as_mut().and_then(|s| s.as_mut()) {
|
if let Some(grab_state) = borrow.as_mut().and_then(|s| s.as_mut()) {
|
||||||
let mut window_geo = self.window.geometry();
|
let mut window_geo = self.window.geometry();
|
||||||
window_geo.loc += event.location.to_i32_round() + grab_state.window_offset;
|
window_geo.loc += event.location.to_i32_round() + grab_state.window_offset;
|
||||||
for output in &state.common.shell.outputs {
|
for output in state.common.shell.outputs() {
|
||||||
if let Some(overlap) = output.geometry().intersection(window_geo) {
|
if let Some(overlap) = output.geometry().as_logical().intersection(window_geo) {
|
||||||
if self.window_outputs.insert(output.clone()) {
|
if self.window_outputs.insert(output.clone()) {
|
||||||
self.window.output_enter(output, overlap);
|
self.window.output_enter(output, overlap);
|
||||||
if let Some(indicator) =
|
if let Some(indicator) =
|
||||||
|
|
@ -261,11 +269,20 @@ impl PointerGrab<State> for MoveGrab {
|
||||||
|
|
||||||
if indicator_location.is_some() != grab_state.stacking_indicator.is_some() {
|
if indicator_location.is_some() != grab_state.stacking_indicator.is_some() {
|
||||||
grab_state.stacking_indicator = indicator_location.map(|geo| {
|
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 {
|
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>,
|
start_data: PointerGrabStartData<State>,
|
||||||
window: CosmicMapped,
|
window: CosmicMapped,
|
||||||
seat: &Seat<State>,
|
seat: &Seat<State>,
|
||||||
initial_cursor_location: Point<f64, Logical>,
|
initial_cursor_location: Point<f64, Global>,
|
||||||
initial_window_location: Point<i32, Logical>,
|
initial_window_location: Point<i32, Global>,
|
||||||
indicator_thickness: u8,
|
indicator_thickness: u8,
|
||||||
was_tiled: bool,
|
was_tiled: bool,
|
||||||
) -> MoveGrab {
|
) -> MoveGrab {
|
||||||
|
|
@ -409,7 +426,8 @@ impl MoveGrab {
|
||||||
|
|
||||||
let grab_state = MoveGrabState {
|
let grab_state = MoveGrabState {
|
||||||
window: window.clone(),
|
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,
|
indicator_thickness,
|
||||||
start: Instant::now(),
|
start: Instant::now(),
|
||||||
stacking_indicator: None,
|
stacking_indicator: None,
|
||||||
|
|
@ -451,16 +469,16 @@ impl MoveGrab {
|
||||||
// No more buttons are pressed, release the grab.
|
// No more buttons are pressed, release the grab.
|
||||||
let output = self.seat.active_output();
|
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
|
.seat
|
||||||
.user_data()
|
.user_data()
|
||||||
.get::<SeatMoveGrabState>()
|
.get::<SeatMoveGrabState>()
|
||||||
.and_then(|s| s.borrow_mut().take())
|
.and_then(|s| s.borrow_mut().take())
|
||||||
{
|
{
|
||||||
if grab_state.window.alive() {
|
if grab_state.window.alive() {
|
||||||
let window_location = handle.current_location().to_i32_round()
|
let window_location = (handle.current_location().to_i32_round()
|
||||||
- output.geometry().loc
|
+ grab_state.window_offset)
|
||||||
+ grab_state.window_offset;
|
.as_global();
|
||||||
|
|
||||||
let workspace_handle = state.common.shell.active_space(&output).handle;
|
let workspace_handle = state.common.shell.active_space(&output).handle;
|
||||||
for old_output in self.window_outputs.iter().filter(|o| *o != &output) {
|
for old_output in self.window_outputs.iter().filter(|o| *o != &output) {
|
||||||
|
|
@ -480,41 +498,26 @@ impl MoveGrab {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.tiling {
|
if self.tiling {
|
||||||
Some(
|
let (window, location) = state
|
||||||
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
|
|
||||||
.common
|
.common
|
||||||
.shell
|
.shell
|
||||||
.active_space_mut(&output)
|
.active_space_mut(&output)
|
||||||
.floating_layer
|
.tiling_layer
|
||||||
.map_internal(grab_state.window, &output, Some(window_location + offset));
|
.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();
|
Some((self.window.clone(), window_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(),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
@ -535,7 +538,7 @@ impl MoveGrab {
|
||||||
state,
|
state,
|
||||||
Some((
|
Some((
|
||||||
PointerFocusTarget::from(mapped.clone()),
|
PointerFocusTarget::from(mapped.clone()),
|
||||||
position - self.window.geometry().loc,
|
position.as_logical() - self.window.geometry().loc,
|
||||||
)),
|
)),
|
||||||
&MotionEvent {
|
&MotionEvent {
|
||||||
location: handle.current_location(),
|
location: handle.current_location(),
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,10 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
||||||
self.window.set_resizing(true);
|
self.window.set_resizing(true);
|
||||||
self.window.set_geometry(Rectangle::from_loc_and_size(
|
self.window.set_geometry(Rectangle::from_loc_and_size(
|
||||||
match self.window.active_window() {
|
match self.window.active_window() {
|
||||||
CosmicSurface::X11(s) => s.geometry().loc,
|
CosmicSurface::X11(s) => s.geometry().loc.as_global(),
|
||||||
_ => (0, 0).into(),
|
_ => (0, 0).into(),
|
||||||
},
|
},
|
||||||
self.last_window_size,
|
self.last_window_size.as_global(),
|
||||||
));
|
));
|
||||||
self.window.configure();
|
self.window.configure();
|
||||||
}
|
}
|
||||||
|
|
@ -139,10 +139,10 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
||||||
self.window.set_resizing(false);
|
self.window.set_resizing(false);
|
||||||
self.window.set_geometry(Rectangle::from_loc_and_size(
|
self.window.set_geometry(Rectangle::from_loc_and_size(
|
||||||
match self.window.active_window() {
|
match self.window.active_window() {
|
||||||
CosmicSurface::X11(s) => s.geometry().loc,
|
CosmicSurface::X11(s) => s.geometry().loc.as_global(),
|
||||||
_ => (0, 0).into(),
|
_ => (0, 0).into(),
|
||||||
},
|
},
|
||||||
self.last_window_size,
|
self.last_window_size.as_global(),
|
||||||
));
|
));
|
||||||
self.window.configure();
|
self.window.configure();
|
||||||
|
|
||||||
|
|
@ -271,7 +271,13 @@ impl ResizeSurfaceGrab {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_resize_to_location(window: CosmicMapped, space: &mut Workspace) {
|
pub fn apply_resize_to_location(window: CosmicMapped, space: &mut Workspace) {
|
||||||
if let Some(location) = space.floating_layer.space.element_location(&window) {
|
if let Some(location) = space
|
||||||
|
.floating_layer
|
||||||
|
.space
|
||||||
|
.element_location(&window)
|
||||||
|
.map(PointExt::as_local)
|
||||||
|
.map(|p| p.to_global(space.output()))
|
||||||
|
{
|
||||||
let mut new_location = None;
|
let mut new_location = None;
|
||||||
|
|
||||||
let mut resize_state = window.resize_state.lock().unwrap();
|
let mut resize_state = window.resize_state.lock().unwrap();
|
||||||
|
|
@ -316,13 +322,13 @@ impl ResizeSurfaceGrab {
|
||||||
CosmicSurface::Wayland(window) => {
|
CosmicSurface::Wayland(window) => {
|
||||||
update_reactive_popups(
|
update_reactive_popups(
|
||||||
&window,
|
&window,
|
||||||
new_location + offset,
|
new_location + offset.as_global(),
|
||||||
space.floating_layer.space.outputs(),
|
space.floating_layer.space.outputs(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
CosmicSurface::X11(surface) => {
|
CosmicSurface::X11(surface) => {
|
||||||
let mut geometry = surface.geometry();
|
let mut geometry = surface.geometry();
|
||||||
geometry.loc += location - new_location;
|
geometry.loc += (location - new_location).as_logical();
|
||||||
let _ = surface.configure(geometry);
|
let _ = surface.configure(geometry);
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|
@ -331,7 +337,7 @@ impl ResizeSurfaceGrab {
|
||||||
space
|
space
|
||||||
.floating_layer
|
.floating_layer
|
||||||
.space
|
.space
|
||||||
.map_element(window, new_location, false);
|
.map_element(window, new_location.as_logical(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -471,7 +471,7 @@ impl FloatingLayout {
|
||||||
})
|
})
|
||||||
.then_some(pos);
|
.then_some(pos);
|
||||||
|
|
||||||
self.map_internal(mapped.clone(), &output, position);
|
self.map_internal(mapped.clone(), position.map(PointExt::as_local), None);
|
||||||
return MoveResult::ShiftFocus(KeyboardFocusTarget::Element(mapped));
|
return MoveResult::ShiftFocus(KeyboardFocusTarget::Element(mapped));
|
||||||
}
|
}
|
||||||
StackMoveResult::Default => {}
|
StackMoveResult::Default => {}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ pub struct NodeDesc {
|
||||||
enum TargetZone {
|
enum TargetZone {
|
||||||
Initial,
|
Initial,
|
||||||
InitialPlaceholder(NodeId),
|
InitialPlaceholder(NodeId),
|
||||||
WindowStack(NodeId, Rectangle<i32, Logical>),
|
WindowStack(NodeId, Rectangle<i32, Local>),
|
||||||
WindowSplit(NodeId, Direction),
|
WindowSplit(NodeId, Direction),
|
||||||
GroupEdge(NodeId, Direction),
|
GroupEdge(NodeId, Direction),
|
||||||
GroupInterior(NodeId, usize),
|
GroupInterior(NodeId, usize),
|
||||||
|
|
@ -171,22 +171,22 @@ pub enum Data {
|
||||||
Group {
|
Group {
|
||||||
orientation: Orientation,
|
orientation: Orientation,
|
||||||
sizes: Vec<i32>,
|
sizes: Vec<i32>,
|
||||||
last_geometry: Rectangle<i32, Logical>,
|
last_geometry: Rectangle<i32, Local>,
|
||||||
alive: Arc<()>,
|
alive: Arc<()>,
|
||||||
pill_indicator: Option<PillIndicator>,
|
pill_indicator: Option<PillIndicator>,
|
||||||
},
|
},
|
||||||
Mapped {
|
Mapped {
|
||||||
mapped: CosmicMapped,
|
mapped: CosmicMapped,
|
||||||
last_geometry: Rectangle<i32, Logical>,
|
last_geometry: Rectangle<i32, Local>,
|
||||||
},
|
},
|
||||||
Placeholder {
|
Placeholder {
|
||||||
last_geometry: Rectangle<i32, Logical>,
|
last_geometry: Rectangle<i32, Local>,
|
||||||
initial_placeholder: bool,
|
initial_placeholder: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Data {
|
impl Data {
|
||||||
fn new_group(orientation: Orientation, geo: Rectangle<i32, Logical>) -> Data {
|
fn new_group(orientation: Orientation, geo: Rectangle<i32, Local>) -> Data {
|
||||||
Data::Group {
|
Data::Group {
|
||||||
orientation,
|
orientation,
|
||||||
sizes: vec![
|
sizes: vec![
|
||||||
|
|
@ -296,7 +296,7 @@ impl Data {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn geometry(&self) -> &Rectangle<i32, Logical> {
|
fn geometry(&self) -> &Rectangle<i32, Local> {
|
||||||
match self {
|
match self {
|
||||||
Data::Group { last_geometry, .. } => last_geometry,
|
Data::Group { last_geometry, .. } => last_geometry,
|
||||||
Data::Mapped { last_geometry, .. } => last_geometry,
|
Data::Mapped { last_geometry, .. } => last_geometry,
|
||||||
|
|
@ -304,7 +304,7 @@ impl Data {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_geometry(&mut self, geo: Rectangle<i32, Logical>) {
|
fn update_geometry(&mut self, geo: Rectangle<i32, Local>) {
|
||||||
match self {
|
match self {
|
||||||
Data::Group {
|
Data::Group {
|
||||||
orientation,
|
orientation,
|
||||||
|
|
@ -2816,7 +2816,9 @@ impl TilingLayout {
|
||||||
let mut configures = Vec::new();
|
let mut configures = Vec::new();
|
||||||
|
|
||||||
let (outer, inner) = gaps;
|
let (outer, inner) = gaps;
|
||||||
let mut geo = layer_map_for_output(&output).non_exclusive_zone();
|
let mut geo = layer_map_for_output(&output)
|
||||||
|
.non_exclusive_zone()
|
||||||
|
.as_local();
|
||||||
geo.loc.x += outer;
|
geo.loc.x += outer;
|
||||||
geo.loc.y += outer;
|
geo.loc.y += outer;
|
||||||
geo.size.w -= outer * 2;
|
geo.size.w -= outer * 2;
|
||||||
|
|
@ -3861,8 +3863,8 @@ fn swap_factor(size: Size<i32, Logical>) -> f64 {
|
||||||
|
|
||||||
fn swap_geometry(
|
fn swap_geometry(
|
||||||
size: Size<i32, Logical>,
|
size: Size<i32, Logical>,
|
||||||
relative_to: Rectangle<i32, Logical>,
|
relative_to: Rectangle<i32, Local>,
|
||||||
) -> Rectangle<i32, Logical> {
|
) -> Rectangle<i32, Local> {
|
||||||
let factor = swap_factor(size);
|
let factor = swap_factor(size);
|
||||||
|
|
||||||
let new_size = Size::from((
|
let new_size = Size::from((
|
||||||
|
|
@ -3881,7 +3883,7 @@ fn swap_geometry(
|
||||||
fn geometries_for_groupview<'a, R>(
|
fn geometries_for_groupview<'a, R>(
|
||||||
tree: &Tree<Data>,
|
tree: &Tree<Data>,
|
||||||
renderer: impl Into<Option<&'a mut R>>,
|
renderer: impl Into<Option<&'a mut R>>,
|
||||||
non_exclusive_zone: Rectangle<i32, Logical>,
|
non_exclusive_zone: Rectangle<i32, Local>,
|
||||||
seat: Option<&Seat<State>>,
|
seat: Option<&Seat<State>>,
|
||||||
alpha: f32,
|
alpha: f32,
|
||||||
transition: f32,
|
transition: f32,
|
||||||
|
|
@ -3891,7 +3893,7 @@ fn geometries_for_groupview<'a, R>(
|
||||||
swap_desc: Option<NodeDesc>,
|
swap_desc: Option<NodeDesc>,
|
||||||
swap_tree: Option<&Tree<Data>>,
|
swap_tree: Option<&Tree<Data>>,
|
||||||
) -> (
|
) -> (
|
||||||
HashMap<NodeId, Rectangle<i32, Logical>>,
|
HashMap<NodeId, Rectangle<i32, Local>>,
|
||||||
Vec<CosmicMappedRenderElement<R>>,
|
Vec<CosmicMappedRenderElement<R>>,
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
@ -3921,7 +3923,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut elements = Vec::new();
|
let mut elements = Vec::new();
|
||||||
let mut geometries: HashMap<NodeId, Rectangle<i32, Logical>> = HashMap::new();
|
let mut geometries: HashMap<NodeId, Rectangle<i32, Local>> = HashMap::new();
|
||||||
let alpha = alpha * transition;
|
let alpha = alpha * transition;
|
||||||
|
|
||||||
let focused = seat
|
let focused = seat
|
||||||
|
|
@ -4268,7 +4270,7 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let swap_geo = swap_geometry(
|
let swap_geo = swap_geometry(
|
||||||
geo.size,
|
geo.size.as_logical(),
|
||||||
focused_geo.unwrap_or({
|
focused_geo.unwrap_or({
|
||||||
let mut geo = non_exclusive_zone;
|
let mut geo = non_exclusive_zone;
|
||||||
geo.loc += (WINDOW_BACKDROP_BORDER, WINDOW_BACKDROP_BORDER).into();
|
geo.loc += (WINDOW_BACKDROP_BORDER, WINDOW_BACKDROP_BORDER).into();
|
||||||
|
|
@ -4469,7 +4471,7 @@ where
|
||||||
if matches!(swap_desc, Some(ref desc) if &desc.node == &node_id && desc.stack_window.is_none())
|
if matches!(swap_desc, Some(ref desc) if &desc.node == &node_id && desc.stack_window.is_none())
|
||||||
{
|
{
|
||||||
let swap_geo = swap_geometry(
|
let swap_geo = swap_geometry(
|
||||||
geo.size,
|
geo.size.as_logical(),
|
||||||
focused_geo.unwrap_or({
|
focused_geo.unwrap_or({
|
||||||
let mut geo = non_exclusive_zone;
|
let mut geo = non_exclusive_zone;
|
||||||
geo.loc += (WINDOW_BACKDROP_BORDER, WINDOW_BACKDROP_BORDER).into();
|
geo.loc += (WINDOW_BACKDROP_BORDER, WINDOW_BACKDROP_BORDER).into();
|
||||||
|
|
@ -4523,7 +4525,7 @@ fn render_old_tree<R>(
|
||||||
reference_tree: &Tree<Data>,
|
reference_tree: &Tree<Data>,
|
||||||
target_tree: &Tree<Data>,
|
target_tree: &Tree<Data>,
|
||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
geometries: Option<HashMap<NodeId, Rectangle<i32, Logical>>>,
|
geometries: Option<HashMap<NodeId, Rectangle<i32, Local>>>,
|
||||||
output_scale: f64,
|
output_scale: f64,
|
||||||
percentage: f32,
|
percentage: f32,
|
||||||
is_swap_mode: bool,
|
is_swap_mode: bool,
|
||||||
|
|
@ -4585,7 +4587,10 @@ where
|
||||||
.unwrap_or(*original_geo);
|
.unwrap_or(*original_geo);
|
||||||
|
|
||||||
let crop_rect = geo.clone();
|
let crop_rect = geo.clone();
|
||||||
let original_location = original_geo.loc.to_physical_precise_round(output_scale)
|
let original_location = original_geo
|
||||||
|
.loc
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale)
|
||||||
- mapped
|
- mapped
|
||||||
.geometry()
|
.geometry()
|
||||||
.loc
|
.loc
|
||||||
|
|
@ -4605,7 +4610,9 @@ where
|
||||||
let cropped = CropRenderElement::from_element(
|
let cropped = CropRenderElement::from_element(
|
||||||
elem,
|
elem,
|
||||||
output_scale,
|
output_scale,
|
||||||
crop_rect.to_physical_precise_round(output_scale),
|
crop_rect
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale),
|
||||||
)?;
|
)?;
|
||||||
let rescaled = RescaleRenderElement::from_element(
|
let rescaled = RescaleRenderElement::from_element(
|
||||||
cropped,
|
cropped,
|
||||||
|
|
@ -4615,6 +4622,7 @@ where
|
||||||
let relocated = RelocateRenderElement::from_element(
|
let relocated = RelocateRenderElement::from_element(
|
||||||
rescaled,
|
rescaled,
|
||||||
(geo.loc - original_geo.loc)
|
(geo.loc - original_geo.loc)
|
||||||
|
.as_logical()
|
||||||
.to_physical_precise_round(output_scale),
|
.to_physical_precise_round(output_scale),
|
||||||
Relocate::Relative,
|
Relocate::Relative,
|
||||||
);
|
);
|
||||||
|
|
@ -4626,7 +4634,9 @@ where
|
||||||
let cropped = CropRenderElement::from_element(
|
let cropped = CropRenderElement::from_element(
|
||||||
elem,
|
elem,
|
||||||
output_scale,
|
output_scale,
|
||||||
crop_rect.to_physical_precise_round(output_scale),
|
crop_rect
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale),
|
||||||
)?;
|
)?;
|
||||||
let rescaled = RescaleRenderElement::from_element(
|
let rescaled = RescaleRenderElement::from_element(
|
||||||
cropped,
|
cropped,
|
||||||
|
|
@ -4636,6 +4646,7 @@ where
|
||||||
let relocated = RelocateRenderElement::from_element(
|
let relocated = RelocateRenderElement::from_element(
|
||||||
rescaled,
|
rescaled,
|
||||||
(geo.loc - original_geo.loc)
|
(geo.loc - original_geo.loc)
|
||||||
|
.as_logical()
|
||||||
.to_physical_precise_round(output_scale),
|
.to_physical_precise_round(output_scale),
|
||||||
Relocate::Relative,
|
Relocate::Relative,
|
||||||
);
|
);
|
||||||
|
|
@ -4655,9 +4666,9 @@ fn render_new_tree<R>(
|
||||||
target_tree: &Tree<Data>,
|
target_tree: &Tree<Data>,
|
||||||
reference_tree: Option<&Tree<Data>>,
|
reference_tree: Option<&Tree<Data>>,
|
||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
non_exclusive_zone: Rectangle<i32, Logical>,
|
non_exclusive_zone: Rectangle<i32, Local>,
|
||||||
geometries: Option<HashMap<NodeId, Rectangle<i32, Logical>>>,
|
geometries: Option<HashMap<NodeId, Rectangle<i32, Local>>>,
|
||||||
old_geometries: Option<HashMap<NodeId, Rectangle<i32, Logical>>>,
|
old_geometries: Option<HashMap<NodeId, Rectangle<i32, Local>>>,
|
||||||
is_overview: bool,
|
is_overview: bool,
|
||||||
seat: Option<&Seat<State>>,
|
seat: Option<&Seat<State>>,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
|
|
@ -4685,13 +4696,7 @@ where
|
||||||
seat.get_keyboard()
|
seat.get_keyboard()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_focus()
|
.current_focus()
|
||||||
.and_then(|target| {
|
.and_then(|target| TilingLayout::currently_focused_node(&target_tree, target))
|
||||||
TilingLayout::currently_focused_node(
|
|
||||||
&target_tree,
|
|
||||||
&seat.active_output(),
|
|
||||||
target,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.map(|(id, _)| id);
|
.map(|(id, _)| id);
|
||||||
let focused_geo = if let Some(focused) = focused.as_ref() {
|
let focused_geo = if let Some(focused) = focused.as_ref() {
|
||||||
|
|
@ -4778,7 +4783,8 @@ where
|
||||||
transition.unwrap_or(1.0),
|
transition.unwrap_or(1.0),
|
||||||
));
|
));
|
||||||
|
|
||||||
let render_loc = (swap_geo.loc - window_geo.loc).to_physical_precise_round(output_scale);
|
let render_loc =
|
||||||
|
(swap_geo.loc.as_logical() - window_geo.loc).to_physical_precise_round(output_scale);
|
||||||
|
|
||||||
swap_elements.extend(
|
swap_elements.extend(
|
||||||
window
|
window
|
||||||
|
|
@ -4792,7 +4798,10 @@ where
|
||||||
.map(|window| {
|
.map(|window| {
|
||||||
CosmicMappedRenderElement::GrabbedWindow(RescaleRenderElement::from_element(
|
CosmicMappedRenderElement::GrabbedWindow(RescaleRenderElement::from_element(
|
||||||
window,
|
window,
|
||||||
swap_geo.loc.to_physical_precise_round(output_scale),
|
swap_geo
|
||||||
|
.loc
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale),
|
||||||
ease(
|
ease(
|
||||||
Linear,
|
Linear,
|
||||||
1.0,
|
1.0,
|
||||||
|
|
@ -4985,12 +4994,12 @@ where
|
||||||
.unwrap_or(false))
|
.unwrap_or(false))
|
||||||
{
|
{
|
||||||
if let Some(swap) = swap_indicator.as_ref() {
|
if let Some(swap) = swap_indicator.as_ref() {
|
||||||
swap.resize(geo.size);
|
swap.resize(geo.size.as_logical());
|
||||||
swap.output_enter(output, output_geo);
|
swap.output_enter(output, output_geo.as_logical());
|
||||||
swap_elements.extend(
|
swap_elements.extend(
|
||||||
swap.render_elements::<CosmicWindowRenderElement<R>>(
|
swap.render_elements::<CosmicWindowRenderElement<R>>(
|
||||||
renderer,
|
renderer,
|
||||||
geo.loc.to_physical_precise_round(output_scale),
|
geo.loc.as_logical().to_physical_precise_round(output_scale),
|
||||||
output_scale.into(),
|
output_scale.into(),
|
||||||
alpha * overview.0.alpha().unwrap_or(1.0),
|
alpha * overview.0.alpha().unwrap_or(1.0),
|
||||||
)
|
)
|
||||||
|
|
@ -5006,8 +5015,8 @@ where
|
||||||
geo.loc -= (18, 18).into();
|
geo.loc -= (18, 18).into();
|
||||||
geo.size += (36, 36).into();
|
geo.size += (36, 36).into();
|
||||||
|
|
||||||
resize.resize(geo.size);
|
resize.resize(geo.size.as_logical());
|
||||||
resize.output_enter(output, output_geo);
|
resize.output_enter(output, output_geo.as_logical());
|
||||||
let possible_edges =
|
let possible_edges =
|
||||||
TilingLayout::possible_resizes(target_tree, node_id.clone());
|
TilingLayout::possible_resizes(target_tree, node_id.clone());
|
||||||
if !possible_edges.is_empty() {
|
if !possible_edges.is_empty() {
|
||||||
|
|
@ -5026,7 +5035,7 @@ where
|
||||||
resize
|
resize
|
||||||
.render_elements::<CosmicWindowRenderElement<R>>(
|
.render_elements::<CosmicWindowRenderElement<R>>(
|
||||||
renderer,
|
renderer,
|
||||||
geo.loc.to_physical_precise_round(output_scale),
|
geo.loc.as_logical().to_physical_precise_round(output_scale),
|
||||||
output_scale.into(),
|
output_scale.into(),
|
||||||
alpha * mode.alpha().unwrap_or(1.0),
|
alpha * mode.alpha().unwrap_or(1.0),
|
||||||
)
|
)
|
||||||
|
|
@ -5039,7 +5048,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Data::Mapped { mapped, .. } = data {
|
if let Data::Mapped { mapped, .. } = data {
|
||||||
let original_location = (original_geo.loc - mapped.geometry().loc)
|
let original_location = (original_geo.loc.as_logical() - mapped.geometry().loc)
|
||||||
.to_physical_precise_round(output_scale);
|
.to_physical_precise_round(output_scale);
|
||||||
|
|
||||||
let (mut w_elements, p_elements) = mapped
|
let (mut w_elements, p_elements) = mapped
|
||||||
|
|
@ -5069,7 +5078,7 @@ where
|
||||||
})
|
})
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
let mut geo = mapped.active_window_geometry();
|
let mut geo = mapped.active_window_geometry().as_local();
|
||||||
geo.loc += original_geo.loc;
|
geo.loc += original_geo.loc;
|
||||||
w_elements.insert(
|
w_elements.insert(
|
||||||
0,
|
0,
|
||||||
|
|
@ -5090,16 +5099,22 @@ where
|
||||||
let cropped = CropRenderElement::from_element(
|
let cropped = CropRenderElement::from_element(
|
||||||
elem,
|
elem,
|
||||||
output_scale,
|
output_scale,
|
||||||
crop_rect.to_physical_precise_round(output_scale),
|
crop_rect
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale),
|
||||||
)?;
|
)?;
|
||||||
let rescaled = RescaleRenderElement::from_element(
|
let rescaled = RescaleRenderElement::from_element(
|
||||||
cropped,
|
cropped,
|
||||||
original_geo.loc.to_physical_precise_round(output_scale),
|
original_geo
|
||||||
|
.loc
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale),
|
||||||
scale,
|
scale,
|
||||||
);
|
);
|
||||||
let relocated = RelocateRenderElement::from_element(
|
let relocated = RelocateRenderElement::from_element(
|
||||||
rescaled,
|
rescaled,
|
||||||
(geo.loc - original_geo.loc)
|
(geo.loc - original_geo.loc)
|
||||||
|
.as_logical()
|
||||||
.to_physical_precise_round(output_scale),
|
.to_physical_precise_round(output_scale),
|
||||||
Relocate::Relative,
|
Relocate::Relative,
|
||||||
);
|
);
|
||||||
|
|
@ -5111,16 +5126,22 @@ where
|
||||||
let cropped = CropRenderElement::from_element(
|
let cropped = CropRenderElement::from_element(
|
||||||
elem,
|
elem,
|
||||||
output_scale,
|
output_scale,
|
||||||
crop_rect.to_physical_precise_round(output_scale),
|
crop_rect
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale),
|
||||||
)?;
|
)?;
|
||||||
let rescaled = RescaleRenderElement::from_element(
|
let rescaled = RescaleRenderElement::from_element(
|
||||||
cropped,
|
cropped,
|
||||||
original_geo.loc.to_physical_precise_round(output_scale),
|
original_geo
|
||||||
|
.loc
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale),
|
||||||
scale,
|
scale,
|
||||||
);
|
);
|
||||||
let relocated = RelocateRenderElement::from_element(
|
let relocated = RelocateRenderElement::from_element(
|
||||||
rescaled,
|
rescaled,
|
||||||
(geo.loc - original_geo.loc)
|
(geo.loc - original_geo.loc)
|
||||||
|
.as_logical()
|
||||||
.to_physical_precise_round(output_scale),
|
.to_physical_precise_round(output_scale),
|
||||||
Relocate::Relative,
|
Relocate::Relative,
|
||||||
);
|
);
|
||||||
|
|
@ -5132,16 +5153,22 @@ where
|
||||||
let cropped = CropRenderElement::from_element(
|
let cropped = CropRenderElement::from_element(
|
||||||
elem,
|
elem,
|
||||||
output_scale,
|
output_scale,
|
||||||
crop_rect.to_physical_precise_round(output_scale),
|
crop_rect
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale),
|
||||||
)?;
|
)?;
|
||||||
let rescaled = RescaleRenderElement::from_element(
|
let rescaled = RescaleRenderElement::from_element(
|
||||||
cropped,
|
cropped,
|
||||||
original_geo.loc.to_physical_precise_round(output_scale),
|
original_geo
|
||||||
|
.loc
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale),
|
||||||
scale,
|
scale,
|
||||||
);
|
);
|
||||||
let relocated = RelocateRenderElement::from_element(
|
let relocated = RelocateRenderElement::from_element(
|
||||||
rescaled,
|
rescaled,
|
||||||
(geo.loc - original_geo.loc)
|
(geo.loc - original_geo.loc)
|
||||||
|
.as_logical()
|
||||||
.to_physical_precise_round(output_scale),
|
.to_physical_precise_round(output_scale),
|
||||||
Relocate::Relative,
|
Relocate::Relative,
|
||||||
);
|
);
|
||||||
|
|
@ -5187,10 +5214,10 @@ where
|
||||||
(window_elements, popup_elements)
|
(window_elements, popup_elements)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scale_to_center(
|
fn scale_to_center<C>(
|
||||||
old_geo: &Rectangle<i32, Logical>,
|
old_geo: &Rectangle<i32, C>,
|
||||||
new_geo: &Rectangle<i32, Logical>,
|
new_geo: &Rectangle<i32, C>,
|
||||||
) -> (f64, Point<i32, Logical>) {
|
) -> (f64, Point<i32, C>) {
|
||||||
let scale_w = new_geo.size.w as f64 / old_geo.size.w as f64;
|
let scale_w = new_geo.size.w as f64 / old_geo.size.w as f64;
|
||||||
let scale_h = new_geo.size.h as f64 / old_geo.size.h as f64;
|
let scale_h = new_geo.size.h as f64 / old_geo.size.h as f64;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1073,7 +1073,10 @@ impl Shell {
|
||||||
.filter(|o| {
|
.filter(|o| {
|
||||||
self.override_redirect_windows.iter().any(|or| {
|
self.override_redirect_windows.iter().any(|or| {
|
||||||
if or.wl_surface().as_ref() == Some(surface) {
|
if or.wl_surface().as_ref() == Some(surface) {
|
||||||
or.geometry().intersection(o.geometry()).is_some()
|
or.geometry()
|
||||||
|
.as_global()
|
||||||
|
.intersection(o.geometry())
|
||||||
|
.is_some()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
@ -1393,13 +1396,12 @@ impl Shell {
|
||||||
|
|
||||||
pub fn map_override_redirect(state: &mut State, window: X11Surface) {
|
pub fn map_override_redirect(state: &mut State, window: X11Surface) {
|
||||||
let geo = window.geometry();
|
let geo = window.geometry();
|
||||||
for (output, overlap) in state
|
for (output, overlap) in state.common.shell.outputs().cloned().filter_map(|o| {
|
||||||
.common
|
o.geometry()
|
||||||
.shell
|
.as_logical()
|
||||||
.outputs()
|
.intersection(geo)
|
||||||
.cloned()
|
.map(|overlap| (o, overlap))
|
||||||
.filter_map(|o| o.geometry().intersection(geo).map(|overlap| (o, overlap)))
|
}) {
|
||||||
{
|
|
||||||
window.output_enter(&output, overlap);
|
window.output_enter(&output, overlap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1444,7 +1446,7 @@ impl Shell {
|
||||||
to: (&Output, Option<usize>),
|
to: (&Output, Option<usize>),
|
||||||
follow: bool,
|
follow: bool,
|
||||||
direction: Option<Direction>,
|
direction: Option<Direction>,
|
||||||
) -> Result<Option<Point<i32, Logical>>, InvalidWorkspaceIndex> {
|
) -> Result<Option<Point<i32, Global>>, InvalidWorkspaceIndex> {
|
||||||
let (to_output, to_idx) = to;
|
let (to_output, to_idx) = to;
|
||||||
let to_idx = to_idx.unwrap_or(state.common.shell.workspaces.active_num(to_output).1);
|
let to_idx = to_idx.unwrap_or(state.common.shell.workspaces.active_num(to_output).1);
|
||||||
if state
|
if state
|
||||||
|
|
@ -1578,14 +1580,18 @@ impl Shell {
|
||||||
|
|
||||||
pub fn update_reactive_popups(&self, mapped: &CosmicMapped) {
|
pub fn update_reactive_popups(&self, mapped: &CosmicMapped) {
|
||||||
if let Some(workspace) = self.space_for(mapped) {
|
if let Some(workspace) = self.space_for(mapped) {
|
||||||
let element_loc = workspace.element_geometry(mapped).unwrap().loc;
|
let element_loc = workspace
|
||||||
|
.element_geometry(mapped)
|
||||||
|
.unwrap()
|
||||||
|
.loc
|
||||||
|
.to_global(&workspace.output);
|
||||||
for (toplevel, offset) in mapped.windows() {
|
for (toplevel, offset) in mapped.windows() {
|
||||||
if let CosmicSurface::Wayland(toplevel) = toplevel {
|
if let CosmicSurface::Wayland(toplevel) = toplevel {
|
||||||
let window_geo_offset = toplevel.geometry().loc;
|
let window_geo_offset = toplevel.geometry().loc.as_global();
|
||||||
update_reactive_popups(
|
update_reactive_popups(
|
||||||
&toplevel,
|
&toplevel,
|
||||||
element_loc + offset + window_geo_offset,
|
element_loc + offset.as_global() + window_geo_offset,
|
||||||
self.outputs.iter(),
|
self.outputs(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -935,20 +935,28 @@ impl Workspace {
|
||||||
let mut window_elements = Vec::new();
|
let mut window_elements = Vec::new();
|
||||||
let mut popup_elements = Vec::new();
|
let mut popup_elements = Vec::new();
|
||||||
|
|
||||||
let output_scale = output.current_scale().fractional_scale();
|
let output_scale = self.output.current_scale().fractional_scale();
|
||||||
let layer_map = layer_map_for_output(output);
|
let zone = {
|
||||||
let zone = layer_map.non_exclusive_zone();
|
let layer_map = layer_map_for_output(&self.output);
|
||||||
|
layer_map.non_exclusive_zone().as_local()
|
||||||
|
};
|
||||||
|
|
||||||
// OR windows above all
|
// OR windows above all
|
||||||
popup_elements.extend(
|
popup_elements.extend(
|
||||||
override_redirect_windows
|
override_redirect_windows
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|or| (*or).geometry().intersection(output.geometry()).is_some())
|
.filter(|or| {
|
||||||
|
(*or)
|
||||||
|
.geometry()
|
||||||
|
.as_global()
|
||||||
|
.intersection(self.output.geometry())
|
||||||
|
.is_some()
|
||||||
|
})
|
||||||
.flat_map(|or| {
|
.flat_map(|or| {
|
||||||
AsRenderElements::<R>::render_elements::<WorkspaceRenderElement<R>>(
|
AsRenderElements::<R>::render_elements::<WorkspaceRenderElement<R>>(
|
||||||
or,
|
or,
|
||||||
renderer,
|
renderer,
|
||||||
(or.geometry().loc - output.geometry().loc)
|
(or.geometry().loc - self.output.geometry().loc.as_logical())
|
||||||
.to_physical_precise_round(output_scale),
|
.to_physical_precise_round(output_scale),
|
||||||
Scale::from(output_scale),
|
Scale::from(output_scale),
|
||||||
1.0,
|
1.0,
|
||||||
|
|
@ -1027,7 +1035,10 @@ impl Workspace {
|
||||||
(None, None) => (full_geo, 1.0),
|
(None, None) => (full_geo, 1.0),
|
||||||
};
|
};
|
||||||
|
|
||||||
let render_loc = target_geo.loc.to_physical_precise_round(output_scale);
|
let render_loc = target_geo
|
||||||
|
.loc
|
||||||
|
.as_logical()
|
||||||
|
.to_physical_precise_round(output_scale);
|
||||||
let scale = Scale {
|
let scale = Scale {
|
||||||
x: target_geo.size.w as f64 / bbox.size.w as f64,
|
x: target_geo.size.w as f64 / bbox.size.w as f64,
|
||||||
y: target_geo.size.h as f64 / bbox.size.h as f64,
|
y: target_geo.size.h as f64 / bbox.size.h as f64,
|
||||||
|
|
|
||||||
149
src/utils/geometry.rs
Normal file
149
src/utils/geometry.rs
Normal file
|
|
@ -0,0 +1,149 @@
|
||||||
|
use smithay::{
|
||||||
|
output::Output,
|
||||||
|
utils::{Coordinate, Logical, Point, Rectangle, Size},
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::prelude::OutputExt;
|
||||||
|
|
||||||
|
/// Marker type for coordinates in global space
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Global;
|
||||||
|
|
||||||
|
/// Marker type for coordinates in workspace local space
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Local;
|
||||||
|
|
||||||
|
pub trait PointExt<C: Coordinate> {
|
||||||
|
fn as_global(self) -> Point<C, Global>;
|
||||||
|
fn as_local(self) -> Point<C, Local>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait PointGlobalExt<C: Coordinate> {
|
||||||
|
fn to_local(self, output: &Output) -> Point<C, Local>;
|
||||||
|
fn as_logical(self) -> Point<C, Logical>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait PointLocalExt<C: Coordinate> {
|
||||||
|
fn to_global(self, output: &Output) -> Point<C, Global>;
|
||||||
|
fn as_logical(self) -> Point<C, Logical>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait SizeExt<C: Coordinate> {
|
||||||
|
fn as_logical(self) -> Size<C, Logical>;
|
||||||
|
fn as_local(self) -> Size<C, Local>;
|
||||||
|
fn as_global(self) -> Size<C, Global>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait RectExt<C: Coordinate> {
|
||||||
|
fn as_global(self) -> Rectangle<C, Global>;
|
||||||
|
fn as_local(self) -> Rectangle<C, Local>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait RectGlobalExt<C: Coordinate> {
|
||||||
|
fn to_local(self, output: &Output) -> Rectangle<C, Local>;
|
||||||
|
fn as_logical(self) -> Rectangle<C, Logical>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait RectLocalExt<C: Coordinate> {
|
||||||
|
fn to_global(self, output: &Output) -> Rectangle<C, Global>;
|
||||||
|
fn as_logical(self) -> Rectangle<C, Logical>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Coordinate> PointExt<C> for Point<C, Logical> {
|
||||||
|
fn as_global(self) -> Point<C, Global> {
|
||||||
|
(self.x, self.y).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_local(self) -> Point<C, Local> {
|
||||||
|
(self.x, self.y).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Coordinate> PointGlobalExt<C> for Point<C, Global> {
|
||||||
|
fn to_local(self, output: &Output) -> Point<C, Local> {
|
||||||
|
let point = (self.to_f64() - output.geometry().loc.to_f64()).as_logical();
|
||||||
|
(C::from_f64(point.x), C::from_f64(point.y)).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_logical(self) -> Point<C, Logical> {
|
||||||
|
(self.x, self.y).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Coordinate> PointLocalExt<C> for Point<C, Local> {
|
||||||
|
fn to_global(self, output: &Output) -> Point<C, Global> {
|
||||||
|
let point =
|
||||||
|
(self.to_f64().as_logical() + output.geometry().loc.to_f64().as_logical()).as_global();
|
||||||
|
(C::from_f64(point.x), C::from_f64(point.y)).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_logical(self) -> Point<C, Logical> {
|
||||||
|
(self.x, self.y).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Coordinate> SizeExt<C> for Size<C, Global> {
|
||||||
|
fn as_logical(self) -> Size<C, Logical> {
|
||||||
|
(self.w, self.h).into()
|
||||||
|
}
|
||||||
|
fn as_global(self) -> Size<C, Global> {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
fn as_local(self) -> Size<C, Local> {
|
||||||
|
(self.w, self.h).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Coordinate> SizeExt<C> for Size<C, Local> {
|
||||||
|
fn as_logical(self) -> Size<C, Logical> {
|
||||||
|
(self.w, self.h).into()
|
||||||
|
}
|
||||||
|
fn as_global(self) -> Size<C, Global> {
|
||||||
|
(self.w, self.h).into()
|
||||||
|
}
|
||||||
|
fn as_local(self) -> Size<C, Local> {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Coordinate> SizeExt<C> for Size<C, Logical> {
|
||||||
|
fn as_logical(self) -> Size<C, Logical> {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
fn as_global(self) -> Size<C, Global> {
|
||||||
|
(self.w, self.h).into()
|
||||||
|
}
|
||||||
|
fn as_local(self) -> Size<C, Local> {
|
||||||
|
(self.w, self.h).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Coordinate> RectExt<C> for Rectangle<C, Logical> {
|
||||||
|
fn as_global(self) -> Rectangle<C, Global> {
|
||||||
|
Rectangle::from_loc_and_size(self.loc.as_global(), (self.size.w, self.size.h))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_local(self) -> Rectangle<C, Local> {
|
||||||
|
Rectangle::from_loc_and_size(self.loc.as_local(), (self.size.w, self.size.h))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Coordinate> RectGlobalExt<C> for Rectangle<C, Global> {
|
||||||
|
fn to_local(self, output: &Output) -> Rectangle<C, Local> {
|
||||||
|
Rectangle::from_loc_and_size(self.loc.to_local(output), (self.size.w, self.size.h))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_logical(self) -> Rectangle<C, Logical> {
|
||||||
|
Rectangle::from_loc_and_size(self.loc.as_logical(), self.size.as_logical())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Coordinate> RectLocalExt<C> for Rectangle<C, Local> {
|
||||||
|
fn to_global(self, output: &Output) -> Rectangle<C, Global> {
|
||||||
|
Rectangle::from_loc_and_size(self.loc.to_global(output), (self.size.w, self.size.h))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_logical(self) -> Rectangle<C, Logical> {
|
||||||
|
Rectangle::from_loc_and_size(self.loc.as_logical(), self.size.as_logical())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
mod ids;
|
mod ids;
|
||||||
pub(crate) use self::ids::id_gen;
|
pub(crate) use self::ids::id_gen;
|
||||||
|
pub mod geometry;
|
||||||
pub mod iced;
|
pub mod iced;
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
pub mod tween;
|
pub mod tween;
|
||||||
|
|
|
||||||
|
|
@ -11,20 +11,21 @@ use smithay::{
|
||||||
Seat,
|
Seat,
|
||||||
},
|
},
|
||||||
output::Output,
|
output::Output,
|
||||||
utils::{Buffer, IsAlive, Logical, Monotonic, Point, Rectangle, Time, Transform},
|
utils::{Buffer, IsAlive, Monotonic, Point, Rectangle, Time, Transform},
|
||||||
wayland::compositor::with_states,
|
wayland::compositor::with_states,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub use super::geometry::*;
|
||||||
pub use crate::shell::{Shell, Workspace};
|
pub use crate::shell::{Shell, Workspace};
|
||||||
pub use crate::state::{Common, State};
|
pub use crate::state::{Common, State};
|
||||||
pub use crate::wayland::handlers::xdg_shell::popup::update_reactive_popups;
|
pub use crate::wayland::handlers::xdg_shell::popup::update_reactive_popups;
|
||||||
|
|
||||||
pub trait OutputExt {
|
pub trait OutputExt {
|
||||||
fn geometry(&self) -> Rectangle<i32, Logical>;
|
fn geometry(&self) -> Rectangle<i32, Global>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutputExt for Output {
|
impl OutputExt for Output {
|
||||||
fn geometry(&self) -> Rectangle<i32, Logical> {
|
fn geometry(&self) -> Rectangle<i32, Global> {
|
||||||
Rectangle::from_loc_and_size(self.current_location(), {
|
Rectangle::from_loc_and_size(self.current_location(), {
|
||||||
Transform::from(self.current_transform())
|
Transform::from(self.current_transform())
|
||||||
.transform_size(
|
.transform_size(
|
||||||
|
|
@ -36,6 +37,7 @@ impl OutputExt for Output {
|
||||||
.to_logical(self.current_scale().fractional_scale())
|
.to_logical(self.current_scale().fractional_scale())
|
||||||
.to_i32_round()
|
.to_i32_round()
|
||||||
})
|
})
|
||||||
|
.as_global()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
shell::{CosmicMappedRenderElement, CosmicSurface, WorkspaceRenderElement},
|
shell::{CosmicMappedRenderElement, CosmicSurface, WorkspaceRenderElement},
|
||||||
state::{BackendData, ClientState, Common, State},
|
state::{BackendData, ClientState, Common, State},
|
||||||
utils::prelude::OutputExt,
|
utils::prelude::{OutputExt, PointExt},
|
||||||
wayland::protocols::{
|
wayland::protocols::{
|
||||||
screencopy::{
|
screencopy::{
|
||||||
delegate_screencopy, BufferInfo, BufferParams, CursorMode as ScreencopyCursorMode,
|
delegate_screencopy, BufferInfo, BufferParams, CursorMode as ScreencopyCursorMode,
|
||||||
|
|
@ -106,7 +106,7 @@ impl ScreencopyHandler for State {
|
||||||
if let Some(pointer) = seat.get_pointer() {
|
if let Some(pointer) = seat.get_pointer() {
|
||||||
if output
|
if output
|
||||||
.geometry()
|
.geometry()
|
||||||
.contains(pointer.current_location().to_i32_round())
|
.contains(pointer.current_location().to_i32_round().as_global())
|
||||||
{
|
{
|
||||||
session.cursor_enter(seat, InputType::Pointer);
|
session.cursor_enter(seat, InputType::Pointer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,27 +27,28 @@ use std::sync::Mutex;
|
||||||
use tracing::{trace, warn};
|
use tracing::{trace, warn};
|
||||||
|
|
||||||
impl Shell {
|
impl Shell {
|
||||||
pub fn unconstrain_popup(&self, surface: &PopupSurface, positioner: &PositionerState) {
|
pub fn unconstrain_popup(&self, surface: &PopupSurface) {
|
||||||
if let Some(parent) = get_popup_toplevel(&surface) {
|
if let Some(parent) = get_popup_toplevel(&surface) {
|
||||||
if let Some(elem) = self.element_for_wl_surface(&parent) {
|
if let Some(elem) = self.element_for_wl_surface(&parent) {
|
||||||
let workspace = self.space_for(elem).unwrap();
|
let workspace = self.space_for(elem).unwrap();
|
||||||
let mut element_geo = workspace.element_geometry(elem).unwrap();
|
let mut element_geo = workspace
|
||||||
|
.element_geometry(elem)
|
||||||
|
.unwrap()
|
||||||
|
.to_global(workspace.output());
|
||||||
let (window, offset) = elem
|
let (window, offset) = elem
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(&parent))
|
.find(|(w, _)| w.wl_surface().as_ref() == Some(&parent))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let window_geo_offset = window.geometry().loc;
|
let window_geo_offset = window.geometry().loc;
|
||||||
let window_loc = element_geo.loc + offset + window_geo_offset;
|
let window_loc: Point<i32, Global> =
|
||||||
let anchor_point = get_anchor_point(&positioner) + window_loc;
|
element_geo.loc + offset.as_global() + window_geo_offset.as_global();
|
||||||
if workspace.is_tiled(elem) {
|
if workspace.is_tiled(elem) {
|
||||||
element_geo.loc = (0, 0).into(); //-= window_loc;
|
element_geo.loc = (0, 0).into();
|
||||||
if !unconstrain_xdg_popup_tile(surface, element_geo) {
|
if !unconstrain_xdg_popup_tile(surface, element_geo.as_logical()) {
|
||||||
if let Some(output) = workspace.output_under(anchor_point) {
|
unconstrain_xdg_popup(surface, window_loc, workspace.output().geometry());
|
||||||
unconstrain_xdg_popup(surface, window_loc, output.geometry());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if let Some(output) = workspace.output_under(anchor_point) {
|
} else {
|
||||||
unconstrain_xdg_popup(surface, window_loc, output.geometry());
|
unconstrain_xdg_popup(surface, window_loc, workspace.output().geometry());
|
||||||
}
|
}
|
||||||
} else if let Some((output, layer_surface)) = self.outputs().find_map(|o| {
|
} else if let Some((output, layer_surface)) = self.outputs().find_map(|o| {
|
||||||
let map = layer_map_for_output(o);
|
let map = layer_map_for_output(o);
|
||||||
|
|
@ -62,7 +63,7 @@ impl Shell {
|
||||||
|
|
||||||
pub fn update_reactive_popups<'a>(
|
pub fn update_reactive_popups<'a>(
|
||||||
window: &Window,
|
window: &Window,
|
||||||
loc: Point<i32, Logical>,
|
loc: Point<i32, Global>,
|
||||||
outputs: impl Iterator<Item = &'a Output>,
|
outputs: impl Iterator<Item = &'a Output>,
|
||||||
) {
|
) {
|
||||||
let output_geo = outputs.map(|o| o.geometry()).collect::<Vec<_>>();
|
let output_geo = outputs.map(|o| o.geometry()).collect::<Vec<_>>();
|
||||||
|
|
@ -79,7 +80,7 @@ pub fn update_reactive_popups<'a>(
|
||||||
attributes.current.positioner.clone()
|
attributes.current.positioner.clone()
|
||||||
});
|
});
|
||||||
if positioner.reactive {
|
if positioner.reactive {
|
||||||
let anchor_point = get_anchor_point(&positioner) + loc;
|
let anchor_point = loc + get_anchor_point(&positioner).as_global();
|
||||||
if let Some(rect) = output_geo
|
if let Some(rect) = output_geo
|
||||||
.iter()
|
.iter()
|
||||||
.find(|geo| geo.contains(anchor_point))
|
.find(|geo| geo.contains(anchor_point))
|
||||||
|
|
@ -116,11 +117,11 @@ fn unconstrain_xdg_popup_tile(surface: &PopupSurface, rect: Rectangle<i32, Logic
|
||||||
|
|
||||||
fn unconstrain_xdg_popup(
|
fn unconstrain_xdg_popup(
|
||||||
surface: &PopupSurface,
|
surface: &PopupSurface,
|
||||||
window_loc: Point<i32, Logical>,
|
window_loc: Point<i32, Global>,
|
||||||
rect: Rectangle<i32, Logical>,
|
mut rect: Rectangle<i32, Global>,
|
||||||
) {
|
) {
|
||||||
let mut relative = rect;
|
rect.loc -= window_loc;
|
||||||
relative.loc -= window_loc;
|
let relative = rect.as_logical();
|
||||||
let geometry = surface.with_pending_state(|state| state.positioner.get_geometry());
|
let geometry = surface.with_pending_state(|state| state.positioner.get_geometry());
|
||||||
let offset = check_constrained(geometry, relative);
|
let offset = check_constrained(geometry, relative);
|
||||||
|
|
||||||
|
|
@ -139,7 +140,7 @@ fn unconstrain_layer_popup(surface: &PopupSurface, output: &Output, layer_surfac
|
||||||
let layer_geo = map.layer_geometry(layer_surface).unwrap();
|
let layer_geo = map.layer_geometry(layer_surface).unwrap();
|
||||||
|
|
||||||
// the output_rect represented relative to the parents coordinate system
|
// the output_rect represented relative to the parents coordinate system
|
||||||
let mut relative = Rectangle::from_loc_and_size((0, 0), output.geometry().size);
|
let mut relative = Rectangle::from_loc_and_size((0, 0), output.geometry().size).as_logical();
|
||||||
relative.loc -= layer_geo.loc;
|
relative.loc -= layer_geo.loc;
|
||||||
let geometry = surface.with_pending_state(|state| state.positioner.get_geometry());
|
let geometry = surface.with_pending_state(|state| state.positioner.get_geometry());
|
||||||
let offset = check_constrained(geometry, relative);
|
let offset = check_constrained(geometry, relative);
|
||||||
|
|
|
||||||
|
|
@ -277,13 +277,16 @@ impl XwmHandler for State {
|
||||||
{
|
{
|
||||||
let space = self.common.shell.space_for(mapped).unwrap();
|
let space = self.common.shell.space_for(mapped).unwrap();
|
||||||
if space.is_floating(mapped) {
|
if space.is_floating(mapped) {
|
||||||
mapped.set_geometry(Rectangle::from_loc_and_size(
|
mapped.set_geometry(
|
||||||
current_geo.loc,
|
Rectangle::from_loc_and_size(
|
||||||
(
|
current_geo.loc,
|
||||||
w.map(|w| w as i32).unwrap_or(current_geo.size.w),
|
(
|
||||||
h.map(|h| h as i32).unwrap_or(current_geo.size.h),
|
w.map(|w| w as i32).unwrap_or(current_geo.size.w),
|
||||||
),
|
h.map(|h| h as i32).unwrap_or(current_geo.size.h),
|
||||||
))
|
),
|
||||||
|
)
|
||||||
|
.as_global(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(x) = x {
|
if let Some(x) = x {
|
||||||
|
|
@ -325,13 +328,13 @@ impl XwmHandler for State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let geo = window.geometry();
|
let geo = window.geometry().as_global();
|
||||||
for (output, overlap) in self.common.shell.outputs().cloned().map(|o| {
|
for (output, overlap) in self.common.shell.outputs().cloned().map(|o| {
|
||||||
let intersection = o.geometry().intersection(geo);
|
let intersection = o.geometry().intersection(geo);
|
||||||
(o, intersection)
|
(o, intersection)
|
||||||
}) {
|
}) {
|
||||||
if let Some(overlap) = overlap {
|
if let Some(overlap) = overlap {
|
||||||
window.output_enter(&output, overlap);
|
window.output_enter(&output, overlap.as_logical());
|
||||||
} else {
|
} else {
|
||||||
window.output_leave(&output);
|
window.output_leave(&output);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue