Skip to content
Extraits de code Groupes Projets
Vérifiée Valider ca88f04a rédigé par salixor's avatar salixor
Parcourir les fichiers

Constrain windows to the output they are in

parent 538a6017
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -30,8 +30,21 @@ impl PointerGrab<Smallvil> for MoveSurfaceGrab {
let delta = event.location - self.start_data.location;
let new_location = self.initial_window_location.to_f64() + delta;
let wsize = data.space.element_geometry(&self.window).unwrap().size;
let window_outputs = data.space.outputs_for_element(&self.window);
let output = window_outputs
.first()
.or_else(|| data.space.outputs().next())
.expect("No outputs?");
let output_size = output.current_mode().unwrap().size;
let x = (new_location.x as i32).max(0).min(output_size.w - wsize.w);
let y = (new_location.y as i32).max(0).min(output_size.h - wsize.h);
data.space
.map_element(self.window.clone(), new_location.to_i32_round(), true);
.map_element(self.window.clone(), Point::from((x, y)), true);
}
fn relative_motion(
......
......@@ -104,11 +104,10 @@ impl XdgShellHandler for Smallvil {
let ratio =
(pointer_pos.x - win_geometry.loc.x as f64) / (win_geometry.size.w as f64);
initial_window_location = (
initial_window_location = Point::from((
(pointer_pos.x - ratio * target_size.w as f64) as i32,
(pointer_pos.y as i32),
)
.into();
));
}
let grab = MoveSurfaceGrab {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter