| 352 | } |
| 353 | |
| 354 | class vswitch : public wf::per_output_plugin_instance_t |
| 355 | { |
| 356 | private: |
| 357 | |
| 358 | /** |
| 359 | * Adapter around the general algorithm, so that our own stop function is |
| 360 | * called. |
| 361 | */ |
| 362 | class vswitch_basic_plugin : public wf::vswitch::workspace_switch_t |
| 363 | { |
| 364 | public: |
| 365 | vswitch_basic_plugin(wf::output_t *output, |
| 366 | std::function<void()> on_done) : workspace_switch_t(output) |
| 367 | { |
| 368 | this->on_done = on_done; |
| 369 | } |
| 370 | |
| 371 | void stop_switch(bool normal_exit) override |
| 372 | { |
| 373 | workspace_switch_t::stop_switch(normal_exit); |
| 374 | on_done(); |
| 375 | } |
| 376 | |
| 377 | private: |
| 378 | std::function<void()> on_done; |
| 379 | }; |
| 380 | |
| 381 | std::unique_ptr<vswitch_basic_plugin> algorithm; |
| 382 | std::unique_ptr<wf::vswitch::control_bindings_t> bindings; |
| 383 | |
| 384 | // Capabilities which are always required for vswitch, for now wall needs |
| 385 | // a custom renderer. |
| 386 | static constexpr uint32_t base_caps = wf::CAPABILITY_CUSTOM_RENDERER; |
| 387 | |
| 388 | wf::plugin_activation_data_t grab_interface = { |
| 389 | .name = "vswitch", |
| 390 | .cancel = [=] () { algorithm->stop_switch(false); }, |
| 391 | }; |
| 392 | |
| 393 | public: |
| 394 | void init() |
| 395 | { |
| 396 | output->connect(&on_set_workspace_request); |
| 397 | output->connect(&on_grabbed_view_disappear); |
| 398 | |
| 399 | algorithm = std::make_unique<vswitch_basic_plugin>(output, |
| 400 | [=] () { output->deactivate_plugin(&grab_interface); }); |
| 401 | |
| 402 | bindings = std::make_unique<wf::vswitch::control_bindings_t>(output); |
| 403 | bindings->setup([this] (wf::point_t delta, wayfire_toplevel_view view, bool only_view) |
| 404 | { |
| 405 | // Do not switch workspace with sticky view, they are on all |
| 406 | // workspaces anyway |
| 407 | if (view && view->sticky) |
| 408 | { |
| 409 | view = nullptr; |
| 410 | } |
| 411 |
nothing calls this directly
no test coverage detected