Skip to content

Commit

Permalink
move: Check if grid is enabled before activating edges on drag
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 committed Jul 24, 2024
1 parent 44e1fa9 commit 96091e5
Show file tree
Hide file tree
Showing 3 changed files with 31 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
12 changes: 11 additions & 1 deletion plugins/single_plugins/move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,19 @@ 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 */
LOGI("Comparing: ", new_slot_id, " == ", wf::grid::slot_t::SLOT_CENTER);
if (new_slot_id)
{
wf::geometry_t slot_geometry = wf::grid::get_slot_dimensions(output, new_slot_id);
Expand Down

0 comments on commit 96091e5

Please sign in to comment.