diff --git a/src/grabs/move_grab.rs b/src/grabs/move_grab.rs
index f599870ca15c2b0ee2f647ea5b2c751026d67708..ecd936362585f32a2f6bca611135d902de284628 100644
--- a/src/grabs/move_grab.rs
+++ b/src/grabs/move_grab.rs
@@ -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(
diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs
index f40e93ef6366a77d24e72078f7b409241747e73a..8920083dc485dfebae5a7b3503c65c47d9edce6e 100644
--- a/src/handlers/xdg_shell.rs
+++ b/src/handlers/xdg_shell.rs
@@ -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 {