Skip to content

Commit

Permalink
move: Check if grid is enabled before activating edges on drag (#2404)
Browse files Browse the repository at this point in the history
Before, dragging to an edge with move enabled and grid disabled would
result in the indicator being drawn for the slot but always maximized.
Fix this by emitting a signal that grid or another plugin can tell move
the request is handled, so move can try gridding. In this implementation,
we just hard code top to maximize if grid is disabled.

Fixes #2403.
  • Loading branch information
soreau authored Jul 27, 2024
1 parent cb2fc81 commit 2b30aca
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions plugins/grid/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,16 @@ class wayfire_grid : public wf::plugin_interface_t, public wf::per_output_tracke
return false;
});
}

wf::get_core().connect(&grid_request_signal_cb);
}

wf::signal::connection_t<wf::grid::grid_request_signal> grid_request_signal_cb =
[=] (wf::grid::grid_request_signal *ev)
{
ev->carried_out = true;
};

void handle_new_output(wf::output_t *output) override
{
output->connect(&on_workarea_changed);
Expand Down
12 changes: 12 additions & 0 deletions plugins/grid/wayfire/plugins/grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ namespace wf
{
namespace grid
{
/**
* name: request
* on: core
* when: Emitted before move renders a grid indicator and sets the slot.
* carried_out: true if a plugin can handle move request to grid.
*/
struct grid_request_signal
{
/* True if a plugin handled this signal */
bool carried_out = false;
};

/**
* The slot where a view can be placed with grid.
* BL = bottom-left, TR = top-right, etc.
Expand Down
11 changes: 10 additions & 1 deletion plugins/single_plugins/move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,16 @@ class wayfire_move : public wf::per_output_plugin_instance_t,
slot.preview = nullptr;
}

slot.slot_id = new_slot_id;
wf::grid::grid_request_signal grid_signal;
wf::get_core().emit(&grid_signal);

if (grid_signal.carried_out || (new_slot_id == wf::grid::slot_t::SLOT_CENTER))
{
slot.slot_id = new_slot_id;
} else
{
slot.slot_id = new_slot_id = wf::grid::slot_t::SLOT_NONE;
}

/* Show a preview overlay */
if (new_slot_id)
Expand Down

0 comments on commit 2b30aca

Please sign in to comment.