changed handling of focus, handling of view by type

This commit is contained in:
taiyu 2015-08-18 00:28:44 -07:00
parent 780893a933
commit 11321ca2dd
12 changed files with 392 additions and 324 deletions

View file

@ -39,17 +39,11 @@ static void free_swayc(swayc_t *c) {
}
/* New containers */
static void add_output_widths(swayc_t *container, void *_width) {
int *width = _width;
if (container->type == C_OUTPUT) {
*width += container->width;
}
}
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);
sway_log(L_DEBUG, "Added output %lu:%s", handle, name);
swayc_t *output = new_swayc(C_OUTPUT);
output->width = size->w;
@ -59,9 +53,12 @@ swayc_t *new_output(wlc_handle handle) {
add_child(&root_container, output);
//TODO something with this
int total_width = 0;
container_map(&root_container, add_output_widths, &total_width);
//TODO still dont know why this is here?
// int total_width = 0;
// int i;
// for (i = 0; i < root_container.children->length; ++i) {
// total_width += ((swayc_t*)root_container.children->items[i])->width;
// }
//Create workspace
char *ws_name = NULL;
@ -79,7 +76,10 @@ swayc_t *new_output(wlc_handle handle) {
if (!ws_name) {
ws_name = workspace_next_name();
}
new_workspace(output, ws_name);
//create and initilize default workspace
swayc_t *ws = new_workspace(output, ws_name);
ws->is_focused = true;
free(ws_name);
return output;
@ -139,14 +139,15 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
}
swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
const char *title = wlc_view_get_title(handle);
const char *title = wlc_view_get_title(handle);
swayc_t *view = new_swayc(C_VIEW);
sway_log(L_DEBUG, "Adding new view %u:%s to container %p %d",
(unsigned int)handle, title, sibling, sibling?sibling->type:0);
sway_log(L_DEBUG, "Adding new view %lu:%s to container %p %d",
handle, title, sibling, sibling ? sibling->type : 0);
//Setup values
view->handle = handle;
view->name = title ? strdup(title) : NULL;
view->visible = true;
view->is_focused = true;
view->desired_width = -1;
view->desired_height = -1;
@ -168,8 +169,8 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
swayc_t *new_floating_view(wlc_handle handle) {
const char *title = wlc_view_get_title(handle);
swayc_t *view = new_swayc(C_VIEW);
sway_log(L_DEBUG, "Adding new view %u:%s as a floating view",
(unsigned int)handle, title);
sway_log(L_DEBUG, "Adding new view %lu:%x:%s as a floating view",
handle, wlc_view_get_type(handle), title);
//Setup values
view->handle = handle;
view->name = title ? strdup(title) : NULL;
@ -197,6 +198,7 @@ swayc_t *new_floating_view(wlc_handle handle) {
return view;
}
/* Destroy container */
swayc_t *destroy_output(swayc_t *output) {
if (output->children->length == 0) {
@ -300,3 +302,5 @@ void set_view_visibility(swayc_t *view, void *data) {
}
view->visible = (*p == 2);
}