remove old focus member

This commit is contained in:
Tony Crisci 2018-02-10 19:53:50 -05:00
parent ce3a1b3922
commit 93084c9cf8
6 changed files with 19 additions and 22 deletions

View file

@ -106,10 +106,6 @@ struct sway_container {
* The parent of this container. NULL for the root container.
*/
struct sway_container *parent;
/**
* Which of this container's children has focus.
*/
struct sway_container *focused;
/**
* Number of master views in auto layouts.

View file

@ -225,7 +225,12 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
wlr_output_make_current(wlr_output, &buffer_age);
wlr_renderer_begin(server->renderer, wlr_output);
swayc_t *workspace = soutput->swayc->focused;
struct sway_seat *seat = input_manager_current_seat(input_manager);
swayc_t *focus = sway_seat_get_focus_inactive(seat, soutput->swayc);
swayc_t *workspace = (focus->type == C_WORKSPACE ?
focus :
swayc_parent_by_type(focus, C_WORKSPACE));
swayc_descendants_of_type(workspace, C_VIEW, output_frame_view, soutput);
// render unmanaged views on top

View file

@ -74,8 +74,8 @@ static void ipc_json_describe_output(swayc_t *container, json_object *object) {
json_object_object_add(object, "refresh", json_object_new_int(wlr_output->refresh));
json_object_object_add(object, "transform",
json_object_new_string(ipc_json_get_output_transform(wlr_output->transform)));
json_object_object_add(object, "current_workspace",
(container->focused) ? json_object_new_string(container->focused->name) : NULL);
// TODO WLR need to set "current_workspace" to the currently focused
// workspace in a way that makes sense with multiseat
}
static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) {

View file

@ -151,7 +151,6 @@ swayc_t *new_output(struct sway_output *sway_output) {
char *ws_name = workspace_next_name(output->name);
wlr_log(L_DEBUG, "Creating default workspace %s", ws_name);
swayc_t *ws = new_workspace(output, ws_name);
output->focused = ws;
// Set each seat's focus if not already set
// TODO FOCUS: this is probably stupid, we shouldn't define focus in two
// places. We should probably put the active workspace on the sway_output

View file

@ -84,8 +84,6 @@ swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) {
int i = index_child(fixed);
list_insert(parent->children, i + 1, active);
active->parent = parent;
// focus new child
parent->focused = active;
return active->parent;
}
@ -96,9 +94,6 @@ void add_child(swayc_t *parent, swayc_t *child) {
list_add(parent->children, child);
child->parent = parent;
// set focus for this container
if (!parent->focused) {
parent->focused = child;
}
/* TODO WLR
if (parent->type == C_WORKSPACE && child->type == C_VIEW && (parent->workspace_layout == L_TABBED || parent->workspace_layout == L_STACKED)) {
child = new_container(child, parent->workspace_layout);

View file

@ -120,9 +120,15 @@ swayc_t *workspace_output_prev_next_impl(swayc_t *output, bool next) {
return NULL;
}
struct sway_seat *seat = input_manager_current_seat(input_manager);
swayc_t *focus = sway_seat_get_focus_inactive(seat, output);
swayc_t *workspace = (focus->type == C_WORKSPACE ?
focus :
swayc_parent_by_type(focus, C_WORKSPACE));
int i;
for (i = 0; i < output->children->length; i++) {
if (output->children->items[i] == output->focused) {
if (output->children->items[i] == workspace) {
return output->children->items[
wrap(i + (next ? 1 : -1), output->children->length)];
}
@ -225,16 +231,12 @@ bool workspace_switch(swayc_t *workspace) {
// TODO: Deal with sticky containers
wlr_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name);
// TODO FOCUS: Focus the last view this seat had focused on this workspace
if (workspace->children->length) {
// TODO FOCUS: This is really fucking stupid
sway_seat_set_focus(seat, workspace->children->items[0]);
} else {
sway_seat_set_focus(seat, workspace);
swayc_t *next = sway_seat_get_focus_inactive(seat, workspace);
if (next == NULL) {
next = workspace;
}
sway_seat_set_focus(seat, next);
swayc_t *output = swayc_parent_by_type(workspace, C_OUTPUT);
// TODO FOCUS: take a look at this
output->focused = workspace;
arrange_windows(output, -1, -1);
return true;
}