Skip to content

Conversation

Miitto
Copy link
Contributor

@Miitto Miitto commented Aug 16, 2025

Fix to drop dragged windows onto the workspace the cursor is hovered over, rather than the workspace under the center of the window

Could also modify this to be an option in config, but using the cursor seems to be the more intuitive option.

@github-project-automation github-project-automation bot moved this to 📬 Needs triage in glazewm Aug 16, 2025
state: &mut WmState,
config: &UserConfig,
) -> anyhow::Result<()> {
moved_window.set_insertion_target(Some(InsertionTarget {
Copy link
Member

Choose a reason for hiding this comment

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

can be simplified by setting insertion target to None (will also use the workspace as target). we only set an explicit insertion target when transitioning from tiling -> floating, so that it'll go back into the same spot as previously

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parent of the window needs to be changed manually, otherwise the window will be dropped into the workspace that containing the center point of the window, rather than the cursor position. Not sure how best to do that, as calling move_container_within_tree errors since the window and the other monitors workspace have no common ancestor.

config,
)?;

Ok(())
Copy link
Member

Choose a reason for hiding this comment

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

can remove the Ok(()) by having update_window_state(...) be the return

.captures(unparsed)
.context(err_msg.to_string())?;
let captures =
units_regex.captures(unparsed).context(err_msg.clone())?;
Copy link
Member

Choose a reason for hiding this comment

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

it's a bit inconsistent but we typically use .to_string() vs string cloning to be more explicit. would be good to add a linting rule for this at some point

.and_then(|monitor| monitor.displayed_workspace())
.unwrap_or_else(|| {
warn!("No workspace at mouse position, using window workspace.");
moved_window.workspace().expect("Window has no workspace")
Copy link
Member

Choose a reason for hiding this comment

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

we don't have error logging for panics. would recommend:

    .monitor_at_point(&mouse_pos)
    .and_then(|monitor| monitor.displayed_workspace())
    .or_else(|_| moved_window.workspace())
    .context("Window has no workspace.")

@Miitto Miitto force-pushed the feat/drag-window-to-cursor branch from 6d85aa4 to adddeb6 Compare August 17, 2025 13:11
@Miitto Miitto force-pushed the feat/drag-window-to-cursor branch 2 times, most recently from 76fb418 to 6f3dadb Compare September 18, 2025 16:22
@Miitto Miitto force-pushed the feat/drag-window-to-cursor branch from 6f3dadb to ea29009 Compare September 18, 2025 16:23
vantm added a commit to vantm/glazewm that referenced this pull request Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬 Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants