예제 #1
0
파일: container.c 프로젝트: braneed/sway
swayc_t *new_output(wlc_handle handle) {
    const struct wlc_size* size = wlc_output_get_resolution(handle);
    const char *name = wlc_output_get_name(handle);
    sway_log(L_DEBUG, "Added output %u %s", (unsigned int)handle, name);

    swayc_t *output = new_swayc(C_OUTPUT);
    output->width = size->w;
    output->height = size->h;
    output->handle = handle;
    if (name) {
        output->name = strdup(name);
    }

    add_child(&root_container, output);

    //TODO something with this
    int total_width = 0;
    container_map(&root_container, add_output_widths, &total_width);

    //Create workspace
    char *ws_name = workspace_next_name();
    new_workspace(output, ws_name);
    free(ws_name);

    return output;
}
예제 #2
0
파일: container.c 프로젝트: Half-Shot/sway
swayc_t *new_output(wlc_handle handle) {
	const struct wlc_size* size = wlc_output_get_resolution(handle);
	const char *name = wlc_output_get_name(handle);
	sway_log(L_DEBUG, "Added output %lu:%s", handle, name);

	swayc_t *output = new_swayc(C_OUTPUT);
	output->width = size->w;
	output->height = size->h;
	output->handle = handle;
	output->name = name ? strdup(name) : NULL;
	output->gaps = config->gaps_outer + config->gaps_inner / 2;

	add_child(&root_container, output);

	// Create workspace
	char *ws_name = NULL;
	if (name) {
		int i;
		for (i = 0; i < config->workspace_outputs->length; ++i) {
			struct workspace_output *wso = config->workspace_outputs->items[i];
			if (strcasecmp(wso->output, name) == 0) {
				sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output);
				// Check if any other workspaces are using this name
				if (find_container(&root_container, workspace_test, wso->workspace)) {
					sway_log(L_DEBUG, "But it's already taken");
					break;
				}
				sway_log(L_DEBUG, "So we're going to use it");
				ws_name = strdup(wso->workspace);
				break;
			}
		}
	}
	if (!ws_name) {
		ws_name = workspace_next_name();
	}

	// create and initilize default workspace
	swayc_t *ws = new_workspace(output, ws_name);
	ws->is_focused = true;

	free(ws_name);
	
	return output;
}
예제 #3
0
swayc_t *new_output(wlc_handle handle) {
	const struct wlc_size* size = wlc_output_get_resolution(handle);
	const char *name = wlc_output_get_name(handle);
	sway_log(L_DEBUG, "Added output %u %s", (unsigned int)handle, name);

	swayc_t *output = new_swayc(C_OUTPUT);
	output->width = size->w;
	output->height = size->h;
	output->handle = handle;
	output->name = name ? strdup(name) : NULL;

	add_child(&root_container, output);

	//TODO something with this
	int total_width = 0;
	container_map(&root_container, add_output_widths, &total_width);

	//Create workspace
	char *ws_name = NULL;
	if (name) {
		int i;
		for (i = 0; i < config->workspace_outputs->length; ++i) {
			struct workspace_output *wso = config->workspace_outputs->items[i];
			if (strcasecmp(wso->output, name) == 0) {
				sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output);
				ws_name = strdup(wso->workspace);
				break;
			}
		}
	}
	if (!ws_name) {
		ws_name = workspace_next_name();
	}
	new_workspace(output, ws_name);
	free(ws_name);
	
	return output;
}