Skip to content

seat: select drag-and-drop action from keyboard modifiers#3037

Open
coffeejunk wants to merge 1 commit into
WayfireWM:masterfrom
CaligraLtd:dnd-modifier-actions
Open

seat: select drag-and-drop action from keyboard modifiers#3037
coffeejunk wants to merge 1 commit into
WayfireWM:masterfrom
CaligraLtd:dnd-modifier-actions

Conversation

@coffeejunk
Copy link
Copy Markdown
Contributor

The drag_handle_keyboard_modifiers implementation in wlroots is empty, so ctrl/shift have no effect on a drag.

static void drag_handle_keyboard_modifiers(struct wlr_seat_keyboard_grab *grab,
		const struct wlr_keyboard_modifiers *modifiers) {
	//struct wlr_keyboard *keyboard = grab->seat->keyboard_state.keyboard;
	// TODO change the dnd action based on what modifier is pressed on the
	// keyboard
}

Separately, it was stated that this should be implemented by the compositor swaywm/sway#8219 (comment)

Map the modifiers to wlr_data_source::compositor_action on each modifier's event while a drag is active: ctrl copies, shift moves, ctrl+shift asks.

As an example, Thunar:

Without the patch, dragging a file between two windows while pressing CTRL moves it:

no-dnd-modifier.mp4

With the patch applied, dragging a file between two windows while pressing CTRL copies it:

dnd-modifier.mp4

@coffeejunk coffeejunk force-pushed the dnd-modifier-actions branch from e908c66 to f042090 Compare June 3, 2026 17:06
Comment thread src/core/seat/seat-impl.hpp Outdated
std::unique_ptr<wf::drag_icon_t> drag_icon;
// Is dragging active. Note we can have a drag without a drag icon.
bool drag_active = false;
// The active drag, valid while drag_active. Its source may be NULL.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we store the active_drag object, then we don't need drag_active at all. The latter should be removed, and all the places that use it can simply compare the active drag against a null pointer (or, if you prefer, you could add a helper function is_drag_active() which does the check). Otherwise lgtm.

The `drag_handle_keyboard_modifiers` implementation in [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots/-/raw/master/types/data_device/wlr_drag.c) is empty, so `ctrl`/`shift` have no effect on a drag.

```c
static void drag_handle_keyboard_modifiers(struct wlr_seat_keyboard_grab *grab,
		const struct wlr_keyboard_modifiers *modifiers) {
	//struct wlr_keyboard *keyboard = grab->seat->keyboard_state.keyboard;
	// TODO change the dnd action based on what modifier is pressed on the
	// keyboard
}
```

Separately, it was stated that this should be implemented by the compositor swaywm/sway#8219 (comment)

Map the modifiers to `wlr_data_source::compositor_action` on each modifier's event while a drag is active: `ctrl` copies, `shift` moves, `ctrl+shift` asks.
@coffeejunk coffeejunk force-pushed the dnd-modifier-actions branch from f042090 to 05c2956 Compare June 7, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants