MCPcopy Create free account
hub / github.com/WayfireWM/wayfire / wf_vswitch_global_plugin_t

Class wf_vswitch_global_plugin_t

plugins/vswitch/vswitch.cpp:568–670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566};
567
568class wf_vswitch_global_plugin_t : public wf::per_output_plugin_t<vswitch>
569{
570 wf::shared_data::ref_ptr_t<wf::ipc::method_repository_t> ipc_repo;
571
572 public:
573 void init() override
574 {
575 per_output_plugin_t::init();
576 ipc_repo->register_method("vswitch/set-workspace", request_workspace);
577 ipc_repo->register_method("vswitch/send-view", send_view);
578 }
579
580 void fini() override
581 {
582 per_output_plugin_t::fini();
583 ipc_repo->unregister_method("vswitch/set-workspace");
584 ipc_repo->unregister_method("vswitch/send-view");
585 }
586
587 wf::ipc::method_callback request_workspace = [=] (const wf::json_t& data)
588 {
589 uint64_t x = wf::ipc::json_get_uint64(data, "x");
590 uint64_t y = wf::ipc::json_get_uint64(data, "y");
591 uint64_t output_id = wf::ipc::json_get_uint64(data, "output-id");
592 std::optional<uint64_t> view_id = wf::ipc::json_get_optional_uint64(data, "view-id");
593
594 auto wo = wf::ipc::find_output_by_id(output_id);
595 if (!wo)
596 {
597 return wf::ipc::json_error("Invalid output!");
598 }
599
600 auto grid_size = wo->wset()->get_workspace_grid_size();
601 if ((int(data["x"]) >= grid_size.width) || (int(data["y"]) >= grid_size.height))
602 {
603 return wf::ipc::json_error("Workspace coordinates are too big!");
604 }
605
606 wayfire_toplevel_view switch_with_view;
607 if (view_id.has_value())
608 {
609 auto view = toplevel_cast(wf::ipc::find_view_by_id(view_id.value()));
610 if (!view)
611 {
612 return wf::ipc::json_error("Invalid view or view not toplevel!");
613 }
614
615 if (!view->is_mapped())
616 {
617 return wf::ipc::json_error("Cannot grab unmapped view!");
618 }
619
620 if (view->get_output() != wo)
621 {
622 return wf::ipc::json_error("Cannot grab view on a different output!");
623 }
624
625 switch_with_view = view;

Callers

nothing calls this directly

Calls 14

find_output_by_idFunction · 0.85
json_errorFunction · 0.85
toplevel_castFunction · 0.85
find_view_by_idFunction · 0.85
json_okFunction · 0.85
move_viewFunction · 0.85
wsetMethod · 0.80
set_capabilitiesMethod · 0.80
add_directionMethod · 0.80
get_wsetMethod · 0.80
is_mappedMethod · 0.45

Tested by

no test coverage detected