Exemplo n.º 1
0
void ipc_bar_init(struct bar *bar, const char *bar_id) {
	// Get bar config
	uint32_t len = strlen(bar_id);
	char *res = ipc_single_command(bar->ipc_socketfd, IPC_GET_BAR_CONFIG, bar_id, &len);

	ipc_parse_config(bar->config, res);
	free(res);

	// Get outputs
	len = 0;
	res = ipc_single_command(bar->ipc_socketfd, IPC_GET_OUTPUTS, NULL, &len);
	json_object *outputs = json_tokener_parse(res);
	int i;
	int length = json_object_array_length(outputs);
	json_object *output, *output_name, *output_active;
	const char *name;
	bool active;
	for (i = 0; i < length; ++i) {
		output = json_object_array_get_idx(outputs, i);
		json_object_object_get_ex(output, "name", &output_name);
		json_object_object_get_ex(output, "active", &output_active);
		name = json_object_get_string(output_name);
		active = json_object_get_boolean(output_active);
		if (!active) {
			continue;
		}

		bool use_output = false;
		if (bar->config->all_outputs) {
			use_output = true;
		} else {
			int j = 0;
			for (j = 0; j < bar->config->outputs->length; ++j) {
				const char *conf_name = bar->config->outputs->items[j];
				if (strcasecmp(name, conf_name) == 0) {
					use_output = true;
					break;
				}
			}
		}

		if (!use_output) {
			continue;
		}

		// add bar to the output
		struct output *bar_output = new_output(name);
		bar_output->idx = i;
		list_add(bar->outputs, bar_output);
	}
	free(res);
	json_object_put(outputs);

	const char *subscribe_json = "[ \"workspace\", \"mode\" ]";
	len = strlen(subscribe_json);
	res = ipc_single_command(bar->ipc_event_socketfd, IPC_SUBSCRIBE, subscribe_json, &len);
	free(res);

	ipc_update_workspaces(bar);
}
Exemplo n.º 2
0
static bool handle_output_created(wlc_handle output) {
	swayc_t *op = new_output(output);

	//Switch to workspace if we need to
	if (active_workspace == NULL) {
		swayc_t *ws = op->children->items[0];
		workspace_switch(ws);
	}
	return true;
}
Exemplo n.º 3
0
END_TEST

START_TEST(test_clogger_expanded_macro)
{
    new_output();
    ck_assert_int_eq(output_size(), 0);
    LOG_INFO("This is a log line");
    fflush(output_fd);
    ck_assert_int_gt(output_size(), 0);
}
Exemplo n.º 4
0
END_TEST

START_TEST(test_clogger_log_levels)
{
    new_output();
    clogger_set_level(Warn);
    ck_assert_int_eq(output_size(), 0);
    LOG_INFO("This is a log line");
    fflush(output_fd);
    ck_assert_int_eq(output_size(), 0);
    LOG_WARN("This is a log line");
    fflush(output_fd);
    ck_assert_int_gt(output_size(), 0);
}
Exemplo n.º 5
0
static bool handle_output_created(wlc_handle output) {
	swayc_t *op = new_output(output);

	// Visibility mask to be able to make view invisible
	wlc_output_set_mask(output, VISIBLE);

	if (!op) {
		return false;
	}

	// Switch to workspace if we need to
	if (swayc_active_workspace() == NULL) {
		swayc_t *ws = op->children->items[0];
		workspace_switch(ws);
	}
	return true;
}
Exemplo n.º 6
0
static bool handle_output_created(wlc_handle output) {
	swayc_t *op = new_output(output);

	// Visibility mask to be able to make view invisible
	wlc_output_set_mask(output, VISIBLE);

	if (!op) {
		return false;
	}

	// Switch to workspace if we need to
	if (swayc_active_workspace() == NULL) {
		swayc_t *ws = op->children->items[0];
		workspace_switch(ws);
	}

	// Fixes issues with backgrounds and wlc
	wlc_handle prev = wlc_get_focused_output();
	wlc_output_focus(output);
	wlc_output_focus(prev);
	return true;
}
Exemplo n.º 7
0
int quence(char *src, char *output) {
    output_thingy *out;

    int sz_theory;
    int sz_actual;

    int success;
    int err;

    /* Parse the input file */

//	if (src[0] = 0)
//		yyin = stdin;
//	else
//		yyin = fopen(src, "r");

    err = start_preprocessor(preprocessor, src, &yyin);
    switch (err) {
    case 0 :
        break;
    case 1 :
        eprintf("Preprocessor executable \"%s\" not found.\n", preprocessor);
        break;
    case 2 :
        eprintf("Could not open input file \"%s\" for reading.\n", src);
        break;
    case 3 :
        eprintf("Preprocessor \"%s\" returned error on file \"%s\".\n", preprocessor, src);
        break;
    default :
        eprintf("Unknown preprocessor error (%d).\n", err);
    }
    if (err) return 1;

    asm_source_file = cpstring(src);
    asm_base_file = cpstring(src);
    asm_linenum = 1;
    success = (yyparse() == 0);

    /* Close input file, and delete temporary file if used */

    if (fileno(yyin) != STDIN_FILENO) {
        fclose(yyin);
        if (preprocessor != NULL)
            unlink(CPP_TEMP_FILE);
    }

    if (! success)
        return 1;

    /* Check for unresolvable label refs */

    if (resolve_all_label_refs(parsed_text) != 0) {
        eprintf("Unresolved labels (and number of occurences):\n");
        print_table(0, unresolved_labels);
        eprintf("\n");

        return 2;
    }

    /* Print parsed text */

    d_printf(2, "Input file %s parsed as follows:\n", src);
    print_text(2, parsed_text);
    d_printf(2, "\n");

    /* output assembled data */

    out = new_output(src);
    if (output)
        set_output_file(out, output);

    sz_theory = encoded_text_size(parsed_text);
    sz_actual = compile_text(out, parsed_text);

    if (sz_theory == sz_actual) {
        output_data(out);
        eprintf("Syntax OK: %d bytes written.\n", sz_actual);
    } else {
        if (! safe_write) {
            output_data(out);
            eprintf("Internal compile error: %d of %d bytes written.\n", sz_actual, sz_theory);
        } else {
            eprintf("Internal compile error: %d of %d bytes generated (0 written).\n", sz_actual, sz_theory);
        }
        return 3;
    }

    return 0;
}