1
1
Fork 0
mirror of https://github.com/swaywm/sway synced 2024-05-09 15:56:14 +02:00

Compare commits

...

5 Commits

Author SHA1 Message Date
dmorilha 6a34d13217
Merge a90a2902cf into 646019cad9 2024-04-27 09:39:36 +02:00
Kenny Levinsen 646019cad9 desktop/output: Fix check if config should be stored
We want to check if a config_head existed for the current
matched_output_config, so we should check cfg->output. sway_output is a
temporary variable from a previous wl_list_for_each, and does not
contain anything useful to us.

Fixes: https://github.com/swaywm/sway/issues/8128
2024-04-23 13:31:30 +02:00
Kenny Levinsen ffcde7a70c server: Use wlr_renderer_get_texture_formats
wlr_renderer_get_{dmabuf|shm}_texture_formats have been replaced by a
unified wlr_renderer_get_texture_formats interface using buffer caps.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4644
2024-04-21 17:19:33 +02:00
dmorilha a90a2902cf
Update sway.5.scd 2024-03-19 09:03:24 -05:00
dmorilha de69105576
add optional next to move command for cursor | mouse | pointer
Currently moving a window to the cursor position centers it. This change creates an optional "next" argument that moves the top upper corner of the window to the pointer's position. Useful for floating popups.
2024-03-19 08:59:32 -05:00
4 changed files with 29 additions and 15 deletions

View File

@ -775,16 +775,20 @@ static struct cmd_results *cmd_move_in_direction(
}
static struct cmd_results *cmd_move_to_position_pointer(
struct sway_container *container) {
struct sway_container *container, bool next) {
struct sway_seat *seat = config->handler_context.seat;
if (!seat->cursor) {
return cmd_results_new(CMD_FAILURE, "No cursor device");
}
struct wlr_cursor *cursor = seat->cursor->cursor;
/* Determine where to put the window. */
double lx = cursor->x - container->pending.width / 2;
double ly = cursor->y - container->pending.height / 2;
double lx = cursor->x;
double ly = cursor->y;
if (!next) {
lx -= container->pending.width / 2;
ly -= container->pending.height / 2;
}
/* Correct target coordinates to be in bounds (on screen). */
struct wlr_output *output = wlr_output_layout_output_at(
root->output_layout, cursor->x, cursor->y);
@ -809,7 +813,7 @@ static struct cmd_results *cmd_move_to_position_pointer(
static const char expected_position_syntax[] =
"Expected 'move [absolute] position <x> [px] <y> [px]' or "
"'move [absolute] position center' or "
"'move position cursor|mouse|pointer'";
"'move position [next] cursor|mouse|pointer'";
static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
struct sway_container *container = config->handler_context.container;
@ -838,13 +842,23 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
if (!argc) {
return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
}
bool next = false;
if (strcmp(argv[0], "next") == 0) {
next = true;
--argc;
++argv;
}
if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 ||
strcmp(argv[0], "pointer") == 0) {
if (absolute) {
return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
}
return cmd_move_to_position_pointer(container);
} else if (strcmp(argv[0], "center") == 0) {
return cmd_move_to_position_pointer(container, next);
} else if (next) {
return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
}
if (strcmp(argv[0], "center") == 0) {
double lx, ly;
if (absolute) {
lx = root->x + (root->width - container->pending.width) / 2;

View File

@ -619,7 +619,7 @@ static void output_manager_apply(struct sway_server *server,
if (!test_only && ok) {
struct wlr_output_configuration_head_v1 *config_head;
wl_list_for_each(config_head, &config->heads, link) {
if (config_head->state.output == sway_output->wlr_output) {
if (config_head->state.output == cfg->output->wlr_output) {
store_config = true;
break;
}

View File

@ -240,13 +240,12 @@ bool server_init(struct sway_server *server) {
wlr_renderer_init_wl_shm(server->renderer, server->wl_display);
if (wlr_renderer_get_dmabuf_texture_formats(server->renderer) != NULL) {
if (wlr_renderer_get_texture_formats(server->renderer, WLR_BUFFER_CAP_DMABUF) != NULL) {
server->linux_dmabuf_v1 = wlr_linux_dmabuf_v1_create_with_renderer(
server->wl_display, 4, server->renderer);
}
if (wlr_renderer_get_dmabuf_texture_formats(server->renderer) != NULL &&
debug.legacy_wl_drm) {
wlr_drm_create(server->wl_display, server->renderer);
if (debug.legacy_wl_drm) {
wlr_drm_create(server->wl_display, server->renderer);
}
}
server->allocator = wlr_allocator_autocreate(server->backend,

View File

@ -230,8 +230,9 @@ set|plus|minus|toggle <amount>
Moves the focused container to be centered on the workspace. If _absolute_
is used, it is moved to the center of all outputs.
*move* position cursor|mouse|pointer
Moves the focused container to be centered on the cursor.
*move* position [next] cursor|mouse|pointer
Moves the focused container to be centered on the cursor. If _next_ is
used, it moves the left upper corner to the cursor's position.
*move* [container|window] [to] mark <mark>
Moves the focused container to the specified mark.