Codebase list i3-gaps / 6b2d8cb
Make get_assigned_output public Orestis Floros 3 years ago
2 changed file(s) with 27 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
4343 *
4444 */
4545 Con *get_existing_workspace_by_num(int num);
46
47 /**
48 * Returns the first output that is assigned to a workspace specified by the
49 * given name or number. Returns NULL if no such output exists.
50 *
51 * If an assignment matches by number but there is an assignment later that
52 * matches by name, the second one is preferred.
53 * The order of the 'ws_assignments' queue is respected: if multiple
54 * assignments match the criteria, the first one is returned.
55 * 'name' is ignored when NULL, 'parsed_num' is ignored when it is -1.
56 *
57 */
58 Con *get_assigned_output(const char *name, long parsed_num);
4659
4760 /**
4861 * Returns true if the first output assigned to a workspace with the given
7171
7272 /*
7373 * Returns the first output that is assigned to a workspace specified by the
74 * given name or number or NULL if no such output exists. If there is a
75 * workspace with a matching name and another workspace with a matching number,
76 * the output assigned to the first one is returned.
77 * The order of the 'ws_assignments' queue is respected: if multiple assignments
78 * match the specified workspace, the first one is returned.
79 * If 'name' is NULL it will be ignored.
80 * If 'parsed_num' is -1 it will be ignored.
81 *
82 */
83 static Con *get_assigned_output(const char *name, long parsed_num) {
74 * given name or number. Returns NULL if no such output exists.
75 *
76 * If an assignment matches by number but there is an assignment later that
77 * matches by name, the second one is preferred.
78 * The order of the 'ws_assignments' queue is respected: if multiple
79 * assignments match the criteria, the first one is returned.
80 * 'name' is ignored when NULL, 'parsed_num' is ignored when it is -1.
81 *
82 */
83 Con *get_assigned_output(const char *name, long parsed_num) {
8484 Con *output = NULL;
8585 struct Workspace_Assignment *assignment;
8686 TAILQ_FOREACH (assignment, &ws_assignments, ws_assignments) {
8787 if (name && strcmp(assignment->name, name) == 0) {
88 DLOG("Found workspace name assignment to output \"%s\"\n", assignment->output);
88 DLOG("Found workspace name=\"%s\" assignment to output \"%s\"\n",
89 name, assignment->output);
8990 Output *assigned_by_name = get_output_by_name(assignment->output, true);
9091 if (assigned_by_name) {
9192 /* When the name matches exactly, skip numbered assignments. */
9596 parsed_num != -1 &&
9697 name_is_digits(assignment->name) &&
9798 ws_name_to_number(assignment->name) == parsed_num) {
98 DLOG("Found workspace number assignment to output \"%s\"\n", assignment->output);
99 DLOG("Found workspace number=%ld assignment to output \"%s\"\n",
100 parsed_num, assignment->output);
99101 Output *assigned_by_num = get_output_by_name(assignment->output, true);
100102 if (assigned_by_num) {
101103 output = assigned_by_num->con;