Take window geometry into account for IME unconstraining
Browse files at this commitd0cd58ec5ac6b2d41d42478fb4f3cc7c0c687db9Parent: 39dc2191 changed file +14 -3
- src/handlers/xdg_shell.rs +14 -3
src/handlers/xdg_shell.rsmodified+14 -3
| @@ -19,7 +19,7 @@ use smithay::reexports::wayland_server::protocol::wl_output; | ||
| 19 | 19 | use smithay::reexports::wayland_server::protocol::wl_seat::WlSeat; |
| 20 | 20 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; |
| 21 | 21 | use smithay::reexports::wayland_server::{self, Resource, WEnum}; |
| 22 | -use smithay::utils::{Logical, Rectangle, Serial}; | |
| 22 | +use smithay::utils::{Logical, Point, Rectangle, Serial}; | |
| 23 | 23 | use smithay::wayland::compositor::{ |
| 24 | 24 | add_blocker, add_pre_commit_hook, with_states, BufferAssignment, CompositorHandler as _, |
| 25 | 25 | HookId, SurfaceAttributes, |
| @@ -1311,8 +1311,10 @@ impl State { | ||
| 1311 | 1311 | let mut target = self.niri.layout.popup_target_rect(window, ime); |
| 1312 | 1312 | target.loc -= get_popup_toplevel_coords(popup).to_f64(); |
| 1313 | 1313 | |
| 1314 | + let geo_off = window.geometry().loc.to_f64(); | |
| 1315 | + | |
| 1314 | 1316 | // Don't add padding for IME popups; better to give them more space. |
| 1315 | - self.position_popup_within_rect(popup, target, !ime); | |
| 1317 | + self.position_popup_within_rect(popup, geo_off, target, !ime); | |
| 1316 | 1318 | } |
| 1317 | 1319 | |
| 1318 | 1320 | pub fn unconstrain_layer_shell_popup( |
| @@ -1346,13 +1348,17 @@ impl State { | ||
| 1346 | 1348 | target.loc -= layer_geo.loc; |
| 1347 | 1349 | target.loc -= get_popup_toplevel_coords(popup); |
| 1348 | 1350 | |
| 1351 | + // Layer surfaces don't have geometry. | |
| 1352 | + let geo_off = Point::new(0., 0.); | |
| 1353 | + | |
| 1349 | 1354 | // Don't add padding to layer-shell popups. It's not really needed, and it's unexpected. |
| 1350 | - self.position_popup_within_rect(popup, target.to_f64(), false); | |
| 1355 | + self.position_popup_within_rect(popup, geo_off, target.to_f64(), false); | |
| 1351 | 1356 | } |
| 1352 | 1357 | |
| 1353 | 1358 | fn position_popup_within_rect( |
| 1354 | 1359 | &self, |
| 1355 | 1360 | popup: &PopupKind, |
| 1361 | + geo_off: Point<f64, Logical>, | |
| 1356 | 1362 | target: Rectangle<f64, Logical>, |
| 1357 | 1363 | padding: bool, |
| 1358 | 1364 | ) { |
| @@ -1369,6 +1375,11 @@ impl State { | ||
| 1369 | 1375 | }); |
| 1370 | 1376 | } |
| 1371 | 1377 | PopupKind::InputMethod(popup) => { |
| 1378 | + // IME popups are positioned in surface-local coordinates, but target is in | |
| 1379 | + // geometry-relative coordinates. | |
| 1380 | + let mut target = target; | |
| 1381 | + target.loc += geo_off; | |
| 1382 | + | |
| 1372 | 1383 | let text_input_rectangle = popup.text_input_rectangle(); |
| 1373 | 1384 | let mut bbox = |
| 1374 | 1385 | utils::bbox_from_surface_tree(popup.wl_surface(), text_input_rectangle.loc) |