chore: clippy
This commit is contained in:
parent
c13e52da04
commit
2ca99c670a
59 changed files with 1974 additions and 2137 deletions
|
|
@ -49,8 +49,9 @@ pub struct ScrollConfig {
|
|||
pub scroll_factor: Option<f64>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub enum DeviceState {
|
||||
#[default]
|
||||
Enabled,
|
||||
Disabled,
|
||||
DisabledOnExternalMouse,
|
||||
|
|
@ -63,12 +64,6 @@ pub enum TouchpadOverride {
|
|||
ForceDisable,
|
||||
}
|
||||
|
||||
impl Default for DeviceState {
|
||||
fn default() -> Self {
|
||||
Self::Enabled
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct TapConfig {
|
||||
pub enabled: bool,
|
||||
|
|
|
|||
|
|
@ -204,20 +204,20 @@ impl State {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(blocklist) = dev_list_var("COSMIC_DRM_BLOCK_DEVICES") {
|
||||
if let Ok(node) = DrmNode::from_dev_id(dev) {
|
||||
let node = node
|
||||
.node_with_type(NodeType::Render)
|
||||
.and_then(|res| res.ok())
|
||||
.unwrap_or(node);
|
||||
for ident in blocklist {
|
||||
if ident.matches(&node) {
|
||||
info!(
|
||||
"Skipping device {} due to COSMIC_DRM_BLOCK_DEVICE list.",
|
||||
path.display()
|
||||
);
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
if let Some(blocklist) = dev_list_var("COSMIC_DRM_BLOCK_DEVICES")
|
||||
&& let Ok(node) = DrmNode::from_dev_id(dev)
|
||||
{
|
||||
let node = node
|
||||
.node_with_type(NodeType::Render)
|
||||
.and_then(|res| res.ok())
|
||||
.unwrap_or(node);
|
||||
for ident in blocklist {
|
||||
if ident.matches(&node) {
|
||||
info!(
|
||||
"Skipping device {} due to COSMIC_DRM_BLOCK_DEVICE list.",
|
||||
path.display()
|
||||
);
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -271,10 +271,10 @@ impl State {
|
|||
notifier,
|
||||
move |event, metadata, state: &mut State| match event {
|
||||
DrmEvent::VBlank(crtc) => {
|
||||
if let Some(device) = state.backend.kms().drm_devices.get_mut(&drm_node) {
|
||||
if let Some(surface) = device.inner.surfaces.get_mut(&crtc) {
|
||||
surface.on_vblank(metadata.take());
|
||||
}
|
||||
if let Some(device) = state.backend.kms().drm_devices.get_mut(&drm_node)
|
||||
&& let Some(surface) = device.inner.surfaces.get_mut(&crtc)
|
||||
{
|
||||
surface.on_vblank(metadata.take());
|
||||
}
|
||||
}
|
||||
DrmEvent::Error(err) => {
|
||||
|
|
@ -676,10 +676,10 @@ impl LockedDevice<'_> {
|
|||
|
||||
let mut compositor = compositor.lock().unwrap();
|
||||
compositor.render_frame(renderer, &elements, CLEAR_COLOR, FrameFlags::empty())?;
|
||||
if let Err(err) = compositor.commit_frame() {
|
||||
if !matches!(err, FrameError::EmptyFrame) {
|
||||
return Err(err.into());
|
||||
}
|
||||
if let Err(err) = compositor.commit_frame()
|
||||
&& !matches!(err, FrameError::EmptyFrame)
|
||||
{
|
||||
return Err(err.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,17 +32,17 @@ pub fn display_configuration(
|
|||
.iter()
|
||||
.flat_map(|conn| device.get_connector(*conn, true).ok())
|
||||
{
|
||||
if let Some(enc) = conn.current_encoder() {
|
||||
if let Some(crtc) = device.get_encoder(enc)?.crtc() {
|
||||
// If is is connected we found a mapping
|
||||
if conn.state() == ConnectorState::Connected {
|
||||
map.insert(conn.handle(), Some(crtc));
|
||||
// If not, the user just unplugged something,
|
||||
// or the drm master did not cleanup?
|
||||
// Well, I guess we cleanup after them.
|
||||
} else {
|
||||
cleanup.push(crtc);
|
||||
}
|
||||
if let Some(enc) = conn.current_encoder()
|
||||
&& let Some(crtc) = device.get_encoder(enc)?.crtc()
|
||||
{
|
||||
// If is is connected we found a mapping
|
||||
if conn.state() == ConnectorState::Connected {
|
||||
map.insert(conn.handle(), Some(crtc));
|
||||
// If not, the user just unplugged something,
|
||||
// or the drm master did not cleanup?
|
||||
// Well, I guess we cleanup after them.
|
||||
} else {
|
||||
cleanup.push(crtc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,12 +81,11 @@ pub fn display_configuration(
|
|||
.iter()
|
||||
.flat_map(|conn| device.get_connector(*conn, false).ok())
|
||||
.filter(|conn| {
|
||||
if let Some(enc) = conn.current_encoder() {
|
||||
if let Ok(enc) = device.get_encoder(enc) {
|
||||
if let Some(crtc) = enc.crtc() {
|
||||
return cleanup.contains(&crtc);
|
||||
}
|
||||
}
|
||||
if let Some(enc) = conn.current_encoder()
|
||||
&& let Ok(enc) = device.get_encoder(enc)
|
||||
&& let Some(crtc) = enc.crtc()
|
||||
{
|
||||
return cleanup.contains(&crtc);
|
||||
}
|
||||
false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -230,14 +230,14 @@ fn determine_primary_gpu(
|
|||
drm_devices: &IndexMap<DrmNode, Device>,
|
||||
seat: String,
|
||||
) -> Result<Option<DrmNode>> {
|
||||
if let Some(device) = dev_var("COSMIC_RENDER_DEVICE") {
|
||||
if let Some(node) = drm_devices.values().find_map(|dev| {
|
||||
if let Some(device) = dev_var("COSMIC_RENDER_DEVICE")
|
||||
&& let Some(node) = drm_devices.values().find_map(|dev| {
|
||||
device
|
||||
.matches(&dev.inner.render_node)
|
||||
.then_some(dev.inner.render_node)
|
||||
}) {
|
||||
return Ok(Some(node));
|
||||
}
|
||||
})
|
||||
{
|
||||
return Ok(Some(node));
|
||||
}
|
||||
|
||||
// try to find builtin display
|
||||
|
|
@ -256,13 +256,12 @@ fn determine_primary_gpu(
|
|||
|
||||
// else try to find the boot gpu
|
||||
let boot = determine_boot_gpu(seat);
|
||||
if let Some(boot) = boot {
|
||||
if drm_devices
|
||||
if let Some(boot) = boot
|
||||
&& drm_devices
|
||||
.values()
|
||||
.any(|dev| dev.inner.render_node == boot)
|
||||
{
|
||||
return Ok(Some(boot));
|
||||
}
|
||||
{
|
||||
return Ok(Some(boot));
|
||||
}
|
||||
|
||||
// else just take the first
|
||||
|
|
@ -319,10 +318,9 @@ fn init_udev(
|
|||
let backend = state.backend.kms();
|
||||
if matches!(event, UdevEvent::Added { .. } | UdevEvent::Removed { .. })
|
||||
&& backend.primary_node.read().unwrap().is_none()
|
||||
&& let Err(err) = state.backend.kms().select_primary_gpu(&dh)
|
||||
{
|
||||
if let Err(err) = state.backend.kms().select_primary_gpu(&dh) {
|
||||
warn!("Failed to determine a new primary gpu: {}", err);
|
||||
}
|
||||
warn!("Failed to determine a new primary gpu: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -462,18 +460,17 @@ impl KmsState {
|
|||
if let Some(primary_node) = primary_node
|
||||
.as_ref()
|
||||
.and_then(|node| node.node_with_type(NodeType::Primary).and_then(|x| x.ok()))
|
||||
&& let Some(device) = self.drm_devices.get(&primary_node)
|
||||
{
|
||||
if let Some(device) = self.drm_devices.get(&primary_node) {
|
||||
let import_device = device.drm.device().device_fd().clone();
|
||||
if supports_syncobj_eventfd(&import_device) {
|
||||
if let Some(state) = self.syncobj_state.as_mut() {
|
||||
state.update_device(import_device);
|
||||
} else {
|
||||
let syncobj_state = DrmSyncobjState::new::<State>(dh, import_device);
|
||||
self.syncobj_state = Some(syncobj_state);
|
||||
}
|
||||
return Ok(());
|
||||
let import_device = device.drm.device().device_fd().clone();
|
||||
if supports_syncobj_eventfd(&import_device) {
|
||||
if let Some(state) = self.syncobj_state.as_mut() {
|
||||
state.update_device(import_device);
|
||||
} else {
|
||||
let syncobj_state = DrmSyncobjState::new::<State>(dh, import_device);
|
||||
self.syncobj_state = Some(syncobj_state);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -939,15 +936,15 @@ impl KmsGuard<'_> {
|
|||
compositor
|
||||
};
|
||||
|
||||
if let Some(bpc) = output_config.0.max_bpc {
|
||||
if let Err(err) = drm_helpers::set_max_bpc(drm.device(), conn, bpc) {
|
||||
warn!(
|
||||
?bpc,
|
||||
?err,
|
||||
"Failed to set max_bpc on connector: {}",
|
||||
surface.output.name()
|
||||
);
|
||||
}
|
||||
if let Some(bpc) = output_config.0.max_bpc
|
||||
&& let Err(err) = drm_helpers::set_max_bpc(drm.device(), conn, bpc)
|
||||
{
|
||||
warn!(
|
||||
?bpc,
|
||||
?err,
|
||||
"Failed to set max_bpc on connector: {}",
|
||||
surface.output.name()
|
||||
);
|
||||
}
|
||||
|
||||
let vrr = output_config.0.vrr;
|
||||
|
|
|
|||
|
|
@ -782,91 +782,90 @@ impl SurfaceThreadState {
|
|||
// mark last frame completed
|
||||
if let Ok(Some(Some((mut feedback, frames, estimated_presentation_time)))) =
|
||||
compositor.frame_submitted()
|
||||
&& self.mirroring.is_none()
|
||||
{
|
||||
if self.mirroring.is_none() {
|
||||
let name = self.output.name();
|
||||
let message = if let Some(presentation_time) = presentation_time {
|
||||
let misprediction_s =
|
||||
presentation_time.as_secs_f64() - estimated_presentation_time.as_secs_f64();
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.presentation_misprediction_plot_name,
|
||||
misprediction_s * 1000.,
|
||||
);
|
||||
let name = self.output.name();
|
||||
let message = if let Some(presentation_time) = presentation_time {
|
||||
let misprediction_s =
|
||||
presentation_time.as_secs_f64() - estimated_presentation_time.as_secs_f64();
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.presentation_misprediction_plot_name,
|
||||
misprediction_s * 1000.,
|
||||
);
|
||||
|
||||
let now = Duration::from(now);
|
||||
if presentation_time > now {
|
||||
let diff = presentation_time - now;
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.time_since_presentation_plot_name,
|
||||
-diff.as_secs_f64() * 1000.,
|
||||
);
|
||||
format!("vblank on {name}, presentation is {diff:?} later")
|
||||
} else {
|
||||
let diff = now - presentation_time;
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.time_since_presentation_plot_name,
|
||||
diff.as_secs_f64() * 1000.,
|
||||
);
|
||||
format!("vblank on {name}, presentation was {diff:?} ago")
|
||||
}
|
||||
let now = Duration::from(now);
|
||||
if presentation_time > now {
|
||||
let diff = presentation_time - now;
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.time_since_presentation_plot_name,
|
||||
-diff.as_secs_f64() * 1000.,
|
||||
);
|
||||
format!("vblank on {name}, presentation is {diff:?} later")
|
||||
} else {
|
||||
format!("vblank on {name}, presentation time unknown")
|
||||
};
|
||||
let diff = now - presentation_time;
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.time_since_presentation_plot_name,
|
||||
diff.as_secs_f64() * 1000.,
|
||||
);
|
||||
format!("vblank on {name}, presentation was {diff:?} ago")
|
||||
}
|
||||
} else {
|
||||
format!("vblank on {name}, presentation time unknown")
|
||||
};
|
||||
tracy_client::Client::running()
|
||||
.unwrap()
|
||||
.message(&message, 0);
|
||||
|
||||
let (clock, flags) = if let Some(tp) = presentation_time {
|
||||
(
|
||||
tp.into(),
|
||||
wp_presentation_feedback::Kind::Vsync
|
||||
| wp_presentation_feedback::Kind::HwClock
|
||||
| wp_presentation_feedback::Kind::HwCompletion,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
now,
|
||||
wp_presentation_feedback::Kind::Vsync
|
||||
| wp_presentation_feedback::Kind::HwCompletion,
|
||||
)
|
||||
};
|
||||
|
||||
let rate = self
|
||||
.output
|
||||
.current_mode()
|
||||
.map(|mode| Duration::from_secs_f64(1_000.0 / mode.refresh as f64));
|
||||
let refresh = match rate {
|
||||
Some(rate)
|
||||
if self
|
||||
.compositor
|
||||
.as_ref()
|
||||
.is_some_and(|comp| comp.with_compositor(|c| c.vrr_enabled())) =>
|
||||
{
|
||||
Refresh::Variable(rate)
|
||||
}
|
||||
Some(rate) => Refresh::Fixed(rate),
|
||||
None => Refresh::Unknown,
|
||||
};
|
||||
|
||||
if let Some(last_sequence) = self.last_sequence {
|
||||
let delta = sequence as f64 - last_sequence as f64;
|
||||
tracy_client::Client::running()
|
||||
.unwrap()
|
||||
.message(&message, 0);
|
||||
.plot(self.sequence_delta_plot_name, delta);
|
||||
}
|
||||
self.last_sequence = Some(sequence);
|
||||
|
||||
let (clock, flags) = if let Some(tp) = presentation_time {
|
||||
(
|
||||
tp.into(),
|
||||
wp_presentation_feedback::Kind::Vsync
|
||||
| wp_presentation_feedback::Kind::HwClock
|
||||
| wp_presentation_feedback::Kind::HwCompletion,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
now,
|
||||
wp_presentation_feedback::Kind::Vsync
|
||||
| wp_presentation_feedback::Kind::HwCompletion,
|
||||
)
|
||||
};
|
||||
feedback.presented(clock, refresh, sequence as u64, flags);
|
||||
|
||||
let rate = self
|
||||
.output
|
||||
.current_mode()
|
||||
.map(|mode| Duration::from_secs_f64(1_000.0 / mode.refresh as f64));
|
||||
let refresh = match rate {
|
||||
Some(rate)
|
||||
if self
|
||||
.compositor
|
||||
.as_ref()
|
||||
.is_some_and(|comp| comp.with_compositor(|c| c.vrr_enabled())) =>
|
||||
{
|
||||
Refresh::Variable(rate)
|
||||
}
|
||||
Some(rate) => Refresh::Fixed(rate),
|
||||
None => Refresh::Unknown,
|
||||
};
|
||||
self.timings.presented(clock);
|
||||
|
||||
if let Some(last_sequence) = self.last_sequence {
|
||||
let delta = sequence as f64 - last_sequence as f64;
|
||||
tracy_client::Client::running()
|
||||
.unwrap()
|
||||
.plot(self.sequence_delta_plot_name, delta);
|
||||
}
|
||||
self.last_sequence = Some(sequence);
|
||||
|
||||
feedback.presented(clock, refresh, sequence as u64, flags);
|
||||
|
||||
self.timings.presented(clock);
|
||||
|
||||
while let Ok(pending_image_copy_data) = frames.recv() {
|
||||
pending_image_copy_data.send_success_when_ready(
|
||||
self.output.current_transform(),
|
||||
&self.loop_handle,
|
||||
clock,
|
||||
);
|
||||
}
|
||||
while let Ok(pending_image_copy_data) = frames.recv() {
|
||||
pending_image_copy_data.send_success_when_ready(
|
||||
self.output.current_transform(),
|
||||
&self.loop_handle,
|
||||
clock,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1077,11 +1076,11 @@ impl SurfaceThreadState {
|
|||
// we can't use the elements after `compositor.render_frame`,
|
||||
// so let's collect everything we need for screencopy now
|
||||
let mut has_cursor_mode_none = false;
|
||||
let frames = self
|
||||
.mirroring
|
||||
.is_none()
|
||||
.then(|| take_screencopy_frames(&self.output, &elements, &mut has_cursor_mode_none))
|
||||
.unwrap_or_default();
|
||||
let frames = if self.mirroring.is_none() {
|
||||
take_screencopy_frames(&self.output, &elements, &mut has_cursor_mode_none)
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
|
||||
// actual rendering
|
||||
let source_output = self
|
||||
|
|
@ -1312,10 +1311,10 @@ impl SurfaceThreadState {
|
|||
None
|
||||
};
|
||||
|
||||
if frame_result.needs_sync() {
|
||||
if let PrimaryPlaneElement::Swapchain(elem) = &frame_result.primary_element {
|
||||
elem.sync.wait()?;
|
||||
}
|
||||
if frame_result.needs_sync()
|
||||
&& let PrimaryPlaneElement::Swapchain(elem) = &frame_result.primary_element
|
||||
{
|
||||
elem.sync.wait()?;
|
||||
}
|
||||
|
||||
match compositor.queue_frame(feedback) {
|
||||
|
|
|
|||
|
|
@ -103,10 +103,10 @@ pub fn init_backend_auto(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(inverted) = greeter_state.invert_colors {
|
||||
if inverted != state.a11y_state().screen_inverted() {
|
||||
state.request_screen_invert(inverted);
|
||||
}
|
||||
if let Some(inverted) = greeter_state.invert_colors
|
||||
&& inverted != state.a11y_state().screen_inverted()
|
||||
{
|
||||
state.request_screen_invert(inverted);
|
||||
}
|
||||
|
||||
if state
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ where
|
|||
};
|
||||
|
||||
let buf_translation = Matrix3::from_translation(Vector2::new(
|
||||
(view.src.loc.x as f64 / buf_size.w as f64) as f32,
|
||||
(view.src.loc.y as f64 / buf_size.h as f64) as f32,
|
||||
(view.src.loc.x / buf_size.w as f64) as f32,
|
||||
(view.src.loc.y / buf_size.h as f64) as f32,
|
||||
));
|
||||
|
||||
let input_to_geo =
|
||||
|
|
|
|||
|
|
@ -528,19 +528,17 @@ where
|
|||
);
|
||||
}
|
||||
|
||||
if !exclude_dnd_icon {
|
||||
if let Some(dnd_icon) = get_dnd_icon(seat) {
|
||||
elements.extend(
|
||||
cursor::draw_dnd_icon(
|
||||
renderer,
|
||||
&dnd_icon.surface,
|
||||
(location + dnd_icon.offset.to_f64()).to_i32_round(),
|
||||
scale,
|
||||
)
|
||||
.into_iter()
|
||||
.map(CosmicElement::Dnd),
|
||||
);
|
||||
}
|
||||
if !exclude_dnd_icon && let Some(dnd_icon) = get_dnd_icon(seat) {
|
||||
elements.extend(
|
||||
cursor::draw_dnd_icon(
|
||||
renderer,
|
||||
&dnd_icon.surface,
|
||||
(location + dnd_icon.offset.to_f64()).to_i32_round(),
|
||||
scale,
|
||||
)
|
||||
.into_iter()
|
||||
.map(CosmicElement::Dnd),
|
||||
);
|
||||
}
|
||||
|
||||
let theme = theme.cosmic();
|
||||
|
|
@ -1102,17 +1100,15 @@ impl PostprocessState {
|
|||
if let (Some(tex), Some(tracker)) = (
|
||||
self.cursor_texture.as_ref(),
|
||||
self.cursor_damage_tracker.as_ref(),
|
||||
) {
|
||||
if tex.format().is_some_and(|f| f == format)
|
||||
&& tracker.mode()
|
||||
== &(OutputModeSource::Static {
|
||||
size,
|
||||
scale,
|
||||
transform: Transform::Normal,
|
||||
})
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
) && tex.format().is_some_and(|f| f == format)
|
||||
&& tracker.mode()
|
||||
== &(OutputModeSource::Static {
|
||||
size,
|
||||
scale,
|
||||
transform: Transform::Normal,
|
||||
})
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let texture = Offscreen::<GlesTexture>::create_buffer(renderer, format, buffer_size)?;
|
||||
|
|
|
|||
|
|
@ -61,10 +61,10 @@ impl ShadowShader {
|
|||
|
||||
let mut geo = geo.to_f64();
|
||||
let fractional_pixel = scale.ceil() / scale;
|
||||
geo.loc.x = geo.loc.x + fractional_pixel;
|
||||
geo.loc.y = geo.loc.y + fractional_pixel;
|
||||
geo.size.w = geo.size.w - fractional_pixel * 2.;
|
||||
geo.size.h = geo.size.h - fractional_pixel * 2.;
|
||||
geo.loc.x += fractional_pixel;
|
||||
geo.loc.y += fractional_pixel;
|
||||
geo.size.w -= fractional_pixel * 2.;
|
||||
geo.size.h -= fractional_pixel * 2.;
|
||||
|
||||
let user_data = Borrow::<GlesRenderer>::borrow(renderer.glow_renderer())
|
||||
.egl_context()
|
||||
|
|
@ -125,7 +125,7 @@ impl ShadowShader {
|
|||
.cast::<f32>()
|
||||
.unwrap();
|
||||
|
||||
let window_geo_loc = Vector2::new(window_geo.loc.x as f64, window_geo.loc.y as f64);
|
||||
let window_geo_loc = Vector2::new(window_geo.loc.x, window_geo.loc.y);
|
||||
let window_input_to_geo = (Matrix3::from_nonuniform_scale(area_size.x, area_size.y)
|
||||
* Matrix3::from_translation(Vector2::new(
|
||||
-window_geo_loc.x / area_size.x,
|
||||
|
|
|
|||
|
|
@ -517,24 +517,24 @@ where
|
|||
impl State {
|
||||
pub fn process_x11_event(&mut self, event: InputEvent<X11Input>) {
|
||||
// here we can handle special cases for x11 inputs, like mapping them to windows
|
||||
if let InputEvent::PointerMotionAbsolute { event } = &event {
|
||||
if let Some(window) = event.window() {
|
||||
let output = self
|
||||
.backend
|
||||
.x11()
|
||||
.surfaces
|
||||
.iter()
|
||||
.find(|surface| &surface.window == window.as_ref())
|
||||
.map(|surface| surface.output.clone())
|
||||
.unwrap();
|
||||
if let InputEvent::PointerMotionAbsolute { event } = &event
|
||||
&& let Some(window) = event.window()
|
||||
{
|
||||
let output = self
|
||||
.backend
|
||||
.x11()
|
||||
.surfaces
|
||||
.iter()
|
||||
.find(|surface| &surface.window == window.as_ref())
|
||||
.map(|surface| surface.output.clone())
|
||||
.unwrap();
|
||||
|
||||
let device = event.device();
|
||||
for seat in self.common.shell.read().seats.iter() {
|
||||
let devices = seat.user_data().get::<Devices>().unwrap();
|
||||
if devices.has_device(&device) {
|
||||
seat.set_active_output(&output);
|
||||
break;
|
||||
}
|
||||
let device = event.device();
|
||||
for seat in self.common.shell.read().seats.iter() {
|
||||
let devices = seat.user_data().get::<Devices>().unwrap();
|
||||
if devices.has_device(&device) {
|
||||
seat.set_active_output(&output);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -142,70 +142,70 @@ pub fn update_device(
|
|||
);
|
||||
}
|
||||
if let Some((accel, is_default)) = config!(|x| x.acceleration.as_ref()) {
|
||||
if let Some(profile) = accel.profile {
|
||||
if let Err(err) = device.config_accel_set_profile(profile) {
|
||||
config_set_error(device, "acceleration profile", profile, err, is_default);
|
||||
}
|
||||
if let Some(profile) = accel.profile
|
||||
&& let Err(err) = device.config_accel_set_profile(profile)
|
||||
{
|
||||
config_set_error(device, "acceleration profile", profile, err, is_default);
|
||||
}
|
||||
if let Err(err) = device.config_accel_set_speed(accel.speed) {
|
||||
config_set_error(device, "acceleration speed", accel.speed, err, is_default);
|
||||
}
|
||||
}
|
||||
if let Some((matrix, is_default)) = config!(|x| x.calibration) {
|
||||
if let Err(err) = device.config_calibration_set_matrix(matrix) {
|
||||
config_set_error(device, "calibration matrix", matrix, err, is_default);
|
||||
}
|
||||
if let Some((matrix, is_default)) = config!(|x| x.calibration)
|
||||
&& let Err(err) = device.config_calibration_set_matrix(matrix)
|
||||
{
|
||||
config_set_error(device, "calibration matrix", matrix, err, is_default);
|
||||
}
|
||||
if let Some((method, is_default)) = config!(|x| x.click_method) {
|
||||
if let Err(err) = device.config_click_set_method(method) {
|
||||
config_set_error(device, "click method", method, err, is_default);
|
||||
}
|
||||
if let Some((method, is_default)) = config!(|x| x.click_method)
|
||||
&& let Err(err) = device.config_click_set_method(method)
|
||||
{
|
||||
config_set_error(device, "click method", method, err, is_default);
|
||||
}
|
||||
if let Some((dwt, is_default)) = config!(|x| x.disable_while_typing) {
|
||||
if let Err(err) = device.config_dwt_set_enabled(dwt) {
|
||||
config_set_error(device, "disable-while-typing", dwt, err, is_default);
|
||||
}
|
||||
if let Some((dwt, is_default)) = config!(|x| x.disable_while_typing)
|
||||
&& let Err(err) = device.config_dwt_set_enabled(dwt)
|
||||
{
|
||||
config_set_error(device, "disable-while-typing", dwt, err, is_default);
|
||||
}
|
||||
if let Some((left, is_default)) = config!(|x| x.left_handed) {
|
||||
if let Err(err) = device.config_left_handed_set(left) {
|
||||
config_set_error(device, "left-handed", left, err, is_default);
|
||||
}
|
||||
if let Some((left, is_default)) = config!(|x| x.left_handed)
|
||||
&& let Err(err) = device.config_left_handed_set(left)
|
||||
{
|
||||
config_set_error(device, "left-handed", left, err, is_default);
|
||||
}
|
||||
if let Some((middle, is_default)) = config!(|x| x.middle_button_emulation) {
|
||||
if let Err(err) = device.config_middle_emulation_set_enabled(middle) {
|
||||
config_set_error(device, "middle-button-emulation", middle, err, is_default);
|
||||
}
|
||||
if let Some((middle, is_default)) = config!(|x| x.middle_button_emulation)
|
||||
&& let Err(err) = device.config_middle_emulation_set_enabled(middle)
|
||||
{
|
||||
config_set_error(device, "middle-button-emulation", middle, err, is_default);
|
||||
}
|
||||
if let Some((angle, is_default)) = config!(|x| x.rotation_angle) {
|
||||
if let Err(err) = device.config_rotation_set_angle(angle) {
|
||||
config_set_error(device, "rotation-angle", angle, err, is_default);
|
||||
}
|
||||
if let Some((angle, is_default)) = config!(|x| x.rotation_angle)
|
||||
&& let Err(err) = device.config_rotation_set_angle(angle)
|
||||
{
|
||||
config_set_error(device, "rotation-angle", angle, err, is_default);
|
||||
}
|
||||
if let Some((scroll, is_default)) = config!(|x| x.scroll_config.as_ref()) {
|
||||
if let Some(method) = scroll.method {
|
||||
if let Err(err) = device.config_scroll_set_method(method) {
|
||||
config_set_error(device, "scroll method", scroll, err, is_default);
|
||||
}
|
||||
if let Some(method) = scroll.method
|
||||
&& let Err(err) = device.config_scroll_set_method(method)
|
||||
{
|
||||
config_set_error(device, "scroll method", scroll, err, is_default);
|
||||
}
|
||||
if let Some(natural) = scroll.natural_scroll {
|
||||
if let Err(err) = device.config_scroll_set_natural_scroll_enabled(natural) {
|
||||
config_set_error(device, "natural scrolling", natural, err, is_default);
|
||||
}
|
||||
if let Some(natural) = scroll.natural_scroll
|
||||
&& let Err(err) = device.config_scroll_set_natural_scroll_enabled(natural)
|
||||
{
|
||||
config_set_error(device, "natural scrolling", natural, err, is_default);
|
||||
}
|
||||
if let Some(button) = scroll.scroll_button {
|
||||
if let Err(err) = device.config_scroll_set_button(button) {
|
||||
config_set_error(device, "scroll button", button, err, is_default);
|
||||
}
|
||||
if let Some(button) = scroll.scroll_button
|
||||
&& let Err(err) = device.config_scroll_set_button(button)
|
||||
{
|
||||
config_set_error(device, "scroll button", button, err, is_default);
|
||||
}
|
||||
}
|
||||
if let Some((tap, is_default)) = config!(|x| x.tap_config.as_ref()) {
|
||||
if let Err(err) = device.config_tap_set_enabled(tap.enabled) {
|
||||
config_set_error(device, "tap-to-click", tap.enabled, err, is_default);
|
||||
}
|
||||
if let Some(button_map) = tap.button_map {
|
||||
if let Err(err) = device.config_tap_set_button_map(button_map) {
|
||||
config_set_error(device, "button map", button_map, err, is_default);
|
||||
}
|
||||
if let Some(button_map) = tap.button_map
|
||||
&& let Err(err) = device.config_tap_set_button_map(button_map)
|
||||
{
|
||||
config_set_error(device, "button map", button_map, err, is_default);
|
||||
}
|
||||
if let Err(err) = device.config_tap_set_drag_enabled(tap.drag) {
|
||||
config_set_error(device, "tap-drag", tap.drag, err, is_default);
|
||||
|
|
|
|||
|
|
@ -371,20 +371,20 @@ impl Config {
|
|||
}
|
||||
|
||||
fn load_filter_state(path: &Option<PathBuf>) -> ScreenFilter {
|
||||
if let Some(path) = path.as_ref() {
|
||||
if path.exists() {
|
||||
match ron::de::from_reader::<_, ScreenFilter>(
|
||||
OpenOptions::new().read(true).open(path).unwrap(),
|
||||
) {
|
||||
Ok(config) => return config,
|
||||
Err(err) => {
|
||||
warn!(?err, "Failed to read screen_filter state, resetting..");
|
||||
if let Err(err) = std::fs::remove_file(path) {
|
||||
error!(?err, "Failed to remove screen_filter state.");
|
||||
}
|
||||
if let Some(path) = path.as_ref()
|
||||
&& path.exists()
|
||||
{
|
||||
match ron::de::from_reader::<_, ScreenFilter>(
|
||||
OpenOptions::new().read(true).open(path).unwrap(),
|
||||
) {
|
||||
Ok(config) => return config,
|
||||
Err(err) => {
|
||||
warn!(?err, "Failed to read screen_filter state, resetting..");
|
||||
if let Err(err) = std::fs::remove_file(path) {
|
||||
error!(?err, "Failed to remove screen_filter state.");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ScreenFilter {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use zbus::{
|
|||
|
||||
use super::name_owners::NameOwners;
|
||||
|
||||
static ALLOWED_NAMES: &'static [WellKnownName] = &[WellKnownName::from_static_str_unchecked(
|
||||
static ALLOWED_NAMES: &[WellKnownName] = &[WellKnownName::from_static_str_unchecked(
|
||||
"org.gnome.Orca.KeyboardMonitor",
|
||||
)];
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ impl NameOwners {
|
|||
} else {
|
||||
allowed_names
|
||||
.iter()
|
||||
.any(|n| inner.name_owners.get(n).map(|x| x.as_ref()).flatten() == Some(name))
|
||||
.any(|n| inner.name_owners.get(n).and_then(|x| x.as_ref()) == Some(name))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -188,16 +188,15 @@ impl State {
|
|||
}
|
||||
|
||||
Action::NextWorkspace => {
|
||||
if let Some(direction) = pattern.inferred_direction() {
|
||||
if ((direction == Direction::Left || direction == Direction::Right)
|
||||
if let Some(direction) = pattern.inferred_direction()
|
||||
&& (((direction == Direction::Left || direction == Direction::Right)
|
||||
&& self.common.config.cosmic_conf.workspaces.workspace_layout
|
||||
== WorkspaceLayout::Vertical)
|
||||
|| ((direction == Direction::Up || direction == Direction::Down)
|
||||
&& self.common.config.cosmic_conf.workspaces.workspace_layout
|
||||
== WorkspaceLayout::Horizontal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
== WorkspaceLayout::Horizontal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let next = to_next_workspace(
|
||||
|
|
@ -234,16 +233,15 @@ impl State {
|
|||
}
|
||||
|
||||
Action::PreviousWorkspace => {
|
||||
if let Some(direction) = pattern.inferred_direction() {
|
||||
if ((direction == Direction::Left || direction == Direction::Right)
|
||||
if let Some(direction) = pattern.inferred_direction()
|
||||
&& (((direction == Direction::Left || direction == Direction::Right)
|
||||
&& self.common.config.cosmic_conf.workspaces.workspace_layout
|
||||
== WorkspaceLayout::Vertical)
|
||||
|| ((direction == Direction::Up || direction == Direction::Down)
|
||||
&& self.common.config.cosmic_conf.workspaces.workspace_layout
|
||||
== WorkspaceLayout::Horizontal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
== WorkspaceLayout::Horizontal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let previous = to_previous_workspace(
|
||||
|
|
@ -336,16 +334,15 @@ impl State {
|
|||
}
|
||||
|
||||
x @ Action::MoveToNextWorkspace | x @ Action::SendToNextWorkspace => {
|
||||
if let Some(direction) = pattern.inferred_direction() {
|
||||
if ((direction == Direction::Left || direction == Direction::Right)
|
||||
if let Some(direction) = pattern.inferred_direction()
|
||||
&& (((direction == Direction::Left || direction == Direction::Right)
|
||||
&& self.common.config.cosmic_conf.workspaces.workspace_layout
|
||||
== WorkspaceLayout::Vertical)
|
||||
|| ((direction == Direction::Up || direction == Direction::Down)
|
||||
&& self.common.config.cosmic_conf.workspaces.workspace_layout
|
||||
== WorkspaceLayout::Horizontal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
== WorkspaceLayout::Horizontal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
let Some(focused_output) = seat.focused_output() else {
|
||||
return;
|
||||
|
|
@ -420,16 +417,15 @@ impl State {
|
|||
}
|
||||
|
||||
x @ Action::MoveToPreviousWorkspace | x @ Action::SendToPreviousWorkspace => {
|
||||
if let Some(direction) = pattern.inferred_direction() {
|
||||
if ((direction == Direction::Left || direction == Direction::Right)
|
||||
if let Some(direction) = pattern.inferred_direction()
|
||||
&& (((direction == Direction::Left || direction == Direction::Right)
|
||||
&& self.common.config.cosmic_conf.workspaces.workspace_layout
|
||||
== WorkspaceLayout::Vertical)
|
||||
|| ((direction == Direction::Up || direction == Direction::Down)
|
||||
&& self.common.config.cosmic_conf.workspaces.workspace_layout
|
||||
== WorkspaceLayout::Horizontal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
== WorkspaceLayout::Horizontal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
let Some(focused_output) = seat.focused_output() else {
|
||||
return;
|
||||
|
|
@ -511,21 +507,18 @@ impl State {
|
|||
if let Some(next_output) = next_output {
|
||||
let res = {
|
||||
let mut workspace_guard = self.common.workspace_state.update();
|
||||
if propagate {
|
||||
if let Some((serial, prev_output, prev_idx)) =
|
||||
if propagate
|
||||
&& let Some((serial, prev_output, prev_idx)) =
|
||||
shell.previous_workspace_idx.take()
|
||||
{
|
||||
if seat.last_modifier_change().is_some_and(|s| s == serial)
|
||||
&& prev_output == current_output
|
||||
{
|
||||
let _ = shell.activate(
|
||||
¤t_output,
|
||||
prev_idx,
|
||||
WorkspaceDelta::new_shortcut(),
|
||||
&mut workspace_guard,
|
||||
);
|
||||
}
|
||||
}
|
||||
&& seat.last_modifier_change().is_some_and(|s| s == serial)
|
||||
&& prev_output == current_output
|
||||
{
|
||||
let _ = shell.activate(
|
||||
¤t_output,
|
||||
prev_idx,
|
||||
WorkspaceDelta::new_shortcut(),
|
||||
&mut workspace_guard,
|
||||
);
|
||||
}
|
||||
|
||||
let idx = shell.workspaces.active_num(&next_output).1;
|
||||
|
|
@ -607,19 +600,18 @@ impl State {
|
|||
&self.common.event_loop_handle,
|
||||
);
|
||||
|
||||
if is_move_action && propagate {
|
||||
if let Some((_, prev_output, prev_idx)) =
|
||||
if is_move_action
|
||||
&& propagate
|
||||
&& let Some((_, prev_output, prev_idx)) =
|
||||
shell.previous_workspace_idx.take()
|
||||
{
|
||||
if prev_output == focused_output {
|
||||
let _ = shell.activate(
|
||||
&focused_output,
|
||||
prev_idx,
|
||||
WorkspaceDelta::new_shortcut(),
|
||||
&mut workspace_guard,
|
||||
);
|
||||
}
|
||||
}
|
||||
&& prev_output == focused_output
|
||||
{
|
||||
let _ = shell.activate(
|
||||
&focused_output,
|
||||
prev_idx,
|
||||
WorkspaceDelta::new_shortcut(),
|
||||
&mut workspace_guard,
|
||||
);
|
||||
}
|
||||
res
|
||||
};
|
||||
|
|
@ -837,13 +829,12 @@ impl State {
|
|||
let workspace = shell.active_space(¤t_output).unwrap();
|
||||
if let Some(FocusTarget::Window(focused_window)) =
|
||||
workspace.focus_stack.get(seat).last()
|
||||
&& workspace.is_tiled(&focused_window.active_window())
|
||||
{
|
||||
if workspace.is_tiled(&focused_window.active_window()) {
|
||||
shell.set_overview_mode(
|
||||
Some(Trigger::KeyboardMove(pattern.modifiers)),
|
||||
self.common.event_loop_handle.clone(),
|
||||
);
|
||||
}
|
||||
shell.set_overview_mode(
|
||||
Some(Trigger::KeyboardMove(pattern.modifiers)),
|
||||
self.common.event_loop_handle.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -858,17 +849,17 @@ impl State {
|
|||
let workspace = shell.active_space_mut(&focused_output).unwrap();
|
||||
let keyboard_handle = seat.get_keyboard().unwrap();
|
||||
|
||||
if let Some(focus) = keyboard_handle.current_focus() {
|
||||
if let Some(descriptor) = workspace.node_desc(focus) {
|
||||
let grab = SwapWindowGrab::new(seat.clone(), descriptor.clone());
|
||||
drop(shell);
|
||||
keyboard_handle.set_grab(self, grab, serial);
|
||||
let mut shell = self.common.shell.write();
|
||||
shell.set_overview_mode(
|
||||
Some(Trigger::KeyboardSwap(pattern, descriptor)),
|
||||
self.common.event_loop_handle.clone(),
|
||||
);
|
||||
}
|
||||
if let Some(focus) = keyboard_handle.current_focus()
|
||||
&& let Some(descriptor) = workspace.node_desc(focus)
|
||||
{
|
||||
let grab = SwapWindowGrab::new(seat.clone(), descriptor.clone());
|
||||
drop(shell);
|
||||
keyboard_handle.set_grab(self, grab, serial);
|
||||
let mut shell = self.common.shell.write();
|
||||
shell.set_overview_mode(
|
||||
Some(Trigger::KeyboardSwap(pattern, descriptor)),
|
||||
self.common.event_loop_handle.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,14 +73,14 @@ impl GestureState {
|
|||
fn push(&mut self, delta: f64, timestamp: Duration) {
|
||||
// For the events that we care about, timestamps should always increase
|
||||
// monotonically.
|
||||
if let Some(last) = self.history.back() {
|
||||
if timestamp < last.timestamp {
|
||||
trace!(
|
||||
"ignoring event with timestamp {timestamp:?} earlier than last {:?}",
|
||||
last.timestamp
|
||||
);
|
||||
return;
|
||||
}
|
||||
if let Some(last) = self.history.back()
|
||||
&& timestamp < last.timestamp
|
||||
{
|
||||
trace!(
|
||||
"ignoring event with timestamp {timestamp:?} earlier than last {:?}",
|
||||
last.timestamp
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
self.history.push_back(SwipeEvent { delta, timestamp });
|
||||
|
|
|
|||
479
src/input/mod.rs
479
src/input/mod.rs
|
|
@ -493,51 +493,48 @@ impl State {
|
|||
}
|
||||
|
||||
// If confined, don't move pointer if it would go outside surface or region
|
||||
if pointer_confined {
|
||||
if let Some((surface, surface_loc)) = &under {
|
||||
if new_under.as_ref().and_then(|(under, _)| under.wl_surface())
|
||||
!= surface.wl_surface()
|
||||
{
|
||||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
match surface {
|
||||
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||
if under_from_surface_tree(
|
||||
surface,
|
||||
position.as_logical() - surface_loc.to_f64(),
|
||||
(0, 0),
|
||||
WindowSurfaceType::ALL,
|
||||
)
|
||||
.is_none()
|
||||
{
|
||||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
PointerFocusTarget::X11Surface { surface, .. } => {
|
||||
if surface
|
||||
.surface_under(
|
||||
position.as_logical() - surface_loc.to_f64(),
|
||||
(0, 0),
|
||||
WindowSurfaceType::ALL,
|
||||
)
|
||||
.is_none()
|
||||
{
|
||||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if let Some(region) = confine_region {
|
||||
if !region
|
||||
.contains((position.as_logical() - *surface_loc).to_i32_round())
|
||||
if pointer_confined && let Some((surface, surface_loc)) = &under {
|
||||
if new_under.as_ref().and_then(|(under, _)| under.wl_surface())
|
||||
!= surface.wl_surface()
|
||||
{
|
||||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
match surface {
|
||||
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||
if under_from_surface_tree(
|
||||
surface,
|
||||
position.as_logical() - surface_loc.to_f64(),
|
||||
(0, 0),
|
||||
WindowSurfaceType::ALL,
|
||||
)
|
||||
.is_none()
|
||||
{
|
||||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
PointerFocusTarget::X11Surface { surface, .. } => {
|
||||
if surface
|
||||
.surface_under(
|
||||
position.as_logical() - surface_loc.to_f64(),
|
||||
(0, 0),
|
||||
WindowSurfaceType::ALL,
|
||||
)
|
||||
.is_none()
|
||||
{
|
||||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if let Some(region) = confine_region
|
||||
&& !region
|
||||
.contains((position.as_logical() - *surface_loc).to_i32_round())
|
||||
{
|
||||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -722,99 +719,95 @@ impl State {
|
|||
State::element_under(global_position, &output, &shell, &seat)
|
||||
};
|
||||
if let Some(target) = under {
|
||||
if let Some(surface) = target.toplevel().map(Cow::into_owned) {
|
||||
if seat.get_keyboard().unwrap().modifier_state().logo
|
||||
&& !shortcuts_inhibited
|
||||
{
|
||||
let seat_clone = seat.clone();
|
||||
let mouse_button = PointerButtonEvent::button(&event);
|
||||
if let Some(surface) = target.toplevel().map(Cow::into_owned)
|
||||
&& seat.get_keyboard().unwrap().modifier_state().logo
|
||||
&& !shortcuts_inhibited
|
||||
{
|
||||
let seat_clone = seat.clone();
|
||||
let mouse_button = PointerButtonEvent::button(&event);
|
||||
|
||||
let mut supress_button = || {
|
||||
// If the logo is held then the pointer event is
|
||||
// aimed at the compositor and shouldn't be passed
|
||||
// to the application.
|
||||
pass_event = false;
|
||||
seat.supressed_buttons().add(button);
|
||||
};
|
||||
let mut supress_button = || {
|
||||
// If the logo is held then the pointer event is
|
||||
// aimed at the compositor and shouldn't be passed
|
||||
// to the application.
|
||||
pass_event = false;
|
||||
seat.supressed_buttons().add(button);
|
||||
};
|
||||
|
||||
fn dispatch_grab<G: PointerGrab<State> + 'static>(
|
||||
grab: Option<(G, smithay::input::pointer::Focus)>,
|
||||
seat: Seat<State>,
|
||||
serial: Serial,
|
||||
state: &mut State,
|
||||
) {
|
||||
if let Some((target, focus)) = grab {
|
||||
seat.modifiers_shortcut_queue().clear();
|
||||
fn dispatch_grab<G: PointerGrab<State> + 'static>(
|
||||
grab: Option<(G, smithay::input::pointer::Focus)>,
|
||||
seat: Seat<State>,
|
||||
serial: Serial,
|
||||
state: &mut State,
|
||||
) {
|
||||
if let Some((target, focus)) = grab {
|
||||
seat.modifiers_shortcut_queue().clear();
|
||||
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, target, serial, focus);
|
||||
}
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, target, serial, focus);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(mouse_button) = mouse_button {
|
||||
match mouse_button {
|
||||
smithay::backend::input::MouseButton::Left => {
|
||||
supress_button();
|
||||
self.common.event_loop_handle.insert_idle(
|
||||
move |state| {
|
||||
let mut shell = state.common.shell.write();
|
||||
let res = shell.move_request(
|
||||
&surface,
|
||||
&seat_clone,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
drop(shell);
|
||||
dispatch_grab(
|
||||
res, seat_clone, serial, state,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
smithay::backend::input::MouseButton::Right => {
|
||||
supress_button();
|
||||
self.common.event_loop_handle.insert_idle(
|
||||
move |state| {
|
||||
let mut shell = state.common.shell.write();
|
||||
let Some(target_elem) =
|
||||
shell.element_for_surface(&surface)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Some(geom) = shell
|
||||
.space_for(target_elem)
|
||||
.and_then(|f| {
|
||||
f.element_geometry(target_elem)
|
||||
})
|
||||
.or_else(|| {
|
||||
shell
|
||||
.workspaces
|
||||
.sets
|
||||
.get(&output)
|
||||
.and_then(|set| {
|
||||
set.sticky_layer
|
||||
.element_geometry(
|
||||
target_elem,
|
||||
)
|
||||
})
|
||||
})
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let geom = geom.to_f64();
|
||||
let center =
|
||||
geom.loc + geom.size.downscale(2.0);
|
||||
let offset = center.to_global(&output)
|
||||
- global_position;
|
||||
let edge = match (
|
||||
offset.x > 0.0,
|
||||
offset.y > 0.0,
|
||||
) {
|
||||
if let Some(mouse_button) = mouse_button {
|
||||
match mouse_button {
|
||||
smithay::backend::input::MouseButton::Left => {
|
||||
supress_button();
|
||||
self.common.event_loop_handle.insert_idle(
|
||||
move |state| {
|
||||
let mut shell = state.common.shell.write();
|
||||
let res = shell.move_request(
|
||||
&surface,
|
||||
&seat_clone,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
drop(shell);
|
||||
dispatch_grab(res, seat_clone, serial, state);
|
||||
},
|
||||
);
|
||||
}
|
||||
smithay::backend::input::MouseButton::Right => {
|
||||
supress_button();
|
||||
self.common.event_loop_handle.insert_idle(
|
||||
move |state| {
|
||||
let mut shell = state.common.shell.write();
|
||||
let Some(target_elem) =
|
||||
shell.element_for_surface(&surface)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Some(geom) = shell
|
||||
.space_for(target_elem)
|
||||
.and_then(|f| {
|
||||
f.element_geometry(target_elem)
|
||||
})
|
||||
.or_else(|| {
|
||||
shell
|
||||
.workspaces
|
||||
.sets
|
||||
.get(&output)
|
||||
.and_then(|set| {
|
||||
set.sticky_layer
|
||||
.element_geometry(
|
||||
target_elem,
|
||||
)
|
||||
})
|
||||
})
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let geom = geom.to_f64();
|
||||
let center =
|
||||
geom.loc + geom.size.downscale(2.0);
|
||||
let offset =
|
||||
center.to_global(&output) - global_position;
|
||||
let edge =
|
||||
match (offset.x > 0.0, offset.y > 0.0) {
|
||||
(true, true) => ResizeEdge::TOP_LEFT,
|
||||
(false, true) => ResizeEdge::TOP_RIGHT,
|
||||
(true, false) => {
|
||||
|
|
@ -824,27 +817,24 @@ impl State {
|
|||
ResizeEdge::BOTTOM_RIGHT
|
||||
}
|
||||
};
|
||||
let res = shell.resize_request(
|
||||
&surface,
|
||||
&seat_clone,
|
||||
serial,
|
||||
edge,
|
||||
state
|
||||
.common
|
||||
.config
|
||||
.cosmic_conf
|
||||
.edge_snap_threshold,
|
||||
false,
|
||||
);
|
||||
drop(shell);
|
||||
dispatch_grab(
|
||||
res, seat_clone, serial, state,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
let res = shell.resize_request(
|
||||
&surface,
|
||||
&seat_clone,
|
||||
serial,
|
||||
edge,
|
||||
state
|
||||
.common
|
||||
.config
|
||||
.cosmic_conf
|
||||
.edge_snap_threshold,
|
||||
false,
|
||||
);
|
||||
drop(shell);
|
||||
dispatch_grab(res, seat_clone, serial, state);
|
||||
},
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -856,10 +846,9 @@ impl State {
|
|||
let mut shell = self.common.shell.write();
|
||||
if let Some(Trigger::Pointer(action_button)) =
|
||||
shell.overview_mode().0.active_trigger()
|
||||
&& *action_button == button
|
||||
{
|
||||
if *action_button == button {
|
||||
shell.set_overview_mode(None, self.common.event_loop_handle.clone());
|
||||
}
|
||||
shell.set_overview_mode(None, self.common.event_loop_handle.clone());
|
||||
}
|
||||
std::mem::drop(shell);
|
||||
};
|
||||
|
|
@ -1016,10 +1005,9 @@ impl State {
|
|||
let mut natural_scroll = false;
|
||||
if let Some(scroll_config) =
|
||||
&self.common.config.cosmic_conf.input_touchpad.scroll_config
|
||||
&& let Some(natural) = scroll_config.natural_scroll
|
||||
{
|
||||
if let Some(natural) = scroll_config.natural_scroll {
|
||||
natural_scroll = natural;
|
||||
}
|
||||
natural_scroll = natural;
|
||||
}
|
||||
activate_action = match gesture_state.fingers {
|
||||
3 => None, // TODO: 3 finger gestures
|
||||
|
|
@ -1317,10 +1305,10 @@ impl State {
|
|||
}
|
||||
InputEvent::TouchUp { event, .. } => {
|
||||
let mut shell = self.common.shell.write();
|
||||
if let Some(Trigger::Touch(slot)) = shell.overview_mode().0.active_trigger() {
|
||||
if *slot == event.slot() {
|
||||
shell.set_overview_mode(None, self.common.event_loop_handle.clone());
|
||||
}
|
||||
if let Some(Trigger::Touch(slot)) = shell.overview_mode().0.active_trigger()
|
||||
&& *slot == event.slot()
|
||||
{
|
||||
shell.set_overview_mode(None, self.common.event_loop_handle.clone());
|
||||
}
|
||||
|
||||
let maybe_seat = shell.seats.for_device(&event.device()).cloned();
|
||||
|
|
@ -1621,37 +1609,33 @@ impl State {
|
|||
// Leave move overview mode, if any modifier was released
|
||||
if let Some(Trigger::KeyboardMove(action_modifiers)) =
|
||||
shell.overview_mode().0.active_trigger()
|
||||
{
|
||||
if (action_modifiers.ctrl && !modifiers.ctrl)
|
||||
&& ((action_modifiers.ctrl && !modifiers.ctrl)
|
||||
|| (action_modifiers.alt && !modifiers.alt)
|
||||
|| (action_modifiers.logo && !modifiers.logo)
|
||||
|| (action_modifiers.shift && !modifiers.shift)
|
||||
{
|
||||
shell.set_overview_mode(None, self.common.event_loop_handle.clone());
|
||||
}
|
||||
|| (action_modifiers.shift && !modifiers.shift))
|
||||
{
|
||||
shell.set_overview_mode(None, self.common.event_loop_handle.clone());
|
||||
}
|
||||
// Leave swap overview mode, if any key was released
|
||||
if let Some(Trigger::KeyboardSwap(action_pattern, old_descriptor)) =
|
||||
shell.overview_mode().0.active_trigger()
|
||||
{
|
||||
if (action_pattern.modifiers.ctrl && !modifiers.ctrl)
|
||||
&& ((action_pattern.modifiers.ctrl && !modifiers.ctrl)
|
||||
|| (action_pattern.modifiers.alt && !modifiers.alt)
|
||||
|| (action_pattern.modifiers.logo && !modifiers.logo)
|
||||
|| (action_pattern.modifiers.shift && !modifiers.shift)
|
||||
|| (action_pattern.key.is_some()
|
||||
&& key_matches(action_pattern.key.unwrap())
|
||||
&& event.state() == KeyState::Released)
|
||||
{
|
||||
shell.set_overview_mode(None, self.common.event_loop_handle.clone());
|
||||
&& event.state() == KeyState::Released))
|
||||
{
|
||||
shell.set_overview_mode(None, self.common.event_loop_handle.clone());
|
||||
|
||||
self.keyboard_swap(
|
||||
seat,
|
||||
&mut shell,
|
||||
old_descriptor,
|
||||
current_focus,
|
||||
&focused_output,
|
||||
);
|
||||
}
|
||||
self.keyboard_swap(
|
||||
seat,
|
||||
&mut shell,
|
||||
old_descriptor,
|
||||
current_focus,
|
||||
&focused_output,
|
||||
);
|
||||
}
|
||||
|
||||
// Leave or update resize mode, if modifiers changed or initial key was released
|
||||
|
|
@ -1832,13 +1816,13 @@ impl State {
|
|||
}
|
||||
|
||||
// Skip released events for initially surpressed keys
|
||||
if event.state() == KeyState::Released {
|
||||
if let Some(tokens) = seat.supressed_keys().filter(&handle) {
|
||||
for token in tokens {
|
||||
self.common.event_loop_handle.remove(token);
|
||||
}
|
||||
return FilterResult::Intercept(None);
|
||||
if event.state() == KeyState::Released
|
||||
&& let Some(tokens) = seat.supressed_keys().filter(&handle)
|
||||
{
|
||||
for token in tokens {
|
||||
self.common.event_loop_handle.remove(token);
|
||||
}
|
||||
return FilterResult::Intercept(None);
|
||||
}
|
||||
|
||||
// Handle VT switches
|
||||
|
|
@ -1944,41 +1928,40 @@ impl State {
|
|||
if old_descriptor.handle != new_descriptor.handle {
|
||||
let (mut old_w, mut other_w) =
|
||||
spaces.partition::<Vec<_>, _>(|w| w.handle == old_descriptor.handle);
|
||||
if let Some(old_workspace) = old_w.get_mut(0) {
|
||||
if let Some(new_workspace) = other_w
|
||||
if let Some(old_workspace) = old_w.get_mut(0)
|
||||
&& let Some(new_workspace) = other_w
|
||||
.iter_mut()
|
||||
.find(|w| w.handle == new_descriptor.handle)
|
||||
{
|
||||
{
|
||||
{
|
||||
let mut stack = new_workspace.focus_stack.get_mut(seat);
|
||||
for elem in old_descriptor.focus_stack.iter().flat_map(|node_id| {
|
||||
old_workspace.tiling_layer.element_for_node(node_id)
|
||||
}) {
|
||||
stack.append(elem.clone());
|
||||
}
|
||||
let mut stack = new_workspace.focus_stack.get_mut(seat);
|
||||
for elem in old_descriptor.focus_stack.iter().flat_map(|node_id| {
|
||||
old_workspace.tiling_layer.element_for_node(node_id)
|
||||
}) {
|
||||
stack.append(elem.clone());
|
||||
}
|
||||
{
|
||||
let mut stack = old_workspace.focus_stack.get_mut(seat);
|
||||
for elem in new_descriptor.focus_stack.iter().flat_map(|node_id| {
|
||||
new_workspace.tiling_layer.element_for_node(node_id)
|
||||
}) {
|
||||
stack.append(elem.clone());
|
||||
}
|
||||
}
|
||||
if let Some(focus) = TilingLayout::swap_trees(
|
||||
&mut old_workspace.tiling_layer,
|
||||
Some(&mut new_workspace.tiling_layer),
|
||||
old_descriptor,
|
||||
&new_descriptor,
|
||||
) {
|
||||
let seat = seat.clone();
|
||||
self.common.event_loop_handle.insert_idle(move |state| {
|
||||
Shell::set_focus(state, Some(&focus), &seat, None, true);
|
||||
});
|
||||
}
|
||||
old_workspace.refresh_focus_stack();
|
||||
new_workspace.refresh_focus_stack();
|
||||
}
|
||||
{
|
||||
let mut stack = old_workspace.focus_stack.get_mut(seat);
|
||||
for elem in new_descriptor.focus_stack.iter().flat_map(|node_id| {
|
||||
new_workspace.tiling_layer.element_for_node(node_id)
|
||||
}) {
|
||||
stack.append(elem.clone());
|
||||
}
|
||||
}
|
||||
if let Some(focus) = TilingLayout::swap_trees(
|
||||
&mut old_workspace.tiling_layer,
|
||||
Some(&mut new_workspace.tiling_layer),
|
||||
old_descriptor,
|
||||
&new_descriptor,
|
||||
) {
|
||||
let seat = seat.clone();
|
||||
self.common.event_loop_handle.insert_idle(move |state| {
|
||||
Shell::set_focus(state, Some(&focus), &seat, None, true);
|
||||
});
|
||||
}
|
||||
old_workspace.refresh_focus_stack();
|
||||
new_workspace.refresh_focus_stack();
|
||||
}
|
||||
} else if let Some(workspace) = spaces.find(|w| w.handle == new_descriptor.handle) {
|
||||
if let Some(focus) = TilingLayout::swap_trees(
|
||||
|
|
@ -2002,36 +1985,34 @@ impl State {
|
|||
let spaces = shell.workspaces.spaces_mut();
|
||||
let (mut old_w, mut other_w) =
|
||||
spaces.partition::<Vec<_>, _>(|w| w.handle == old_descriptor.handle);
|
||||
if let Some(old_workspace) = old_w.get_mut(0) {
|
||||
if let Some(new_workspace) =
|
||||
if let Some(old_workspace) = old_w.get_mut(0)
|
||||
&& let Some(new_workspace) =
|
||||
other_w.iter_mut().find(|w| w.handle == new_workspace)
|
||||
&& new_workspace.tiling_layer.windows().next().is_none()
|
||||
{
|
||||
{
|
||||
if new_workspace.tiling_layer.windows().next().is_none() {
|
||||
{
|
||||
let mut stack = new_workspace.focus_stack.get_mut(seat);
|
||||
for elem in old_descriptor.focus_stack.iter().flat_map(|node_id| {
|
||||
old_workspace.tiling_layer.element_for_node(node_id)
|
||||
}) {
|
||||
stack.append(elem.clone());
|
||||
}
|
||||
}
|
||||
if let Some(focus) = TilingLayout::move_tree(
|
||||
&mut old_workspace.tiling_layer,
|
||||
&mut new_workspace.tiling_layer,
|
||||
&new_workspace.handle,
|
||||
seat,
|
||||
new_workspace.focus_stack.get(seat).iter(),
|
||||
old_descriptor.clone(),
|
||||
None,
|
||||
) {
|
||||
let seat = seat.clone();
|
||||
self.common.event_loop_handle.insert_idle(move |state| {
|
||||
Shell::set_focus(state, Some(&focus), &seat, None, true);
|
||||
});
|
||||
}
|
||||
old_workspace.refresh_focus_stack();
|
||||
let mut stack = new_workspace.focus_stack.get_mut(seat);
|
||||
for elem in old_descriptor.focus_stack.iter().flat_map(|node_id| {
|
||||
old_workspace.tiling_layer.element_for_node(node_id)
|
||||
}) {
|
||||
stack.append(elem.clone());
|
||||
}
|
||||
}
|
||||
if let Some(focus) = TilingLayout::move_tree(
|
||||
&mut old_workspace.tiling_layer,
|
||||
&mut new_workspace.tiling_layer,
|
||||
&new_workspace.handle,
|
||||
seat,
|
||||
new_workspace.focus_stack.get(seat).iter(),
|
||||
old_descriptor.clone(),
|
||||
None,
|
||||
) {
|
||||
let seat = seat.clone();
|
||||
self.common.event_loop_handle.insert_idle(move |state| {
|
||||
Shell::set_focus(state, Some(&focus), &seat, None, true);
|
||||
});
|
||||
}
|
||||
old_workspace.refresh_focus_stack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2136,10 +2117,9 @@ impl State {
|
|||
.is_some_and(|geometry| {
|
||||
geometry.contains(global_pos.to_local(output).to_i32_round())
|
||||
})
|
||||
&& let Some(element) = workspace.popup_element_under(location, seat)
|
||||
{
|
||||
if let Some(element) = workspace.popup_element_under(location, seat) {
|
||||
return ControlFlow::Break(Ok(Some(element)));
|
||||
}
|
||||
return ControlFlow::Break(Ok(Some(element)));
|
||||
}
|
||||
}
|
||||
Stage::Workspace { workspace, offset } => {
|
||||
|
|
@ -2151,11 +2131,9 @@ impl State {
|
|||
.is_some_and(|geometry| {
|
||||
geometry.contains(global_pos.to_local(output).to_i32_round())
|
||||
})
|
||||
&& let Some(element) = workspace.toplevel_element_under(location, seat)
|
||||
{
|
||||
if let Some(element) = workspace.toplevel_element_under(location, seat)
|
||||
{
|
||||
return ControlFlow::Break(Ok(Some(element)));
|
||||
}
|
||||
return ControlFlow::Break(Ok(Some(element)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2199,12 +2177,11 @@ impl State {
|
|||
|stage| {
|
||||
match stage {
|
||||
Stage::ZoomUI => {
|
||||
if let Some(zoom_state) = shell.zoom_state() {
|
||||
if let Some((target, loc)) =
|
||||
if let Some(zoom_state) = shell.zoom_state()
|
||||
&& let Some((target, loc)) =
|
||||
zoom_state.surface_under(output, global_pos)
|
||||
{
|
||||
return ControlFlow::Break(Ok(Some((target, loc))));
|
||||
}
|
||||
{
|
||||
return ControlFlow::Break(Ok(Some((target, loc))));
|
||||
}
|
||||
}
|
||||
Stage::SessionLock(lock_surface) => {
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ pub fn setup_socket(handle: LoopHandle<State>, common: &Common) -> Result<()> {
|
|||
stream.read_bytes = 0;
|
||||
match std::str::from_utf8(&stream.buffer) {
|
||||
Ok(message) => {
|
||||
match serde_json::from_str::<'_, Message>(&message) {
|
||||
match serde_json::from_str::<'_, Message>(message) {
|
||||
Ok(Message::SetEnv { .. }) => warn!("Got SetEnv from session? What is this?"),
|
||||
_ => warn!("Unknown session socket message, are you using incompatible cosmic-session and cosmic-comp versions?"),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -602,10 +602,10 @@ impl CosmicStack {
|
|||
let previous = p.previous_keyboard.swap(active, Ordering::SeqCst);
|
||||
if previous != active || p.reenter.swap(false, Ordering::SeqCst) {
|
||||
let windows = p.windows.lock().unwrap();
|
||||
if let Some(previous_surface) = windows.get(previous) {
|
||||
if previous != active {
|
||||
KeyboardTarget::leave(previous_surface, seat, data, serial);
|
||||
}
|
||||
if let Some(previous_surface) = windows.get(previous)
|
||||
&& previous != active
|
||||
{
|
||||
KeyboardTarget::leave(previous_surface, seat, data, serial);
|
||||
}
|
||||
KeyboardTarget::enter(
|
||||
&windows[active],
|
||||
|
|
@ -685,15 +685,15 @@ impl CosmicStack {
|
|||
if tiled && !appearance.shadow_tiled_windows {
|
||||
return None;
|
||||
}
|
||||
let radii = round
|
||||
.then(|| {
|
||||
theme
|
||||
.cosmic()
|
||||
.radius_s()
|
||||
.map(|x| if x < 4.0 { x } else { x + 4.0 })
|
||||
.map(|x| (x * scale as f32).round() as u8)
|
||||
})
|
||||
.unwrap_or([0, 0, 0, 0]);
|
||||
let radii = if round {
|
||||
theme
|
||||
.cosmic()
|
||||
.radius_s()
|
||||
.map(|x| if x < 4.0 { x } else { x + 4.0 })
|
||||
.map(|x| (x * scale as f32).round() as u8)
|
||||
} else {
|
||||
[0, 0, 0, 0]
|
||||
};
|
||||
|
||||
let mut geo = SpaceElement::geometry(&windows[active]).to_f64();
|
||||
geo.size.h += TAB_HEIGHT as f64;
|
||||
|
|
@ -857,37 +857,35 @@ impl CosmicStack {
|
|||
if let Some(dragged_out) = self
|
||||
.0
|
||||
.with_program(|p| p.potential_drag.lock().unwrap().take())
|
||||
{
|
||||
if let Some(surface) = self
|
||||
&& let Some(surface) = self
|
||||
.0
|
||||
.with_program(|p| p.windows.lock().unwrap().get(dragged_out).cloned())
|
||||
{
|
||||
let seat = seat.clone();
|
||||
surface.try_force_undecorated(false);
|
||||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
{
|
||||
let seat = seat.clone();
|
||||
surface.try_force_undecorated(false);
|
||||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1152,47 +1150,46 @@ impl Program for CosmicStackInternal {
|
|||
}
|
||||
}
|
||||
Message::TabMenu(idx) => {
|
||||
if let Some((seat, serial)) = last_seat.cloned() {
|
||||
if let Some(surface) = self.windows.lock().unwrap()[idx]
|
||||
if let Some((seat, serial)) = last_seat.cloned()
|
||||
&& let Some(surface) = self.windows.lock().unwrap()[idx]
|
||||
.wl_surface()
|
||||
.map(Cow::into_owned)
|
||||
{
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let shell = state.common.shell.read();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
if let Some(workspace) = shell.space_for(&mapped) {
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
let position = elem_geo.loc.to_global(&workspace.output);
|
||||
{
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let shell = state.common.shell.read();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned()
|
||||
&& let Some(workspace) = shell.space_for(&mapped)
|
||||
{
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
let position = elem_geo.loc.to_global(&workspace.output);
|
||||
|
||||
let mut cursor = seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.current_location()
|
||||
.to_i32_round();
|
||||
cursor.y -= TAB_HEIGHT;
|
||||
let res = shell.menu_request(
|
||||
false,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
let mut cursor = seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.current_location()
|
||||
.to_i32_round();
|
||||
cursor.y -= TAB_HEIGHT;
|
||||
let res = shell.menu_request(
|
||||
false,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
|
@ -1701,37 +1698,35 @@ impl PointerTarget<State> for CosmicStack {
|
|||
if let Some(dragged_out) = self
|
||||
.0
|
||||
.with_program(|p| p.potential_drag.lock().unwrap().take())
|
||||
{
|
||||
if let Some(surface) = self
|
||||
&& let Some(surface) = self
|
||||
.0
|
||||
.with_program(|p| p.windows.lock().unwrap().get(dragged_out).cloned())
|
||||
{
|
||||
let seat = seat.clone();
|
||||
surface.try_force_undecorated(false);
|
||||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
{
|
||||
let seat = seat.clone();
|
||||
surface.try_force_undecorated(false);
|
||||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,22 +356,20 @@ where
|
|||
if matches!(
|
||||
event,
|
||||
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
|
||||
) {
|
||||
if let Some(message) = self.press_message.clone() {
|
||||
shell.publish(message);
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
) && let Some(message) = self.press_message.clone()
|
||||
{
|
||||
shell.publish(message);
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
if matches!(
|
||||
event,
|
||||
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Right))
|
||||
) {
|
||||
if let Some(message) = self.right_click_message.clone() {
|
||||
shell.publish(message);
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
) && let Some(message) = self.right_click_message.clone()
|
||||
{
|
||||
shell.publish(message);
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
if matches!(
|
||||
event,
|
||||
|
|
@ -379,7 +377,6 @@ where
|
|||
) {
|
||||
shell.publish(Message::activate(self.idx));
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,10 +270,10 @@ impl State {
|
|||
pub fn cleanup_old_animations(&mut self) {
|
||||
let start_time = Instant::now();
|
||||
|
||||
if let Some(animation) = self.scroll_animation.as_ref() {
|
||||
if start_time.duration_since(animation.start_time) > SCROLL_ANIMATION_DURATION {
|
||||
self.scroll_animation.take();
|
||||
}
|
||||
if let Some(animation) = self.scroll_animation.as_ref()
|
||||
&& start_time.duration_since(animation.start_time) > SCROLL_ANIMATION_DURATION
|
||||
{
|
||||
self.scroll_animation.take();
|
||||
}
|
||||
|
||||
Self::discard_expired_tab_animations(&mut self.tab_animations, start_time);
|
||||
|
|
|
|||
|
|
@ -693,15 +693,13 @@ impl CosmicSurface {
|
|||
.primary_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback)
|
||||
} else if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback)
|
||||
} else {
|
||||
if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback)
|
||||
} else {
|
||||
&feedback.render_feedback
|
||||
}
|
||||
&feedback.render_feedback
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -983,6 +981,6 @@ fn with_toplevel_state<T, F: FnOnce(Option<&smithay::wayland::shell::xdg::Toplev
|
|||
if pending {
|
||||
toplevel.with_pending_state(|pending| cb(Some(pending)))
|
||||
} else {
|
||||
toplevel.with_committed_state(|committed| cb(committed))
|
||||
toplevel.with_committed_state(cb)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -576,10 +576,8 @@ impl CosmicWindow {
|
|||
*conf = *appearance;
|
||||
if appearance.clip_floating_windows {
|
||||
p.window.set_tiled(true);
|
||||
} else {
|
||||
if !p.tiled.load(Ordering::Acquire) {
|
||||
p.window.set_tiled(false);
|
||||
}
|
||||
} else if !p.tiled.load(Ordering::Acquire) {
|
||||
p.window.set_tiled(false);
|
||||
}
|
||||
p.window.send_configure();
|
||||
}
|
||||
|
|
@ -633,8 +631,8 @@ impl CosmicWindow {
|
|||
&& !p.window.is_maximized(false);
|
||||
let round =
|
||||
(!is_tiled || appearance.clip_tiled_windows) && !p.window.is_maximized(false);
|
||||
let radii = round
|
||||
.then(|| {
|
||||
let radii = if round {
|
||||
{
|
||||
p.theme
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
|
@ -642,8 +640,10 @@ impl CosmicWindow {
|
|||
.radius_s()
|
||||
.map(|x| if x < 4.0 { x } else { x + 4.0 })
|
||||
.map(|x| x.round() as u8)
|
||||
})
|
||||
.unwrap_or([0; 4]);
|
||||
}
|
||||
} else {
|
||||
[0; 4]
|
||||
};
|
||||
|
||||
match (has_ssd, clip) {
|
||||
(has_ssd, true) => {
|
||||
|
|
@ -698,30 +698,30 @@ impl Program for CosmicWindowInternal {
|
|||
) -> Task<Self::Message> {
|
||||
match message {
|
||||
Message::DragStart => {
|
||||
if let Some((seat, serial)) = last_seat.cloned() {
|
||||
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
if let Some((seat, serial)) = last_seat.cloned()
|
||||
&& let Some(surface) = self.window.wl_surface().map(Cow::into_owned)
|
||||
{
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let res = state.common.shell.write().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Message::Minimize => {
|
||||
|
|
@ -745,51 +745,51 @@ impl Program for CosmicWindowInternal {
|
|||
}
|
||||
Message::Close => self.window.close(),
|
||||
Message::Menu => {
|
||||
if let Some((seat, serial)) = last_seat.cloned() {
|
||||
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let shell = state.common.shell.read();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
let position = if let Some((output, set)) =
|
||||
shell.workspaces.sets.iter().find(|(_, set)| {
|
||||
set.sticky_layer.mapped().any(|m| m == &mapped)
|
||||
}) {
|
||||
set.sticky_layer
|
||||
.element_geometry(&mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(output)
|
||||
} else if let Some(workspace) = shell.space_for(&mapped) {
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
elem_geo.loc.to_global(&workspace.output)
|
||||
} else {
|
||||
if let Some((seat, serial)) = last_seat.cloned()
|
||||
&& let Some(surface) = self.window.wl_surface().map(Cow::into_owned)
|
||||
{
|
||||
loop_handle.insert_idle(move |state| {
|
||||
let shell = state.common.shell.read();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
let position = if let Some((output, set)) =
|
||||
shell.workspaces.sets.iter().find(|(_, set)| {
|
||||
set.sticky_layer.mapped().any(|m| m == &mapped)
|
||||
}) {
|
||||
set.sticky_layer
|
||||
.element_geometry(&mapped)
|
||||
.unwrap()
|
||||
.loc
|
||||
.to_global(output)
|
||||
} else if let Some(workspace) = shell.space_for(&mapped) {
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
elem_geo.loc.to_global(&workspace.output)
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
let mut cursor = pointer.current_location().to_i32_round();
|
||||
cursor.y -= SSD_HEIGHT;
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
let mut cursor = pointer.current_location().to_i32_round();
|
||||
cursor.y -= SSD_HEIGHT;
|
||||
|
||||
let res = shell.menu_request(
|
||||
false,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
let res = shell.menu_request(
|
||||
false,
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,10 +238,9 @@ impl Shell {
|
|||
.user_data()
|
||||
.get::<PopupGrabData>()
|
||||
.and_then(|x| x.take())
|
||||
&& !popup_grab.has_ended()
|
||||
{
|
||||
if !popup_grab.has_ended() {
|
||||
popup_grab.ungrab(PopupUngrabStrategy::All);
|
||||
}
|
||||
popup_grab.ungrab(PopupUngrabStrategy::All);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -501,31 +500,28 @@ impl Common {
|
|||
trace!("Wrong Window, focus fixup");
|
||||
}
|
||||
} else {
|
||||
if let KeyboardFocusTarget::Popup(_) = target {
|
||||
if let Some(popup_grab) = seat
|
||||
if let KeyboardFocusTarget::Popup(_) = target
|
||||
&& let Some(popup_grab) = seat
|
||||
.user_data()
|
||||
.get::<PopupGrabData>()
|
||||
.and_then(|x| x.take())
|
||||
{
|
||||
if !popup_grab.has_ended() {
|
||||
if let Some(new) = popup_grab.current_grab() {
|
||||
trace!("restore focus to previous popup grab");
|
||||
std::mem::drop(shell);
|
||||
// TODO: verify whether cursor should be updated at end of popup grab
|
||||
update_focus_state(
|
||||
seat,
|
||||
Some(&new),
|
||||
state,
|
||||
Some(SERIAL_COUNTER.next_serial()),
|
||||
false,
|
||||
);
|
||||
seat.user_data()
|
||||
.get_or_insert::<PopupGrabData, _>(PopupGrabData::default)
|
||||
.set(Some(popup_grab));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
&& !popup_grab.has_ended()
|
||||
&& let Some(new) = popup_grab.current_grab()
|
||||
{
|
||||
trace!("restore focus to previous popup grab");
|
||||
std::mem::drop(shell);
|
||||
// TODO: verify whether cursor should be updated at end of popup grab
|
||||
update_focus_state(
|
||||
seat,
|
||||
Some(&new),
|
||||
state,
|
||||
Some(SERIAL_COUNTER.next_serial()),
|
||||
false,
|
||||
);
|
||||
seat.user_data()
|
||||
.get_or_insert::<PopupGrabData, _>(PopupGrabData::default)
|
||||
.set(Some(popup_grab));
|
||||
continue;
|
||||
}
|
||||
trace!("Surface dead, focus fixup");
|
||||
}
|
||||
|
|
@ -547,10 +543,9 @@ impl Common {
|
|||
.user_data()
|
||||
.get::<PopupGrabData>()
|
||||
.and_then(|x| x.take())
|
||||
&& !popup_grab.has_ended()
|
||||
{
|
||||
if !popup_grab.has_ended() {
|
||||
popup_grab.ungrab(PopupUngrabStrategy::All);
|
||||
}
|
||||
popup_grab.ungrab(PopupUngrabStrategy::All);
|
||||
}
|
||||
|
||||
// update keyboard focus
|
||||
|
|
@ -682,12 +677,12 @@ fn update_focus_target(
|
|||
} else {
|
||||
let workspace = shell.active_space(output).unwrap();
|
||||
|
||||
if let Some(Trigger::KeyboardSwap(_, desc)) = shell.overview_mode().0.active_trigger() {
|
||||
if workspace.handle == desc.handle && workspace.tiling_layer.has_node(&desc.node) {
|
||||
if let Some(focus) = workspace.tiling_layer.node_desc_to_focus(desc) {
|
||||
return Some(focus);
|
||||
}
|
||||
}
|
||||
if let Some(Trigger::KeyboardSwap(_, desc)) = shell.overview_mode().0.active_trigger()
|
||||
&& workspace.handle == desc.handle
|
||||
&& workspace.tiling_layer.has_node(&desc.node)
|
||||
&& let Some(focus) = workspace.tiling_layer.node_desc_to_focus(desc)
|
||||
{
|
||||
return Some(focus);
|
||||
}
|
||||
|
||||
workspace
|
||||
|
|
|
|||
|
|
@ -271,16 +271,16 @@ fn render_input_order_internal<R: 'static>(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some((_, has_fullscreen, offset)) = previous.as_ref() {
|
||||
if !has_fullscreen {
|
||||
// previous bottom layer popups
|
||||
for (layer, popup, location) in layer_popups(output, Layer::Bottom, element_filter) {
|
||||
callback(Stage::LayerPopup {
|
||||
layer,
|
||||
popup: &popup,
|
||||
location: location + offset.as_global(),
|
||||
})?;
|
||||
}
|
||||
if let Some((_, has_fullscreen, offset)) = previous.as_ref()
|
||||
&& !has_fullscreen
|
||||
{
|
||||
// previous bottom layer popups
|
||||
for (layer, popup, location) in layer_popups(output, Layer::Bottom, element_filter) {
|
||||
callback(Stage::LayerPopup {
|
||||
layer,
|
||||
popup: &popup,
|
||||
location: location + offset.as_global(),
|
||||
})?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,17 +295,16 @@ fn render_input_order_internal<R: 'static>(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some((_, has_fullscreen, offset)) = previous.as_ref() {
|
||||
if !has_fullscreen {
|
||||
// previous background layer popups
|
||||
for (layer, popup, location) in layer_popups(output, Layer::Background, element_filter)
|
||||
{
|
||||
callback(Stage::LayerPopup {
|
||||
layer,
|
||||
popup: &popup,
|
||||
location: location + offset.as_global(),
|
||||
})?;
|
||||
}
|
||||
if let Some((_, has_fullscreen, offset)) = previous.as_ref()
|
||||
&& !has_fullscreen
|
||||
{
|
||||
// previous background layer popups
|
||||
for (layer, popup, location) in layer_popups(output, Layer::Background, element_filter) {
|
||||
callback(Stage::LayerPopup {
|
||||
layer,
|
||||
popup: &popup,
|
||||
location: location + offset.as_global(),
|
||||
})?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -348,13 +347,13 @@ fn render_input_order_internal<R: 'static>(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some((_, has_fullscreen, offset)) = previous.as_ref() {
|
||||
if !has_fullscreen {
|
||||
// previous bottom layer
|
||||
for (layer, mut location) in layer_surfaces(output, Layer::Bottom, element_filter) {
|
||||
location += offset.as_global();
|
||||
callback(Stage::LayerSurface { layer, location })?;
|
||||
}
|
||||
if let Some((_, has_fullscreen, offset)) = previous.as_ref()
|
||||
&& !has_fullscreen
|
||||
{
|
||||
// previous bottom layer
|
||||
for (layer, mut location) in layer_surfaces(output, Layer::Bottom, element_filter) {
|
||||
location += offset.as_global();
|
||||
callback(Stage::LayerSurface { layer, location })?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -366,13 +365,13 @@ fn render_input_order_internal<R: 'static>(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some((_, has_fullscreen, offset)) = previous.as_ref() {
|
||||
if !has_fullscreen {
|
||||
// previous background layer
|
||||
for (layer, mut location) in layer_surfaces(output, Layer::Background, element_filter) {
|
||||
location += offset.as_global();
|
||||
callback(Stage::LayerSurface { layer, location })?;
|
||||
}
|
||||
if let Some((_, has_fullscreen, offset)) = previous.as_ref()
|
||||
&& !has_fullscreen
|
||||
{
|
||||
// previous background layer
|
||||
for (layer, mut location) in layer_surfaces(output, Layer::Background, element_filter) {
|
||||
location += offset.as_global();
|
||||
callback(Stage::LayerSurface { layer, location })?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,18 +63,18 @@ impl<G: PointerGrab<State>> PointerGrab<State> for DelayGrab<G> {
|
|||
handle.motion(data, focus, event);
|
||||
|
||||
let distance = self.start_data.distance(event.location);
|
||||
if distance >= 1. {
|
||||
if let Some(factory) = self.grab_factory.take() {
|
||||
let serial = self.serial.unwrap_or(event.serial);
|
||||
let seat = self.seat.clone();
|
||||
data.common.event_loop_handle.insert_idle(move |data| {
|
||||
if let Some((grab, focus)) = factory(data) {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(data, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
if distance >= 1.
|
||||
&& let Some(factory) = self.grab_factory.take()
|
||||
{
|
||||
let serial = self.serial.unwrap_or(event.serial);
|
||||
let seat = self.seat.clone();
|
||||
data.common.event_loop_handle.insert_idle(move |data| {
|
||||
if let Some((grab, focus)) = factory(data) {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(data, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -232,16 +232,16 @@ impl<G: TouchGrab<State>> TouchGrab<State> for DelayGrab<G> {
|
|||
handle.motion(data, focus, event, seq);
|
||||
|
||||
let distance = self.start_data.distance(event.location);
|
||||
if distance >= 1. {
|
||||
if let Some(factory) = self.grab_factory.take() {
|
||||
let seat = self.seat.clone();
|
||||
let serial = self.serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial());
|
||||
data.common.event_loop_handle.insert_idle(move |data| {
|
||||
if let Some((grab, _)) = factory(data) {
|
||||
seat.get_touch().unwrap().set_grab(data, grab, serial);
|
||||
}
|
||||
});
|
||||
}
|
||||
if distance >= 1.
|
||||
&& let Some(factory) = self.grab_factory.take()
|
||||
{
|
||||
let seat = self.seat.clone();
|
||||
let serial = self.serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial());
|
||||
data.common.event_loop_handle.insert_idle(move |data| {
|
||||
if let Some((grab, _)) = factory(data) {
|
||||
seat.get_touch().unwrap().set_grab(data, grab, serial);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -260,115 +260,112 @@ impl Program for ContextMenu {
|
|||
// But right now we don't have any touch responsive menus with submenus
|
||||
}
|
||||
Message::ItemEntered(idx, bounds) => {
|
||||
if let Some(Item::Submenu { items, .. }) = self.items.get_mut(idx) {
|
||||
if let Some((seat, _)) = last_seat.cloned() {
|
||||
let items = items.clone();
|
||||
let _ = loop_handle.insert_idle(move |state| {
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
if let Some(Item::Submenu { items, .. }) = self.items.get_mut(idx)
|
||||
&& let Some((seat, _)) = last_seat.cloned()
|
||||
{
|
||||
let items = items.clone();
|
||||
let _ = loop_handle.insert_idle(move |state| {
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
|
||||
if let Some(grab_state) = &*grab_state {
|
||||
let mut elements = grab_state.elements.lock().unwrap();
|
||||
if let Some(grab_state) = &*grab_state {
|
||||
let mut elements = grab_state.elements.lock().unwrap();
|
||||
|
||||
let position = elements.last().unwrap().position;
|
||||
let element = IcedElement::new(
|
||||
ContextMenu::new(items),
|
||||
Size::default(),
|
||||
state.common.event_loop_handle.clone(),
|
||||
state.common.theme.clone(),
|
||||
);
|
||||
let position = elements.last().unwrap().position;
|
||||
let element = IcedElement::new(
|
||||
ContextMenu::new(items),
|
||||
Size::default(),
|
||||
state.common.event_loop_handle.clone(),
|
||||
state.common.theme.clone(),
|
||||
);
|
||||
|
||||
let min_size = element.minimum_size();
|
||||
element.with_program(|p| {
|
||||
*p.row_width.lock().unwrap() = Some(min_size.w as f32);
|
||||
});
|
||||
element.resize(min_size);
|
||||
let min_size = element.minimum_size();
|
||||
element.with_program(|p| {
|
||||
*p.row_width.lock().unwrap() = Some(min_size.w as f32);
|
||||
});
|
||||
element.resize(min_size);
|
||||
|
||||
let output = seat.active_output();
|
||||
let position = [
|
||||
// to the right -> down
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
bounds.width.ceil() as i32,
|
||||
bounds.y.ceil() as i32,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the right -> up
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
bounds.width.ceil() as i32,
|
||||
bounds.y.ceil() as i32
|
||||
+ bounds.height.ceil() as i32
|
||||
- min_size.h,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the left -> down
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((-min_size.w, bounds.y.ceil() as i32)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the left -> up
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
-min_size.w,
|
||||
bounds.y.ceil() as i32
|
||||
+ bounds.height.ceil() as i32
|
||||
- min_size.h,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
]
|
||||
.iter()
|
||||
.rev() // preference of max_by_key is backwards
|
||||
.max_by_key(|rect| {
|
||||
output
|
||||
.geometry()
|
||||
.intersection(**rect)
|
||||
.map(|rect| rect.size.w * rect.size.h)
|
||||
})
|
||||
.unwrap()
|
||||
.loc;
|
||||
element.output_enter(&output, element.bbox());
|
||||
element.set_additional_scale(*grab_state.scale.lock().unwrap());
|
||||
let output = seat.active_output();
|
||||
let position = [
|
||||
// to the right -> down
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
bounds.width.ceil() as i32,
|
||||
bounds.y.ceil() as i32,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the right -> up
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
bounds.width.ceil() as i32,
|
||||
bounds.y.ceil() as i32 + bounds.height.ceil() as i32
|
||||
- min_size.h,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the left -> down
|
||||
Rectangle::new(
|
||||
position + Point::from((-min_size.w, bounds.y.ceil() as i32)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
// to the left -> up
|
||||
Rectangle::new(
|
||||
position
|
||||
+ Point::from((
|
||||
-min_size.w,
|
||||
bounds.y.ceil() as i32 + bounds.height.ceil() as i32
|
||||
- min_size.h,
|
||||
)),
|
||||
min_size.as_global(),
|
||||
),
|
||||
]
|
||||
.iter()
|
||||
.rev() // preference of max_by_key is backwards
|
||||
.max_by_key(|rect| {
|
||||
output
|
||||
.geometry()
|
||||
.intersection(**rect)
|
||||
.map(|rect| rect.size.w * rect.size.h)
|
||||
})
|
||||
.unwrap()
|
||||
.loc;
|
||||
element.output_enter(&output, element.bbox());
|
||||
element.set_additional_scale(*grab_state.scale.lock().unwrap());
|
||||
|
||||
elements.push(Element {
|
||||
iced: element,
|
||||
position,
|
||||
pointer_entered: false,
|
||||
touch_entered: None,
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
elements.push(Element {
|
||||
iced: element,
|
||||
position,
|
||||
pointer_entered: false,
|
||||
touch_entered: None,
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Message::ItemLeft(idx, _) => {
|
||||
if let Some(Item::Submenu { .. }) = self.items.get_mut(idx) {
|
||||
if let Some((seat, _)) = last_seat.cloned() {
|
||||
let _ = loop_handle.insert_idle(move |_| {
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
if let Some(Item::Submenu { .. }) = self.items.get_mut(idx)
|
||||
&& let Some((seat, _)) = last_seat.cloned()
|
||||
{
|
||||
let _ = loop_handle.insert_idle(move |_| {
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
|
||||
if let Some(grab_state) = &*grab_state {
|
||||
let mut elements = grab_state.elements.lock().unwrap();
|
||||
elements.pop();
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(grab_state) = &*grab_state {
|
||||
let mut elements = grab_state.elements.lock().unwrap();
|
||||
elements.pop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -862,43 +862,43 @@ impl Drop for MoveGrab {
|
|||
window_location.to_local(&workspace.output),
|
||||
);
|
||||
|
||||
if matches!(previous, ManagedLayer::Floating) {
|
||||
if let Some(sz) = grab_state.snapping_zone {
|
||||
if sz == SnappingZone::Maximize {
|
||||
shell.maximize_toggle(
|
||||
&window,
|
||||
&seat,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
} else {
|
||||
let directions = match sz {
|
||||
SnappingZone::Maximize => vec![],
|
||||
SnappingZone::Top => vec![Direction::Up],
|
||||
SnappingZone::TopLeft => {
|
||||
vec![Direction::Up, Direction::Left]
|
||||
}
|
||||
SnappingZone::Left => vec![Direction::Left],
|
||||
SnappingZone::BottomLeft => {
|
||||
vec![Direction::Down, Direction::Left]
|
||||
}
|
||||
SnappingZone::Bottom => vec![Direction::Down],
|
||||
SnappingZone::BottomRight => {
|
||||
vec![Direction::Down, Direction::Right]
|
||||
}
|
||||
SnappingZone::Right => vec![Direction::Right],
|
||||
SnappingZone::TopRight => {
|
||||
vec![Direction::Up, Direction::Right]
|
||||
}
|
||||
};
|
||||
for direction in directions {
|
||||
workspace.floating_layer.move_element(
|
||||
direction,
|
||||
&seat,
|
||||
ManagedLayer::Floating,
|
||||
&theme,
|
||||
&window,
|
||||
);
|
||||
if matches!(previous, ManagedLayer::Floating)
|
||||
&& let Some(sz) = grab_state.snapping_zone
|
||||
{
|
||||
if sz == SnappingZone::Maximize {
|
||||
shell.maximize_toggle(
|
||||
&window,
|
||||
&seat,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
} else {
|
||||
let directions = match sz {
|
||||
SnappingZone::Maximize => vec![],
|
||||
SnappingZone::Top => vec![Direction::Up],
|
||||
SnappingZone::TopLeft => {
|
||||
vec![Direction::Up, Direction::Left]
|
||||
}
|
||||
SnappingZone::Left => vec![Direction::Left],
|
||||
SnappingZone::BottomLeft => {
|
||||
vec![Direction::Down, Direction::Left]
|
||||
}
|
||||
SnappingZone::Bottom => vec![Direction::Down],
|
||||
SnappingZone::BottomRight => {
|
||||
vec![Direction::Down, Direction::Right]
|
||||
}
|
||||
SnappingZone::Right => vec![Direction::Right],
|
||||
SnappingZone::TopRight => {
|
||||
vec![Direction::Up, Direction::Right]
|
||||
}
|
||||
};
|
||||
for direction in directions {
|
||||
workspace.floating_layer.move_element(
|
||||
direction,
|
||||
&seat,
|
||||
ManagedLayer::Floating,
|
||||
&theme,
|
||||
&window,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -525,10 +525,10 @@ impl ResizeSurfaceGrab {
|
|||
};
|
||||
|
||||
// Finish resizing.
|
||||
if let Some(ResizeState::WaitingForCommit(_)) = *resize_state {
|
||||
if !window.is_resizing(false).unwrap_or(false) {
|
||||
*resize_state = None;
|
||||
}
|
||||
if let Some(ResizeState::WaitingForCommit(_)) = *resize_state
|
||||
&& !window.is_resizing(false).unwrap_or(false)
|
||||
{
|
||||
*resize_state = None;
|
||||
}
|
||||
std::mem::drop(resize_state);
|
||||
|
||||
|
|
|
|||
|
|
@ -385,13 +385,12 @@ impl FloatingLayout {
|
|||
} else {
|
||||
self.animations.remove(&mapped);
|
||||
}
|
||||
if mapped.floating_tiled.lock().unwrap().take().is_some() {
|
||||
if let Some(state) = mapped.maximized_state.lock().unwrap().as_mut() {
|
||||
if let Some(real_old_geo) = *mapped.last_geometry.lock().unwrap() {
|
||||
state.original_geometry = real_old_geo;
|
||||
}
|
||||
};
|
||||
}
|
||||
if mapped.floating_tiled.lock().unwrap().take().is_some()
|
||||
&& let Some(state) = mapped.maximized_state.lock().unwrap().as_mut()
|
||||
&& let Some(real_old_geo) = *mapped.last_geometry.lock().unwrap()
|
||||
{
|
||||
state.original_geometry = real_old_geo;
|
||||
};
|
||||
self.space
|
||||
.map_element(mapped, geometry.loc.as_logical(), true);
|
||||
self.space.refresh();
|
||||
|
|
@ -683,10 +682,10 @@ impl FloatingLayout {
|
|||
mapped_geometry.size = last_size;
|
||||
}
|
||||
} else if !window.is_maximized(true) {
|
||||
if window.active_window().has_pending_changes() {
|
||||
if let Some(pending_size) = window.pending_size() {
|
||||
mapped_geometry.size = pending_size.as_local();
|
||||
}
|
||||
if window.active_window().has_pending_changes()
|
||||
&& let Some(pending_size) = window.pending_size()
|
||||
{
|
||||
mapped_geometry.size = pending_size.as_local();
|
||||
}
|
||||
*window.last_geometry.lock().unwrap() = Some(mapped_geometry);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -452,53 +452,51 @@ impl TilingLayout {
|
|||
mut sizes,
|
||||
}) = tiling_state
|
||||
{
|
||||
if let Some(node) = parent.as_ref().and_then(|parent| tree.get_mut(parent).ok()) {
|
||||
if let Data::Group {
|
||||
if let Some(node) = parent.as_ref().and_then(|parent| tree.get_mut(parent).ok())
|
||||
&& let Data::Group {
|
||||
orientation: current_orientation,
|
||||
sizes: current_sizes,
|
||||
..
|
||||
} = node.data_mut()
|
||||
{
|
||||
let parent_id = parent.unwrap();
|
||||
{
|
||||
let parent_id = parent.unwrap();
|
||||
|
||||
if *current_orientation == orientation && sizes.len() == current_sizes.len() + 1
|
||||
{
|
||||
let previous_length: i32 = sizes.iter().copied().sum();
|
||||
let new_length: i32 = current_sizes.iter().copied().sum();
|
||||
if previous_length != new_length {
|
||||
// rescale sizes
|
||||
sizes.iter_mut().for_each(|len| {
|
||||
*len = (((*len as f64) / (previous_length as f64))
|
||||
* (new_length as f64))
|
||||
.round() as i32;
|
||||
});
|
||||
let sum: i32 = sizes.iter().sum();
|
||||
if *current_orientation == orientation && sizes.len() == current_sizes.len() + 1 {
|
||||
let previous_length: i32 = sizes.iter().copied().sum();
|
||||
let new_length: i32 = current_sizes.iter().copied().sum();
|
||||
if previous_length != new_length {
|
||||
// rescale sizes
|
||||
sizes.iter_mut().for_each(|len| {
|
||||
*len = (((*len as f64) / (previous_length as f64))
|
||||
* (new_length as f64))
|
||||
.round() as i32;
|
||||
});
|
||||
let sum: i32 = sizes.iter().sum();
|
||||
|
||||
// fix rounding issues
|
||||
if sum != new_length {
|
||||
let diff = new_length - sum;
|
||||
*sizes.last_mut().unwrap() += diff;
|
||||
}
|
||||
// fix rounding issues
|
||||
if sum != new_length {
|
||||
let diff = new_length - sum;
|
||||
*sizes.last_mut().unwrap() += diff;
|
||||
}
|
||||
}
|
||||
|
||||
*current_sizes = sizes;
|
||||
let new_node = Node::new(Data::Mapped {
|
||||
mapped: window.clone(),
|
||||
last_geometry: Rectangle::from_size((100, 100).into()),
|
||||
minimize_rect: from,
|
||||
});
|
||||
let new_id = tree
|
||||
.insert(new_node, InsertBehavior::UnderNode(&parent_id))
|
||||
.unwrap();
|
||||
tree.make_nth_sibling(&new_id, idx).unwrap();
|
||||
*window.tiling_node_id.lock().unwrap() = Some(new_id);
|
||||
|
||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||
self.queue
|
||||
.push_tree(tree, MINIMIZE_ANIMATION_DURATION, blocker);
|
||||
return;
|
||||
}
|
||||
|
||||
*current_sizes = sizes;
|
||||
let new_node = Node::new(Data::Mapped {
|
||||
mapped: window.clone(),
|
||||
last_geometry: Rectangle::from_size((100, 100).into()),
|
||||
minimize_rect: from,
|
||||
});
|
||||
let new_id = tree
|
||||
.insert(new_node, InsertBehavior::UnderNode(&parent_id))
|
||||
.unwrap();
|
||||
tree.make_nth_sibling(&new_id, idx).unwrap();
|
||||
*window.tiling_node_id.lock().unwrap() = Some(new_id);
|
||||
|
||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||
self.queue
|
||||
.push_tree(tree, MINIMIZE_ANIMATION_DURATION, blocker);
|
||||
return;
|
||||
}
|
||||
|
||||
if sibling
|
||||
|
|
@ -1414,8 +1412,8 @@ impl TilingLayout {
|
|||
let tiling_node_id = mapped.tiling_node_id.lock().unwrap().as_ref().cloned();
|
||||
let gaps = self.gaps();
|
||||
|
||||
if let Some(node_id) = tiling_node_id {
|
||||
if self
|
||||
if let Some(node_id) = tiling_node_id
|
||||
&& self
|
||||
.queue
|
||||
.trees
|
||||
.back()
|
||||
|
|
@ -1424,21 +1422,20 @@ impl TilingLayout {
|
|||
.get(&node_id)
|
||||
.map(|node| node.data().is_mapped(Some(mapped)))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let mut tree = self.queue.trees.back().unwrap().0.copy_clone();
|
||||
{
|
||||
let mut tree = self.queue.trees.back().unwrap().0.copy_clone();
|
||||
|
||||
TilingLayout::unmap_internal(&mut tree, &node_id);
|
||||
TilingLayout::unmap_internal(&mut tree, &node_id);
|
||||
|
||||
let duration = if minimizing {
|
||||
MINIMIZE_ANIMATION_DURATION
|
||||
} else {
|
||||
ANIMATION_DURATION
|
||||
};
|
||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||
self.queue.push_tree(tree, duration, blocker);
|
||||
let duration = if minimizing {
|
||||
MINIMIZE_ANIMATION_DURATION
|
||||
} else {
|
||||
ANIMATION_DURATION
|
||||
};
|
||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||
self.queue.push_tree(tree, duration, blocker);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
|
@ -1742,7 +1739,7 @@ impl TilingLayout {
|
|||
_ => {
|
||||
// we want the middle
|
||||
let group_len = tree.get(&next_child_id).unwrap().data().len();
|
||||
if group_len % 2 == 0 {
|
||||
if group_len.is_multiple_of(2) {
|
||||
tree.make_nth_sibling(&node_id, group_len / 2).unwrap();
|
||||
tree.get_mut(&next_child_id)
|
||||
.unwrap()
|
||||
|
|
@ -1965,8 +1962,8 @@ impl TilingLayout {
|
|||
if focus_subtree.is_some() {
|
||||
let mut node_id = focus_subtree;
|
||||
while node_id.is_some() {
|
||||
if let Some(desc) = swap_desc.as_ref() {
|
||||
if let Some(replacement_id) = tree
|
||||
if let Some(desc) = swap_desc.as_ref()
|
||||
&& let Some(replacement_id) = tree
|
||||
.ancestor_ids(node_id.unwrap())
|
||||
.unwrap()
|
||||
.find(|anchestor| *anchestor == &desc.node)
|
||||
|
|
@ -1975,31 +1972,30 @@ impl TilingLayout {
|
|||
.unwrap()
|
||||
.find(|child| *child == &desc.node)
|
||||
})
|
||||
{
|
||||
return match tree.get(replacement_id).unwrap().data() {
|
||||
Data::Group { alive, .. } => {
|
||||
FocusResult::Some(KeyboardFocusTarget::Group(WindowGroup {
|
||||
node: replacement_id.clone(),
|
||||
alive: Arc::downgrade(alive),
|
||||
focus_stack: tree
|
||||
.children_ids(replacement_id)
|
||||
.unwrap()
|
||||
.cloned()
|
||||
.collect(),
|
||||
}))
|
||||
{
|
||||
return match tree.get(replacement_id).unwrap().data() {
|
||||
Data::Group { alive, .. } => {
|
||||
FocusResult::Some(KeyboardFocusTarget::Group(WindowGroup {
|
||||
node: replacement_id.clone(),
|
||||
alive: Arc::downgrade(alive),
|
||||
focus_stack: tree
|
||||
.children_ids(replacement_id)
|
||||
.unwrap()
|
||||
.cloned()
|
||||
.collect(),
|
||||
}))
|
||||
}
|
||||
Data::Mapped { mapped, .. } => {
|
||||
if mapped.is_stack()
|
||||
&& desc.stack_window.is_none()
|
||||
&& replacement_id == &desc.node
|
||||
{
|
||||
mapped.stack_ref().unwrap().focus_stack();
|
||||
}
|
||||
Data::Mapped { mapped, .. } => {
|
||||
if mapped.is_stack()
|
||||
&& desc.stack_window.is_none()
|
||||
&& replacement_id == &desc.node
|
||||
{
|
||||
mapped.stack_ref().unwrap().focus_stack();
|
||||
}
|
||||
FocusResult::Some(KeyboardFocusTarget::Element(mapped.clone()))
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
FocusResult::Some(KeyboardFocusTarget::Element(mapped.clone()))
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
||||
match tree.get(node_id.unwrap()).unwrap().data() {
|
||||
|
|
@ -2098,40 +2094,38 @@ impl TilingLayout {
|
|||
};
|
||||
|
||||
let mut tree = self.queue.trees.back().unwrap().0.copy_clone();
|
||||
if let Some((last_active, _)) = TilingLayout::currently_focused_node(&tree, target) {
|
||||
if let Some(group) = tree.get(&last_active).unwrap().parent().cloned() {
|
||||
if let &mut Data::Group {
|
||||
ref mut orientation,
|
||||
ref mut sizes,
|
||||
ref last_geometry,
|
||||
..
|
||||
} = tree.get_mut(&group).unwrap().data_mut()
|
||||
{
|
||||
let previous_length = match orientation {
|
||||
Orientation::Horizontal => last_geometry.size.h,
|
||||
Orientation::Vertical => last_geometry.size.w,
|
||||
};
|
||||
let new_orientation = new_orientation.unwrap_or(!*orientation);
|
||||
let new_length = match new_orientation {
|
||||
Orientation::Horizontal => last_geometry.size.h,
|
||||
Orientation::Vertical => last_geometry.size.w,
|
||||
};
|
||||
if let Some((last_active, _)) = TilingLayout::currently_focused_node(&tree, target)
|
||||
&& let Some(group) = tree.get(&last_active).unwrap().parent().cloned()
|
||||
&& let &mut Data::Group {
|
||||
ref mut orientation,
|
||||
ref mut sizes,
|
||||
ref last_geometry,
|
||||
..
|
||||
} = tree.get_mut(&group).unwrap().data_mut()
|
||||
{
|
||||
let previous_length = match orientation {
|
||||
Orientation::Horizontal => last_geometry.size.h,
|
||||
Orientation::Vertical => last_geometry.size.w,
|
||||
};
|
||||
let new_orientation = new_orientation.unwrap_or(!*orientation);
|
||||
let new_length = match new_orientation {
|
||||
Orientation::Horizontal => last_geometry.size.h,
|
||||
Orientation::Vertical => last_geometry.size.w,
|
||||
};
|
||||
|
||||
sizes.iter_mut().for_each(|len| {
|
||||
*len = (((*len as f64) / (previous_length as f64)) * (new_length as f64))
|
||||
.round() as i32;
|
||||
});
|
||||
let sum: i32 = sizes.iter().sum();
|
||||
if sum < new_length {
|
||||
*sizes.last_mut().unwrap() += new_length - sum;
|
||||
}
|
||||
|
||||
*orientation = new_orientation;
|
||||
|
||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
||||
}
|
||||
sizes.iter_mut().for_each(|len| {
|
||||
*len = (((*len as f64) / (previous_length as f64)) * (new_length as f64)).round()
|
||||
as i32;
|
||||
});
|
||||
let sum: i32 = sizes.iter().sum();
|
||||
if sum < new_length {
|
||||
*sizes.last_mut().unwrap() += new_length - sum;
|
||||
}
|
||||
|
||||
*orientation = new_orientation;
|
||||
|
||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3371,21 +3365,20 @@ impl TilingLayout {
|
|||
if matches!(
|
||||
overview.active_trigger(),
|
||||
Some(Trigger::Pointer(_) | Trigger::Touch(_))
|
||||
) {
|
||||
if location_f64.is_some() {
|
||||
let mut tree = tree.copy_clone();
|
||||
tree.insert(
|
||||
Node::new(Data::Placeholder {
|
||||
id: Id::new(),
|
||||
last_geometry: Rectangle::from_size((100, 100).into()),
|
||||
type_: PlaceholderType::DropZone,
|
||||
}),
|
||||
InsertBehavior::AsRoot,
|
||||
)
|
||||
.unwrap();
|
||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
||||
}
|
||||
) && location_f64.is_some()
|
||||
{
|
||||
let mut tree = tree.copy_clone();
|
||||
tree.insert(
|
||||
Node::new(Data::Placeholder {
|
||||
id: Id::new(),
|
||||
last_geometry: Rectangle::from_size((100, 100).into()),
|
||||
type_: PlaceholderType::DropZone,
|
||||
}),
|
||||
InsertBehavior::AsRoot,
|
||||
)
|
||||
.unwrap();
|
||||
let blocker = TilingLayout::update_positions(&self.output, &mut tree, gaps);
|
||||
self.queue.push_tree(tree, ANIMATION_DURATION, blocker);
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
|
@ -4626,62 +4619,62 @@ where
|
|||
geo.loc += (gap, gap).into();
|
||||
geo.size -= (gap * 2, gap * 2).into();
|
||||
|
||||
if mouse_tiling.is_some() {
|
||||
if let Some(PillIndicator::Outer(direction)) = pill_indicator {
|
||||
let (pill_geo, remaining_geo) = match direction {
|
||||
Direction::Left => (
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y).into(),
|
||||
(16, geo.size.h).into(),
|
||||
),
|
||||
Rectangle::new(
|
||||
(geo.loc.x + 48, geo.loc.y).into(),
|
||||
(geo.size.w - 48, geo.size.h).into(),
|
||||
),
|
||||
if mouse_tiling.is_some()
|
||||
&& let Some(PillIndicator::Outer(direction)) = pill_indicator
|
||||
{
|
||||
let (pill_geo, remaining_geo) = match direction {
|
||||
Direction::Left => (
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y).into(),
|
||||
(16, geo.size.h).into(),
|
||||
),
|
||||
Direction::Up => (
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y).into(),
|
||||
(geo.size.w, 16).into(),
|
||||
),
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y + 48).into(),
|
||||
(geo.size.w, geo.size.h - 48).into(),
|
||||
),
|
||||
Rectangle::new(
|
||||
(geo.loc.x + 48, geo.loc.y).into(),
|
||||
(geo.size.w - 48, geo.size.h).into(),
|
||||
),
|
||||
Direction::Right => (
|
||||
Rectangle::new(
|
||||
(geo.loc.x + geo.size.w - 16, geo.loc.y).into(),
|
||||
(16, geo.size.h).into(),
|
||||
),
|
||||
Rectangle::new(geo.loc, (geo.size.w - 48, geo.size.h).into()),
|
||||
),
|
||||
Direction::Up => (
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y).into(),
|
||||
(geo.size.w, 16).into(),
|
||||
),
|
||||
Direction::Down => (
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y + geo.size.h - 16).into(),
|
||||
(geo.size.w, 16).into(),
|
||||
),
|
||||
Rectangle::new(geo.loc, (geo.size.w, geo.size.h - 48).into()),
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y + 48).into(),
|
||||
(geo.size.w, geo.size.h - 48).into(),
|
||||
),
|
||||
};
|
||||
|
||||
if let Some(renderer) = renderer.as_mut() {
|
||||
elements.push(
|
||||
BackdropShader::element(
|
||||
*renderer,
|
||||
backdrop_id.clone(),
|
||||
pill_geo,
|
||||
8.,
|
||||
alpha * 0.4,
|
||||
group_color,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
geo = remaining_geo;
|
||||
),
|
||||
Direction::Right => (
|
||||
Rectangle::new(
|
||||
(geo.loc.x + geo.size.w - 16, geo.loc.y).into(),
|
||||
(16, geo.size.h).into(),
|
||||
),
|
||||
Rectangle::new(geo.loc, (geo.size.w - 48, geo.size.h).into()),
|
||||
),
|
||||
Direction::Down => (
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y + geo.size.h - 16).into(),
|
||||
(geo.size.w, 16).into(),
|
||||
),
|
||||
Rectangle::new(geo.loc, (geo.size.w, geo.size.h - 48).into()),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if let Some(renderer) = renderer.as_mut() {
|
||||
elements.push(
|
||||
BackdropShader::element(
|
||||
*renderer,
|
||||
backdrop_id.clone(),
|
||||
pill_geo,
|
||||
8.,
|
||||
alpha * 0.4,
|
||||
group_color,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
geo = remaining_geo;
|
||||
};
|
||||
|
||||
if matches!(swap_desc, Some(ref desc) if desc.node == node_id) {
|
||||
if let Some(renderer) = renderer.as_mut() {
|
||||
|
|
@ -4758,35 +4751,35 @@ where
|
|||
(geo.loc.x, geo.loc.y + previous).into(),
|
||||
(geo.size.w, *size).into(),
|
||||
);
|
||||
if mouse_tiling.is_some() {
|
||||
if let Some(PillIndicator::Inner(pill_idx)) = pill_indicator {
|
||||
if *pill_idx == idx {
|
||||
geo.size.h -= 32;
|
||||
}
|
||||
if idx
|
||||
.checked_sub(1)
|
||||
.map(|idx| idx == *pill_idx)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if let Some(renderer) = renderer.as_mut() {
|
||||
elements.push(
|
||||
BackdropShader::element(
|
||||
*renderer,
|
||||
backdrop_id.clone(),
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y - 8).into(),
|
||||
(geo.size.w, 16).into(),
|
||||
),
|
||||
8.,
|
||||
alpha * 0.4,
|
||||
group_color,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
geo.loc.y += 32;
|
||||
geo.size.h -= 32;
|
||||
if mouse_tiling.is_some()
|
||||
&& let Some(PillIndicator::Inner(pill_idx)) = pill_indicator
|
||||
{
|
||||
if *pill_idx == idx {
|
||||
geo.size.h -= 32;
|
||||
}
|
||||
if idx
|
||||
.checked_sub(1)
|
||||
.map(|idx| idx == *pill_idx)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if let Some(renderer) = renderer.as_mut() {
|
||||
elements.push(
|
||||
BackdropShader::element(
|
||||
*renderer,
|
||||
backdrop_id.clone(),
|
||||
Rectangle::new(
|
||||
(geo.loc.x, geo.loc.y - 8).into(),
|
||||
(geo.size.w, 16).into(),
|
||||
),
|
||||
8.,
|
||||
alpha * 0.4,
|
||||
group_color,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
geo.loc.y += 32;
|
||||
geo.size.h -= 32;
|
||||
}
|
||||
}
|
||||
stack.push((geo, depth + 1));
|
||||
|
|
@ -4800,35 +4793,35 @@ where
|
|||
(geo.loc.x + previous, geo.loc.y).into(),
|
||||
(*size, geo.size.h).into(),
|
||||
);
|
||||
if mouse_tiling.is_some() {
|
||||
if let Some(PillIndicator::Inner(pill_idx)) = pill_indicator {
|
||||
if *pill_idx == idx {
|
||||
geo.size.w -= 32;
|
||||
}
|
||||
if idx
|
||||
.checked_sub(1)
|
||||
.map(|idx| idx == *pill_idx)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if let Some(renderer) = renderer.as_mut() {
|
||||
elements.push(
|
||||
BackdropShader::element(
|
||||
*renderer,
|
||||
backdrop_id.clone(),
|
||||
Rectangle::new(
|
||||
(geo.loc.x - 8, geo.loc.y).into(),
|
||||
(16, geo.size.h).into(),
|
||||
),
|
||||
8.,
|
||||
alpha * 0.4,
|
||||
group_color,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
geo.loc.x += 32;
|
||||
geo.size.w -= 32;
|
||||
if mouse_tiling.is_some()
|
||||
&& let Some(PillIndicator::Inner(pill_idx)) = pill_indicator
|
||||
{
|
||||
if *pill_idx == idx {
|
||||
geo.size.w -= 32;
|
||||
}
|
||||
if idx
|
||||
.checked_sub(1)
|
||||
.map(|idx| idx == *pill_idx)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if let Some(renderer) = renderer.as_mut() {
|
||||
elements.push(
|
||||
BackdropShader::element(
|
||||
*renderer,
|
||||
backdrop_id.clone(),
|
||||
Rectangle::new(
|
||||
(geo.loc.x - 8, geo.loc.y).into(),
|
||||
(16, geo.size.h).into(),
|
||||
),
|
||||
8.,
|
||||
alpha * 0.4,
|
||||
group_color,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
geo.loc.x += 32;
|
||||
geo.size.w -= 32;
|
||||
}
|
||||
}
|
||||
stack.push((geo, depth + 1));
|
||||
|
|
@ -5102,10 +5095,7 @@ where
|
|||
},
|
||||
);
|
||||
|
||||
shadow_elements
|
||||
.into_iter()
|
||||
.chain(elements.into_iter())
|
||||
.collect()
|
||||
shadow_elements.into_iter().chain(elements).collect()
|
||||
}
|
||||
|
||||
fn render_old_tree(
|
||||
|
|
@ -5518,21 +5508,20 @@ where
|
|||
.unwrap_or(false)
|
||||
})
|
||||
.unwrap_or(false))
|
||||
&& let Some(swap) = swap_indicator.as_ref()
|
||||
{
|
||||
if let Some(swap) = swap_indicator.as_ref() {
|
||||
swap.resize(geo.size.as_logical());
|
||||
swap.output_enter(output, output_geo.as_logical());
|
||||
swap_elements.extend(
|
||||
swap.render_elements::<CosmicWindowRenderElement<R>>(
|
||||
renderer,
|
||||
geo.loc.as_logical().to_physical_precise_round(output_scale),
|
||||
output_scale.into(),
|
||||
alpha * overview.0.alpha().unwrap_or(1.0),
|
||||
)
|
||||
.into_iter()
|
||||
.map(CosmicMappedRenderElement::from),
|
||||
);
|
||||
}
|
||||
swap.resize(geo.size.as_logical());
|
||||
swap.output_enter(output, output_geo.as_logical());
|
||||
swap_elements.extend(
|
||||
swap.render_elements::<CosmicWindowRenderElement<R>>(
|
||||
renderer,
|
||||
geo.loc.as_logical().to_physical_precise_round(output_scale),
|
||||
output_scale.into(),
|
||||
alpha * overview.0.alpha().unwrap_or(1.0),
|
||||
)
|
||||
.into_iter()
|
||||
.map(CosmicMappedRenderElement::from),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5716,7 +5705,7 @@ where
|
|||
.into_iter()
|
||||
.flatten()
|
||||
.chain(swap_elements)
|
||||
.chain(indicators.into_iter().map(Into::into))
|
||||
.chain(indicators)
|
||||
.chain(window_elements)
|
||||
.chain(animating_window_elements)
|
||||
.chain(shadow_elements)
|
||||
|
|
@ -5858,10 +5847,10 @@ fn render_new_tree(
|
|||
(new_geo, percentage, false)
|
||||
};
|
||||
|
||||
if let Data::Mapped { mapped, .. } = data {
|
||||
if mapped.is_maximized(false) {
|
||||
return;
|
||||
}
|
||||
if let Data::Mapped { mapped, .. } = data
|
||||
&& mapped.is_maximized(false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
processor(node_id, data, geo, original_geo, alpha, animating)
|
||||
});
|
||||
|
|
|
|||
346
src/shell/mod.rs
346
src/shell/mod.rs
|
|
@ -479,7 +479,7 @@ impl WorkspaceSet {
|
|||
appearance: AppearanceConfig,
|
||||
) -> WorkspaceSet {
|
||||
let group_handle = state.create_workspace_group();
|
||||
let sticky_layer = FloatingLayout::new(theme.clone(), appearance.clone(), output);
|
||||
let sticky_layer = FloatingLayout::new(theme.clone(), appearance, output);
|
||||
|
||||
WorkspaceSet {
|
||||
previously_active: None,
|
||||
|
|
@ -753,7 +753,7 @@ impl Workspaces {
|
|||
autotile: config.cosmic_conf.autotile,
|
||||
autotile_behavior: config.cosmic_conf.autotile_behavior,
|
||||
theme,
|
||||
appearance: config.cosmic_conf.appearance_settings.clone(),
|
||||
appearance: config.cosmic_conf.appearance_settings,
|
||||
persisted_workspaces: config.cosmic_conf.pinned_workspaces.clone(),
|
||||
}
|
||||
}
|
||||
|
|
@ -1462,7 +1462,7 @@ impl Common {
|
|||
let mut shell = self.shell.write();
|
||||
let shell_ref = &mut *shell;
|
||||
shell_ref.active_hint = self.config.cosmic_conf.active_hint;
|
||||
shell_ref.appearance_conf = self.config.cosmic_conf.appearance_settings.clone();
|
||||
shell_ref.appearance_conf = self.config.cosmic_conf.appearance_settings;
|
||||
if let Some(zoom_state) = shell_ref.zoom_state.as_mut() {
|
||||
zoom_state.increment = self.config.cosmic_conf.accessibility_zoom.increment;
|
||||
zoom_state.movement = self.config.cosmic_conf.accessibility_zoom.view_moves;
|
||||
|
|
@ -1519,12 +1519,12 @@ impl Common {
|
|||
let shell = self.shell.read();
|
||||
|
||||
for seat in shell.seats.iter() {
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() {
|
||||
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() {
|
||||
let mapped = grab_state.element();
|
||||
if mapped.active_window().wl_surface().as_deref() == Some(surface) {
|
||||
mapped.on_commit(surface);
|
||||
}
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
|
||||
&& let Some(grab_state) = move_grab.lock().unwrap().as_ref()
|
||||
{
|
||||
let mapped = grab_state.element();
|
||||
if mapped.active_window().wl_surface().as_deref() == Some(surface) {
|
||||
mapped.on_commit(surface);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1595,7 +1595,7 @@ impl Shell {
|
|||
resize_mode: ResizeMode::None,
|
||||
resize_state: None,
|
||||
resize_indicator: None,
|
||||
appearance_conf: config.cosmic_conf.appearance_settings.clone(),
|
||||
appearance_conf: config.cosmic_conf.appearance_settings,
|
||||
zoom_state: None,
|
||||
tiling_exceptions,
|
||||
|
||||
|
|
@ -1972,22 +1972,22 @@ impl Shell {
|
|||
.filter(|seat| seat.active_output() == **o)
|
||||
.any(|seat| {
|
||||
let cursor_status = seat.cursor_image_status();
|
||||
if let CursorImageStatus::Surface(s) = cursor_status {
|
||||
if s == *surface {
|
||||
return true;
|
||||
}
|
||||
if let CursorImageStatus::Surface(s) = cursor_status
|
||||
&& s == *surface
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() {
|
||||
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() {
|
||||
for (window, _) in grab_state.element().windows() {
|
||||
let mut matches = false;
|
||||
window.0.with_surfaces(|s, _| {
|
||||
matches |= s == surface;
|
||||
});
|
||||
if matches {
|
||||
return true;
|
||||
}
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
|
||||
&& let Some(grab_state) = move_grab.lock().unwrap().as_ref()
|
||||
{
|
||||
for (window, _) in grab_state.element().windows() {
|
||||
let mut matches = false;
|
||||
window.0.with_surfaces(|s, _| {
|
||||
matches |= s == surface;
|
||||
});
|
||||
if matches {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2216,18 +2216,18 @@ impl Shell {
|
|||
}
|
||||
|
||||
pub fn overview_mode(&self) -> (OverviewMode, Option<SwapIndicator>) {
|
||||
if let OverviewMode::Started(trigger, timestamp) = &self.overview_mode {
|
||||
if Instant::now().duration_since(*timestamp) > ANIMATION_DURATION {
|
||||
return (
|
||||
OverviewMode::Active(trigger.clone()),
|
||||
self.swap_indicator.clone(),
|
||||
);
|
||||
}
|
||||
if let OverviewMode::Started(trigger, timestamp) = &self.overview_mode
|
||||
&& Instant::now().duration_since(*timestamp) > ANIMATION_DURATION
|
||||
{
|
||||
return (
|
||||
OverviewMode::Active(trigger.clone()),
|
||||
self.swap_indicator.clone(),
|
||||
);
|
||||
}
|
||||
if let OverviewMode::Ended(_, timestamp) = &self.overview_mode {
|
||||
if Instant::now().duration_since(*timestamp) > ANIMATION_DURATION {
|
||||
return (OverviewMode::None, None);
|
||||
}
|
||||
if let OverviewMode::Ended(_, timestamp) = &self.overview_mode
|
||||
&& Instant::now().duration_since(*timestamp) > ANIMATION_DURATION
|
||||
{
|
||||
return (OverviewMode::None, None);
|
||||
}
|
||||
|
||||
(self.overview_mode.clone(), self.swap_indicator.clone())
|
||||
|
|
@ -2261,18 +2261,18 @@ impl Shell {
|
|||
}
|
||||
|
||||
pub fn resize_mode(&self) -> (ResizeMode, Option<ResizeIndicator>) {
|
||||
if let ResizeMode::Started(binding, timestamp, direction) = &self.resize_mode {
|
||||
if Instant::now().duration_since(*timestamp) > ANIMATION_DURATION {
|
||||
return (
|
||||
ResizeMode::Active(binding.clone(), *direction),
|
||||
self.resize_indicator.clone(),
|
||||
);
|
||||
}
|
||||
if let ResizeMode::Started(binding, timestamp, direction) = &self.resize_mode
|
||||
&& Instant::now().duration_since(*timestamp) > ANIMATION_DURATION
|
||||
{
|
||||
return (
|
||||
ResizeMode::Active(binding.clone(), *direction),
|
||||
self.resize_indicator.clone(),
|
||||
);
|
||||
}
|
||||
if let ResizeMode::Ended(timestamp, _) = self.resize_mode {
|
||||
if Instant::now().duration_since(timestamp) > ANIMATION_DURATION {
|
||||
return (ResizeMode::None, None);
|
||||
}
|
||||
if let ResizeMode::Ended(timestamp, _) = self.resize_mode
|
||||
&& Instant::now().duration_since(timestamp) > ANIMATION_DURATION
|
||||
{
|
||||
return (ResizeMode::None, None);
|
||||
}
|
||||
|
||||
(self.resize_mode.clone(), self.resize_indicator.clone())
|
||||
|
|
@ -2299,7 +2299,7 @@ impl Shell {
|
|||
}
|
||||
|
||||
pub fn appearance_config(&self) -> AppearanceConfig {
|
||||
self.appearance_conf.clone()
|
||||
self.appearance_conf
|
||||
}
|
||||
|
||||
pub fn trigger_zoom(
|
||||
|
|
@ -2333,10 +2333,10 @@ impl Shell {
|
|||
}
|
||||
|
||||
let mut toggled = self.zoom_state.is_none();
|
||||
if let Some(old_state) = self.zoom_state.as_ref() {
|
||||
if &old_state.seat != seat {
|
||||
return;
|
||||
}
|
||||
if let Some(old_state) = self.zoom_state.as_ref()
|
||||
&& &old_state.seat != seat
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for output in &outputs {
|
||||
|
|
@ -2766,18 +2766,16 @@ impl Shell {
|
|||
}
|
||||
|
||||
let maybe_focused = workspace.focus_stack.get(&seat).iter().next().cloned();
|
||||
if let Some(FocusTarget::Window(focused)) = maybe_focused {
|
||||
if (focused.is_stack() && !is_dialog && !should_be_maximized)
|
||||
&& !(workspace.is_tiled(&focused.active_window()) && floating_exception)
|
||||
{
|
||||
focused.stack_ref().unwrap().add_window(window, None, None);
|
||||
if was_activated {
|
||||
workspace_state.add_workspace_state(&workspace_handle, WState::Urgent);
|
||||
}
|
||||
return (workspace_output == seat.active_output()
|
||||
&& active_handle == workspace_handle)
|
||||
.then_some(KeyboardFocusTarget::Element(focused));
|
||||
if let Some(FocusTarget::Window(focused)) = maybe_focused
|
||||
&& (focused.is_stack() && !is_dialog && !should_be_maximized)
|
||||
&& !(workspace.is_tiled(&focused.active_window()) && floating_exception)
|
||||
{
|
||||
focused.stack_ref().unwrap().add_window(window, None, None);
|
||||
if was_activated {
|
||||
workspace_state.add_workspace_state(&workspace_handle, WState::Urgent);
|
||||
}
|
||||
return (workspace_output == seat.active_output() && active_handle == workspace_handle)
|
||||
.then_some(KeyboardFocusTarget::Element(focused));
|
||||
}
|
||||
|
||||
let mapped = CosmicMapped::from(CosmicWindow::new(
|
||||
|
|
@ -3026,62 +3024,62 @@ impl Shell {
|
|||
|
||||
let spaces = self.workspaces.spaces_mut();
|
||||
let (mut from_w, mut other_w) = spaces.partition::<Vec<_>, _>(|w| w.handle == from);
|
||||
if let Some(from_workspace) = from_w.get_mut(0) {
|
||||
if let Some(to_workspace) = other_w.iter_mut().find(|w| w.handle == to) {
|
||||
{
|
||||
let mut stack = to_workspace.focus_stack.get_mut(seat);
|
||||
for elem in focus_stack.iter().flat_map(|node_id| {
|
||||
from_workspace.tiling_layer.element_for_node(node_id)
|
||||
}) {
|
||||
stack.append(elem.clone());
|
||||
}
|
||||
if let Some(from_workspace) = from_w.get_mut(0)
|
||||
&& let Some(to_workspace) = other_w.iter_mut().find(|w| w.handle == to)
|
||||
{
|
||||
{
|
||||
let mut stack = to_workspace.focus_stack.get_mut(seat);
|
||||
for elem in focus_stack.iter().flat_map(|node_id| {
|
||||
from_workspace.tiling_layer.element_for_node(node_id)
|
||||
}) {
|
||||
stack.append(elem.clone());
|
||||
}
|
||||
|
||||
if to_workspace.tiling_enabled {
|
||||
for mapped in to_workspace
|
||||
.mapped()
|
||||
.filter(|m| m.maximized_state.lock().unwrap().is_some())
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
{
|
||||
to_workspace.unmaximize_request(&mapped);
|
||||
}
|
||||
}
|
||||
|
||||
let res = TilingLayout::move_tree(
|
||||
&mut from_workspace.tiling_layer,
|
||||
&mut to_workspace.tiling_layer,
|
||||
&to,
|
||||
seat,
|
||||
to_workspace.focus_stack.get(seat).iter(),
|
||||
NodeDesc {
|
||||
handle: from,
|
||||
node,
|
||||
stack_window: None,
|
||||
focus_stack,
|
||||
},
|
||||
direction,
|
||||
);
|
||||
from_workspace.refresh_focus_stack();
|
||||
to_workspace.refresh_focus_stack();
|
||||
|
||||
if !to_workspace.tiling_enabled {
|
||||
to_workspace.tiling_enabled = true;
|
||||
for mapped in to_workspace
|
||||
.tiling_layer
|
||||
.mapped()
|
||||
.map(|(mapped, _)| mapped.clone())
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
{
|
||||
to_workspace.toggle_floating_window(seat, &mapped);
|
||||
}
|
||||
to_workspace.tiling_enabled = false;
|
||||
}
|
||||
|
||||
return Ok(res.zip(new_pos));
|
||||
}
|
||||
|
||||
if to_workspace.tiling_enabled {
|
||||
for mapped in to_workspace
|
||||
.mapped()
|
||||
.filter(|m| m.maximized_state.lock().unwrap().is_some())
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
{
|
||||
to_workspace.unmaximize_request(&mapped);
|
||||
}
|
||||
}
|
||||
|
||||
let res = TilingLayout::move_tree(
|
||||
&mut from_workspace.tiling_layer,
|
||||
&mut to_workspace.tiling_layer,
|
||||
&to,
|
||||
seat,
|
||||
to_workspace.focus_stack.get(seat).iter(),
|
||||
NodeDesc {
|
||||
handle: from,
|
||||
node,
|
||||
stack_window: None,
|
||||
focus_stack,
|
||||
},
|
||||
direction,
|
||||
);
|
||||
from_workspace.refresh_focus_stack();
|
||||
to_workspace.refresh_focus_stack();
|
||||
|
||||
if !to_workspace.tiling_enabled {
|
||||
to_workspace.tiling_enabled = true;
|
||||
for mapped in to_workspace
|
||||
.tiling_layer
|
||||
.mapped()
|
||||
.map(|(mapped, _)| mapped.clone())
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
{
|
||||
to_workspace.toggle_floating_window(seat, &mapped);
|
||||
}
|
||||
to_workspace.tiling_enabled = false;
|
||||
}
|
||||
|
||||
return Ok(res.zip(new_pos));
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
|
|
@ -3155,12 +3153,10 @@ impl Shell {
|
|||
was_maximized: previous.was_maximized(),
|
||||
},
|
||||
};
|
||||
} else {
|
||||
if let FullscreenRestoreState::Tiling { workspace, .. }
|
||||
| FullscreenRestoreState::Floating { workspace, .. } = previous
|
||||
{
|
||||
*workspace = *to;
|
||||
}
|
||||
} else if let FullscreenRestoreState::Tiling { workspace, .. }
|
||||
| FullscreenRestoreState::Floating { workspace, .. } = previous
|
||||
{
|
||||
*workspace = *to;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3408,20 +3404,19 @@ impl Shell {
|
|||
}
|
||||
|
||||
pub fn update_reactive_popups(&self, mapped: &CosmicMapped) {
|
||||
if let Some(workspace) = self.space_for(mapped) {
|
||||
if let Some(element_loc) = workspace
|
||||
if let Some(workspace) = self.space_for(mapped)
|
||||
&& let Some(element_loc) = workspace
|
||||
.element_geometry(mapped)
|
||||
.map(|geo| geo.loc.to_global(&workspace.output))
|
||||
{
|
||||
for (window, offset) in mapped.windows() {
|
||||
if let Some(toplevel) = window.0.toplevel() {
|
||||
let window_geo_offset = window.geometry().loc.as_global();
|
||||
update_reactive_popups(
|
||||
toplevel,
|
||||
element_loc + offset.as_global() + window_geo_offset,
|
||||
self.outputs(),
|
||||
);
|
||||
}
|
||||
{
|
||||
for (window, offset) in mapped.windows() {
|
||||
if let Some(toplevel) = window.0.toplevel() {
|
||||
let window_geo_offset = window.geometry().loc.as_global();
|
||||
update_reactive_popups(
|
||||
toplevel,
|
||||
element_loc + offset.as_global() + window_geo_offset,
|
||||
self.outputs(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3744,12 +3739,11 @@ impl Shell {
|
|||
None
|
||||
};
|
||||
|
||||
if mapped == old_mapped {
|
||||
if let Some(geo) = sticky_layer.unmap(&mapped, None) {
|
||||
if geo.size != elem_geo.size {
|
||||
new_size = Some(geo.size.as_logical());
|
||||
}
|
||||
}
|
||||
if mapped == old_mapped
|
||||
&& let Some(geo) = sticky_layer.unmap(&mapped, None)
|
||||
&& geo.size != elem_geo.size
|
||||
{
|
||||
new_size = Some(geo.size.as_logical());
|
||||
}
|
||||
|
||||
if let Some(new_size) = new_size {
|
||||
|
|
@ -4404,47 +4398,47 @@ impl Shell {
|
|||
.resize(&focused, direction, edge, amount)
|
||||
{
|
||||
self.resize_state = Some((focused, direction, edge, amount, idx, output));
|
||||
} else if let Some(workspace) = self.workspaces.get_mut(idx, &output) {
|
||||
if workspace.resize(&focused, direction, edge, amount) {
|
||||
self.resize_state = Some((focused, direction, edge, amount, idx, output));
|
||||
}
|
||||
} else if let Some(workspace) = self.workspaces.get_mut(idx, &output)
|
||||
&& workspace.resize(&focused, direction, edge, amount)
|
||||
{
|
||||
self.resize_state = Some((focused, direction, edge, amount, idx, output));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn finish_resize(&mut self, direction: ResizeDirection, edge: ResizeEdge) {
|
||||
if let Some((old_focused, old_direction, old_edge, _, idx, output)) =
|
||||
self.resize_state.take()
|
||||
&& old_direction == direction
|
||||
&& old_edge == edge
|
||||
{
|
||||
if old_direction == direction && old_edge == edge {
|
||||
let Some(toplevel) = old_focused.toplevel() else {
|
||||
return;
|
||||
};
|
||||
let Some(mapped) = self
|
||||
.workspaces
|
||||
.sets
|
||||
.values()
|
||||
.find_map(|set| {
|
||||
set.sticky_layer
|
||||
.mapped()
|
||||
.find(|m| m.has_surface(&toplevel, WindowSurfaceType::TOPLEVEL))
|
||||
})
|
||||
.cloned()
|
||||
.or_else(|| {
|
||||
let workspace = self.workspaces.get(idx, &output).unwrap();
|
||||
workspace
|
||||
.mapped()
|
||||
.find(|m| m.has_surface(&toplevel, WindowSurfaceType::TOPLEVEL))
|
||||
.cloned()
|
||||
})
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Some(toplevel) = old_focused.toplevel() else {
|
||||
return;
|
||||
};
|
||||
let Some(mapped) = self
|
||||
.workspaces
|
||||
.sets
|
||||
.values()
|
||||
.find_map(|set| {
|
||||
set.sticky_layer
|
||||
.mapped()
|
||||
.find(|m| m.has_surface(&toplevel, WindowSurfaceType::TOPLEVEL))
|
||||
})
|
||||
.cloned()
|
||||
.or_else(|| {
|
||||
let workspace = self.workspaces.get(idx, &output).unwrap();
|
||||
workspace
|
||||
.mapped()
|
||||
.find(|m| m.has_surface(&toplevel, WindowSurfaceType::TOPLEVEL))
|
||||
.cloned()
|
||||
})
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
let mut resize_state = mapped.resize_state.lock().unwrap();
|
||||
if let Some(ResizeState::Resizing(data)) = *resize_state {
|
||||
mapped.set_resizing(false);
|
||||
*resize_state = Some(ResizeState::WaitingForCommit(data));
|
||||
}
|
||||
let mut resize_state = mapped.resize_state.lock().unwrap();
|
||||
if let Some(ResizeState::Resizing(data)) = *resize_state {
|
||||
mapped.set_resizing(false);
|
||||
*resize_state = Some(ResizeState::WaitingForCommit(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4520,10 +4514,8 @@ impl Shell {
|
|||
None
|
||||
};
|
||||
|
||||
if was_maximized {
|
||||
if let Some(KeyboardFocusTarget::Element(mapped)) = res.as_ref() {
|
||||
self.maximize_request(mapped, seat, false, loop_handle);
|
||||
}
|
||||
if was_maximized && let Some(KeyboardFocusTarget::Element(mapped)) = res.as_ref() {
|
||||
self.maximize_request(mapped, seat, false, loop_handle);
|
||||
}
|
||||
|
||||
res
|
||||
|
|
|
|||
|
|
@ -112,12 +112,12 @@ impl Devices {
|
|||
.collect::<Vec<_>>();
|
||||
map.insert(id, caps);
|
||||
|
||||
if device.has_capability(DeviceCapability::Keyboard) {
|
||||
if let Some(device) = <dyn Any>::downcast_ref::<InputDevice>(device) {
|
||||
let mut device = device.clone();
|
||||
device.led_update(led_state.into());
|
||||
self.keyboards.borrow_mut().push(device);
|
||||
}
|
||||
if device.has_capability(DeviceCapability::Keyboard)
|
||||
&& let Some(device) = <dyn Any>::downcast_ref::<InputDevice>(device)
|
||||
{
|
||||
let mut device = device.clone();
|
||||
device.led_update(led_state.into());
|
||||
self.keyboards.borrow_mut().push(device);
|
||||
}
|
||||
|
||||
new_caps
|
||||
|
|
@ -385,10 +385,10 @@ impl SeatExt for Seat<State> {
|
|||
let lock = self.user_data().get::<Mutex<CursorImageStatus>>().unwrap();
|
||||
// Reset the cursor if the surface is no longer alive
|
||||
let mut cursor_status = lock.lock().unwrap();
|
||||
if let CursorImageStatus::Surface(ref surface) = *cursor_status {
|
||||
if !surface.alive() {
|
||||
*cursor_status = CursorImageStatus::default_named();
|
||||
}
|
||||
if let CursorImageStatus::Surface(ref surface) = *cursor_status
|
||||
&& !surface.alive()
|
||||
{
|
||||
*cursor_status = CursorImageStatus::default_named();
|
||||
}
|
||||
cursor_status.clone()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -487,11 +487,9 @@ impl Workspace {
|
|||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
let move_mapped = if let Some(move_grab_state) = &*move_grab_state {
|
||||
Some(move_grab_state.element())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let move_mapped = (*move_grab_state)
|
||||
.as_ref()
|
||||
.map(|move_grab_state| move_grab_state.element());
|
||||
|
||||
let mapped = || {
|
||||
self.floating_layer
|
||||
|
|
@ -640,7 +638,7 @@ impl Workspace {
|
|||
})));
|
||||
}
|
||||
|
||||
let was_snapped = mapped.floating_tiled.lock().unwrap().clone();
|
||||
let was_snapped = *mapped.floating_tiled.lock().unwrap();
|
||||
// unmaximize_request might have triggered a `floating_layer.refresh()`,
|
||||
// which may have already removed a non-alive surface.
|
||||
if let Some(floating_geometry) = self.floating_layer.unmap(mapped, None).or(was_maximized) {
|
||||
|
|
@ -695,18 +693,18 @@ impl Workspace {
|
|||
|
||||
let mapped = self.element_for_surface(surface)?;
|
||||
let maybe_stack = mapped.stack_ref().filter(|s| s.len() > 1);
|
||||
if let Some(stack) = maybe_stack {
|
||||
if stack.len() > 1 {
|
||||
let idx = stack.surfaces().position(|s| &s == surface);
|
||||
let layer = if self.is_tiled(surface) {
|
||||
ManagedLayer::Tiling
|
||||
} else {
|
||||
ManagedLayer::Floating
|
||||
};
|
||||
return idx
|
||||
.and_then(|idx| stack.remove_idx(idx))
|
||||
.map(|s| (s, layer.into()));
|
||||
}
|
||||
if let Some(stack) = maybe_stack
|
||||
&& stack.len() > 1
|
||||
{
|
||||
let idx = stack.surfaces().position(|s| &s == surface);
|
||||
let layer = if self.is_tiled(surface) {
|
||||
ManagedLayer::Tiling
|
||||
} else {
|
||||
ManagedLayer::Floating
|
||||
};
|
||||
return idx
|
||||
.and_then(|idx| stack.remove_idx(idx))
|
||||
.map(|s| (s, layer.into()));
|
||||
}
|
||||
|
||||
// we know mapped is no stack with more than one element now,
|
||||
|
|
@ -774,25 +772,25 @@ impl Workspace {
|
|||
let stack = self.focus_stack.get(seat);
|
||||
let last_focused = stack.last();
|
||||
|
||||
if let Some(fullscreen) = self.fullscreen.as_ref() {
|
||||
if last_focused.is_some_and(
|
||||
if let Some(fullscreen) = self.fullscreen.as_ref()
|
||||
&& last_focused.is_some_and(
|
||||
|t| matches!(t, FocusTarget::Fullscreen(f) if f == &fullscreen.surface),
|
||||
) && !fullscreen.is_animating()
|
||||
{
|
||||
let geometry = self.fullscreen_geometry().unwrap();
|
||||
return fullscreen_element_under(fullscreen, geometry);
|
||||
}
|
||||
)
|
||||
&& !fullscreen.is_animating()
|
||||
{
|
||||
let geometry = self.fullscreen_geometry().unwrap();
|
||||
return fullscreen_element_under(fullscreen, geometry);
|
||||
}
|
||||
|
||||
self.floating_layer
|
||||
.popup_element_under(location)
|
||||
.or_else(|| self.tiling_layer.popup_element_under(location))
|
||||
.or_else(|| {
|
||||
if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_))) {
|
||||
if let Some(fullscreen) = self.fullscreen.as_ref() {
|
||||
let geometry = self.fullscreen_geometry().unwrap();
|
||||
return fullscreen_element_under(fullscreen, geometry);
|
||||
}
|
||||
if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_)))
|
||||
&& let Some(fullscreen) = self.fullscreen.as_ref()
|
||||
{
|
||||
let geometry = self.fullscreen_geometry().unwrap();
|
||||
return fullscreen_element_under(fullscreen, geometry);
|
||||
}
|
||||
None
|
||||
})
|
||||
|
|
@ -824,25 +822,25 @@ impl Workspace {
|
|||
let stack = self.focus_stack.get(seat);
|
||||
let last_focused = stack.last();
|
||||
|
||||
if let Some(fullscreen) = self.fullscreen.as_ref() {
|
||||
if last_focused.is_some_and(
|
||||
if let Some(fullscreen) = self.fullscreen.as_ref()
|
||||
&& last_focused.is_some_and(
|
||||
|t| matches!(t, FocusTarget::Fullscreen(f) if f == &fullscreen.surface),
|
||||
) && !fullscreen.is_animating()
|
||||
{
|
||||
let geometry = self.fullscreen_geometry().unwrap();
|
||||
return fullscreen_element_under(fullscreen, geometry);
|
||||
}
|
||||
)
|
||||
&& !fullscreen.is_animating()
|
||||
{
|
||||
let geometry = self.fullscreen_geometry().unwrap();
|
||||
return fullscreen_element_under(fullscreen, geometry);
|
||||
}
|
||||
|
||||
self.floating_layer
|
||||
.toplevel_element_under(location)
|
||||
.or_else(|| self.tiling_layer.toplevel_element_under(location))
|
||||
.or_else(|| {
|
||||
if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_))) {
|
||||
if let Some(fullscreen) = self.fullscreen.as_ref() {
|
||||
let geometry = self.fullscreen_geometry().unwrap();
|
||||
return fullscreen_element_under(fullscreen, geometry);
|
||||
}
|
||||
if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_)))
|
||||
&& let Some(fullscreen) = self.fullscreen.as_ref()
|
||||
{
|
||||
let geometry = self.fullscreen_geometry().unwrap();
|
||||
return fullscreen_element_under(fullscreen, geometry);
|
||||
}
|
||||
None
|
||||
})
|
||||
|
|
@ -1071,7 +1069,7 @@ impl Workspace {
|
|||
mapped.set_minimized(true);
|
||||
mapped.configure();
|
||||
|
||||
let was_snapped = mapped.floating_tiled.lock().unwrap().clone();
|
||||
let was_snapped = *mapped.floating_tiled.lock().unwrap();
|
||||
if let Some(geometry) = self.floating_layer.unmap(&mapped, Some(to)) {
|
||||
return Some(MinimizedWindow::Floating {
|
||||
window: mapped,
|
||||
|
|
|
|||
|
|
@ -232,24 +232,24 @@ impl ZoomState {
|
|||
let active_output = self.seat.active_output();
|
||||
let output = output.unwrap_or(&active_output);
|
||||
let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap();
|
||||
let res = output_state
|
||||
|
||||
output_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.animating_focal_point()
|
||||
.to_global(output);
|
||||
res
|
||||
.to_global(output)
|
||||
}
|
||||
|
||||
pub fn current_focal_point(&self, output: Option<&Output>) -> Point<f64, Global> {
|
||||
let active_output = self.seat.active_output();
|
||||
let output = output.unwrap_or(&active_output);
|
||||
let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap();
|
||||
let res = output_state
|
||||
|
||||
output_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.current_focal_point()
|
||||
.to_global(output);
|
||||
res
|
||||
.to_global(output)
|
||||
}
|
||||
|
||||
pub fn update_focal_point(
|
||||
|
|
|
|||
271
src/state.rs
271
src/state.rs
|
|
@ -655,9 +655,9 @@ impl State {
|
|||
let cosmic_image_capture_source_state =
|
||||
CosmicImageCaptureSourceState::new::<Self, _>(dh, client_not_sandboxed);
|
||||
let output_capture_source_state =
|
||||
OutputCaptureSourceState::new_with_filter::<State, _>(&dh, client_not_sandboxed);
|
||||
OutputCaptureSourceState::new_with_filter::<State, _>(dh, client_not_sandboxed);
|
||||
let toplevel_capture_source_state =
|
||||
ToplevelCaptureSourceState::new_with_filter::<State, _>(&dh, client_not_sandboxed);
|
||||
ToplevelCaptureSourceState::new_with_filter::<State, _>(dh, client_not_sandboxed);
|
||||
let image_copy_capture_state =
|
||||
ImageCopyCaptureState::new_with_filter::<Self, _>(dh, client_not_sandboxed);
|
||||
let shm_state =
|
||||
|
|
@ -681,7 +681,7 @@ impl State {
|
|||
VirtualKeyboardManagerState::new::<State, _>(dh, client_not_sandboxed);
|
||||
AlphaModifierState::new::<Self>(dh);
|
||||
SinglePixelBufferState::new::<Self>(dh);
|
||||
FixesState::new::<Self>(&dh);
|
||||
FixesState::new::<Self>(dh);
|
||||
|
||||
let idle_notifier_state = IdleNotifierState::<Self>::new(dh, handle.clone());
|
||||
let idle_inhibit_manager_state = IdleInhibitManagerState::new::<State>(dh);
|
||||
|
|
@ -954,10 +954,10 @@ impl Common {
|
|||
};
|
||||
|
||||
// lock surface
|
||||
if let Some(session_lock) = shell.session_lock.as_ref() {
|
||||
if let Some(lock_surface) = session_lock.surfaces.get(output) {
|
||||
with_surfaces_surface_tree(lock_surface.wl_surface(), processor)
|
||||
}
|
||||
if let Some(session_lock) = shell.session_lock.as_ref()
|
||||
&& let Some(lock_surface) = session_lock.surfaces.get(output)
|
||||
{
|
||||
with_surfaces_surface_tree(lock_surface.wl_surface(), processor)
|
||||
}
|
||||
|
||||
for seat in shell
|
||||
|
|
@ -973,11 +973,11 @@ impl Common {
|
|||
}
|
||||
|
||||
// grabs
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() {
|
||||
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() {
|
||||
for (window, _) in grab_state.element().windows() {
|
||||
window.with_surfaces(processor);
|
||||
}
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
|
||||
&& let Some(grab_state) = move_grab.lock().unwrap().as_ref()
|
||||
{
|
||||
for (window, _) in grab_state.element().windows() {
|
||||
window.with_surfaces(processor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1037,30 +1037,28 @@ impl Common {
|
|||
) {
|
||||
let shell = self.shell.read();
|
||||
|
||||
if let Some(session_lock) = shell.session_lock.as_ref() {
|
||||
if let Some(lock_surface) = session_lock.surfaces.get(output) {
|
||||
if let Some(feedback) =
|
||||
advertised_node_for_surface(lock_surface.wl_surface(), &self.display_handle)
|
||||
.and_then(&mut dmabuf_feedback)
|
||||
{
|
||||
send_dmabuf_feedback_surface_tree(
|
||||
lock_surface.wl_surface(),
|
||||
output,
|
||||
surface_primary_scanout_output,
|
||||
|surface, _| {
|
||||
select_dmabuf_feedback(
|
||||
surface,
|
||||
render_element_states,
|
||||
&feedback.render_feedback,
|
||||
feedback
|
||||
.primary_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback),
|
||||
)
|
||||
},
|
||||
if let Some(session_lock) = shell.session_lock.as_ref()
|
||||
&& let Some(lock_surface) = session_lock.surfaces.get(output)
|
||||
&& let Some(feedback) =
|
||||
advertised_node_for_surface(lock_surface.wl_surface(), &self.display_handle)
|
||||
.and_then(&mut dmabuf_feedback)
|
||||
{
|
||||
send_dmabuf_feedback_surface_tree(
|
||||
lock_surface.wl_surface(),
|
||||
output,
|
||||
surface_primary_scanout_output,
|
||||
|surface, _| {
|
||||
select_dmabuf_feedback(
|
||||
surface,
|
||||
render_element_states,
|
||||
&feedback.render_feedback,
|
||||
feedback
|
||||
.primary_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback),
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
for seat in shell
|
||||
|
|
@ -1070,71 +1068,69 @@ impl Common {
|
|||
{
|
||||
let cursor_status = seat.cursor_image_status();
|
||||
|
||||
if let CursorImageStatus::Surface(wl_surface) = cursor_status {
|
||||
if let Some(feedback) =
|
||||
if let CursorImageStatus::Surface(wl_surface) = cursor_status
|
||||
&& let Some(feedback) =
|
||||
advertised_node_for_surface(&wl_surface, &self.display_handle)
|
||||
.and_then(&mut dmabuf_feedback)
|
||||
{
|
||||
send_dmabuf_feedback_surface_tree(
|
||||
&wl_surface,
|
||||
output,
|
||||
surface_primary_scanout_output,
|
||||
|surface, _| {
|
||||
select_dmabuf_feedback(
|
||||
surface,
|
||||
render_element_states,
|
||||
&feedback.render_feedback,
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback),
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
{
|
||||
send_dmabuf_feedback_surface_tree(
|
||||
&wl_surface,
|
||||
output,
|
||||
surface_primary_scanout_output,
|
||||
|surface, _| {
|
||||
select_dmabuf_feedback(
|
||||
surface,
|
||||
render_element_states,
|
||||
&feedback.render_feedback,
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback),
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(icon) = get_dnd_icon(seat) {
|
||||
if let Some(feedback) =
|
||||
if let Some(icon) = get_dnd_icon(seat)
|
||||
&& let Some(feedback) =
|
||||
advertised_node_for_surface(&icon.surface, &self.display_handle)
|
||||
.and_then(&mut dmabuf_feedback)
|
||||
{
|
||||
send_dmabuf_feedback_surface_tree(
|
||||
&icon.surface,
|
||||
output,
|
||||
surface_primary_scanout_output,
|
||||
|surface, _| {
|
||||
select_dmabuf_feedback(
|
||||
surface,
|
||||
render_element_states,
|
||||
&feedback.render_feedback,
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback),
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
{
|
||||
send_dmabuf_feedback_surface_tree(
|
||||
&icon.surface,
|
||||
output,
|
||||
surface_primary_scanout_output,
|
||||
|surface, _| {
|
||||
select_dmabuf_feedback(
|
||||
surface,
|
||||
render_element_states,
|
||||
&feedback.render_feedback,
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback),
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() {
|
||||
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() {
|
||||
for (window, _) in grab_state.element().windows() {
|
||||
if let Some(feedback) = window
|
||||
.wl_surface()
|
||||
.and_then(|wl_surface| {
|
||||
advertised_node_for_surface(&wl_surface, &self.display_handle)
|
||||
})
|
||||
.and_then(&mut dmabuf_feedback)
|
||||
{
|
||||
window.send_dmabuf_feedback(
|
||||
output,
|
||||
&feedback,
|
||||
render_element_states,
|
||||
surface_primary_scanout_output,
|
||||
);
|
||||
}
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
|
||||
&& let Some(grab_state) = move_grab.lock().unwrap().as_ref()
|
||||
{
|
||||
for (window, _) in grab_state.element().windows() {
|
||||
if let Some(feedback) = window
|
||||
.wl_surface()
|
||||
.and_then(|wl_surface| {
|
||||
advertised_node_for_surface(&wl_surface, &self.display_handle)
|
||||
})
|
||||
.and_then(&mut dmabuf_feedback)
|
||||
{
|
||||
window.send_dmabuf_feedback(
|
||||
output,
|
||||
&feedback,
|
||||
render_element_states,
|
||||
surface_primary_scanout_output,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1167,21 +1163,20 @@ impl Common {
|
|||
});
|
||||
|
||||
if let Some(active) = shell.active_space(output) {
|
||||
if let Some(window) = active.get_fullscreen() {
|
||||
if let Some(feedback) = window
|
||||
if let Some(window) = active.get_fullscreen()
|
||||
&& let Some(feedback) = window
|
||||
.wl_surface()
|
||||
.and_then(|wl_surface| {
|
||||
advertised_node_for_surface(&wl_surface, &self.display_handle)
|
||||
})
|
||||
.and_then(&mut dmabuf_feedback)
|
||||
{
|
||||
window.send_dmabuf_feedback(
|
||||
output,
|
||||
&feedback,
|
||||
render_element_states,
|
||||
surface_primary_scanout_output,
|
||||
);
|
||||
}
|
||||
{
|
||||
window.send_dmabuf_feedback(
|
||||
output,
|
||||
&feedback,
|
||||
render_element_states,
|
||||
surface_primary_scanout_output,
|
||||
);
|
||||
}
|
||||
active.mapped().for_each(|mapped| {
|
||||
for (window, _) in mapped.windows() {
|
||||
|
|
@ -1204,28 +1199,27 @@ impl Common {
|
|||
}
|
||||
|
||||
shell.override_redirect_windows.iter().for_each(|or| {
|
||||
if let Some(wl_surface) = or.wl_surface() {
|
||||
if let Some(feedback) =
|
||||
if let Some(wl_surface) = or.wl_surface()
|
||||
&& let Some(feedback) =
|
||||
advertised_node_for_surface(&wl_surface, &self.display_handle)
|
||||
.and_then(&mut dmabuf_feedback)
|
||||
{
|
||||
send_dmabuf_feedback_surface_tree(
|
||||
&wl_surface,
|
||||
output,
|
||||
surface_primary_scanout_output,
|
||||
|surface, _| {
|
||||
select_dmabuf_feedback(
|
||||
surface,
|
||||
render_element_states,
|
||||
&feedback.render_feedback,
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
{
|
||||
send_dmabuf_feedback_surface_tree(
|
||||
&wl_surface,
|
||||
output,
|
||||
surface_primary_scanout_output,
|
||||
|surface, _| {
|
||||
select_dmabuf_feedback(
|
||||
surface,
|
||||
render_element_states,
|
||||
&feedback.render_feedback,
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.as_ref()
|
||||
.unwrap_or(&feedback.render_feedback),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1280,10 +1274,11 @@ impl Common {
|
|||
|
||||
// If we already sent a frame callback to this surface this output refresh
|
||||
// cycle, don't send one again to prevent empty-damage commit busy loops.
|
||||
if let Some((last_output, last_sequence)) = &*last_sent_at {
|
||||
if last_output == output && *last_sequence == sequence {
|
||||
send = false;
|
||||
}
|
||||
if let Some((last_output, last_sequence)) = &*last_sent_at
|
||||
&& last_output == output
|
||||
&& *last_sequence == sequence
|
||||
{
|
||||
send = false;
|
||||
}
|
||||
|
||||
if send {
|
||||
|
|
@ -1306,16 +1301,10 @@ impl Common {
|
|||
|
||||
let shell = self.shell.read();
|
||||
|
||||
if let Some(session_lock) = shell.session_lock.as_ref() {
|
||||
if let Some(lock_surface) = session_lock.surfaces.get(output) {
|
||||
send_frames_surface_tree(
|
||||
lock_surface.wl_surface(),
|
||||
output,
|
||||
time,
|
||||
None,
|
||||
should_send,
|
||||
);
|
||||
}
|
||||
if let Some(session_lock) = shell.session_lock.as_ref()
|
||||
&& let Some(lock_surface) = session_lock.surfaces.get(output)
|
||||
{
|
||||
send_frames_surface_tree(lock_surface.wl_surface(), output, time, None, should_send);
|
||||
}
|
||||
|
||||
for seat in shell
|
||||
|
|
@ -1335,11 +1324,11 @@ impl Common {
|
|||
)
|
||||
}
|
||||
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() {
|
||||
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() {
|
||||
for (window, _) in grab_state.element().windows() {
|
||||
window.send_frame(output, time, throttle(&window), should_send);
|
||||
}
|
||||
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>()
|
||||
&& let Some(grab_state) = move_grab.lock().unwrap().as_ref()
|
||||
{
|
||||
for (window, _) in grab_state.element().windows() {
|
||||
window.send_frame(output, time, throttle(&window), should_send);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -449,13 +449,13 @@ impl<P: Program + Send + 'static> IcedElementInternal<P> {
|
|||
)
|
||||
.1;
|
||||
|
||||
if let Some(action) = actions {
|
||||
if let Some(t) = into_stream(action) {
|
||||
let _ = self.scheduler.schedule(t.into_future().map(|f| match f.0 {
|
||||
Some(Action::Output(msg)) => Some(msg),
|
||||
_ => None,
|
||||
}));
|
||||
}
|
||||
if let Some(action) = actions
|
||||
&& let Some(t) = into_stream(action)
|
||||
{
|
||||
let _ = self.scheduler.schedule(t.into_future().map(|f| match f.0 {
|
||||
Some(Action::Output(msg)) => Some(msg),
|
||||
_ => None,
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,11 +145,11 @@ where
|
|||
// for now :^)
|
||||
let temp_cache = user_interface.into_cache();
|
||||
|
||||
let tasks = Task::batch(messages.into_iter().map(|message| {
|
||||
let task = self.program.update(message);
|
||||
|
||||
task
|
||||
}));
|
||||
let tasks = Task::batch(
|
||||
messages
|
||||
.into_iter()
|
||||
.map(|message| self.program.update(message)),
|
||||
);
|
||||
|
||||
let mut user_interface =
|
||||
build_user_interface(id, &mut self.program, temp_cache, renderer, bounds);
|
||||
|
|
@ -216,7 +216,5 @@ fn build_user_interface<'a, P: Program>(
|
|||
) -> UserInterface<'a, P::Message, cosmic::Theme, cosmic::Renderer> {
|
||||
let view = program.view();
|
||||
|
||||
let user_interface = UserInterface::build(view, size, cache, renderer);
|
||||
|
||||
user_interface
|
||||
UserInterface::build(view, size, cache, renderer)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ fn xdg_popup_ensure_initial_configure(popup: &PopupKind) {
|
|||
|
||||
fn layer_surface_check_inital_configure(surface: &LayerSurface) -> bool {
|
||||
// send the initial configure if relevant
|
||||
let initial_configure_sent = with_states(surface.wl_surface(), |states| {
|
||||
with_states(surface.wl_surface(), |states| {
|
||||
states
|
||||
.data_map
|
||||
.get::<Mutex<LayerSurfaceAttributes>>()
|
||||
|
|
@ -81,9 +81,7 @@ fn layer_surface_check_inital_configure(surface: &LayerSurface) -> bool {
|
|||
.lock()
|
||||
.unwrap()
|
||||
.initial_configure_sent
|
||||
});
|
||||
|
||||
initial_configure_sent
|
||||
})
|
||||
}
|
||||
|
||||
pub fn client_compositor_state(client: &Client) -> &CompositorClientState {
|
||||
|
|
@ -195,23 +193,24 @@ impl CompositorHandler for State {
|
|||
})
|
||||
});
|
||||
if let Some(dmabuf) = maybe_dmabuf {
|
||||
if let Some(acquire_point) = acquire_point {
|
||||
if let Ok((blocker, source)) = acquire_point.generate_blocker() {
|
||||
let client = surface.client().unwrap();
|
||||
let res = state.common.event_loop_handle.insert_source(
|
||||
source,
|
||||
move |_, _, state| {
|
||||
if let Some(acquire_point) = acquire_point
|
||||
&& let Ok((blocker, source)) = acquire_point.generate_blocker()
|
||||
{
|
||||
let client = surface.client().unwrap();
|
||||
let res =
|
||||
state
|
||||
.common
|
||||
.event_loop_handle
|
||||
.insert_source(source, move |_, _, state| {
|
||||
let dh = state.common.display_handle.clone();
|
||||
state
|
||||
.client_compositor_state(&client)
|
||||
.blocker_cleared(state, &dh);
|
||||
Ok(())
|
||||
},
|
||||
);
|
||||
if res.is_ok() {
|
||||
add_blocker(surface, blocker);
|
||||
return;
|
||||
}
|
||||
});
|
||||
if res.is_ok() {
|
||||
add_blocker(surface, blocker);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if let Ok((blocker, source)) = dmabuf.generate_blocker(Interest::READ) {
|
||||
|
|
@ -379,35 +378,34 @@ impl State {
|
|||
.pending_windows
|
||||
.iter()
|
||||
.find(|pending| pending.surface.wl_surface().as_deref() == Some(surface))
|
||||
&& let Some(toplevel) = pending.surface.0.toplevel()
|
||||
{
|
||||
if let Some(toplevel) = pending.surface.0.toplevel() {
|
||||
let initial_size = if let Some(output) = pending.fullscreen.as_ref() {
|
||||
Some(output.geometry().size.as_logical())
|
||||
} else if pending.maximized {
|
||||
let active_output = shell.seats.last_active().active_output();
|
||||
let zone = layer_map_for_output(&active_output).non_exclusive_zone();
|
||||
Some(zone.size)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if toplevel_ensure_initial_configure(toplevel, initial_size)
|
||||
&& with_renderer_surface_state(surface, |state| state.buffer().is_some())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let window = pending.surface.clone();
|
||||
window.on_commit();
|
||||
let res = shell.map_window(
|
||||
&window,
|
||||
&mut self.common.toplevel_info_state,
|
||||
&mut self.common.workspace_state,
|
||||
&self.common.event_loop_handle,
|
||||
);
|
||||
if let Some(target) = res {
|
||||
let seat = shell.seats.last_active().clone();
|
||||
std::mem::drop(shell);
|
||||
Shell::set_focus(self, Some(&target), &seat, None, true);
|
||||
return true;
|
||||
}
|
||||
let initial_size = if let Some(output) = pending.fullscreen.as_ref() {
|
||||
Some(output.geometry().size.as_logical())
|
||||
} else if pending.maximized {
|
||||
let active_output = shell.seats.last_active().active_output();
|
||||
let zone = layer_map_for_output(&active_output).non_exclusive_zone();
|
||||
Some(zone.size)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if toplevel_ensure_initial_configure(toplevel, initial_size)
|
||||
&& with_renderer_surface_state(surface, |state| state.buffer().is_some())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let window = pending.surface.clone();
|
||||
window.on_commit();
|
||||
let res = shell.map_window(
|
||||
&window,
|
||||
&mut self.common.toplevel_info_state,
|
||||
&mut self.common.workspace_state,
|
||||
&self.common.event_loop_handle,
|
||||
);
|
||||
if let Some(target) = res {
|
||||
let seat = shell.seats.last_active().clone();
|
||||
std::mem::drop(shell);
|
||||
Shell::set_focus(self, Some(&target), &seat, None, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -417,17 +415,16 @@ impl State {
|
|||
.iter()
|
||||
.find(|pending| pending.surface.wl_surface() == surface)
|
||||
.map(|pending| pending.surface.clone())
|
||||
&& !layer_surface_check_inital_configure(&layer_surface)
|
||||
{
|
||||
if !layer_surface_check_inital_configure(&layer_surface) {
|
||||
// compute initial dimensions by mapping
|
||||
if let Some(target) = shell.map_layer(&layer_surface) {
|
||||
let seat = shell.seats.last_active().clone();
|
||||
std::mem::drop(shell);
|
||||
Shell::set_focus(self, Some(&target), &seat, None, false);
|
||||
}
|
||||
layer_surface.layer_surface().send_configure();
|
||||
return true;
|
||||
// compute initial dimensions by mapping
|
||||
if let Some(target) = shell.map_layer(&layer_surface) {
|
||||
let seat = shell.seats.last_active().clone();
|
||||
std::mem::drop(shell);
|
||||
Shell::set_focus(self, Some(&target), &seat, None, false);
|
||||
}
|
||||
layer_surface.layer_surface().send_configure();
|
||||
return true;
|
||||
};
|
||||
|
||||
false
|
||||
|
|
|
|||
|
|
@ -74,13 +74,12 @@ impl XdgDecorationHandler for State {
|
|||
if let Some((window, _)) = mapped
|
||||
.windows()
|
||||
.find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface()))
|
||||
&& let Some(toplevel) = window.0.toplevel()
|
||||
{
|
||||
if let Some(toplevel) = window.0.toplevel() {
|
||||
toplevel.with_pending_state(|state| {
|
||||
state.decoration_mode = Some(mode);
|
||||
});
|
||||
toplevel.send_configure();
|
||||
}
|
||||
toplevel.with_pending_state(|state| {
|
||||
state.decoration_mode = Some(mode);
|
||||
});
|
||||
toplevel.send_configure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,14 +90,13 @@ impl XdgDecorationHandler for State {
|
|||
if let Some((window, _)) = mapped
|
||||
.windows()
|
||||
.find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface()))
|
||||
&& let Some(toplevel) = window.0.toplevel()
|
||||
{
|
||||
if let Some(toplevel) = window.0.toplevel() {
|
||||
PreferredDecorationMode::update(&window.0, Some(mode));
|
||||
toplevel.with_pending_state(|state| {
|
||||
state.decoration_mode = Some(mode);
|
||||
});
|
||||
toplevel.send_configure();
|
||||
}
|
||||
PreferredDecorationMode::update(&window.0, Some(mode));
|
||||
toplevel.with_pending_state(|state| {
|
||||
state.decoration_mode = Some(mode);
|
||||
});
|
||||
toplevel.send_configure();
|
||||
}
|
||||
} else {
|
||||
toplevel.with_pending_state(|state| state.decoration_mode = Some(mode));
|
||||
|
|
@ -107,19 +105,17 @@ impl XdgDecorationHandler for State {
|
|||
|
||||
fn unset_mode(&mut self, toplevel: ToplevelSurface) {
|
||||
let shell = self.common.shell.read();
|
||||
if let Some(mapped) = shell.element_for_surface(toplevel.wl_surface()) {
|
||||
if let Some((window, _)) = mapped
|
||||
if let Some(mapped) = shell.element_for_surface(toplevel.wl_surface())
|
||||
&& let Some((window, _)) = mapped
|
||||
.windows()
|
||||
.find(|(window, _)| window.wl_surface().as_deref() == Some(toplevel.wl_surface()))
|
||||
{
|
||||
if let Some(toplevel) = window.0.toplevel() {
|
||||
PreferredDecorationMode::update(&window.0, None);
|
||||
toplevel.with_pending_state(|state| {
|
||||
state.decoration_mode = None;
|
||||
});
|
||||
toplevel.send_configure();
|
||||
}
|
||||
}
|
||||
&& let Some(toplevel) = window.0.toplevel()
|
||||
{
|
||||
PreferredDecorationMode::update(&window.0, None);
|
||||
toplevel.with_pending_state(|state| {
|
||||
state.decoration_mode = None;
|
||||
});
|
||||
toplevel.send_configure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,14 +79,12 @@ impl DmabufHandler for State {
|
|||
feedback
|
||||
.primary_scanout_feedback
|
||||
.unwrap_or(feedback.render_feedback)
|
||||
} else if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.unwrap_or(feedback.render_feedback)
|
||||
} else {
|
||||
if frame_time_filter_fn(data) == Kind::ScanoutCandidate {
|
||||
feedback
|
||||
.overlay_scanout_feedback
|
||||
.unwrap_or(feedback.render_feedback)
|
||||
} else {
|
||||
feedback.render_feedback
|
||||
}
|
||||
feedback.render_feedback
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,22 +237,22 @@ impl ImageCopyCaptureHandler for State {
|
|||
}
|
||||
ImageCaptureSourceKind::Toplevel(mut toplevel) => {
|
||||
let shell = self.common.shell.read();
|
||||
if let Some(element) = shell.element_for_surface(&toplevel) {
|
||||
if element.has_active_window(&toplevel) {
|
||||
if let Some(workspace) = shell.space_for(element) {
|
||||
if let Some(geometry) = workspace.element_geometry(element) {
|
||||
let mut surface_geo = element.active_window_geometry().as_local();
|
||||
surface_geo.loc += geometry.loc;
|
||||
let global_geo = surface_geo.to_global(workspace.output());
|
||||
if global_geo.contains(pointer_loc) {
|
||||
let buffer_pos = (pointer_loc - global_geo.loc)
|
||||
.as_logical()
|
||||
.to_buffer(1, Transform::Normal, &toplevel.geometry().size);
|
||||
session.set_cursor_hotspot(hotspot);
|
||||
session.set_cursor_pos(Some(buffer_pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(element) = shell.element_for_surface(&toplevel)
|
||||
&& element.has_active_window(&toplevel)
|
||||
&& let Some(workspace) = shell.space_for(element)
|
||||
&& let Some(geometry) = workspace.element_geometry(element)
|
||||
{
|
||||
let mut surface_geo = element.active_window_geometry().as_local();
|
||||
surface_geo.loc += geometry.loc;
|
||||
let global_geo = surface_geo.to_global(workspace.output());
|
||||
if global_geo.contains(pointer_loc) {
|
||||
let buffer_pos = (pointer_loc - global_geo.loc).as_logical().to_buffer(
|
||||
1,
|
||||
Transform::Normal,
|
||||
&toplevel.geometry().size,
|
||||
);
|
||||
session.set_cursor_hotspot(hotspot);
|
||||
session.set_cursor_pos(Some(buffer_pos));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -577,18 +577,16 @@ pub fn render_window_to_buffer(
|
|||
let pointer = seat.get_pointer().unwrap();
|
||||
let pointer_loc = pointer.current_location().to_i32_round().as_global();
|
||||
let mut location = None;
|
||||
if let Some(element) = shell.element_for_surface(toplevel) {
|
||||
if element.has_active_window(toplevel) {
|
||||
if let Some(workspace) = shell.space_for(element) {
|
||||
if let Some(geometry) = workspace.element_geometry(element) {
|
||||
let mut surface_geo = element.active_window_geometry().as_local();
|
||||
surface_geo.loc += geometry.loc;
|
||||
let global_geo = surface_geo.to_global(workspace.output());
|
||||
if global_geo.contains(pointer_loc) {
|
||||
location = Some((pointer_loc - global_geo.loc).as_logical().to_f64());
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(element) = shell.element_for_surface(toplevel)
|
||||
&& element.has_active_window(toplevel)
|
||||
&& let Some(workspace) = shell.space_for(element)
|
||||
&& let Some(geometry) = workspace.element_geometry(element)
|
||||
{
|
||||
let mut surface_geo = element.active_window_geometry().as_local();
|
||||
surface_geo.loc += geometry.loc;
|
||||
let global_geo = surface_geo.to_global(workspace.output());
|
||||
if global_geo.contains(pointer_loc) {
|
||||
location = Some((pointer_loc - global_geo.loc).as_logical().to_f64());
|
||||
}
|
||||
};
|
||||
std::mem::drop(shell);
|
||||
|
|
@ -620,19 +618,17 @@ pub fn render_window_to_buffer(
|
|||
|
||||
// TODO cosmic-workspaces wants to omit, but metadata cursor capture in portal should
|
||||
// still include dnd surface in window capture buffer?
|
||||
if draw_cursor {
|
||||
if let Some(dnd_icon) = get_dnd_icon(&seat) {
|
||||
elements.extend(
|
||||
cursor::draw_dnd_icon(
|
||||
renderer,
|
||||
&dnd_icon.surface,
|
||||
(location + dnd_icon.offset.to_f64()).to_i32_round(),
|
||||
1.0,
|
||||
)
|
||||
.into_iter()
|
||||
.map(WindowCaptureElement::from),
|
||||
);
|
||||
}
|
||||
if draw_cursor && let Some(dnd_icon) = get_dnd_icon(&seat) {
|
||||
elements.extend(
|
||||
cursor::draw_dnd_icon(
|
||||
renderer,
|
||||
&dnd_icon.surface,
|
||||
(location + dnd_icon.offset.to_f64()).to_i32_round(),
|
||||
1.0,
|
||||
)
|
||||
.into_iter()
|
||||
.map(WindowCaptureElement::from),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,8 +174,8 @@ impl State {
|
|||
*current_config = backup;
|
||||
}
|
||||
}
|
||||
if !test_only {
|
||||
if let Err(err) = backend.apply_config_for_outputs(
|
||||
if !test_only
|
||||
&& let Err(err) = backend.apply_config_for_outputs(
|
||||
false,
|
||||
&self.common.event_loop_handle,
|
||||
self.common.config.dynamic_conf.screen_filter(),
|
||||
|
|
@ -184,9 +184,9 @@ impl State {
|
|||
&self.common.xdg_activation_state,
|
||||
self.common.startup_done.clone(),
|
||||
&self.common.clock,
|
||||
) {
|
||||
error!("Failed to reset output config: {:?}", err);
|
||||
}
|
||||
)
|
||||
{
|
||||
error!("Failed to reset output config: {:?}", err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,10 +70,9 @@ impl SelectionHandler for State {
|
|||
.xwayland_state
|
||||
.as_mut()
|
||||
.and_then(|xstate| xstate.xwm.as_mut())
|
||||
&& let Err(err) = xwm.send_selection(target, mime_type, fd)
|
||||
{
|
||||
if let Err(err) = xwm.send_selection(target, mime_type, fd) {
|
||||
warn!(?err, "Failed to send selection (X11 -> Wayland).");
|
||||
}
|
||||
warn!(?err, "Failed to send selection (X11 -> Wayland).");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,15 +21,14 @@ impl SessionLockHandler for State {
|
|||
let mut shell = self.common.shell.write();
|
||||
|
||||
// Reject lock if sesion lock exists and is still valid
|
||||
if let Some(session_lock) = shell.session_lock.as_ref() {
|
||||
if self
|
||||
if let Some(session_lock) = shell.session_lock.as_ref()
|
||||
&& self
|
||||
.common
|
||||
.display_handle
|
||||
.get_client(session_lock.ext_session_lock.id())
|
||||
.is_ok()
|
||||
{
|
||||
return;
|
||||
}
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let ext_session_lock = locker.ext_session_lock().clone();
|
||||
|
|
@ -55,17 +54,17 @@ impl SessionLockHandler for State {
|
|||
|
||||
fn new_surface(&mut self, lock_surface: LockSurface, wl_output: WlOutput) {
|
||||
let mut shell = self.common.shell.write();
|
||||
if let Some(session_lock) = &mut shell.session_lock {
|
||||
if let Some(output) = Output::from_resource(&wl_output) {
|
||||
lock_surface.with_pending_state(|states| {
|
||||
let size = output.geometry().size;
|
||||
states.size = Some(Size::from((size.w as u32, size.h as u32)));
|
||||
});
|
||||
lock_surface.send_configure();
|
||||
session_lock
|
||||
.surfaces
|
||||
.insert(output.clone(), lock_surface.clone());
|
||||
}
|
||||
if let Some(session_lock) = &mut shell.session_lock
|
||||
&& let Some(output) = Output::from_resource(&wl_output)
|
||||
{
|
||||
lock_surface.with_pending_state(|states| {
|
||||
let size = output.geometry().size;
|
||||
states.size = Some(Size::from((size.w as u32, size.h as u32)));
|
||||
});
|
||||
lock_surface.send_configure();
|
||||
session_lock
|
||||
.surfaces
|
||||
.insert(output.clone(), lock_surface.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,22 +113,21 @@ impl ToplevelManagementHandler for State {
|
|||
// move pointer to window if it’s on a different monitor/output
|
||||
if seat.active_output() != *output
|
||||
&& self.common.config.cosmic_conf.cursor_follows_focus
|
||||
&& let Some(new_pos) = new_pos
|
||||
{
|
||||
if let Some(new_pos) = new_pos {
|
||||
seat.set_active_output(output);
|
||||
if let Some(ptr) = seat.get_pointer() {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
ptr.motion(
|
||||
self,
|
||||
None,
|
||||
&MotionEvent {
|
||||
location: new_pos.to_f64().as_logical(),
|
||||
serial,
|
||||
time: self.common.clock.now().as_millis(),
|
||||
},
|
||||
);
|
||||
ptr.frame(self);
|
||||
}
|
||||
seat.set_active_output(output);
|
||||
if let Some(ptr) = seat.get_pointer() {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
ptr.motion(
|
||||
self,
|
||||
None,
|
||||
&MotionEvent {
|
||||
location: new_pos.to_f64().as_logical(),
|
||||
serial,
|
||||
time: self.common.clock.now().as_millis(),
|
||||
},
|
||||
);
|
||||
ptr.frame(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ impl State {
|
|||
None,
|
||||
false,
|
||||
);
|
||||
} else if let Some((workspace, _)) = shell.workspace_for_surface(&surface) {
|
||||
} else if let Some((workspace, _)) = shell.workspace_for_surface(surface) {
|
||||
let current_workspace = shell.active_space(¤t_output).unwrap();
|
||||
if workspace == current_workspace.handle {
|
||||
let Some(target) = shell
|
||||
|
|
|
|||
|
|
@ -45,12 +45,7 @@ impl XdgShellHandler for State {
|
|||
let mut shell = self.common.shell.write();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
|
||||
if shell
|
||||
.pending_windows
|
||||
.iter()
|
||||
.find(|w| &w.surface == &surface)
|
||||
.is_none()
|
||||
{
|
||||
if !shell.pending_windows.iter().any(|w| w.surface == surface) {
|
||||
let surface = CosmicSurface::from(surface);
|
||||
shell.pending_windows.push(PendingWindow {
|
||||
surface,
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ pub fn update_reactive_popups<'a>(
|
|||
for (popup, _) in PopupManager::popups_for_surface(toplevel.wl_surface()) {
|
||||
match popup {
|
||||
PopupKind::Xdg(surface) => {
|
||||
let positioner = with_states(&surface.wl_surface(), |states| {
|
||||
let positioner = with_states(surface.wl_surface(), |states| {
|
||||
let mut guard = states.cached_state.get::<PopupCachedState>();
|
||||
guard
|
||||
.current()
|
||||
|
|
|
|||
|
|
@ -204,10 +204,10 @@ where
|
|||
state.request_screen_invert(inverted);
|
||||
}
|
||||
|
||||
if let Ok(filter) = filter {
|
||||
if filter != state.a11y_state().screen_filter {
|
||||
state.request_screen_filter(filter);
|
||||
}
|
||||
if let Ok(filter) = filter
|
||||
&& filter != state.a11y_state().screen_filter
|
||||
{
|
||||
state.request_screen_filter(filter);
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
|
|
|||
|
|
@ -428,15 +428,13 @@ where
|
|||
}
|
||||
} else {
|
||||
None
|
||||
} {
|
||||
if inner.enabled
|
||||
&& output
|
||||
.current_mode()
|
||||
.map(|c| c == output_mode)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
instance.obj.current_mode(mode);
|
||||
}
|
||||
} && inner.enabled
|
||||
&& output
|
||||
.current_mode()
|
||||
.map(|c| c == output_mode)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
instance.obj.current_mode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -513,12 +511,11 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(extension_obj) = instance.extension_obj.as_ref() {
|
||||
if inner.enabled
|
||||
&& extension_obj.version() >= zcosmic_output_head_v1::EVT_XWAYLAND_PRIMARY_SINCE
|
||||
{
|
||||
extension_obj.xwayland_primary(output.config().xwayland_primary as u32);
|
||||
}
|
||||
if let Some(extension_obj) = instance.extension_obj.as_ref()
|
||||
&& inner.enabled
|
||||
&& extension_obj.version() >= zcosmic_output_head_v1::EVT_XWAYLAND_PRIMARY_SINCE
|
||||
{
|
||||
extension_obj.xwayland_primary(output.config().xwayland_primary as u32);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,13 +58,13 @@ impl OutputPowerState {
|
|||
let mut output_powers = mem::take(&mut state.output_power_state().output_powers);
|
||||
for (output_power, old_mode) in output_powers.iter_mut() {
|
||||
let data = output_power.data::<OutputPowerData>().unwrap();
|
||||
if let Some(output) = data.output.upgrade() {
|
||||
if let Some(on) = state.get_dpms(&output) {
|
||||
let mode = output_power_mode(on);
|
||||
if mode != *old_mode {
|
||||
output_power.mode(mode);
|
||||
*old_mode = mode;
|
||||
}
|
||||
if let Some(output) = data.output.upgrade()
|
||||
&& let Some(on) = state.get_dpms(&output)
|
||||
{
|
||||
let mode = output_power_mode(on);
|
||||
if mode != *old_mode {
|
||||
output_power.mode(mode);
|
||||
*old_mode = mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,16 +124,16 @@ impl OverlapNotifyState {
|
|||
})
|
||||
})
|
||||
{
|
||||
if let Some(window_geo) = window.global_geometry() {
|
||||
if let Some(intersection) = layer_geo.intersection(window_geo) {
|
||||
// relative to layer location
|
||||
let region = Rectangle::new(
|
||||
intersection.loc - layer_geo.loc,
|
||||
intersection.size,
|
||||
)
|
||||
.as_logical();
|
||||
new_snapshot.add_toplevel(window, region);
|
||||
}
|
||||
if let Some(window_geo) = window.global_geometry()
|
||||
&& let Some(intersection) = layer_geo.intersection(window_geo)
|
||||
{
|
||||
// relative to layer location
|
||||
let region = Rectangle::new(
|
||||
intersection.loc - layer_geo.loc,
|
||||
intersection.size,
|
||||
)
|
||||
.as_logical();
|
||||
new_snapshot.add_toplevel(window, region);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -238,16 +238,15 @@ impl LayerOverlapNotificationDataInternal {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
for toplevel in self.last_snapshot.toplevel_overlaps.keys() {
|
||||
if !new_snapshot.toplevel_overlaps.contains_key(toplevel) {
|
||||
if let Ok(toplevel) = toplevel.upgrade() {
|
||||
if let Some(client) = toplevel.client() {
|
||||
for notification in notifications
|
||||
.iter()
|
||||
.filter(|n| n.client().is_some_and(|c| c == client))
|
||||
{
|
||||
notification.toplevel_leave(&toplevel);
|
||||
}
|
||||
}
|
||||
if !new_snapshot.toplevel_overlaps.contains_key(toplevel)
|
||||
&& let Ok(toplevel) = toplevel.upgrade()
|
||||
&& let Some(client) = toplevel.client()
|
||||
{
|
||||
for notification in notifications
|
||||
.iter()
|
||||
.filter(|n| n.client().is_some_and(|c| c == client))
|
||||
{
|
||||
notification.toplevel_leave(&toplevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -257,22 +256,20 @@ impl LayerOverlapNotificationDataInternal {
|
|||
.toplevel_overlaps
|
||||
.get(toplevel)
|
||||
.is_some_and(|old_overlap| old_overlap == overlap)
|
||||
&& let Ok(toplevel) = toplevel.upgrade()
|
||||
&& let Some(client) = toplevel.client()
|
||||
{
|
||||
if let Ok(toplevel) = toplevel.upgrade() {
|
||||
if let Some(client) = toplevel.client() {
|
||||
for notification in notifications
|
||||
.iter()
|
||||
.filter(|n| n.client().is_some_and(|c| c == client))
|
||||
{
|
||||
notification.toplevel_enter(
|
||||
&toplevel,
|
||||
overlap.loc.x,
|
||||
overlap.loc.y,
|
||||
overlap.size.w,
|
||||
overlap.size.h,
|
||||
);
|
||||
}
|
||||
}
|
||||
for notification in notifications
|
||||
.iter()
|
||||
.filter(|n| n.client().is_some_and(|c| c == client))
|
||||
{
|
||||
notification.toplevel_enter(
|
||||
&toplevel,
|
||||
overlap.loc.x,
|
||||
overlap.loc.y,
|
||||
overlap.size.w,
|
||||
overlap.size.h,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -574,10 +574,8 @@ where
|
|||
instance.geometry(&wl_output, geo.loc.x, geo.loc.y, geo.size.w, geo.size.h);
|
||||
}
|
||||
changed = true;
|
||||
} else if geometry_changed {
|
||||
if let Some(geo) = geometry {
|
||||
instance.geometry(&wl_output, geo.loc.x, geo.loc.y, geo.size.w, geo.size.h);
|
||||
}
|
||||
} else if geometry_changed && let Some(geo) = geometry {
|
||||
instance.geometry(&wl_output, geo.loc.x, geo.loc.y, geo.size.w, geo.size.h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -635,10 +633,10 @@ pub fn window_from_handle<W: Window + 'static>(handle: ZcosmicToplevelHandleV1)
|
|||
.and_then(|state| state.lock().unwrap().window.clone())
|
||||
}
|
||||
|
||||
pub fn window_from_ext<'a, W: Window + 'static, D>(
|
||||
state: &'a D,
|
||||
pub fn window_from_ext<W: Window + 'static, D>(
|
||||
state: &D,
|
||||
handle: ForeignToplevelHandle,
|
||||
) -> Option<&'a W>
|
||||
) -> Option<&W>
|
||||
where
|
||||
D: ToplevelInfoHandler<Window = W>,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -258,10 +258,9 @@ where
|
|||
let window = window_from_handle(toplevel).unwrap();
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(&workspace)
|
||||
&& let Some(output) = Output::from_resource(&output)
|
||||
{
|
||||
if let Some(output) = Output::from_resource(&output) {
|
||||
state.move_to_workspace(dh, &window, workspace_handle, output);
|
||||
}
|
||||
state.move_to_workspace(dh, &window, workspace_handle, output);
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
|
|
|||
|
|
@ -94,11 +94,10 @@ where
|
|||
.iter()
|
||||
.flat_map(|g| &g.workspaces)
|
||||
.find(|w| w.ext_instances.contains(&workspace))
|
||||
&& let Ok(ext_mngr) = data.manager.upgrade()
|
||||
{
|
||||
if let Ok(ext_mngr) = data.manager.upgrade() {
|
||||
send_workspace_to_client(&cosmic_workspace, workspace);
|
||||
ext_mngr.done();
|
||||
}
|
||||
send_workspace_to_client(&cosmic_workspace, workspace);
|
||||
ext_mngr.done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -128,20 +127,18 @@ where
|
|||
zcosmic_workspace_handle_v2::Request::Rename { name } => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(&workspace)
|
||||
{
|
||||
if let Ok(manager) =
|
||||
&& let Ok(manager) =
|
||||
workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Rename {
|
||||
workspace: workspace_handle,
|
||||
name,
|
||||
});
|
||||
}
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Rename {
|
||||
workspace: workspace_handle,
|
||||
name,
|
||||
});
|
||||
}
|
||||
}
|
||||
zcosmic_workspace_handle_v2::Request::SetTilingState {
|
||||
|
|
@ -149,58 +146,52 @@ where
|
|||
} => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(&workspace)
|
||||
{
|
||||
if let Ok(manager) =
|
||||
&& let Ok(manager) =
|
||||
workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::SetTilingState {
|
||||
workspace: workspace_handle,
|
||||
state: tiling_state,
|
||||
});
|
||||
}
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::SetTilingState {
|
||||
workspace: workspace_handle,
|
||||
state: tiling_state,
|
||||
});
|
||||
}
|
||||
}
|
||||
zcosmic_workspace_handle_v2::Request::Pin => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(&workspace)
|
||||
{
|
||||
if let Ok(manager) =
|
||||
&& let Ok(manager) =
|
||||
workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::SetPin {
|
||||
workspace: workspace_handle,
|
||||
pinned: true,
|
||||
});
|
||||
}
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::SetPin {
|
||||
workspace: workspace_handle,
|
||||
pinned: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
zcosmic_workspace_handle_v2::Request::Unpin => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(&workspace)
|
||||
{
|
||||
if let Ok(manager) =
|
||||
&& let Ok(manager) =
|
||||
workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::SetPin {
|
||||
workspace: workspace_handle,
|
||||
pinned: false,
|
||||
});
|
||||
}
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::SetPin {
|
||||
workspace: workspace_handle,
|
||||
pinned: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
zcosmic_workspace_handle_v2::Request::MoveBefore {
|
||||
|
|
@ -209,26 +200,22 @@ where
|
|||
} => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(&workspace)
|
||||
{
|
||||
if let Some(other_workspace) = state
|
||||
&& let Some(other_workspace) = state
|
||||
.workspace_state()
|
||||
.get_ext_workspace_handle(&other_workspace)
|
||||
{
|
||||
if let Ok(manager) =
|
||||
workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::MoveBefore {
|
||||
workspace: workspace_handle,
|
||||
other_workspace,
|
||||
axis,
|
||||
});
|
||||
}
|
||||
}
|
||||
&& let Ok(manager) =
|
||||
workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::MoveBefore {
|
||||
workspace: workspace_handle,
|
||||
other_workspace,
|
||||
axis,
|
||||
});
|
||||
}
|
||||
}
|
||||
zcosmic_workspace_handle_v2::Request::MoveAfter {
|
||||
|
|
@ -237,26 +224,22 @@ where
|
|||
} => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(&workspace)
|
||||
{
|
||||
if let Some(other_workspace) = state
|
||||
&& let Some(other_workspace) = state
|
||||
.workspace_state()
|
||||
.get_ext_workspace_handle(&other_workspace)
|
||||
{
|
||||
if let Ok(manager) =
|
||||
workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::MoveAfter {
|
||||
workspace: workspace_handle,
|
||||
other_workspace,
|
||||
axis,
|
||||
});
|
||||
}
|
||||
}
|
||||
&& let Ok(manager) =
|
||||
workspace.data::<WorkspaceData>().unwrap().manager.upgrade()
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::MoveAfter {
|
||||
workspace: workspace_handle,
|
||||
other_workspace,
|
||||
axis,
|
||||
});
|
||||
}
|
||||
}
|
||||
zcosmic_workspace_handle_v2::Request::Destroy => {}
|
||||
|
|
|
|||
|
|
@ -152,18 +152,17 @@ where
|
|||
.iter()
|
||||
.find(|g| g.ext_instances.contains(obj))
|
||||
.map(|g| g.id)
|
||||
&& let Ok(manager) = data.manager.upgrade()
|
||||
{
|
||||
if let Ok(manager) = data.manager.upgrade() {
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Create {
|
||||
in_group: WorkspaceGroupHandle { id },
|
||||
name: workspace,
|
||||
});
|
||||
}
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Create {
|
||||
in_group: WorkspaceGroupHandle { id },
|
||||
name: workspace,
|
||||
});
|
||||
}
|
||||
}
|
||||
ext_workspace_group_handle_v1::Request::Destroy => {
|
||||
|
|
@ -204,68 +203,62 @@ where
|
|||
ext_workspace_handle_v1::Request::Activate => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(obj)
|
||||
&& let Ok(manager) = data.manager.upgrade()
|
||||
{
|
||||
if let Ok(manager) = data.manager.upgrade() {
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Activate(workspace_handle));
|
||||
}
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Activate(workspace_handle));
|
||||
}
|
||||
}
|
||||
ext_workspace_handle_v1::Request::Deactivate => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(obj)
|
||||
&& let Ok(manager) = data.manager.upgrade()
|
||||
{
|
||||
if let Ok(manager) = data.manager.upgrade() {
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Deactivate(workspace_handle));
|
||||
}
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Deactivate(workspace_handle));
|
||||
}
|
||||
}
|
||||
ext_workspace_handle_v1::Request::Remove => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(obj)
|
||||
&& let Ok(manager) = data.manager.upgrade()
|
||||
{
|
||||
if let Ok(manager) = data.manager.upgrade() {
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Remove(workspace_handle));
|
||||
}
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Remove(workspace_handle));
|
||||
}
|
||||
}
|
||||
ext_workspace_handle_v1::Request::Assign { workspace_group } => {
|
||||
if let Some(workspace_handle) =
|
||||
state.workspace_state().get_ext_workspace_handle(obj)
|
||||
{
|
||||
if let Some(group_id) = state
|
||||
&& let Some(group_id) = state
|
||||
.workspace_state()
|
||||
.groups
|
||||
.iter()
|
||||
.find(|g| g.ext_instances.contains(&workspace_group))
|
||||
.map(|g| g.id)
|
||||
{
|
||||
if let Ok(manager) = data.manager.upgrade() {
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Assign {
|
||||
workspace: workspace_handle,
|
||||
group: WorkspaceGroupHandle { id: group_id },
|
||||
});
|
||||
}
|
||||
}
|
||||
&& let Ok(manager) = data.manager.upgrade()
|
||||
{
|
||||
let mut state = manager
|
||||
.data::<WorkspaceManagerData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
state.requests.push(Request::Assign {
|
||||
workspace: workspace_handle,
|
||||
group: WorkspaceGroupHandle { id: group_id },
|
||||
});
|
||||
}
|
||||
}
|
||||
ext_workspace_handle_v1::Request::Destroy => {
|
||||
|
|
@ -491,10 +484,10 @@ where
|
|||
changed = true;
|
||||
}
|
||||
|
||||
if handle_state.ext_id.is_none() {
|
||||
if let Some(id) = workspace.ext_id.clone() {
|
||||
instance.id(id);
|
||||
}
|
||||
if handle_state.ext_id.is_none()
|
||||
&& let Some(id) = workspace.ext_id.clone()
|
||||
{
|
||||
instance.id(id);
|
||||
}
|
||||
|
||||
if let Some(cosmic_v2_handle) = handle_state
|
||||
|
|
|
|||
101
src/xwayland.rs
101
src/xwayland.rs
|
|
@ -85,10 +85,10 @@ fn xrdb_thread(rx: Receiver<(String, u32)>, display: u32) {
|
|||
"Xcursor.theme: {}\nXcursor.size: {}\n",
|
||||
cursor_theme, cursor_size,
|
||||
);
|
||||
if let Some(mut stdin) = child.stdin.take() {
|
||||
if let Err(err) = stdin.write_all(resources.as_bytes()) {
|
||||
warn!("Failed to update xresources: {}", err);
|
||||
}
|
||||
if let Some(mut stdin) = child.stdin.take()
|
||||
&& let Err(err) = stdin.write_all(resources.as_bytes())
|
||||
{
|
||||
warn!("Failed to update xresources: {}", err);
|
||||
}
|
||||
match child.wait() {
|
||||
Ok(code) if code.success() => {}
|
||||
|
|
@ -346,25 +346,23 @@ impl Common {
|
|||
self.xwayland_reset_eavesdropping(serial);
|
||||
|
||||
let xstate = self.xwayland_state.as_mut().unwrap();
|
||||
if let Some(mime_types) = xstate.clipboard_selection_dirty.take() {
|
||||
if let Err(err) = xstate
|
||||
if let Some(mime_types) = xstate.clipboard_selection_dirty.take()
|
||||
&& let Err(err) = xstate
|
||||
.xwm
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.new_selection(SelectionTarget::Clipboard, Some(mime_types))
|
||||
{
|
||||
warn!(?err, "Failed to set Xwayland clipboard selection.");
|
||||
}
|
||||
{
|
||||
warn!(?err, "Failed to set Xwayland clipboard selection.");
|
||||
}
|
||||
if let Some(mime_types) = xstate.primary_selection_dirty.take() {
|
||||
if let Err(err) = xstate
|
||||
if let Some(mime_types) = xstate.primary_selection_dirty.take()
|
||||
&& let Err(err) = xstate
|
||||
.xwm
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.new_selection(SelectionTarget::Primary, Some(mime_types))
|
||||
{
|
||||
warn!(?err, "Failed to set Xwayland clipboard selection.");
|
||||
}
|
||||
{
|
||||
warn!(?err, "Failed to set Xwayland clipboard selection.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -650,16 +648,15 @@ impl Common {
|
|||
}
|
||||
XwaylandDescaling::Fractional => {
|
||||
let shell = self.shell.read();
|
||||
let val =
|
||||
if let Some(output) = shell.outputs().find(|o| o.config().xwayland_primary) {
|
||||
output.current_scale().fractional_scale().max(1f64)
|
||||
} else {
|
||||
shell
|
||||
.outputs()
|
||||
.map(|o| o.current_scale().fractional_scale())
|
||||
.fold(1f64, |acc, val| acc.max(val))
|
||||
};
|
||||
val
|
||||
|
||||
if let Some(output) = shell.outputs().find(|o| o.config().xwayland_primary) {
|
||||
output.current_scale().fractional_scale().max(1f64)
|
||||
} else {
|
||||
shell
|
||||
.outputs()
|
||||
.map(|o| o.current_scale().fractional_scale())
|
||||
.fold(1f64, |acc, val| acc.max(val))
|
||||
}
|
||||
}
|
||||
};
|
||||
let (_, cursor_size) = load_cursor_env();
|
||||
|
|
@ -710,10 +707,14 @@ impl Common {
|
|||
None
|
||||
};
|
||||
|
||||
if let Err(_) = xwayland.xrdb_thread.send((
|
||||
cosmic::icon_theme::default(),
|
||||
(new_scale * cursor_size as f64).round() as u32,
|
||||
)) {
|
||||
if xwayland
|
||||
.xrdb_thread
|
||||
.send((
|
||||
cosmic::icon_theme::default(),
|
||||
(new_scale * cursor_size as f64).round() as u32,
|
||||
))
|
||||
.is_err()
|
||||
{
|
||||
warn!("xrdb thread died");
|
||||
}
|
||||
|
||||
|
|
@ -756,14 +757,13 @@ impl Common {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(xstate) = self.xwayland_state.as_mut() {
|
||||
if let Some(xwm) = xstate.xwm.as_mut() {
|
||||
if let Err(err) = xwm.set_randr_primary_output(xwayland_primary_output.as_ref()) {
|
||||
warn!("Failed to set xwayland primary output: {}", err);
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
if let Some(xstate) = self.xwayland_state.as_mut()
|
||||
&& let Some(xwm) = xstate.xwm.as_mut()
|
||||
&& let Err(err) = xwm.set_randr_primary_output(xwayland_primary_output.as_ref())
|
||||
{
|
||||
warn!("Failed to set xwayland primary output: {}", err);
|
||||
return;
|
||||
};
|
||||
|
||||
self.output_configuration_state.update();
|
||||
}
|
||||
|
|
@ -808,12 +808,7 @@ impl XwmHandler for State {
|
|||
*context,
|
||||
);
|
||||
}
|
||||
if shell
|
||||
.pending_windows
|
||||
.iter()
|
||||
.find(|w| w.surface == window)
|
||||
.is_none()
|
||||
{
|
||||
if !shell.pending_windows.iter().any(|w| w.surface == window) {
|
||||
let surface = CosmicSurface::from(window);
|
||||
shell.pending_windows.push(PendingWindow {
|
||||
surface,
|
||||
|
|
@ -835,17 +830,14 @@ impl XwmHandler for State {
|
|||
if let std::collections::hash_map::Entry::Vacant(e) = shell
|
||||
.pending_activations
|
||||
.entry(crate::shell::ActivationKey::X11(surface.window_id()))
|
||||
&& let Some(startup_id) = window.x11_surface().and_then(|x| x.startup_id())
|
||||
&& let Some(context) = self
|
||||
.common
|
||||
.xdg_activation_state
|
||||
.data_for_token(&XdgActivationToken::from(startup_id))
|
||||
.and_then(|data| data.user_data.get::<ActivationContext>())
|
||||
{
|
||||
if let Some(startup_id) = window.x11_surface().and_then(|x| x.startup_id()) {
|
||||
if let Some(context) = self
|
||||
.common
|
||||
.xdg_activation_state
|
||||
.data_for_token(&XdgActivationToken::from(startup_id))
|
||||
.and_then(|data| data.user_data.get::<ActivationContext>())
|
||||
{
|
||||
e.insert(*context);
|
||||
}
|
||||
}
|
||||
e.insert(*context);
|
||||
}
|
||||
let res = shell.map_window(
|
||||
&window,
|
||||
|
|
@ -881,11 +873,10 @@ impl XwmHandler for State {
|
|||
let seat = shell.seats.last_active().clone();
|
||||
if let Some(pending) =
|
||||
shell.unmap_surface(&window, &seat, &mut self.common.toplevel_info_state)
|
||||
&& shell
|
||||
&& !shell
|
||||
.pending_windows
|
||||
.iter()
|
||||
.find(|w| &w.surface == &pending.surface)
|
||||
.is_none()
|
||||
.any(|w| w.surface == pending.surface)
|
||||
{
|
||||
shell.pending_windows.push(pending);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue