decorations (including those for which the server-side titlebar has been
hidden) are not eligible for shading.
+*<action name="WarpCursor" to="output" x="center" y="center" />*
+ Warp the cursor to a position relative to the active output or window.
+
+ *to* [output|window] Specifies the target area of the warp.
+ Default is "output"
+ *x* [center|value] Specifies the horizontal warp position within the target area.
+ "center": Moves the cursor to the horizontal center of the target area.
+ Positive or negative integers warp the cursor to a position offset by the specified
+ number of pixels from the left or right edge of the target area respectively.
+ Default is "center"
+ *y* [center|value] Equivalent for the vertical warp position within the target area.
+ Default is "center"
+
*<action name="EnableTabletMouseEmulation" />*++
*<action name="DisableTabletMouseEmulation" />*++
*<action name="ToggleTabletMouseEmulation">*
ACTION_TYPE_TOGGLE_TABLET_MOUSE_EMULATION,
ACTION_TYPE_TOGGLE_MAGNIFY,
ACTION_TYPE_ZOOM_IN,
- ACTION_TYPE_ZOOM_OUT
+ ACTION_TYPE_ZOOM_OUT,
+ ACTION_TYPE_WARP_CURSOR,
};
const char *action_names[] = {
"ToggleMagnify",
"ZoomIn",
"ZoomOut",
+ "WarpCursor",
NULL
};
goto cleanup;
}
break;
+ case ACTION_TYPE_WARP_CURSOR:
+ if (!strcmp(argument, "to") || !strcmp(argument, "x") || !strcmp(argument, "y")) {
+ action_arg_add_str(action, argument, content);
+ goto cleanup;
+ }
+ break;
}
wlr_log(WLR_ERROR, "Invalid argument for action %s: '%s'",
return target;
}
+static void
+warp_cursor(struct view *view, struct output *output, const char *to, const char *x, const char *y)
+{
+ struct wlr_box target_area = {0};
+ int goto_x;
+ int goto_y;
+
+ if (!strcasecmp(to, "output") && output) {
+ target_area = output_usable_area_in_layout_coords(output);
+ } else if (!strcasecmp(to, "window") && view) {
+ target_area = view->current;
+ } else {
+ wlr_log(WLR_ERROR, "Invalid argument for action WarpCursor: 'to' (%s)", to);
+ }
+
+ if (!strcasecmp(x, "center")) {
+ goto_x = target_area.x + target_area.width / 2;
+ } else {
+ int offset_x = atoi(x);
+ goto_x = offset_x >= 0 ?
+ target_area.x + offset_x :
+ target_area.x + target_area.width + offset_x;
+ }
+
+ if (!strcasecmp(y, "center")) {
+ goto_y = target_area.y + target_area.height / 2;
+ } else {
+ int offset_y = atoi(y);
+ goto_y = offset_y >= 0 ?
+ target_area.y + offset_y :
+ target_area.y + target_area.height + offset_y;
+ }
+
+ wlr_cursor_warp(output->server->seat.cursor, NULL, goto_x, goto_y);
+ cursor_update_focus(output->server);
+}
+
void
actions_run(struct view *activator, struct server *server,
struct wl_list *actions, struct cursor_context *cursor_ctx)
case ACTION_TYPE_ZOOM_OUT:
magnify_set_scale(server, MAGNIFY_DECREASE);
break;
+ case ACTION_TYPE_WARP_CURSOR:
+ {
+ const char *to = action_get_str(action, "to", "output");
+ const char *x = action_get_str(action, "x", "center");
+ const char *y = action_get_str(action, "y", "center");
+ struct output *output = output_nearest_to_cursor(server);
+
+ warp_cursor(view, output, to, x, y);
+ }
+ break;
case ACTION_TYPE_INVALID:
wlr_log(WLR_ERROR, "Not executing unknown action");
break;