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

Method motion_2d

plugins/single_plugins/wrot.cpp:114–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112 };
113
114 void motion_2d(int x, int y)
115 {
116 auto tr = wf::ensure_named_transformer<wf::scene::view_2d_transformer_t>(
117 current_view, wf::TRANSFORMER_2D, transformer_2d, current_view);
118
119 current_view->get_transformed_node()->begin_transform_update();
120 auto g = current_view->get_geometry();
121
122 double cx = g.x + g.width / 2.0;
123 double cy = g.y + g.height / 2.0;
124
125 double x1 = last_position.x - cx, y1 = last_position.y - cy;
126 double x2 = x - cx, y2 = y - cy;
127
128 if (vlen(x2, y2) <= reset_radius)
129 {
130 current_view->get_transformed_node()->end_transform_update();
131 current_view->get_transformed_node()->rem_transformer(transformer_2d);
132 return;
133 }
134
135 /* cross(a, b) = |a| * |b| * sin(a, b) */
136 tr->angle -= std::asin(cross(x1, y1, x2, y2) / vlen(x1, y1) / vlen(x2,
137 y2));
138
139 current_view->get_transformed_node()->end_transform_update();
140 last_position = {1.0 * x, 1.0 * y};
141 }
142
143 void motion_3d(int x, int y)
144 {

Callers

nothing calls this directly

Calls 6

vlenFunction · 0.85
crossFunction · 0.85
end_transform_updateMethod · 0.80
rem_transformerMethod · 0.80
get_geometryMethod · 0.45

Tested by

no test coverage detected