mirror of
https://github.com/swaywm/sway.git
synced 2025-11-08 13:29:50 -05:00
Move view marks properties to container struct
Like border properties, this will be needed to implement layout saving and restoring.
This commit is contained in:
parent
480b03b734
commit
9fc736f4e1
16 changed files with 236 additions and 261 deletions
|
|
@ -5,9 +5,7 @@
|
|||
#include "sway/tree/container.h"
|
||||
|
||||
static void rebuild_textures_iterator(struct sway_container *con, void *data) {
|
||||
if (con->view) {
|
||||
view_update_marks_textures(con->view);
|
||||
}
|
||||
container_update_marks_textures(con);
|
||||
container_update_title_textures(con);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,10 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
|
|||
return error;
|
||||
}
|
||||
struct sway_container *container = config->handler_context.container;
|
||||
if (!container || !container->view) {
|
||||
if (!container) {
|
||||
return cmd_results_new(CMD_INVALID, "mark",
|
||||
"Only views can have marks");
|
||||
"Only containers can have marks");
|
||||
}
|
||||
struct sway_view *view = container->view;
|
||||
|
||||
bool add = false, toggle = false;
|
||||
while (argc > 0 && strncmp(*argv, "--", 2) == 0) {
|
||||
|
|
@ -47,22 +46,24 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
|
|||
}
|
||||
|
||||
char *mark = join_args(argv, argc);
|
||||
bool had_mark = view_has_mark(view, mark);
|
||||
bool had_mark = container_has_mark(container, mark);
|
||||
|
||||
if (!add) {
|
||||
// Replacing
|
||||
view_clear_marks(view);
|
||||
container_clear_marks(container);
|
||||
}
|
||||
|
||||
view_find_and_unmark(mark);
|
||||
container_find_and_unmark(mark);
|
||||
|
||||
if (!toggle || !had_mark) {
|
||||
view_add_mark(view, mark);
|
||||
container_add_mark(container, mark);
|
||||
}
|
||||
|
||||
free(mark);
|
||||
view_update_marks_textures(view);
|
||||
view_execute_criteria(view);
|
||||
container_update_marks_textures(container);
|
||||
if (container->view) {
|
||||
view_execute_criteria(container->view);
|
||||
}
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -488,12 +488,12 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
|
|||
}
|
||||
destination = seat_get_focus_inactive(seat, &new_output->node);
|
||||
} else if (strcasecmp(argv[1], "mark") == 0) {
|
||||
struct sway_view *dest_view = view_find_mark(argv[2]);
|
||||
if (dest_view == NULL) {
|
||||
struct sway_container *dest_con = container_find_mark(argv[2]);
|
||||
if (dest_con == NULL) {
|
||||
return cmd_results_new(CMD_FAILURE, "move",
|
||||
"Mark '%s' not found", argv[2]);
|
||||
}
|
||||
destination = &dest_view->container->node;
|
||||
destination = &dest_con->node;
|
||||
} else {
|
||||
return cmd_results_new(CMD_INVALID, "move", expected_syntax);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,7 @@
|
|||
#include "log.h"
|
||||
|
||||
static void rebuild_textures_iterator(struct sway_container *con, void *data) {
|
||||
if (con->view) {
|
||||
view_update_marks_textures(con->view);
|
||||
}
|
||||
container_update_marks_textures(con);
|
||||
container_update_title_textures(con);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@
|
|||
#include "util.h"
|
||||
|
||||
static void rebuild_marks_iterator(struct sway_container *con, void *data) {
|
||||
if (con->view) {
|
||||
view_update_marks_textures(con->view);
|
||||
}
|
||||
container_update_marks_textures(con);
|
||||
}
|
||||
|
||||
struct cmd_results *cmd_show_marks(int argc, char **argv) {
|
||||
|
|
|
|||
|
|
@ -159,8 +159,8 @@ static bool test_id(struct sway_container *container, void *id) {
|
|||
}
|
||||
|
||||
static bool test_mark(struct sway_container *container, void *mark) {
|
||||
if (container->view && container->view->marks->length) {
|
||||
return !list_seq_find(container->view->marks,
|
||||
if (container->marks->length) {
|
||||
return !list_seq_find(container->marks,
|
||||
(int (*)(const void *, const void *))strcmp, mark);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -9,10 +9,8 @@
|
|||
#include "stringop.h"
|
||||
|
||||
static void remove_all_marks_iterator(struct sway_container *con, void *data) {
|
||||
if (con->view) {
|
||||
view_clear_marks(con->view);
|
||||
view_update_marks_textures(con->view);
|
||||
}
|
||||
container_clear_marks(con);
|
||||
container_update_marks_textures(con);
|
||||
}
|
||||
|
||||
// unmark Remove all marks from all views
|
||||
|
|
@ -21,15 +19,10 @@ static void remove_all_marks_iterator(struct sway_container *con, void *data) {
|
|||
// [criteria] unmark foo Remove single mark from matched view
|
||||
|
||||
struct cmd_results *cmd_unmark(int argc, char **argv) {
|
||||
// Determine the view
|
||||
struct sway_view *view = NULL;
|
||||
// Determine the container
|
||||
struct sway_container *con = NULL;
|
||||
if (config->handler_context.using_criteria) {
|
||||
struct sway_container *container = config->handler_context.container;
|
||||
if (!container || !container->view) {
|
||||
return cmd_results_new(CMD_INVALID, "unmark",
|
||||
"Only views can have marks");
|
||||
}
|
||||
view = container->view;
|
||||
con = config->handler_context.container;
|
||||
}
|
||||
|
||||
// Determine the mark
|
||||
|
|
@ -38,20 +31,20 @@ struct cmd_results *cmd_unmark(int argc, char **argv) {
|
|||
mark = join_args(argv, argc);
|
||||
}
|
||||
|
||||
if (view && mark) {
|
||||
// Remove the mark from the given view
|
||||
if (view_has_mark(view, mark)) {
|
||||
view_find_and_unmark(mark);
|
||||
if (con && mark) {
|
||||
// Remove the mark from the given container
|
||||
if (container_has_mark(con, mark)) {
|
||||
container_find_and_unmark(mark);
|
||||
}
|
||||
} else if (view && !mark) {
|
||||
// Clear all marks from the given view
|
||||
view_clear_marks(view);
|
||||
view_update_marks_textures(view);
|
||||
} else if (!view && mark) {
|
||||
// Remove mark from whichever view has it
|
||||
view_find_and_unmark(mark);
|
||||
} else if (con && !mark) {
|
||||
// Clear all marks from the given container
|
||||
container_clear_marks(con);
|
||||
container_update_marks_textures(con);
|
||||
} else if (!con && mark) {
|
||||
// Remove mark from whichever container has it
|
||||
container_find_and_unmark(mark);
|
||||
} else {
|
||||
// Remove all marks from all views
|
||||
// Remove all marks from all containers
|
||||
root_for_each_container(remove_all_marks_iterator, NULL);
|
||||
}
|
||||
free(mark);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue