Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/shell/focus/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ fn render_input_order_internal<R: 'static>(
let overview_is_open = workspace_overview_is_open(output);
let has_focused_fullscreen = if is_active_workspace {
let current_focus = seat.get_keyboard().unwrap().current_focus();
matches!(current_focus, Some(KeyboardFocusTarget::Fullscreen(_)))
|| (current_focus.is_none()
&& focus_stack_is_valid_fullscreen
&& !workspace_overview_is_open(output))
current_focus.as_ref().is_some_and(|target| match target {
KeyboardFocusTarget::Fullscreen(s) => Some(s) == fullscreen.map(|f| &f.surface),
KeyboardFocusTarget::Element(m) => fullscreen
.is_some_and(|f| m.windows().any(|(s, _)| s == &f.surface)),
_ => false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird. I'd assume those windows are override-redirect windows otherwise they really shouldn't be Elements but fullscreen.

}) || (current_focus.is_none()
&& focus_stack_is_valid_fullscreen
&& !workspace_overview_is_open(output))
} else {
focus_stack_is_valid_fullscreen && !overview_is_open
};
Expand Down
70 changes: 61 additions & 9 deletions src/shell/layout/floating/grabs/resize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
};
use smithay::{
backend::input::ButtonState,
desktop::{WindowSurface, space::SpaceElement},
desktop::{WindowSurface, layer_map_for_output, space::SpaceElement},
input::{
Seat,
pointer::{
Expand Down Expand Up @@ -100,21 +100,48 @@ impl ResizeSurfaceGrab {

// If the resizing vertical edge is close to our output's edge in the same direction, snap to it.
let output_geom = self.output.geometry().to_local(&self.output);
let layers = layer_map_for_output(&self.output);
let work_area = layers.non_exclusive_zone();

if self.edges.intersects(ResizeEdge::LEFT) {
let initial_x = self.initial_window_location.x;
let final_x = initial_x - dx as i32;

// Clamp to work area
if final_x < work_area.loc.x {
let diff = work_area.loc.x - final_x;
new_window_width -= diff;
location_diff.x += diff as f64;
// Fix dx for future calculations if any (unlikely needed here but consistency)
// dx = dx - diff as f64;
}

if (self.initial_window_location.x - dx as i32 - output_geom.loc.x).unsigned_abs()
< self.edge_snap_threshold
{
new_window_width = self.initial_window_size.w - output_geom.loc.x
+ self.initial_window_location.x;
}
} else if (self.initial_window_location.x + self.initial_window_size.w + dx as i32
} else {
let initial_x = self.initial_window_location.x;
let current_width = self.initial_window_size.w;
let final_right = initial_x + current_width + dx as i32;

// Clamp right edge
if final_right > work_area.loc.x + work_area.size.w {
let diff = final_right - (work_area.loc.x + work_area.size.w);
new_window_width -= diff;
}

if (self.initial_window_location.x + self.initial_window_size.w + dx as i32
- output_geom.loc.x
- output_geom.size.w)
.unsigned_abs()
< self.edge_snap_threshold
{
new_window_width =
output_geom.loc.x - self.initial_window_location.x + output_geom.size.w;
{
new_window_width =
output_geom.loc.x - self.initial_window_location.x + output_geom.size.w;
}
}
}

Expand All @@ -128,21 +155,46 @@ impl ResizeSurfaceGrab {

// If the resizing horizontal edge is close to our output's edge in the same direction, snap to it.
let output_geom = self.output.geometry().to_local(&self.output);
let layers = layer_map_for_output(&self.output);
let work_area = layers.non_exclusive_zone();

if self.edges.intersects(ResizeEdge::TOP) {
let initial_y = self.initial_window_location.y;
let final_y = initial_y - dy as i32;

// Clamp to work area
if final_y < work_area.loc.y {
let diff = work_area.loc.y - final_y;
new_window_height -= diff;
location_diff.y += diff as f64;
}

if (self.initial_window_location.y - dy as i32 - output_geom.loc.y).unsigned_abs()
< self.edge_snap_threshold
{
new_window_height = self.initial_window_size.h - output_geom.loc.y
+ self.initial_window_location.y;
}
} else if (self.initial_window_location.y + self.initial_window_size.h + dy as i32
} else {
let initial_y = self.initial_window_location.y;
let current_height = self.initial_window_size.h;
let final_bottom = initial_y + current_height + dy as i32;

// Clamp bottom edge
if final_bottom > work_area.loc.y + work_area.size.h {
let diff = final_bottom - (work_area.loc.y + work_area.size.h);
new_window_height -= diff;
}

if (self.initial_window_location.y + self.initial_window_size.h + dy as i32
- output_geom.loc.y
- output_geom.size.h)
.unsigned_abs()
< self.edge_snap_threshold
{
new_window_height =
output_geom.loc.y - self.initial_window_location.y + output_geom.size.h;
{
new_window_height =
output_geom.loc.y - self.initial_window_location.y + output_geom.size.h;
}
}
}

Expand Down
35 changes: 35 additions & 0 deletions src/xwayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,41 @@ impl State {
if let Some(mut xwayland_state) = data.common.xwayland_state.take() {
xwayland_state.xwm = None;
}

// Scan for X11 windows in the shell and remove them
let mut shell = data.common.shell.write();
let seat = shell.seats.last_active().clone();

// 1. Remove mapped windows
let to_remove: Vec<_> = shell
.mapped()
.filter_map(|w| {
let surface = w.active_window();
surface.x11_surface().map(|_| surface)
})
.collect();

for window in to_remove {
shell.unmap_surface(
&window,
&seat,
&mut data.common.toplevel_info_state,
);
}

// 2. Clear pending windows
shell
.pending_windows
.retain(|p| p.surface.x11_surface().is_none());

// 3. Clear override redirect windows
shell.override_redirect_windows.clear();

// 4. Clear pending activations
shell
.pending_activations
.retain(|k, _| !matches!(k, crate::shell::ActivationKey::X11(_)));

data.notify_ready();
}
}) {
Expand Down